|
|
|
1
|
+// pages/customer/detail_owner.js
|
|
|
|
2
|
+import util from '../../utils/util';
|
|
|
|
3
|
+import App from '../../utils/api';
|
|
|
|
4
|
+const {regeneratorRuntime} = global
|
|
|
|
5
|
+Page({
|
|
|
|
6
|
+
|
|
|
|
7
|
+ /**
|
|
|
|
8
|
+ * 页面的初始数据
|
|
|
|
9
|
+ */
|
|
|
|
10
|
+ data: {
|
|
|
|
11
|
+ detail:null,
|
|
|
|
12
|
+ invite_name:''
|
|
|
|
13
|
+ },
|
|
|
|
14
|
+ id:null,
|
|
|
|
15
|
+ /**
|
|
|
|
16
|
+ * 生命周期函数--监听页面加载
|
|
|
|
17
|
+ */
|
|
|
|
18
|
+ onLoad: function (options) {
|
|
|
|
19
|
+ this.id=options.id;
|
|
|
|
20
|
+ let invite_names=wx.getStorageSync('invite_names') ||{};
|
|
|
|
21
|
+ let invite_name=invite_names[options.id];
|
|
|
|
22
|
+ if(invite_name){
|
|
|
|
23
|
+ this.setData({
|
|
|
|
24
|
+ invite_name:invite_name
|
|
|
|
25
|
+ })
|
|
|
|
26
|
+ }
|
|
|
|
27
|
+ },
|
|
|
|
28
|
+
|
|
|
|
29
|
+ /**
|
|
|
|
30
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
|
31
|
+ */
|
|
|
|
32
|
+ onReady: function () {
|
|
|
|
33
|
+
|
|
|
|
34
|
+ },
|
|
|
|
35
|
+
|
|
|
|
36
|
+ /**
|
|
|
|
37
|
+ * 生命周期函数--监听页面显示
|
|
|
|
38
|
+ */
|
|
|
|
39
|
+ onShow: function () {
|
|
|
|
40
|
+ this.getDetail();
|
|
|
|
41
|
+ },
|
|
|
|
42
|
+
|
|
|
|
43
|
+ /**
|
|
|
|
44
|
+ * 生命周期函数--监听页面隐藏
|
|
|
|
45
|
+ */
|
|
|
|
46
|
+ onHide: function () {
|
|
|
|
47
|
+
|
|
|
|
48
|
+ },
|
|
|
|
49
|
+
|
|
|
|
50
|
+ /**
|
|
|
|
51
|
+ * 生命周期函数--监听页面卸载
|
|
|
|
52
|
+ */
|
|
|
|
53
|
+ onUnload: function () {
|
|
|
|
54
|
+
|
|
|
|
55
|
+ },
|
|
|
|
56
|
+
|
|
|
|
57
|
+ /**
|
|
|
|
58
|
+ * 用户点击右上角分享
|
|
|
|
59
|
+ */
|
|
|
|
60
|
+ onShareAppMessage: function () {
|
|
|
|
61
|
+ return this.shareSetting();
|
|
|
|
62
|
+ },
|
|
|
|
63
|
+ getDetail(fouce=false){
|
|
|
|
64
|
+ App.Reserve.Detail({
|
|
|
|
65
|
+ openid: getApp().openid,
|
|
|
|
66
|
+ rid: this.id
|
|
|
|
67
|
+ },fouce).then(res => {
|
|
|
|
68
|
+ this.setData({
|
|
|
|
69
|
+ detail:this.formatDatail(res.data)
|
|
|
|
70
|
+ })
|
|
|
|
71
|
+ })
|
|
|
|
72
|
+ },
|
|
|
|
73
|
+ formatDatail(detail){
|
|
|
|
74
|
+ detail.rdateStr=util.unixtoTime(detail.ddate,'YYYY/MM/DD 星期WW HH:II');
|
|
|
|
75
|
+ detail.tableFirst=detail.tables[0].name;
|
|
|
|
76
|
+ if(detail.tables.length>1){
|
|
|
|
77
|
+ detail.tableSubInfo='等'+(detail.tables.length)+'个'
|
|
|
|
78
|
+ +(detail.tables[0].tid==2?'包间':'');
|
|
|
|
79
|
+ }
|
|
|
|
80
|
+ if(detail.sex!=3){
|
|
|
|
81
|
+ detail.rnameStr=detail.rname.substr(0,1)+(detail.sex==1?'先生':'女士')
|
|
|
|
82
|
+ }else{
|
|
|
|
83
|
+ detail.rnameStr=detail.rname
|
|
|
|
84
|
+ }
|
|
|
|
85
|
+ detail.eatStr='邀请您共进晚餐';
|
|
|
|
86
|
+ let hi=util.unixtoTime(detail.ddate,'HHII');
|
|
|
|
87
|
+ if(hi<'10:00'){
|
|
|
|
88
|
+ detail.eatStr='邀请您共进早餐';
|
|
|
|
89
|
+ }else if(hi<'15:00'){
|
|
|
|
90
|
+ detail.eatStr='邀请您共进午餐';
|
|
|
|
91
|
+ }
|
|
|
|
92
|
+
|
|
|
|
93
|
+ // if(!detail.cusman){
|
|
|
|
94
|
+ // detail.cusman='vking';
|
|
|
|
95
|
+ // detail.cusman_phone='15877556369';
|
|
|
|
96
|
+ // detail.cusman_account='wx:vking';
|
|
|
|
97
|
+ // }
|
|
|
|
98
|
+ detail.hasCanSuccess=false;
|
|
|
|
99
|
+ if(detail.customers.length>0){
|
|
|
|
100
|
+ let openid=getApp().openid;
|
|
|
|
101
|
+ detail.customers.forEach(item=>{
|
|
|
|
102
|
+ if(openid==item.openid){
|
|
|
|
103
|
+ detail.hasCanSuccess=true;
|
|
|
|
104
|
+ detail.remindtime=item.remind_date;
|
|
|
|
105
|
+ return true;
|
|
|
|
106
|
+ }
|
|
|
|
107
|
+ })
|
|
|
|
108
|
+ }
|
|
|
|
109
|
+ return detail;
|
|
|
|
110
|
+ },
|
|
|
|
111
|
+ showManager(){
|
|
|
|
112
|
+ if(this.data.detail.cusman_phone || this.data.detail.cusman_account){
|
|
|
|
113
|
+ this.selectComponent('#manager').show();
|
|
|
|
114
|
+ }
|
|
|
|
115
|
+
|
|
|
|
116
|
+ },
|
|
|
|
117
|
+ lookLocation:function(){
|
|
|
|
118
|
+ wx.openLocation({
|
|
|
|
119
|
+ latitude:Number(this.data.detail.seller.lat),
|
|
|
|
120
|
+ longitude:Number(this.data.detail.seller.long),
|
|
|
|
121
|
+ scale:17,
|
|
|
|
122
|
+ address:this.data.detail.seller.map_address,
|
|
|
|
123
|
+ success:function (res) {
|
|
|
|
124
|
+ console.log(res)
|
|
|
|
125
|
+ }
|
|
|
|
126
|
+ })
|
|
|
|
127
|
+ },
|
|
|
|
128
|
+ userinfo(){
|
|
|
|
129
|
+ if(!this.data.detail.hasCanSuccess){
|
|
|
|
130
|
+ let userInfo=util.cache('userInfo');
|
|
|
|
131
|
+ if(userInfo){
|
|
|
|
132
|
+ userInfo=JSON.stringify({
|
|
|
|
133
|
+ openid: getApp().openid,
|
|
|
|
134
|
+ avatar: userInfo.avatarUrl,
|
|
|
|
135
|
+ nickname: userInfo.nickName,
|
|
|
|
136
|
+ gender: userInfo.gender
|
|
|
|
137
|
+ })
|
|
|
|
138
|
+ }
|
|
|
|
139
|
+ App.Reserve.SetRelaSuccess({
|
|
|
|
140
|
+ rid:this.id,
|
|
|
|
141
|
+ openid:getApp().openid,
|
|
|
|
142
|
+ is_agree:1,
|
|
|
|
143
|
+ userinfo:userInfo
|
|
|
|
144
|
+ }).then(res=>{
|
|
|
|
145
|
+ App.Reserve.Detail({
|
|
|
|
146
|
+ openid: getApp().openid,
|
|
|
|
147
|
+ rid: this.id
|
|
|
|
148
|
+ },'clear')
|
|
|
|
149
|
+ wx.navigateTo({
|
|
|
|
150
|
+ //id={{detail.id}}&rdate={{detail.rdate}}
|
|
|
|
151
|
+ url:'remind?id='+this.id+'&rdate='+this.data.detail.rdate,
|
|
|
|
152
|
+ });
|
|
|
|
153
|
+ })
|
|
|
|
154
|
+ }else{
|
|
|
|
155
|
+ // wx.navigateTo({
|
|
|
|
156
|
+ // url:'invite?id='+this.id,
|
|
|
|
157
|
+ // });
|
|
|
|
158
|
+ }
|
|
|
|
159
|
+ },
|
|
|
|
160
|
+ setUserInfoSuccess(){
|
|
|
|
161
|
+ util.toast('授权成功,可以继续转发','none');
|
|
|
|
162
|
+ },
|
|
|
|
163
|
+ reserveCancel(){
|
|
|
|
164
|
+ let userInfo = util.cache('userInfo');
|
|
|
|
165
|
+ if (userInfo) {
|
|
|
|
166
|
+ userInfo = JSON.stringify({
|
|
|
|
167
|
+ openid: getApp().openid,
|
|
|
|
168
|
+ avatar: userInfo.avatarUrl,
|
|
|
|
169
|
+ nickname: userInfo.nickName,
|
|
|
|
170
|
+ gender: userInfo.gender
|
|
|
|
171
|
+ })
|
|
|
|
172
|
+ }
|
|
|
|
173
|
+ App.Reserve.SetRelaSuccess({
|
|
|
|
174
|
+ rid: this.id,
|
|
|
|
175
|
+ openid: getApp().openid,
|
|
|
|
176
|
+ cancel: 'cancel',
|
|
|
|
177
|
+ is_agree: 0,
|
|
|
|
178
|
+ userinfo: userInfo
|
|
|
|
179
|
+ }).then(res => {
|
|
|
|
180
|
+ this.getDetail(true);
|
|
|
|
181
|
+ })
|
|
|
|
182
|
+ },
|
|
|
|
183
|
+ shareSetting(){
|
|
|
|
184
|
+ console.log('this.topicVal',this.topicVal)
|
|
|
|
185
|
+ if(this.topicVal && this.data.detail.openid==getApp().openid){
|
|
|
|
186
|
+ App.Reserve.SetTopicFromShare({
|
|
|
|
187
|
+ rid:this.id,
|
|
|
|
188
|
+ topic:this.topicVal
|
|
|
|
189
|
+ })
|
|
|
|
190
|
+ }
|
|
|
|
191
|
+ let nickname="";
|
|
|
|
192
|
+ try{
|
|
|
|
193
|
+ nickname=util.cache('userInfo').nickName;
|
|
|
|
194
|
+ }catch(e){}
|
|
|
|
195
|
+ return {
|
|
|
|
196
|
+ //title: (nickname||'')+'给你发了一个邀请,点击查看',
|
|
|
|
197
|
+ title: '你收到一个邀请函,点击查看',
|
|
|
|
198
|
+ path: '/pages/customer/index?id='+this.id+'&fromid='+getApp().openid+'&invite_name='+nickname+'&hasInvitation=1',
|
|
|
|
199
|
+ imageUrl:util.cgi('App.Reserve.MakePic&rid=')+this.id,
|
|
|
|
200
|
+ }
|
|
|
|
201
|
+ }
|
|
|
|
202
|
+}) |