|
|
|
var util = require('../../utils/util.js')
|
|
|
|
var uri=require('../../utils/uri.js')
|
|
|
|
var bookOrder=require('../../utils/bookCommon.js')
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import comm from '../../utils/bookCommon';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
Page({
|
|
|
|
data:{
|
|
|
|
desk_type:[
|
|
|
|
{
|
|
|
|
type:2,
|
|
|
|
type_name:'包厢',
|
|
|
|
isselect:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type:1,
|
|
|
|
type_name:'散座',
|
|
|
|
isselect:false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type:'',
|
|
|
|
type_name:'全部',
|
|
|
|
isselect:false
|
|
|
|
}
|
|
|
|
],
|
|
|
|
tabletype:2
|
|
|
|
|
|
|
|
},
|
|
|
|
onLoad:function(opt){
|
|
...
|
...
|
@@ -28,142 +11,16 @@ Page({ |
|
|
|
util.setBarTitle('选择桌位');
|
|
|
|
var radio=750/util.getsystem().windowWidth;
|
|
|
|
var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);
|
|
|
|
var temdate=bookOrder.get_date(opt.date);
|
|
|
|
var stringTime =opt.year+'-'+temdate+' ' +opt.time_dur+':00';
|
|
|
|
console.log(stringTime)
|
|
|
|
var time=bookOrder.gettimestamp(stringTime);
|
|
|
|
this.setData({
|
|
|
|
sellerid:util.cache('sellerid'),
|
|
|
|
selectdate:opt.date,
|
|
|
|
time_dur:opt.time_dur,
|
|
|
|
pnum:opt.pnum,
|
|
|
|
contentHeight:contentHeight,
|
|
|
|
time:time,
|
|
|
|
thisyear:opt.year
|
|
|
|
})
|
|
|
|
console.log(time)
|
|
|
|
var thistype=util.cache('tabletype');
|
|
|
|
var fixedtype=this.data.desk_type;
|
|
|
|
var dd=[];
|
|
|
|
for(var key in thistype){
|
|
|
|
var type=key.split('_')[1];
|
|
|
|
fixedtype.forEach(function(v,i){
|
|
|
|
if(v.type==type){
|
|
|
|
v.isselect=false;
|
|
|
|
if(type==2){
|
|
|
|
dd.unshift(v)
|
|
|
|
}else{
|
|
|
|
dd.push(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(opt.tid==0){
|
|
|
|
delete opt.tid
|
|
|
|
}
|
|
|
|
dd.push({
|
|
|
|
type:'',
|
|
|
|
type_name:'全部',
|
|
|
|
isselect:false
|
|
|
|
})
|
|
|
|
dd[0].isselect=true;
|
|
|
|
this.setData({
|
|
|
|
desk_type:dd,
|
|
|
|
tabletype:dd[0].type
|
|
|
|
sellerid:util.cache('sellerid'),
|
|
|
|
opt:opt
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
},
|
|
|
|
onShow:function(){
|
|
|
|
var that=this;
|
|
|
|
util.postSuccessFun=function(json,uri_code){
|
|
|
|
switch (uri_code) {
|
|
|
|
case uri.CGI_USER_GETTABLELIST__CODE:
|
|
|
|
console.log(json)
|
|
|
|
var desklist=json.data;
|
|
|
|
var thisdesk=[];
|
|
|
|
for(var key in desklist){
|
|
|
|
if(bookOrder.isInteger(key)==true){
|
|
|
|
desklist[key].list.forEach(function(r,n){
|
|
|
|
r.isselect=false;
|
|
|
|
if(util.cache('tableid')){
|
|
|
|
var tables=util.cache('tableid');
|
|
|
|
tables.forEach(function(v,i){
|
|
|
|
if(v==r.id){
|
|
|
|
r.isselect=true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
thisdesk.push(desklist[key])
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(that.data.tabletype!=''){
|
|
|
|
that.selectdesk(thisdesk);
|
|
|
|
}else{
|
|
|
|
that.setData({
|
|
|
|
desklist:thisdesk
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(that.data.desklist)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selectType:function(e){
|
|
|
|
var type=e.currentTarget.dataset.type;
|
|
|
|
var desktype=this.data.desk_type;
|
|
|
|
desktype.forEach(function(v,i){
|
|
|
|
v.isselect=false
|
|
|
|
if(v.type==type){
|
|
|
|
v.isselect=true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
desk_type:desktype,
|
|
|
|
tabletype:type
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
},
|
|
|
|
selectdesk:function(desklist){
|
|
|
|
var type=this.data.tabletype;
|
|
|
|
console.log('tttt',desklist)
|
|
|
|
var thislist=[];
|
|
|
|
var temp={}
|
|
|
|
desklist.forEach(function(v,i){
|
|
|
|
v.list.forEach(function(r,n){
|
|
|
|
if(r.tid==type){
|
|
|
|
if(!temp.hasOwnProperty(v.name)){
|
|
|
|
temp[v.name]=true;
|
|
|
|
thislist.push({
|
|
|
|
name:v.name,
|
|
|
|
list:[]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log(thislist)
|
|
|
|
desklist.forEach(function(v,i){
|
|
|
|
thislist.forEach(function(r,n){
|
|
|
|
if(v.name==r.name){
|
|
|
|
v.list.forEach(function(r1,n1){
|
|
|
|
if(r1.tid==type){
|
|
|
|
r.list.push(r1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
desklist:thislist
|
|
|
|
})
|
|
|
|
},
|
|
|
|
changepnum:function(e){
|
|
|
|
this.setData({
|
|
|
|
pnum:e.detail
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
},
|
|
|
|
changedesk:function(e){
|
|
|
|
var tableid=e.detail;
|
|
...
|
...
|
@@ -178,276 +35,22 @@ Page({ |
|
|
|
wx.navigateBack()
|
|
|
|
},
|
|
|
|
getdesklist:function(){
|
|
|
|
util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.pnum),rdate:this.data.time},uri.CGI_USER_GETTABLELIST__CODE)
|
|
|
|
},
|
|
|
|
backtime:function () {
|
|
|
|
var pages=getCurrentPages();
|
|
|
|
var len=pages.length;
|
|
|
|
var timelist=pages[len-3].data.timeList;
|
|
|
|
var datelist=pages[len-3].data.dateList;
|
|
|
|
var currendate=bookOrder.get_date(this.data.selectdate)
|
|
|
|
var time_dur=this.data.time_dur;
|
|
|
|
var dateindex;
|
|
|
|
datelist.forEach(function(v,i){
|
|
|
|
if(v.date==currendate){
|
|
|
|
dateindex=i;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var formdata=this.data.opt;
|
|
|
|
formdata.sid=this.data.sellerid;
|
|
|
|
var that=this;
|
|
|
|
var timeIndex;
|
|
|
|
var durIndex;
|
|
|
|
timelist.forEach(function(v,i){
|
|
|
|
v.list.forEach(function(r,n){
|
|
|
|
r.isselect=false;
|
|
|
|
if(r.time_dur==time_dur){
|
|
|
|
console.log('xxxx',n,i,time_dur)
|
|
|
|
timeIndex=n;
|
|
|
|
durIndex=i;
|
|
|
|
if(n==0 && i==0){
|
|
|
|
if(dateindex==0){
|
|
|
|
console.log('不能再退了')
|
|
|
|
}else{
|
|
|
|
console.log(11111)
|
|
|
|
dateindex=dateindex-1;
|
|
|
|
datelist.forEach(function(r1,n1){
|
|
|
|
r1.isActive=false;
|
|
|
|
if(dateindex==n1){
|
|
|
|
r1.isActive=true;
|
|
|
|
that.setData({
|
|
|
|
thisyear:r1.year
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
pages[len-3].setData({
|
|
|
|
selectdate:datelist[dateindex].date,
|
|
|
|
dateList:datelist
|
|
|
|
})
|
|
|
|
pages[len-3].getimelist();
|
|
|
|
timelist=pages[len-3].data.timeList;
|
|
|
|
that.setData({
|
|
|
|
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
|
|
|
|
time_dur:'22:00'
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
|
|
|
|
time_dur:'22:00'
|
|
|
|
})
|
|
|
|
console.log(that.data.time_dur)
|
|
|
|
timelist.forEach(function(r1,n1){
|
|
|
|
r1.list.forEach(function(r2,n2){
|
|
|
|
r2.isselect=false;
|
|
|
|
console.log(r2)
|
|
|
|
if(r2.time_dur==that.data.time_dur){
|
|
|
|
console.log('xxxxx',r2)
|
|
|
|
r2.isselect=true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log(timelist)
|
|
|
|
pages[len-3].setData({
|
|
|
|
timeList:timelist,
|
|
|
|
time_dur:'22:00'
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(n>0 && i==0){
|
|
|
|
that.setData({
|
|
|
|
time_dur:v.list[n-1].time_dur
|
|
|
|
})
|
|
|
|
v.list[n-1].isselect=true;
|
|
|
|
pages[len-3].setData({
|
|
|
|
timeList:timelist,
|
|
|
|
time_dur:v.list[n-1].time_dur
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:v.list[n-1].time_dur
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(n==0 && i>0){
|
|
|
|
console.log('xxxx',2)
|
|
|
|
that.setData({
|
|
|
|
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
|
|
|
|
})
|
|
|
|
timelist[i-1].list[timelist[i-1].list.length-1].isselect=true;
|
|
|
|
pages[len-3].setData({
|
|
|
|
timeList:timelist,
|
|
|
|
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
|
|
|
|
App.Reserve.GetTableList(formdata).then(function (json) {
|
|
|
|
if(json.ret==200){
|
|
|
|
if(json.data.length>0){
|
|
|
|
json.data.forEach(function(v,i){
|
|
|
|
v.list.forEach(function(r,n){
|
|
|
|
r.isselect=false
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(n>0 && i>0){
|
|
|
|
that.setData({
|
|
|
|
time_dur:v.list[n-1].time_dur
|
|
|
|
})
|
|
|
|
v.list[n-1].isselect=true;
|
|
|
|
pages[len-3].setData({
|
|
|
|
timeList:timelist,
|
|
|
|
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:v.list[n-1].time_dur
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
var temdate=bookOrder.get_date(this.data.selectdate);
|
|
|
|
var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;
|
|
|
|
var time=bookOrder.gettimestamp(stringTime);
|
|
|
|
this.setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-3].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
aftertime:function(){
|
|
|
|
var pages=getCurrentPages();
|
|
|
|
var len=pages.length;
|
|
|
|
console.log(len)
|
|
|
|
var timelist=pages[len-3].data.timeList;
|
|
|
|
var datelist=pages[len-3].data.dateList;
|
|
|
|
var currendate=bookOrder.get_date(this.data.selectdate);
|
|
|
|
var time_dur=this.data.time_dur;
|
|
|
|
var dateindex;
|
|
|
|
datelist.forEach(function(v,i){
|
|
|
|
if(v.date==currendate){
|
|
|
|
dateindex=i;
|
|
|
|
that.setData({
|
|
|
|
desklist:json.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var that=this;
|
|
|
|
timelist.forEach(function(v,i){
|
|
|
|
v.list.forEach(function(r,n){
|
|
|
|
r.isselect=false
|
|
|
|
if(r.time_dur==time_dur){
|
|
|
|
if(i==timelist.length-1 && n==v.list.length-1){
|
|
|
|
if(dateindex==2){
|
|
|
|
console.log('不能再加了')
|
|
|
|
}else{
|
|
|
|
console.log('tttttt')
|
|
|
|
dateindex=dateindex+1;
|
|
|
|
datelist.forEach(function(r1,n1){
|
|
|
|
r1.isActive=false;
|
|
|
|
if(dateindex==n1){
|
|
|
|
r1.isActive=true;
|
|
|
|
that.setData({
|
|
|
|
thisyear:r1.year
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
pages[len-3].setData({
|
|
|
|
selectdate:datelist[dateindex].date,
|
|
|
|
dateList:datelist
|
|
|
|
})
|
|
|
|
pages[len-3].getimelist();
|
|
|
|
timelist=pages[len-3].data.timeList;
|
|
|
|
that.setData({
|
|
|
|
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
|
|
|
|
time_dur:'6:00'
|
|
|
|
})
|
|
|
|
console.log(time_dur)
|
|
|
|
console.log('hhhh',that.data.time_dur)
|
|
|
|
pages[len-2].setData({
|
|
|
|
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
|
|
|
|
time_dur:'6:00'
|
|
|
|
})
|
|
|
|
console.log(timelist)
|
|
|
|
timelist.forEach(function(r1,n1){
|
|
|
|
r1.list.forEach(function(r2,n2){
|
|
|
|
r2.isselect=false;
|
|
|
|
if(r2.time_dur==that.data.time_dur){
|
|
|
|
r2.isselect=true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
timelist[2].list[0].isselect=false
|
|
|
|
console.log('ffff',timelist)
|
|
|
|
pages[len-3].setData({
|
|
|
|
timeList:timelist,
|
|
|
|
time_dur:'6:00'
|
|
|
|
})
|
|
|
|
var temdate=bookOrder.get_date(that.data.selectdate);
|
|
|
|
var stringTime =that.data.thisyear+'-'+temdate+' ' +that.data.time_dur;
|
|
|
|
var time=bookOrder.gettimestamp(stringTime);
|
|
|
|
that.setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-3].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
that.getdesklist();
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(i==timelist.length-1 && n<v.list.length-1){
|
|
|
|
that.setData({
|
|
|
|
time_dur:v.list[n+1].time_dur
|
|
|
|
})
|
|
|
|
v.list[n+1].isselect=true
|
|
|
|
pages[len-3].setData({
|
|
|
|
time_dur:v.list[n+1].time_dur,
|
|
|
|
timeList:timelist
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:v.list[n+1].time_dur
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(i<timelist.length-1 && n==v.list.length-1){
|
|
|
|
that.setData({
|
|
|
|
time_dur:timelist[i+1].list[0].time_dur,
|
|
|
|
})
|
|
|
|
timelist[i+1].list[0].isselect=true;
|
|
|
|
pages[len-3].setData({
|
|
|
|
time_dur:timelist[i+1].list[0].time_dur,
|
|
|
|
timeList:timelist
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:timelist[i+1].list[0].time_dur,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(i<timelist.length-1 && n<v.list.length-1){
|
|
|
|
that.setData({
|
|
|
|
time_dur:v.list[n+1].time_dur
|
|
|
|
})
|
|
|
|
v.list[n+1].isselect=true
|
|
|
|
pages[len-3].setData({
|
|
|
|
time_dur:v.list[n+1].time_dur,
|
|
|
|
timeList:timelist
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time_dur:v.list[n+1].time_dur
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
var temdate=bookOrder.get_date(this.data.selectdate);
|
|
|
|
var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;
|
|
|
|
var time=bookOrder.gettimestamp(stringTime);
|
|
|
|
this.setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-3].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
pages[len-2].setData({
|
|
|
|
time:time
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|