card.js
5.31 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
// components/2.0/reserve/card.js
import util from '../../../utils/util';
import App from '../../../utils/api';
import RS from '../../../utils/reserveStatus'
Component({
/**
* 组件的属性列表
*/
properties: {
detail:Object,
tabType:Number
},
/**
* 组件的初始数据
*/
data: {
ddate_Str:'',
},
attached(){
//this.init()
},
observers: {
'detail': function() {
this.init()
},
},
/**
* 组件的方法列表
*/
methods: {
init(){
let detail=RS.reserve(this.data.detail)
console.log('detail.init',detail)
let tableSubInfo = ''
let tableFirst = '';
if (detail.tableFirst) {
tableSubInfo = (detail.tableFirst || '') + ' ' + (detail.tableSubInfo || '');
tableFirst = detail.tableFirst
} else if(detail.tables && detail.tables.length>0) {
tableFirst = detail.tables[0].name
tableSubInfo = detail.tables[0].name;
if (detail.tables.length > 1) {
tableSubInfo += ' 等' + (detail.tables.length) + '个'
+ (detail.tables[0].tid == 2 ? '包间' : '');
tableFirst += '等';
}
}
detail.tableFirst=tableFirst
detail.tableSubInfo=tableSubInfo
this.setData({
reserve:detail,
})
console.log('666666',detail);
this.getLocalLunchTime(detail)
if(this.data.tabType==6){
this.remark('auto');
}
},
//获取日期对应的多时段
getLocalLunchTime(detail){
let ddateStr = new Date(detail.ddate * 1000)
let year = ddateStr.getFullYear();
let month = ddateStr.getMonth() + 1;
let day = ddateStr.getDate();
let day1 = year + '-' + (month < 10 ? '0' + month : month) + '-' + day;
App.Seller.getMealSectionByDay({
sellerid: detail.seller.id,
day: day1,
}).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;
}
lunchDinnerList.forEach((item,index)=>{
item.section = 'ket'+index
})
let obj=lunchDinnerList.filter(item=>{return item.ddate_solt == detail.ddate_solt})
if(obj && obj.length>0){
this.setData({
ddate_Str:obj[0].mname
})
}
}).catch(res => {
console.log(res, '获取多时段失败');
})
},
openlocation(){
console.log('6666666')
wx.openLocation({
latitude:Number(this.data.reserve.seller.lat),
longitude:Number(this.data.reserve.seller.long),
scale: 18
})
},
remark(action='click'){
App.Customer.CheckIsComment({rid:this.data.reserve.id}).then(res => {
console.log('66666fffffff',res)
this.setData({
hasComment:res.data!=1,//已评论
})
if(action.type=="tap"){
if(res.data==0){
wx.navigateTo({
url:'/pages/pinglun/create?sid='+this.data.reserve.seller.id+'&oid='+this.data.reserve.id+'&sellername='+this.data.reserve.seller.sellername
})
}else{
wx.showToast({
title:'该订单已评论',
icon:'none'
})
}
}
})
},
cookbook() {
if (this.data.reserve.order && this.data.reserve.order.cookbooklist.length > 0) {
wx.navigateTo({
url: util.http_build_query({
rid: this.data.reserve.id,
oid: this.data.reserve.order.id,
identity: 1
}, '/pack-cookbook/pages/success')
});
} else {
App.Advance.CreateOrder({
rid: this.data.reserve.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.data.reserve.id,
oid: res.data.id,
identity: 1,
sid: res.data.sellerid
}, '/pack-cookbook/pages/index')
});
})
}
},
checkout(){
if(this.data.reserve.status==0){
this.selectComponent('#showModal').options({
header: '您点早啦!',
body: '商家分配包间后,您可以通过在线买单支付,无需到前台结账排队等发票。'
}).show();
}else{
wx.navigateTo({
url:util.http_build_query({
rid:this.data.reserve.id,
sid:this.data.reserve.seller.id
},'/pack-checkout/pages/index')
})
}
},
}
})