board.js
3.26 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
// components/book/board/board.js
import util from '../../../../utils/util';
import App from '../../../../utils/api';
const {regeneratorRuntime} = global
import gl from '../../../global'
Component({
/**
* 组件的属性列表
*/
properties: {
width:{
type:String,
value:160
},
height:{
type:String,
value:160
},
board:{
type:Object,
value:{}
},
event:{
type:String,
value:'',
},
className:{
type:String,
value:'',
},
ddate:{ //带入预订时间 time1-time2
type:String,
value:'',
},
roomDemand:{
type:Boolean,
value:false
},
hasRegionName:Boolean,
},
/**
* 组件的初始数据
*/
data: {
itemList:[],
},
/**
* 组件的方法列表
*/
itemList:[],
ready(){
this.hasEditorFlag=false;
this.hasEditor();
},
methods: {
boardClick(){
if(!this.data.event) return;
this[this.data.event]()
},
boardClickCallback(e){
let board=this.data.board;
switch (e.detail.value){
case '查看详情':
wx.navigateTo({
url:'b_detail?id='+board.reserve_id,
});
break;
case '启用桌位':
this.boardEnable(1)
break;
case '停用桌位':
this.boardEnable(0)
break;
case '订座':
wx.redirectTo({
url:'b_addnew?hasQuick=1&tid='+board.id
+'&tname='+board.name
+'&pnum='+(board.most_pnum>board.table_pnum?board.most_pnum:board.table_pnum)
+'&ddate='+this.data.ddate,
});
break;
}
},
//桌位操作
boardOpt(){
let itemList=[]
if(this.hasEditorFlag){
if(!this.data.board.reserve_id && this.data.board.enable==1){
if(this.data.ddate){
let t=new Date()/1000;
//console.log('this.data.ddate.substr(11,10)',this.data.ddate.substr(11,10))
//if(parseInt(this.data.ddate.substr(11,10))>t){
itemList.push('订座')
//}
}
}
if(this.data.board.reserve_id>0){
itemList.push('查看详情')
}
itemList.push(this.data.board.enable==1?'停用桌位':'启用桌位')
//console.log(getApp().system)
this.itemList=itemList;
this.setData({
itemList:itemList,
})
this.selectComponent('#boardas').show();
console.log('this.data.board',this.data.board)
}else{
if(this.data.board.reserve_id>0){
itemList.push('查看详情')
this.itemList=itemList;
this.setData({
itemList:itemList,
})
this.selectComponent('#boardas').show();
}
}
},
//桌位选择
boardChoose(){
//this.triggerEvent('boardEvent',{type:'boardChoose',id:this.data.board.id})
},
//启停座位
boardEnable(status){
App.Reserve.SetSwitchStatus({
id:this.data.board.id,
status:status
}).then(()=>{
this.triggerEvent('boardEvent',{type:'boardEnable'})
})
},
//是否可以编辑
hasEditor(){
gl.getHasEditorFlag().then(()=>{
this.hasEditorFlag=true
}).catch(()=>{})
},
}
})