detail_invitation.js
11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
// pages/customer/detail_owner.js
var mta = require('mta-wechat-analysis')
import util from '../../utils/util';
import App from '../../utils/api';
import TP from '../../utils/tpls';
import RS from '../../utils/reserveStatus'
const {regeneratorRuntime} = global
Page({
/**
* 页面的初始数据
*/
data: {
detail: null,
height: 667,
current: 0,
tpls: [],
seller: {
name: '',
room: '',
date: '',
addr: ''
},
options: {tplid: ''},
hasOwner: false,//是否为发起人
animation: 'animation',
selecthidden:true,
morehidden:true,
openid:getApp().openid,
showconfirm:true
},
id: null,
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.id = options.id;
let param={
options:options,
hasOwner:options.hasSellerShare==1,//是否为发起人
}
param.tpls=[TP.tpls(options.tplid)]
this.setData(param)
mta.Page.init({
"appID": "500667280",
"eventID": "500667287",
"statPullDownFresh": true,
"statShareApp": true,
"statReachBottom": true,
"lauchOpts": options, //渠道分析
});
this.getreal();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
//导航栏自适应
let systemInfo = wx.getSystemInfoSync();
let reg = /ios/i;
let pt = 20;//导航状态栏上内边距
let h = 44;//导航状态栏高度
if (reg.test(systemInfo.system)) {
pt = systemInfo.statusBarHeight;
h = 44;
} else {
pt = systemInfo.statusBarHeight;
h = 48;
}
this.setData({
statusBarHeight: pt,
titleBarHeight: h,
height: systemInfo.windowHeight
})
this.getDetail();
},
getreal(){
console.log('yyyyy',this.data.openid,this.data.options.id)
App.Reserve.GetIsRelaSuccess({openid:this.data.openid,rid:this.data.options.id}).then((json)=>{
if(json.ret==200){
this.setData({
showconfirm:false
})
}
})
},
cloudsendmsg(){
// 'index.html?id='+this.data.options.id+'&hasInvation=1&hasSellerShare=1&uid='+this.data.options.uid
// let query='id='+this.data.options.id+'&hasInvation=1&hasSellerShare=1&uid='+this.data.options.uid;
// console.log(query)
// wx.cloud.callFunction({
// name:'common',
// data:{
// path:'pages/customer/index',
// query:'id='+this.data.options.id+'&hasInvation=1&hasSellerShare=1&uid='+this.data.options.uid,
// },
// success:(res)=>{
// console.log('success',res)
// },
// fail:(fail)=>{
// console.log('fail',fail)
// }
// })
wx.cloud.callFunction({
name:'sms',
data:{
content:'贵宾您好!您预订的'+this.data.seller.name+',',
path:'/index.html?id='+this.data.options.id+'&hasInvation=1&hasSellerShare=1&uid='+this.data.options.uid,
phoneNumberList:['+8615735929096']
},
success:(res)=>{
console.log('success',res)
},
fail:(fail)=>{
console.log('fail',fail)
}
})
},
call(){
wx.makePhoneCall({
phoneNumber: this.data.staffinfo.phone //仅为示例,并非真实的电话号码
})
},
test(e){
console.log('ttttttttttttttt');
// App.Contact.UploadCustomerMedia({url:this.data.staffinfo.qrcode}).then((json)=>{
// if(json.ret==200) {
// console.log('json')
// }
// })
},
addwechat(){
// wx.previewImage({
// current: this.data.staffinfo.qrcode, // 当前显示图片的http链接
// urls: [this.data.staffinfo.qrcode] // 需要预览的图片http链接列表
// })
util.cache('staffinfo',this.data.staffinfo);
wx.navigateTo({
url:'./wechat?qrcode='+this.data.staffinfo.qrcode
})
},
getstaffinfo(){
App.Activity.GetCustomerActivityBaseinfo({sellerid:this.data.detail.seller.id,uid:this.data.options.uid}).then((json)=>{
if(json.ret==200){
console.log(json)
this.setData({
staffinfo:json.data
})
}
})
},
todetail(e){
let aid=e.currentTarget.dataset.id;
console.log(aid)
wx.navigateTo({
url:'../me/coupon_detail?aid='+aid
})
},
getroomimage(){
App.Photo.getSellerPhotoById({sellerid:this.data.detail.seller.id,type:2}).then((json)=>{
if(json.ret==200){
this.setData({
roomimage:json.data
})
let urls=[];
json.data.forEach((v,i)=>{
urls.push(v.image);
})
this.urls=urls;
console.log(urls,'lllllll')
}
})
},
lookroom(){
wx.previewImage({
current: '', // 当前显示图片的http链接
urls: this.urls, // 需要预览的图片http链接列表
})
},
secondbook(){
wx.redirectTo({
url:'../reserve/detail?id='+this.data.detail.seller.id
})
},
setcoupon(){
if(this.data.list && this.data.list.length>0){
let list=this.data.list,liststr=[];
list.forEach((v,i)=>{
liststr.push(v.id);
})
App.Activity.SetActivityAsReserve({aid:liststr.toString()}).then((json)=>{
if(json.ret==200){
this.setData({
getcoupon:true
})
}
})
}
},
getactivity(){
App.Activity.GetActivityByRid({rid:this.id}).then((json)=>{
if(json.ret==200){
console.log(json.data);
this.setData({
list:json.data
})
this.setcoupon();
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return this.shareSetting();
},
getDetail(fouce = false){
App.Reserve.Detail({
openid: getApp().openid,
rid: this.id
}, fouce).then(res => {
let tables=[];
res.data.tables.forEach(t=>{
tables.push(t.name);
})
let reserev=RS.reserve(res.data)
console.log('reserev',reserev)
let dateSmart
if(res.data.type==1){
dateSmart=util.unixtoTime(reserev.ddate,this.data.tpls[this.data.current].timeStrSmart[0])
if(res.data.is_set_ddate==1){
dateSmart+=' '+util.unixtoTime(reserev.ddate,this.data.tpls[this.data.current].timeStrSmart[1])
}else{
dateSmart+=' '+reserev.soltName
}
}else{
dateSmart=util.unixtoTime(reserev.ddate,this.data.tpls[this.data.current].timeStr)
}
this.setData({
detail: this.formatDatail(res.data,dateSmart),
seller:{
name:res.data.seller.sellername,
room:tables.join('、'),
date:dateSmart,
addr:res.data.seller.real_address||res.data.seller.map_address,
image:res.data.image_url,
}
})
if(this.data.detail.type==0){
this.getstaffinfo();
this.getroomimage();
this.getactivity();
}
})
},
formatDatail(detail,dateSmart){
detail.rdateStr = dateSmart;
detail.tableFirst = detail.tables[0].name;
if (detail.tables.length > 1) {
detail.tableSubInfo = '等' + (detail.tables.length) + '个'
+ (detail.tables[0].tid == 2 ? '包间' : '');
}
if (detail.sex != 3) {
detail.rnameStr = detail.rname.substr(0, 1) + (detail.sex == 1 ? '先生' : '女士')
} else {
detail.rnameStr = detail.rname
}
detail.eatStr = '邀请您共进晚餐';
let hi = util.unixtoTime(detail.ddate, 'HHII');
if (hi < '10:00') {
detail.eatStr = '邀请您共进早餐';
} else if (hi < '15:00') {
detail.eatStr = '邀请您共进午餐';
}
// if(!detail.cusman){
// detail.cusman='vking';
// detail.cusman_phone='15877556369';
// detail.cusman_account='wx:vking';
// }
detail.hasCanSuccess = false;
if (detail.customers.length > 0) {
let openid = getApp().openid;
detail.customers.forEach(item => {
if (openid == item.openid) {
detail.hasCanSuccess = true;
detail.remindtime = item.remind_date;
return true;
}
})
}
return detail;
},
showManager(){
if (this.data.detail.cusman_phone || this.data.detail.cusman_account) {
this.selectComponent('#manager').show();
}
},
lookLocation: function () {
wx.openLocation({
latitude: Number(this.data.detail.seller.lat),
longitude: Number(this.data.detail.seller.long),
scale: 17,
address: this.data.detail.seller.map_address,
success: function (res) {
console.log(res)
}
})
},
confirmed(){
wx.reportMonitor('1016', 1)
if (!this.data.detail.hasCanSuccess) {
let userInfo = util.cache('userInfo');
if (userInfo) {
userInfo = JSON.stringify({
openid: getApp().openid,
avatar: userInfo.avatarUrl,
nickname: userInfo.nickName,
gender: userInfo.gender
})
}
App.Reserve.SetRelaSuccess({
rid: this.id,
openid: getApp().openid,
is_agree: 1,
userinfo: userInfo
}).then(res => {
this.setData({
[`detail.hasCanSuccess`]: true,
showconfirm:false
})
App.Reserve.Detail({
openid: getApp().openid,
rid: this.id
}, 'clear')
util.toast('赴约成功', 'none')
this.setData({
showconfirm:false
})
// let url='/pages/customer/list'
// if(parseInt(this.data.detail.ddate)-(new Date()/1000)>3600){
// if(this.data.detail.type==1){
// if(this.data.detail.is_set_ddate==1){
// url='/pages/customer/list?hasRelaTip=1'
// }
// }else{
// url='/pages/customer/list?hasRelaTip=1'
// }
// }
// wx.reLaunch({
// url: url
// })
})
} else {
util.toast('赴约成功', 'none')
}
},
setUserInfoSuccess(){
util.toast('授权成功,可以继续转发', 'none');
},
reserveCancel(){
let userInfo = util.cache('userInfo');
if (userInfo) {
userInfo = JSON.stringify({
openid: getApp().openid,
avatar: userInfo.avatarUrl,
nickname: userInfo.nickName,
gender: userInfo.gender
})
}
App.Reserve.SetRelaSuccess({
rid: this.id,
openid: getApp().openid,
cancel: 'cancel',
is_agree: 0,
userinfo: userInfo
}).then(res => {
this.getDetail(true);
})
},
shareSetting(){
return {
//title: (nickname||'')+'给你发了一个邀请,点击查看',
title: this.data.tpls[0].shareTitle,
path: util.http_build_query({
id:this.id,
fromid:getApp().openid,
hasInvitation:1,
tplid:this.data.options.tplid,
},'/pages/customer/index'),
imageUrl: this.data.tpls[0].shareImage,
}
},
gotoHome(){
wx.redirectTo({
url: '/pages/reserve/index'
})
},
showselect(){
this.setData({
selecthidden:false
})
},
closeselect(){
console.log('ttttt')
this.setData({
selecthidden:true
})
},
showmore(){
this.setData({
morehidden:false
})
},
closemore(){
this.setData({
morehidden:true
})
},
})