board.js
1.97 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
// components/book/board/board.js
import util from '../../../utils/util';
import App from '../../../utils/api';
const {regeneratorRuntime} = 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:'',
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
itemList:[],
methods: {
boardClick(){
if(!this.data.event) return;
this[this.data.event]()
},
//桌位操作
boardOpt(){
let itemList=[]
if(this.data.board.reserve_id>0){
itemList.push('查看详情')
}
itemList.push(this.data.board.enable==1?'停用桌位':'启用桌位')
//console.log(getApp().system)
if(getApp().system.system.toLowerCase().indexOf('ios')<0){
itemList.push('取消')
}
this.itemList=itemList;
wx.showActionSheet({
itemList:this.itemList,
success:(res)=>{
console.log(res.tapIndex,this.itemList[res.tapIndex]);
if('启用桌位'==this.itemList[res.tapIndex]){
this.boardEnable(1)
}
if('停用桌位'==this.itemList[res.tapIndex]){
this.boardEnable(0)
}
if('查看详情'==this.itemList[res.tapIndex]){
wx.navigateTo({
url:'b_detail?id='+this.data.board.reserve_id,
});
}
},
})
},
//桌位选择
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'})
})
},
}
})