detail_owner_invitation_new.js
9.05 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
// pages/customer/detail_owner_invitation_new.js
import App from '../../utils/api';
import TP from '../../utils/tpls';
import RS from '../../utils/reserveStatus'
import util from '../../utils/util';
Page({
/**
* 页面的初始数据
*/
data: {
options: {
tplid: ''
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let param = {
options: options,
}
param.tpls = [TP.tpls(options.tplid)]
console.log(param);
console.log(options);
this.setData(param)
this.getDetail()
this.setSetRelation()
this.setRelaOpenidFun()
},
// 页面滚动事件
onPageScroll: function (event) {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
/**
* 监听用户点击分享到朋友圈按钮的操作
*/
onShareTimeline() {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
// 设置关系
setSetRelation() {
if (this.data.options && this.data.options.uid) {
App.Activity.SetRelation({
uid: this.data.options.uid,
}).then(res => {
console.log('设置关系', res);
})
}
},
// 创建邀请关系链
setRelaOpenidFun() {
let openid = getApp().openid;
if (this.data.options && this.data.options.id && openid) {
let obj = {
rid: this.data.options.id,
openid,
uid: this.data.options.uid,
fromid: this.data.options.fromid || ''
}
if (this.data.options.fromid) delete obj.uid
App.Reserve.SetRelaOpenid(obj).then(res => {
console.log('创建邀请关系链', res);
})
}
},
// 获取店铺详情
getDetail() {
App.Reserve.Detail({
rid: this.data.options.id
}).then(res => {
let reserev = RS.reserve(res.data)
this.getLocalLunchTime(reserev);
}).catch(res => {
console.log(res, '详情请求失败');
})
},
// 获取日期对应的时段
getLocalLunchTime(reserev) {
let ddateStr = new Date(reserev.ddate * 1000)
let year1 = ddateStr.getFullYear();
let month1 = ddateStr.getMonth() + 1;
let day1 = ddateStr.getDate();
let day2 = year1 + '-' + (month1 < 10 ? '0' + month1 : month1) + '-' + (day1 < 10 ? '0' + day1 : day1);
App.Seller.getMealSectionByDay({
sellerid: reserev.sid,
day: day2,
}).then(res => {
let data = res.data;
let lunchDinnerList = [];
if (data.length <= 3 && !data[0].ddate_solt) {
data.forEach(i => {
if (i.mname == '早餐') {
lunchDinnerList.push({
mname: "早餐",
mdate: i.mdate,
ddate_solt: 1,
})
}
if (i.mname == '午餐') {
lunchDinnerList.push({
mname: "午餐",
mdate: i.mdate,
ddate_solt: 2,
})
}
if (i.mname == '晚餐') {
lunchDinnerList.push({
mname: "晚餐",
mdate: i.mdate,
ddate_solt: 3,
})
}
})
} else {
lunchDinnerList = data;
}
let time;
let obj = lunchDinnerList.filter(i => {
return i.ddate_solt == reserev.ddate_solt
})
if (obj && obj.length > 0) {
time = obj[0].mdate.split('-')[1];
}
let timeHour = time.split(":")[0]; //预订日期--预订餐段的截止时间--小时
let timeMinute = time.split(":")[1]; //预订日期--预订餐段的截止时间--分钟
const date = new Date(reserev.ddate * 1000);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
let isOrder = this.isCurrentTimeGreaterThan(year, month, day, timeHour * 1, timeMinute * 1)
this.getSellerInfo(reserev.sid, isOrder, reserev)
}).catch(res => {
console.log(res, '获取多时段失败');
})
},
getSellerInfo(sid, isOrder, reserev) {
App.Seller.GetDzSellerConf({
sid
}).then(res => {
this.getSellerDetail(sid, isOrder, reserev, res.data.is_show_sex)
})
},
// 获取店铺详情
getSellerDetail(sid, isOrder, reserev, is_show_sex) {
App.Customer.GetSellerDetail({
sid
}).then(res => {
let is_online_reserve = res.data.is_online_reserve;
let isDeposit = res.data.seller_config_info?res.data.seller_config_info.is_show_notice_deposit:'0';
this.getSellerTemplateConfFun(sid, isOrder, reserev,is_online_reserve,isDeposit,is_show_sex);
}).catch(res => {
console.log(res, '商家详情请求失败');
})
},
// 判断是否超过该预订的餐段截止时间 为1 代表超过了
isCurrentTimeGreaterThan(year, month, day, hour, minute) {
const currentTime = new Date();
const targetTime = new Date(year, month - 1, day, hour, minute);
let isorder = currentTime > targetTime ? '1' : '0';
return isorder;
},
// 获取商家设置营销信息
getSellerTemplateConfFun(sid, isOrder, reserev, is_online_reserve, isDeposit,is_show_sex) {
App.Seller.GetSellerTemplateConf({
sid
}).then(res => {
let data = res.data
let url = '';
let arr = [9, 10, 11, 12, 13, 14, 15, 16, 17, 201, 202, 203];
let style =arr.includes(parseInt(data.type))
if (!style) {
url = '/pack-invitation/pages/detail_owner_invitation' + data.type;
} else {
url = '/pack-invitation/pages/detail_owner_invitation9';
}
if(data.type == '0') url = '/pack-invitation/pages/detail_owner_invitation1';
if(data.type == '300') url = '/pack-invitation/pages/detail_owner_invitation13';
if(data.type == '18' || data.type == '21' || data.type == '23') url = '/pack-invitation/pages/detail_owner_invitation11';
if(data.type == '19' || data.type == '22') url = '/pack-invitation/pages/detail_owner_invitation12';
if(data.type == '20') url = '/pack-invitation/pages/detail_owner_invitation10';
let marketing = util.determine(data.marketing);
let isMeeting = !marketing || Object.keys(marketing).length == 0 ? '1' : (marketing && marketing.is_customer_confirm ? marketing.is_customer_confirm : '0');
// is_online_reserve 在线预订开关 hasSellerShare 商家app分享 hasInvitation 受邀人 isDeposit 订金功能 1 是 0 否 isMeeting 赴约功能 1开启 0关闭
url += '?id=' + this.data.options.id + '&tplid=' + this.data.options.tplid + '&onlineReserve=' + is_online_reserve + '&hasInvitation=' + this.data.options.hasInvitation + '&hasSellerShare=' + this.data.options.hasSellerShare + '&isDeposit=' + isDeposit + '&isMeeting=' + isMeeting;
if(data.type == '18' || data.type == '19') url += '&bookType=1';
if(data.type == '21' || data.type == '22') url += '&bookType=2';
if(data.type == '23') url += '&bookType=3';
// console.log('宴会类型-------------',reserev.reserve_type);
// if(reserev.reserve_type == '生日宴') url += '&bookType=1'
// if(reserev.reserve_type == '婚宴' && (data.type == '18' || data.type == '19')) url += '&make=1'
// if(reserev.reserve_type == '商务宴请' && (data.type == '21' || data.type == '22')) url += '&make=2'
// (过了当前餐段结束时间 || 预订是用餐完成状态) 邀请函显示已结束
url += (isOrder == '1' || reserev.status == '3') ? '&isOrder=1' : '';
url+= this.data.options.paymentId?'&paymentId='+this.data.options.paymentId:'&paymentId=' ;
if(data.type == '1') url+= '&uid='+this.data.options.uid
if(is_show_sex != '1') url+= '&showSex=2'
console.log('跳转路径url', url);
wx.redirectTo({
url
})
}).catch(res => {
console.log('GetSellerTemplateConf请求失败');
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
})