|
|
|
// pages/book/b_setting.js
|
|
|
|
var util = require('../../utils/util.js')
|
|
|
|
var bookOrder=require('../../utils/bookCommon.js')
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
dateStr:'',
|
|
|
|
calendarMaskLoad:false,
|
|
|
|
calendarMask:false,
|
|
|
|
dayStyle:[
|
|
|
|
{ month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' },
|
|
|
|
{ month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' }
|
|
|
|
],
|
|
|
|
regions:[],
|
|
|
|
regions_active:'',
|
|
|
|
time:-1,
|
|
|
|
},
|
|
|
|
regions:[],
|
|
|
|
sellerid:0,
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
let d=new Date()/1000;
|
|
|
|
let dateStr=util.unixtoTime(d,'MM-DD DAY');
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
dateStr:dateStr
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: async function () {
|
|
|
|
this.setData({
|
|
|
|
height:getApp().system.windowHeight-170,
|
|
|
|
})
|
|
|
|
setTimeout(()=>{
|
|
|
|
this.setData({
|
|
|
|
calendarMaskLoad:true,
|
|
|
|
})
|
|
|
|
},1000);
|
|
|
|
this.selectComponent('#nav').init();
|
|
|
|
this.sellerid=util.cache('sellerid');
|
|
|
|
App.Tables.GetTableListsBySellerId({
|
|
|
|
sellerid:this.sellerid
|
|
|
|
}).then((res)=>{
|
|
|
|
this.regions=res.data[0];
|
|
|
|
this.getbooklist();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
calendarShow(){
|
|
|
|
console.log('xxxxx')
|
|
|
|
this.setData({
|
|
|
|
calendarMask:true
|
|
|
|
})
|
|
|
|
console.log(this.data.calendarMask)
|
|
|
|
},
|
|
|
|
dateChange(event){
|
|
|
|
var currentdate=event.detail.year+'-'+(event.detail.month<10 ? '0'+event.detail.month : event.detail.month)+'-'+(event.detail.day<10 ? '0'+event.detail.day : event.detail.day);
|
|
|
|
var currentime=bookOrder.gettimestamp(currentdate+' 00:00:00');
|
|
|
|
var myDate = new Date(parseInt(currentime)*1000);
|
|
|
|
var week=bookOrder.getweek(myDate.getDay());
|
|
|
|
var dateStr=(event.detail.month<10 ? '0'+event.detail.month : event.detail.month)+'-'+(event.detail.day<10 ? '0'+event.detail.day : event.detail.day);
|
|
|
|
if(currentime-new Date()/1000<=86400 && currentime-new Date()/1000>0){
|
|
|
|
dateStr+=' 明天'
|
|
|
|
}else{
|
|
|
|
dateStr+=' '+week
|
|
|
|
}
|
|
|
|
let clickDay = event.detail.day;
|
|
|
|
let changeDay = `dayStyle[1].day`;
|
|
|
|
let changeBg = `dayStyle[1].background`;
|
|
|
|
console.log(changeBg)
|
|
|
|
this.setData({
|
|
|
|
showyear:event.detail.year,
|
|
|
|
showmonth:event.detail.month,
|
|
|
|
showday:event.detail.day,
|
|
|
|
dateStr:dateStr,
|
|
|
|
[changeDay]: clickDay,
|
|
|
|
[changeBg]: "#84e7d0"
|
|
|
|
})
|
|
|
|
this.getbooklist();
|
|
|
|
this.calendarClose();
|
|
|
|
},
|
|
|
|
calendarClose(){
|
|
|
|
this.setData({
|
|
|
|
calendarMask:false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async getbooklist(){
|
|
|
|
let obj={};
|
|
|
|
|
|
|
|
let formdata={};
|
|
|
|
formdata.sid=this.sellerid;
|
|
|
|
formdata.x=1;
|
|
|
|
formdata.y=200;
|
|
|
|
let time=0;
|
|
|
|
if(this.data.time<0){
|
|
|
|
time=await bookOrder.getTimeSpaceIndex();
|
|
|
|
obj.time=time;
|
|
|
|
}else{
|
|
|
|
time=this.data.time;
|
|
|
|
}
|
|
|
|
let rdate=await bookOrder.getTimeSpace(this.data.dateStr,time);
|
|
|
|
formdata.rdate=rdate;
|
|
|
|
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=>{
|
|
|
|
tids[tid]={
|
|
|
|
rdate:r.rdate,
|
|
|
|
id:r.id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log('tids',tids);
|
|
|
|
let regions=[];
|
|
|
|
let now=new Date()/1000;
|
|
|
|
this.regions.forEach(region=>{
|
|
|
|
if(region.list.length>0){
|
|
|
|
region.list.forEach(tb=>{
|
|
|
|
tb.status_str='';
|
|
|
|
tb.status_classname='enabled'
|
|
|
|
if(tids[tb.id]){
|
|
|
|
console.log('tids',region.name,tb.name);
|
|
|
|
tb.status_str=now>tids[tb.id].rdate?'用餐中':'已预订';
|
|
|
|
tb.status_classname='highlight';
|
|
|
|
tb.reserve_id=tids[tb.id].id;
|
|
|
|
}else if(tb.enable!=1){
|
|
|
|
tb.status_str='已停用';
|
|
|
|
tb.status_classname='disabled';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
regions.push(region);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
obj.regions=regions
|
|
|
|
if(!this.data.regions_active){
|
|
|
|
obj.regions_active=this.regions[0].name
|
|
|
|
}
|
|
|
|
this.setData(obj)
|
|
|
|
},
|
|
|
|
chooseRegion(e){
|
|
|
|
this.setData({
|
|
|
|
regions_active:util.attr(e,'name')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|