room.js
3.84 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
import App from '../../../utils/api';
import util from '../../../utils/util';
let dur=['morning','noon','night','midnight']
Component({
properties:{
seller:Object,
date:{
type:String,
value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD')
},
section:String,
usecondition:{
type:String,
value:'custom'
},
seletroomlist:{
type:Array,
value:[]
}
},
data:{
roomlist:[],
},
observers: {
'date,section': function(newdate,newsection) {
console.log('room',newdate,newsection)
this.setData({
roomlist:[]
})
if(newdate && newsection){
this.getroomtype();
}
}
},
attached(){
console.log('初次进入详情页---小米8测试',this.data.date ? this.data.date : '没有日期','openid:',getApp().openid)
},
methods:{
getroomtype(){
let parmdata={
sellerid:this.data.seller.id,
day:util.timetouUnix(this.data.date+' 00:00:00'),
interval:dur.indexOf(this.data.section)+1
}
console.log('参数',this.data.date,parmdata);
App.Seller.GetSellerTableClass(parmdata).then((json)=>{
console.log('roomlist',json)
if(json.ret==200){
if(json.data.length>0){
if(this.data.usecondition=="custom"){
json.data.forEach((v,i)=>{
v.selectnum=0;
})
}
}
this.setData({
roomlist:json.data
})
if(this.data.seletroomlist.length>0){
this.changestyle();
}
}
})
},
selectroom(e){
let _target=e.currentTarget.dataset;
console.log(typeof _target.selectnum,this.data.usecondition)
if(this.data.usecondition=='custom'){
console.log('custom:true为点击了订满的包间类型',this.data.roomlist[_target.index].isorderFull==1 || this.data.roomlist[_target.index].isFull==1)
if(this.data.roomlist[_target.index].isorderFull==1 || this.data.roomlist[_target.index].isFull==1){
let obj={
act:'reserve',
seller:this.data.seller.sellername,
date:this.data.date,
section:this.data.section,
room:this.data.roomlist[_target.index].name
}
// this.selectComponent('#qiang').show(obj);
}else{
console.log('执行了选中包间类型');
if((this.data.seletroomlist && this.data.seletroomlist.length<3) || !this.data.seletroomlist){
let setkey='roomlist['+_target.index+'].selectnum';
this.setData({
[setkey]:_target.selectnum+1
})
let obj={
id:_target.id,
name:this.data.roomlist[_target.index].name,
action:'confirm'
}
this.triggerEvent('selectroom',obj)
}else{
util.toast('最多可选3个包间','none');
}
}
}else{
//////
console.log('置满')
if(!this.data.roomlist[_target.index].isorderFull){
let parmdata={
classid:_target.id,
day:util.timetouUnix(this.data.date+' 00:00:00'),
interval:dur.indexOf(this.data.section)+1
}
if(_target.fid){
parmdata.id=_target.fid;
}
App.Seller.SetTableClassFull(parmdata).then((json)=>{
console.log(json)
if(json.ret==200){
this.triggerEvent('changeroom',{id:_target.id,action:parmdata.id ? 'cancel' : 'confirm'})
this.getroomtype();
}
})
}
}
},
cancelroom(id){
let roomlist=this.data.roomlist;
roomlist.forEach((v,i)=>{
if(v.id==id){
let setkey='roomlist['+i+'].selectnum';
this.setData({
[setkey]:v.selectnum-1,
})
}
})
},
changestyle(){
let seletroomlist=this.data.seletroomlist;
let roomlist=this.data.roomlist;
seletroomlist.forEach((v,i)=>{
roomlist.forEach((r,n)=>{
if(v.id==r.id){
if(r.isFull || r.isorderFull){
this.cancelroom(r.id);
let obj={
id:r.id,
name:r.name,
action:'cancel'
}
this.triggerEvent('selectroom',obj)
}else{
r.selectnum+=1;
}
}
})
})
this.setData({
roomlist:roomlist
})
},
}
})