detail_owner_invitation.js
13.5 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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
// 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
import ST from '../../utils/sms_tpls';
Page({
/**
* 页面的初始数据
*/
data: {
detail: null,
height: 667,
current: 0,
tpls: [],
seller: {
name: '',
room: '',
date: '',
addr: ''
},
options: {tplid: ''},
hasOwner: true,//是否为发起人
animation: 'animation',
couponhidden:true,
getcoupon:false,
menuhidden:true,
selecthidden:true,
morehidden:true,
openid:getApp().openid
},
id: null,
msgTpl:'',
/**
* 生命周期函数--监听页面加载
*/
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, //渠道分析
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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(getCurrentPages().length==1);
},
cloudsendmsg(){
wx.cloud.callFunction({
name:'sms',
data:{
content:'测试发送短信息年底是否会iv',
path:'index.html?id='+this.data.options.id+'&hasInvation=1&hasSellerShare=1&uid='+this.data.options.uid,
phoneNumberList:['15735929096']
},
success:(res)=>{
console.log('success',res)
},
fail:(fail)=>{
console.log('fail',res)
}
})
},
call(){
wx.reportMonitor('1012', 1)
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链接列表
// })
wx.reportMonitor('1011', 1)
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
})
}
})
},
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.reportMonitor('1013', 1)
if(this.data.list){
wx.navigateTo({
url:'./discount?sid='+this.data.detail.seller.id+'&id='+this.data.options.id
})
}else{
wx.redirectTo({
url:'../reserve/detail?id='+this.data.detail.seller.id
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return this.sharesetting();
},
onShareTimeline(){
return this.sharesetting();
},
getDetail(fouce = false){
App.Reserve.Detail({
openid: getApp().openid,
rid: this.data.options.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(reserev,dateSmart),
seller:{
name:reserev.seller.sellername,
room:tables.join('、'),
date:dateSmart,
addr:reserev.seller.real_address||reserev.seller.map_address,
image:reserev.image_url,
hasOwner:true,
type:reserev.type,
is_set_ddate:reserev.is_set_ddate,
hasUpTime:reserev.type==1 && reserev.hasRunning && reserev.status!=2,
}
})
if(this.data.detail.type==0){
this.getstaffinfo();
this.getroomimage();
this.getactivity();
}
/*
App.Reserve.SellerInfo({seller_id:reserev.seller.id}).then(async sc=>{
this.msgTpl=await ST.getTplMsg(reserev,sc.data.setting.template_code,sc.data)
console.log('this.msgTpl',this.msgTpl);
})*/
})
App.SendSMS.GetSmsContent({
rid:this.data.options.id,
}).then(res=>{
this.msgTpl=res.data.content
})
},
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=RS.reserve(detail);
return detail;
},
showManager(){
if (this.data.detail.cusman_phone || this.data.detail.cusman_account) {
this.selectComponent('#manager').show();
}
},
looklocation: function () {
wx.reportMonitor('1015', 1)
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)
}
})
},
userinfo(){
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 => {
App.Reserve.Detail({
openid: getApp().openid,
rid: this.id
}, 'clear')
wx.navigateTo({
//id={{detail.id}}&rdate={{detail.rdate}}
url: 'remind?id=' + this.id + '&rdate=' + this.data.detail.rdate,
});
})
} else {
// wx.navigateTo({
// url:'invite?id='+this.id,
// });
}
},
setUserInfoSuccess(){
util.toast('授权成功,可以继续转发', 'none');
},
toast(){
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(){
wx.reportMonitor('1017', 1)
let parmdata={
id:this.id,
fromid:getApp().openid,
hasInvitation:1,
tplid:this.data.options.tplid,
}
if(this.data.options.uid){
parmdata.uid=this.data.options.uid;
}
return {
title: this.data.tpls[0].shareTitle,
path: util.http_build_query(parmdata,'/pages/customer/index'),
imageUrl: this.data.tpls[0].shareImage,
}
},
cookbook(){
if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
wx.navigateTo({
url: util.http_build_query({
rid: this.id,
oid: this.data.detail.order.id,
identity: 1
}, '/pack-cookbook/pages/success')
});
} else {
App.Advance.CreateOrder({
rid: this.id,
openid: getApp().openid,
}).then(res => {
if (res.ret != 200) {
return util.toast(res.msg, 'none')
}
wx.navigateTo({
url: util.http_build_query({
rid: this.id,
oid: res.data.id,
identity: 1,
sid: res.data.sellerid
}, '/pack-cookbook/pages/index')
});
})
}
},
sendmsg(){
wx.setClipboardData({
data: this.msgTpl
})
},
upTime(){
this.selectComponent('#ddate').show();
},
ddateEvent(e){
console.log(e.detail.ddate)
this.getDetail(true)
},
gotoHome(){
wx.switchTab({
url: '/pages/reserve/index'
})
},
load(e){
console.log(e,'care')
},
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
})
}
})
}
},
tohref(){
let systemInfo = wx.getSystemInfoSync();
let reg = /ios/i;
if(reg.test(systemInfo.system)){
wx.showModal({
content:'关注"周到安排"公众号,及时获取更多优惠信息',
comfirmText:'去关注',
comfirmColor:'#5EB2FF',
cancelText:'取消',
cancelColor:'#999999',
success:(res)=>{
if(res.confirm){
wx.setClipboardData({
data: '周到安排',
success (res) {
wx.getClipboardData({
success (res) {
console.log(res.data) // data
}
})
}
})
}
}
})
}else{
wx.navigateTo({
url:'./care'
})
}
},
getactivity(){
App.Activity.GetActivityByRid({rid:this.id}).then((json)=>{
if(json.ret==200){
console.log(json.data);
this.setData({
list:json.data
})
this.setcoupon();
}
})
},
todetail(e){
let aid=e.currentTarget.dataset.id;
console.log(aid)
wx.navigateTo({
url:'../me/coupon_detail?aid='+aid
})
},
close(){
this.setData({
couponhidden:true,
})
},
checkout(){
if(this.data.detail.status==0){
this.selectComponent('#showModal').options({
header: '您点早啦!',
body: '商家分配包间后,您可以通过在线买单支付,无需到前台结账排队等发票。'
}).show();
}else{
wx.navigateTo({
url:util.http_build_query({
rid:this.data.detail.id,
sid:this.data.detail.sid
},'/pack-checkout/pages/index')
})
}
},
showmenu(){
this.setData({
menuhidden:false
})
},
hidemenu(){
this.setData({
menuhidden:true
})
},
noopen(e){
let mark=e.currentTarget.dataset.mark;
wx.showToast({
title:'该商家未开通'+(mark=='buy' ? '提前点餐' : '在线买单'),
duration:2000,
mask:true
})
},
showselect(){
wx.reportMonitor('1014', 1)
this.setData({
selecthidden:false
})
},
closeselect(){
console.log('ttttt')
this.setData({
selecthidden:true
})
},
showmore(){
this.setData({
morehidden:false
})
},
closemore(){
this.setData({
morehidden:true
})
},
cancelmodal(){
wx.showModal({
title:'取消预订',
content:'点击“确认取消”撤回当前预订,否则点击返回',
confirmColor:'#576B95',
confirmText:'确认取消',
cancelColor:'#999999',
cancelText:'返回',
success:(res)=>{
if(res.confirm){
this.cancelSubmit();
}
}
})
},
cancelSubmit(){
App.Reserve.Detail({
openid: getApp().openid,
rid: this.options.id
},'clear')
App.Customer.SetReserveStatusByUser({
rid:this.options.id,
desc:'',
}).then(res=>{
if(res.ret!=200){
return util.toast(res.msg,'none')
}
})
},
})