b_detail.js
8.12 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
var util = require('../../../utils/util.js')
var uri = require('../../../utils/uri.js')
import App from '../../../utils/api';
import RS from '../../../utils/reserveStatus'
import PubSub from '../../../utils/PubSub'
const {regeneratorRuntime} = global
import TP from '../../../utils/tpls';
import gl from '../../global';
Page({
data: {
actionSheetHidden: true,
actionSheetItems: ['客户取消', '客户行程改变'],
hasEditorFlag: false,
},
sc: {},
tpls: TP.tpls(),
enter_params: {},
onLoad: async function (opt) {
util.setBarTitle('预订详情');
console.log(opt)
this.getDetail(opt.id);
wx.showShareMenu({
withShareTicket: true,
success: function (res) {
console.log(res)
}
})
this.enter_params = util.cache('enter_params');
this.sc = (await App.Reserve.SellerInfo(this.enter_params)).data;
console.log('this.sc', this.sc);
this.chooseManagerInit();
PubSub.on('arrangeDesk',(desk)=>{
this.arrangeDesk(desk)
})
},
onShow: function () {
this.notice = this.selectComponent('#notice');
gl.getHasEditorFlag().then(() => {
this.setData({
hasEditorFlag: true,
})
}).catch(()=>{})
},
noticeCall: function () {
this.selectComponent('#notice').show();
},
onShareAppMessage: function () {
this.selectComponent('#notice').close();
var obj = this.data.bookInfo;
let path = util.http_build_query({
id: this.data.bookInfo.id,
fromid: getApp().openid,
hasSellerShare: 1,
hasInvitation: 1,
tplid: 1
}, '/pages/customer/index')
return {
//title: (nickname||'')+'给你发送了一个订座信息,点击查看详情',
title: this.tpls[0].shareFirstTitle,
path: path,
imageUrl: this.tpls[0].shareFirstImage,
success: function (res) {
console.log(res, 666666)
},
fail: function () {
console.log('ccccc')
},
complete: function () {
console.log('ccccc')
}
};
},
getcall: function () {
if (!this.detailData.hasOwner) {
return util.toast('只有记录人可以拨打', 'none');
}
if (this.data.bookInfo.phone.length < 3) {
return util.toast('号码错误', 'none');
}
wx.makePhoneCall({
phoneNumber: this.data.bookInfo.phone, //仅为示例,并非真实的电话号码
complete: () => {
this.selectComponent('#notice').close();
}
})
},
chooseManagerInit() {
try {
let managers = this.sc.manager;
let mans = [];
let mans_role = [];
// let space='';
// for(let i=0;i<50;i++){
// space+=' ';
// }
if (managers.length > 0) {
managers.forEach(man => {
let nickname = man.nick_name || man.user_name;
mans.push(nickname);
//mans_role.push(' ['+man.role_name+'] -- '+man.user_name+space);
mans_role.push('[' + man.role_name + '] -- ' + nickname);
})
}
this.setData({mans: mans, mans_role: mans_role})
} catch (e) {
wx.showToast({
title: '无客户经理',
icon: 'none'
});
}
},
chooseManager(e) {
let mansIndex = util.val(e);
this.setData({mansIndex: mansIndex});
try {
let managers = this.sc.manager;
let man = managers[mansIndex];
if (man) {
App.Reserve.SetReserveCusman({
rid: this.data.bookInfo.id,
cusman_id: man.id,
cusman: man.nick_name || man.user_name,
cusman_phone: man.user_phone ? man.user_phone : '',
cusman_account: man.user_wechat ? man.user_wechat : '',
cusman_openid: man.seat_openid ? man.seat_openid : ''
}).then(() => {
this.getDetail(this.data.bookInfo.id, true);
});
}
} catch (e) {
console.log(e);
}
},
flushSellerInfo() {
App.Reserve.SellerInfo(util.cache('enter_params'), true);
},
detailData: null,
async getDetail(id, force = false) {
let res = await App.Reserve.Detail({rid: id, openid: ''}, force);
res.data.rdateStr = util.unixtoTime(res.data.ddate, "MM月DD日 HH:II")
res.data.phoneStr = res.data.phone || '';
let enter_params = util.cache('enter_params');
let sc = (await App.Reserve.SellerInfo(enter_params)).data
let note_openid = enter_params.seller_openid;
res.data.hasOwner = false;
if (note_openid == res.data.note_openid || sc.seller_user.role_name == '管理员') {
res.data.hasOwner = true;
}
if (!res.data.hasOwner) {
res.data.phoneStr = res.data.phoneStr.replace(/(\d{2})(.{5})(\d{3})/, function ($0, $1, $2, $3) {
return $1 + '**' + $3;
})
}
if (res.data.status == 4 && res.data.cancel) {
res.data.cancel.cdateStr = util.unixtoTime(res.data.cancel.cdate, "YYYY.MM.DD HH:II")
}
this.detailData = RS.reserve(res.data);
this.setData({
tables: res.data.tables,
bookInfo: this.detailData,
})
},
gotoModify() {
wx.redirectTo({
url: './b_addnew?id=' + this.data.bookInfo.id
})
},
cancelReserve() {
this.selectComponent('#cancel').show();
},
reserveCancel(e) {
console.log('reserveCancel', e.detail);
this.getDetail(this.data.bookInfo.id, true);
},
actionSheetChange(e) {
this.setData({
actionSheetHidden: true
})
},
async startDinner(e) {
App.Reserve.SetReserveStatus({
rid: this.data.bookInfo.id,
status: util.attr(e, 'status'),
cause: await this.getCause(),
}).then(() => {
this.getDetail(this.data.bookInfo.id, true);
});
},
showOrder() {
wx.navigateTo({
url: util.http_build_query({
rid: this.data.bookInfo.id,
oid: this.data.bookInfo.orderid,
identity: 2
}, '/pack-cookbook/pages/success')
});
},
refuseOrder(){
wx.showModal({
title: '确认拒绝订单吗?',
content: '如果包间类型已订满,请及时停用',
showCancel:true,
cancelText:'拒绝订单',
cancelColor:'',
confirmText:'去安排',
confirmColor:'',
success:(async (res)=>{
console.info(res)
if(res.cancel){
let params={
rid:this.data.bookInfo.id,
status:6,
cause:await this.getCause('拒绝订单'),
}
App.Reserve.SetReserveStatus(params).then(()=>{
this.getDetail(this.data.bookInfo.id,true);
PubSub.emit('fulshReseveList')
})
}else{//分配
this.arrangeOrder()
}
})
})
},
arrangeOrder(){
let bi=this.data.bookInfo
let checked_tids=''
//rdate=1568023200-1568041200&tid=0&pnum=6&checked_tids=&rid=&hasPubsub=1
wx.navigateTo({
url:util.http_build_query({
rdate:bi.rdate+'-'+bi.edate,
tid:0,
pnum:6,
checked_tids:checked_tids,
rid:'',
hasPubSub:1,
},'./b_desk')
})
},
async arrangeDesk(res){
console.log('arrangeDesk',res.tableid)
let params={
rid:this.data.bookInfo.id,
status:5,
cause:await this.getCause('安排包间'),
tid:res.tableid.toString()
}
App.Reserve.SetReserveStatus(params).then(()=>{
this.getDetail(this.data.bookInfo.id,true);
PubSub.emit('fulshReseveList')
})
},
easyCall(e){
let bi=this.data.bookInfo
let phone=bi.phone
if(util.attr(e,'key')=='seller'){
phone=bi.seller.phone
if(bi.seller.seller_tel){
let seller_tel=bi.seller.seller_tel.split(',');
if(seller_tel.length>0){
phone=seller_tel[parseInt(Math.random()*seller_tel.length)]
}
}
}
phone=phone.replace(/[^\d]/g,'')
if(phone){
wx.makePhoneCall({
phoneNumber: phone
})
}else{
util.toast('号码为空','none')
}
},
async getCause(desc=""){
let cause = {};
let enter_params = util.cache('enter_params');
let sc = (await App.Reserve.SellerInfo(enter_params)).data
cause = {desc: desc}
if (enter_params) {
cause.uid = enter_params.manager_id;
}
if (sc.seller_user) {
cause.uname = (sc.seller_user.nick_name || sc.seller_user.nickname)
}
return JSON.stringify(cause)
}
})