card-review.js
2.59 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
// components/2.0/reserve/card.js
import util from '../../../utils/util';
import RS from '../../../utils/reserveStatus'
import App from '../../../utils/api';
Component({
/**
* 组件的属性列表
*/
properties: {
detail:Object,
seller:Object,
},
/**
* 组件的初始数据
*/
data: {
ddate_Str:'',
},
attached(){
//this.init()
},
observers: {
'detail': function() {
this.init()
},
},
/**
* 组件的方法列表
*/
methods: {
init(){
let detail=this.data.detail
if(!detail) return;
detail.tables=[]
detail.room_demand.some(t=>{
detail.tables.push([t.name])
})
detail.ddateStr=util.unixtoTime(detail.ddate,'MM月DD日,`DAY/周WW`')
console.log('detail.init',detail)
this.getLocalLunchTime(detail.sid,detail.date,detail.section)
this.setData({
reserve:detail,
})
},
//获取日期对应的多时段
getLocalLunchTime(sid,date,section){
App.Seller.getMealSectionByDay({
sellerid: sid,
day: date,
}).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.section == section})
if(obj && obj.length>0){
this.setData({
ddate_Str:obj[0].mname
})
}
}).catch(res => {
console.log(res, '获取多时段失败');
})
},
}
})