|
...
|
...
|
@@ -3,77 +3,81 @@ import comm from '../../../utils/bookCommon'; |
|
|
|
import App from '../../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
Page({
|
|
|
|
data:{
|
|
|
|
menu_active_id:''
|
|
|
|
},
|
|
|
|
checked_tids:[],
|
|
|
|
desks:[],
|
|
|
|
onLoad:function(opt){
|
|
|
|
console.log('onLoad',opt)
|
|
|
|
util.setBarTitle('选择桌位');
|
|
|
|
var radio=750/util.getsystem().windowWidth;
|
|
|
|
var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);
|
|
|
|
if(opt.tid==0){
|
|
|
|
delete opt.tid
|
|
|
|
}
|
|
|
|
if(opt.checked_tids){
|
|
|
|
this.checked_tids=opt.checked_tids.split(',')
|
|
|
|
util.cache('tableid',this.checked_tids)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
sellerid:util.cache('sellerid'),
|
|
|
|
opt:opt,
|
|
|
|
hasCheckedTable:this.checked_tids.length>0
|
|
|
|
})
|
|
|
|
this.getdesklist();
|
|
|
|
},
|
|
|
|
onShow:function(){
|
|
|
|
this.setData({
|
|
|
|
height:getApp().system.windowHeight-55
|
|
|
|
})
|
|
|
|
},
|
|
|
|
changedesk:function(e){
|
|
|
|
let tableid=util.cache('tableid');
|
|
|
|
this.checked_tids= tableid && tableid.length>0?tableid:[];
|
|
|
|
this.setData({
|
|
|
|
hasCheckedTable:this.checked_tids.length>0
|
|
|
|
})
|
|
|
|
},
|
|
|
|
back:function(){
|
|
|
|
this.setData({
|
|
|
|
buttonClick:true
|
|
|
|
})
|
|
|
|
//wx.removeStorage({key:'tableid'})
|
|
|
|
wx.navigateBack();
|
|
|
|
},
|
|
|
|
getdesklist:function(){
|
|
|
|
var formdata=this.data.opt;
|
|
|
|
formdata.sid=this.data.sellerid;
|
|
|
|
var that=this;
|
|
|
|
App.Reserve.GetTableList(formdata).then(function (json) {
|
|
|
|
if(json.ret==200){
|
|
|
|
console.log('this.checked_tids',that.checked_tids);
|
|
|
|
that.desks=json.data
|
|
|
|
that.formatDesklist(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
formatDesklist(hasFirst=true){
|
|
|
|
let desks=this.desks;
|
|
|
|
if(desks.length>0){
|
|
|
|
desks.forEach((v,i)=>{
|
|
|
|
v.list.forEach((r,n)=>{
|
|
|
|
r.isselect=false
|
|
|
|
if(this.checked_tids._indexOf(r.id)>-1){
|
|
|
|
r.isselect=true;
|
|
|
|
data: {
|
|
|
|
menu_active_id: ''
|
|
|
|
},
|
|
|
|
checked_tids: [],
|
|
|
|
desks: [],
|
|
|
|
sellerid:'',
|
|
|
|
options:null,
|
|
|
|
onLoad: function (opt) {
|
|
|
|
console.log('onLoad', opt)
|
|
|
|
this.options=opt;
|
|
|
|
var radio = 750 / util.getsystem().windowWidth;
|
|
|
|
var contentHeight = util.getsystem().windowHeight - Math.ceil(350 / radio);
|
|
|
|
if (opt.tid == 0) {
|
|
|
|
delete opt.tid
|
|
|
|
}
|
|
|
|
if (opt.checked_tids) {
|
|
|
|
this.checked_tids = opt.checked_tids.split(',')
|
|
|
|
util.cache('tableid', this.checked_tids)
|
|
|
|
}
|
|
|
|
this.sellerid=util.cache('sellerid');
|
|
|
|
this.setData({
|
|
|
|
sellerid: this.sellerid,
|
|
|
|
opt: opt,
|
|
|
|
hasCheckedTable: this.checked_tids.length > 0
|
|
|
|
})
|
|
|
|
//this.getdesklist();
|
|
|
|
this.getDeskList();
|
|
|
|
},
|
|
|
|
onShow: function () {
|
|
|
|
this.setData({
|
|
|
|
height: getApp().system.windowHeight - 55
|
|
|
|
})
|
|
|
|
},
|
|
|
|
changedesk: function (e) {
|
|
|
|
let tableid = util.cache('tableid');
|
|
|
|
this.checked_tids = tableid && tableid.length > 0 ? tableid : [];
|
|
|
|
this.setData({
|
|
|
|
hasCheckedTable: this.checked_tids.length > 0
|
|
|
|
})
|
|
|
|
},
|
|
|
|
back: function () {
|
|
|
|
this.setData({
|
|
|
|
buttonClick: true
|
|
|
|
})
|
|
|
|
//wx.removeStorage({key:'tableid'})
|
|
|
|
wx.navigateBack();
|
|
|
|
},
|
|
|
|
getdesklist: function () {
|
|
|
|
var formdata = this.data.opt;
|
|
|
|
formdata.sid = this.data.sellerid;
|
|
|
|
var that = this;
|
|
|
|
App.Reserve.GetTableList(formdata).then(function (json) {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
console.log('this.checked_tids', that.checked_tids);
|
|
|
|
that.desks = json.data
|
|
|
|
that.formatDesklist(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
formatDesklist(hasFirst = true){
|
|
|
|
let desks = this.desks;
|
|
|
|
if (desks.length > 0) {
|
|
|
|
desks.forEach((v, i) => {
|
|
|
|
v.list.forEach((r, n) => {
|
|
|
|
r.isselect = false
|
|
|
|
if (this.checked_tids._indexOf(r.id) > -1) {
|
|
|
|
r.isselect = true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
let param={
|
|
|
|
desklist:desks,
|
|
|
|
let param = {
|
|
|
|
desklist: desks,
|
|
|
|
}
|
|
|
|
if(hasFirst){
|
|
|
|
param.menu_active_id=desks[0].name
|
|
|
|
if (hasFirst) {
|
|
|
|
param.menu_active_id = desks[0].name
|
|
|
|
}
|
|
|
|
this.setData(param)
|
|
|
|
}
|
|
...
|
...
|
@@ -83,7 +87,85 @@ Page({ |
|
|
|
|
|
|
|
this.formatDesklist(false)
|
|
|
|
this.setData({
|
|
|
|
menu_active_id:util.attr(e,'id')
|
|
|
|
menu_active_id: util.attr(e, 'id')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getDeskList(){
|
|
|
|
App.Tables.GetTableListsBySellerId({
|
|
|
|
sellerid:this.sellerid
|
|
|
|
}).then((res)=>{
|
|
|
|
this.desks=res.data[0];
|
|
|
|
this.getbooklist();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async getbooklist(){
|
|
|
|
let obj={};
|
|
|
|
|
|
|
|
let formdata={};
|
|
|
|
formdata.sid=this.sellerid;
|
|
|
|
formdata.x=1;
|
|
|
|
formdata.y=200;
|
|
|
|
formdata.rdate=this.options.rdate;
|
|
|
|
formdata.status='1,2';
|
|
|
|
let tids={};
|
|
|
|
let reserves=await App.Reserve.GetReserveList(formdata);
|
|
|
|
if(reserves.data.length>0){
|
|
|
|
reserves.data.forEach(r=>{
|
|
|
|
let ts=r.tid.split(',');
|
|
|
|
ts.forEach(tid=>{
|
|
|
|
let rname='';
|
|
|
|
if(r.sex==3){
|
|
|
|
rname=r.rname.substr(0,10)
|
|
|
|
}else{
|
|
|
|
rname=r.rname.substr(0,1)+(r.sex==1?'先生':'女士')
|
|
|
|
}
|
|
|
|
tids[tid]={
|
|
|
|
rdate:r.rdate,
|
|
|
|
id:r.id,
|
|
|
|
status:r.status,
|
|
|
|
rname:rname,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log('tids',tids);
|
|
|
|
let regions=[];
|
|
|
|
this.desks.forEach(region=>{
|
|
|
|
if(region.list.length>0){
|
|
|
|
let list_num=0;
|
|
|
|
region.list.forEach(tb=>{
|
|
|
|
tb.status_str='';
|
|
|
|
tb.status_classname='enabled'
|
|
|
|
tb.reserve_name=''
|
|
|
|
tb.reserve_id=''
|
|
|
|
if(tb.status!=0 && tb.status!=""){
|
|
|
|
tb.status_str='用餐中';
|
|
|
|
tb.status_classname='highlight';
|
|
|
|
tb.reserve_name=tb.spell==1?'拼桌':'堂食';
|
|
|
|
}else if(tids[tb.id]){
|
|
|
|
console.log('tids',region.name,tb.name);
|
|
|
|
tb.status_str=tids[tb.id].status==2?'用餐中':'已预订';
|
|
|
|
tb.status_classname='highlight';
|
|
|
|
tb.reserve_id=tids[tb.id].id;
|
|
|
|
tb.reserve_name=tids[tb.id].rname;
|
|
|
|
}
|
|
|
|
if(tb.enable!=1){
|
|
|
|
if(tb.status_str){
|
|
|
|
tb.status_classname='disabled-highlight';
|
|
|
|
}else{
|
|
|
|
tb.status_str='已停用';
|
|
|
|
tb.status_classname='disabled';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!tb.status_str){
|
|
|
|
list_num++;
|
|
|
|
}
|
|
|
|
region.list_num=list_num;
|
|
|
|
})
|
|
|
|
regions.push(region);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.desks=regions
|
|
|
|
this.formatDesklist(true);
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|