|
|
|
// pages/book/b_addnew.js
|
|
|
|
import util from '../../../utils/util';
|
|
|
|
import comm from '../../../utils/bookCommon';
|
|
|
|
import App from '../../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
const formTpl = {
|
|
|
|
rid: '',
|
|
|
|
date: 0,
|
|
|
|
time: 0,
|
|
|
|
//pnum_str:'1-4',
|
|
|
|
pnum: 6,
|
|
|
|
tabid: 0,
|
|
|
|
|
|
...
|
...
|
@@ -17,16 +12,16 @@ const formTpl = { |
|
|
|
cusdem: '',
|
|
|
|
|
|
|
|
tid: [],
|
|
|
|
is_set_ddate:0,
|
|
|
|
|
|
|
|
}
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
dateStr: [],
|
|
|
|
type:1, // type 1/2/3 新增/修改/桌位
|
|
|
|
time:0,//组件最终构造的到店时间
|
|
|
|
runTime:0,//当前时间戳,或修改到店,或桌位预订时间
|
|
|
|
form: JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
tables: [],
|
|
|
|
grand: [
|
|
...
|
...
|
@@ -47,148 +42,35 @@ Page({ |
|
|
|
}
|
|
|
|
],
|
|
|
|
buttonhide: true,
|
|
|
|
|
|
|
|
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'}
|
|
|
|
],
|
|
|
|
timePickerArray: [
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
],
|
|
|
|
timePickerIndex: [0, 0, 0],
|
|
|
|
tablesLength: 0,
|
|
|
|
|
|
|
|
timePickerMask: false,
|
|
|
|
pnumInputFocus: false,
|
|
|
|
pageMarginBottom: 0,
|
|
|
|
speciallist: [],
|
|
|
|
calendar: {
|
|
|
|
nextNum: 0,
|
|
|
|
},
|
|
|
|
defDtime: ['', '12:00', '18:30'],
|
|
|
|
hasUseDefDtime: true,
|
|
|
|
CustomRemark:[],
|
|
|
|
CustomRemarkMoreMask:false,
|
|
|
|
},
|
|
|
|
reserve_id: '',
|
|
|
|
checkedTables:{},//已选中的桌子集合
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
reserve_id: '',
|
|
|
|
checkedTables:{},//已选中的桌子集合
|
|
|
|
year:util.unixtoTime(new Date() / 1000,'YYYY'),
|
|
|
|
onLoad: async function (options) {
|
|
|
|
this.options=options
|
|
|
|
this.initLoad(options)
|
|
|
|
this.sellerid = util.cache('enter_params')['seller_id'];
|
|
|
|
this.getCustomRemark();
|
|
|
|
},
|
|
|
|
async initLoad(options = {}){
|
|
|
|
let nt = new Date() / 1000;
|
|
|
|
let speciallist = [
|
|
|
|
{date: util.unixtoTime(nt, 'YYYY-MM-DD'), background: '', text: '今 天'},
|
|
|
|
{date: util.unixtoTime(nt + 86400, 'YYYY-MM-DD'), background: '', text: '明 天'},
|
|
|
|
{date: util.unixtoTime(nt + 86400 * 2, 'YYYY-MM-DD'), background: '', text: '后 天'},
|
|
|
|
];
|
|
|
|
this.reserve_id = options.id || '';
|
|
|
|
let rev_time=parseInt(nt)
|
|
|
|
if(options.hasQuick==1){
|
|
|
|
let rdate=options.ddate.split('-')
|
|
|
|
if(!(rev_time>=rdate[0] && rev_time<=rdate[1])){
|
|
|
|
rev_time=rdate[0]
|
|
|
|
}
|
|
|
|
await this.setDateStr(rev_time);
|
|
|
|
if(options.id>0){
|
|
|
|
//修改
|
|
|
|
this.reserve_id=options.id
|
|
|
|
return this.initModify();
|
|
|
|
}
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
let hasUseDefDtime = true;
|
|
|
|
let mmii = util.unixtoTime(rev_time, 'HH:II');
|
|
|
|
if (mmii > this.data.defDtime[this.data.form.time]) {
|
|
|
|
hasUseDefDtime = false;
|
|
|
|
if(options.hasQuick==1){
|
|
|
|
//桌位预订
|
|
|
|
return this.initQuick();
|
|
|
|
}
|
|
|
|
console.log('initLoad::setDateStr',util.unixtoTime(rev_time,'YYYY-MM-DD HH:II'),this.data.defDtime[this.data.form.time])
|
|
|
|
await this.setDateStr(rev_time,hasUseDefDtime);
|
|
|
|
this.sellerid = util.cache('enter_params')['seller_id'];
|
|
|
|
let timePickerArray = await comm.getDayTimeSpace();
|
|
|
|
this.setData({
|
|
|
|
timePickerArray: timePickerArray,
|
|
|
|
speciallist: speciallist,
|
|
|
|
hasUseDefDtime: hasUseDefDtime,
|
|
|
|
runTime:parseInt(new Date()/1000),
|
|
|
|
type:1
|
|
|
|
})
|
|
|
|
if (this.reserve_id > 0) {
|
|
|
|
this.initModify(this.reserve_id);
|
|
|
|
} else if(options.hasQuick==1){
|
|
|
|
this.initQuick(options);
|
|
|
|
} else {
|
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hasInTimeSpace(hhii,timeIndex){
|
|
|
|
if(this.data.timePickerArray.length)return false
|
|
|
|
let timePickerArray=this.data.timePickerArray[timeIndex];
|
|
|
|
let tl=timePickerArray.length
|
|
|
|
if(tl<1) return false
|
|
|
|
console.log('hasInTimeSpace',hhii,timePickerArray[0],timePickerArray[tl-1],hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1])
|
|
|
|
if(hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1]) return true
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
async setDateStr(d = new Date() / 1000,hasUseDefDtime=false,fouceTime=-1){
|
|
|
|
fouceTime=fouceTime>-1?fouceTime:this.data.form.time
|
|
|
|
hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[fouceTime],fouceTime)
|
|
|
|
if(hasUseDefDtime){//
|
|
|
|
let timestr=util.unixtoTime(d,'YYYY-MM-DD '+this.data.defDtime[this.data.form.time])
|
|
|
|
d=util.timetouUnix(timestr)
|
|
|
|
}
|
|
|
|
console.log('setDateStr',util.unixtoTime(d,'YYYY-MM-DD HH:II'),hasUseDefDtime)
|
|
|
|
this.year=util.unixtoTime(d,'YYYY');
|
|
|
|
let ns = new Date() / 1000;
|
|
|
|
let dateStr = [
|
|
|
|
util.unixtoTime(ns, 'MM-DD `DAY/周WW`'),
|
|
|
|
util.unixtoTime(parseInt(ns) + 86400, 'MM-DD `DAY/周WW`'),
|
|
|
|
];
|
|
|
|
//let dateStr=this.data.dateStr;
|
|
|
|
let nowStr = util.unixtoTime(d, 'MM-DD `DAY/周WW`')
|
|
|
|
let form = this.data.form;
|
|
|
|
|
|
|
|
let timeObj = await comm.getTimeSpaceIndexData(d);
|
|
|
|
if(fouceTime!=timeObj.timeIndex && fouceTime>0){
|
|
|
|
timeObj.timeIndex=fouceTime
|
|
|
|
}
|
|
|
|
//form.time=await comm.getTimeSpaceIndex(d);
|
|
|
|
//如果小于默认时间,使用默认时间
|
|
|
|
let mmii = util.unixtoTime(d,'HH:II')
|
|
|
|
if (mmii < this.data.defDtime[timeObj.timeIndex]) {
|
|
|
|
hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[timeObj.timeIndex],timeObj.timeIndex)
|
|
|
|
if(hasUseDefDtime) {
|
|
|
|
let str = util.unixtoTime(d, 'YYYY-MM-DD ' + this.data.defDtime[timeObj.timeIndex] + ':00')
|
|
|
|
timeObj = await comm.getTimeSpaceIndexData(util.timetouUnix(str));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
form.time = timeObj.timeIndex;
|
|
|
|
let ind = dateStr._indexOf(nowStr);
|
|
|
|
if (ind > -1) {
|
|
|
|
form.date = ind
|
|
|
|
} else {
|
|
|
|
dateStr.push(nowStr.substr(0, 5));
|
|
|
|
form.date = 2;
|
|
|
|
}
|
|
|
|
let timePickerIndex = this.data.timePickerIndex;
|
|
|
|
timePickerIndex[timeObj.timeIndex] = timeObj.timeMatchIndex;
|
|
|
|
form.is_set_ddate = this.is_set_ddate
|
|
|
|
let obj = {
|
|
|
|
dateStr: dateStr,
|
|
|
|
form: form,
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
timeOpt: timeObj.timeOpt,
|
|
|
|
hasUseDefDtime:hasUseDefDtime
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setData(obj)
|
|
|
|
return obj;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -202,16 +84,7 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
//if(!this.reserve_id || util.cache('tableid').length>0){
|
|
|
|
//if (util.cache('tableid').length > 0) {
|
|
|
|
this.getTables();
|
|
|
|
//}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setData({
|
|
|
|
calendarMaskLoad: true,
|
|
|
|
})
|
|
|
|
}, 1000);
|
|
|
|
this.conditionInfo()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -248,239 +121,71 @@ Page({ |
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
async selectedValueAsync(e){
|
|
|
|
console.log(e);
|
|
|
|
let key = util.attr(e, 'key');
|
|
|
|
let val;
|
|
|
|
let sobj = {};
|
|
|
|
if (key == 'date') {
|
|
|
|
this.year=util.unixtoTime(new Date() / 1000,'YYYY');
|
|
|
|
}
|
|
|
|
if (e.type == 'input' || e.type == 'confirm') {
|
|
|
|
val = util.val(e);
|
|
|
|
if (key == 'phone') {
|
|
|
|
var that = this;
|
|
|
|
if (e.detail.value != '' && e.detail.value.length >= 3) {
|
|
|
|
App.Reserve.GetReserveUser(
|
|
|
|
{
|
|
|
|
keywords: e.detail.value,
|
|
|
|
sid: this.sellerid
|
|
|
|
}
|
|
|
|
).then(function (json) {
|
|
|
|
if (json.ret == 200 && json.data.length > 0) {
|
|
|
|
that.setData({
|
|
|
|
searchlist: json.data
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
that.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key == 'pnum') {
|
|
|
|
sobj.pnumInputFocus = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = util.attr(e, 'value');
|
|
|
|
}
|
|
|
|
if (key == 'time') {
|
|
|
|
if (this.data.timeOpt[val]) return;
|
|
|
|
}
|
|
|
|
if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {
|
|
|
|
if (util.attr(e, 'display') != 'block') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let form = this.data.form;
|
|
|
|
|
|
|
|
if (key == 'tid') {
|
|
|
|
let ts = this.data.tables;
|
|
|
|
if (ts[val].isselect) {
|
|
|
|
ts[val].isselect = false;
|
|
|
|
form.tid.remove(ts[val].id);
|
|
|
|
delete this.checkedTables[ts[val].id]
|
|
|
|
} else {
|
|
|
|
ts[val].isselect = true;
|
|
|
|
form.tid.push(ts[val].id);
|
|
|
|
this.checkedTables[ts[val].id]=ts[val].name
|
|
|
|
}
|
|
|
|
sobj.tables = ts;
|
|
|
|
} else {
|
|
|
|
form[key] = val;
|
|
|
|
}
|
|
|
|
console.log('ts', sobj.tables,this.checkedTables);
|
|
|
|
//console.log(e.type,key,val,form);
|
|
|
|
sobj.form = form;
|
|
|
|
sobj.buttonhide = this.data.buttonhide;
|
|
|
|
if (form.tid.length > 0 && form.rname.length > 0) {
|
|
|
|
sobj.buttonhide = false;
|
|
|
|
}else{
|
|
|
|
sobj.buttonhide = true;
|
|
|
|
}
|
|
|
|
let displayTimes = false;
|
|
|
|
if (key == 'time') {
|
|
|
|
if (util.attr(e, 'display') == 'block') {
|
|
|
|
displayTimes = true;
|
|
|
|
sobj.timePickerMask = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {
|
|
|
|
sobj.hasUseDefDtime = true
|
|
|
|
let ntime = parseInt(new Date() / 1000)
|
|
|
|
let xtime =ntime
|
|
|
|
if(key == 'time'){
|
|
|
|
xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
xtime=util.timetouUnix(xtime)
|
|
|
|
//if 当前时间在区间内 hasUseDefDtime 为 false
|
|
|
|
let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
this.data.form.time, null,null,this.year);
|
|
|
|
d_rdate=d_rdate.split('-');
|
|
|
|
if(d_rdate[0] <= ntime && ntime<=d_rdate[1]){
|
|
|
|
sobj.hasUseDefDtime=false
|
|
|
|
//到店时间选择通知
|
|
|
|
addTimeDurItemsEvent(e){
|
|
|
|
//{time: 1577788200, ddate_solt: 2, timeDur: "1577786400-1577804400"}
|
|
|
|
console.log('addTimeDurItemsEvent',e.detail,util.unixtoTime(e.detail.time))
|
|
|
|
this.time=e.detail.time
|
|
|
|
this.ddate_solt=e.detail.ddate_solt
|
|
|
|
this.timeDur=e.detail.timeDur//预订所在时段区间时间戳
|
|
|
|
this.hasManual=e.detail.hasManual//手动设置时间
|
|
|
|
this.setData({
|
|
|
|
...e.detail,
|
|
|
|
})
|
|
|
|
this.getTables();
|
|
|
|
},
|
|
|
|
getCustomRemark(){
|
|
|
|
App.User.GetCustomRemark({
|
|
|
|
uid:util.cache('enter_params')['manager_id'],
|
|
|
|
}).then(res=>{
|
|
|
|
let CustomRemark=[];
|
|
|
|
res.data.forEach(r=>{
|
|
|
|
if(r.often_use){
|
|
|
|
CustomRemark.push(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setDateStr(xtime,sobj.hasUseDefDtime,sobj.form.time);
|
|
|
|
}
|
|
|
|
if (this.data.form.date == 0) {//
|
|
|
|
let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
|
|
if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {
|
|
|
|
sobj.hasUseDefDtime = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {
|
|
|
|
if (!displayTimes) {
|
|
|
|
//sobj.form.tid = []; //切换日期时间清空桌位
|
|
|
|
//sobj.buttonhide = true;
|
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
if (key == 'date') {
|
|
|
|
let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData(sobj)
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
CustomRemark:CustomRemark,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
selectedValue(e){
|
|
|
|
console.log(e);
|
|
|
|
let key = util.attr(e, 'key');
|
|
|
|
let val;
|
|
|
|
let sobj = {};
|
|
|
|
if (key == 'date') {
|
|
|
|
this.year=util.unixtoTime(new Date() / 1000,'YYYY');
|
|
|
|
}
|
|
|
|
if (e.type == 'input' || e.type == 'confirm') {
|
|
|
|
val = util.val(e);
|
|
|
|
if (key == 'phone') {
|
|
|
|
var that = this;
|
|
|
|
if (e.detail.value != '' && e.detail.value.length >= 3) {
|
|
|
|
App.Reserve.GetReserveUser(
|
|
|
|
{
|
|
|
|
keywords: e.detail.value,
|
|
|
|
sid: this.sellerid
|
|
|
|
}
|
|
|
|
).then(function (json) {
|
|
|
|
if (json.ret == 200 && json.data.length > 0) {
|
|
|
|
that.setData({
|
|
|
|
searchlist: json.data
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
that.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
oftenUse(e){
|
|
|
|
let id=util.attr(e,'id');
|
|
|
|
let val=util.attr(e,'value');
|
|
|
|
let CustomRemark=this.data.CustomRemark;
|
|
|
|
let form=this.data.form;
|
|
|
|
CustomRemark.forEach(r=>{
|
|
|
|
if(id==r.id){
|
|
|
|
if(r.active){
|
|
|
|
form.cusdem=form.cusdem.replace(val+'、','')
|
|
|
|
}
|
|
|
|
r.active=!r.active
|
|
|
|
if(r.active){
|
|
|
|
form.cusdem+=val+'、'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key == 'pnum') {
|
|
|
|
sobj.pnumInputFocus = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = util.attr(e, 'value');
|
|
|
|
}
|
|
|
|
if (key == 'time') {
|
|
|
|
if (this.data.timeOpt[val]) return;
|
|
|
|
}
|
|
|
|
if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {
|
|
|
|
if (util.attr(e, 'display') != 'block') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let form = this.data.form;
|
|
|
|
|
|
|
|
if (key == 'tid') {
|
|
|
|
let ts = this.data.tables;
|
|
|
|
if (ts[val].isselect) {
|
|
|
|
ts[val].isselect = false;
|
|
|
|
form.tid.remove(ts[val].id);
|
|
|
|
delete this.checkedTables[ts[val].id]
|
|
|
|
} else {
|
|
|
|
ts[val].isselect = true;
|
|
|
|
form.tid.push(ts[val].id);
|
|
|
|
this.checkedTables[ts[val].id]=ts[val].name
|
|
|
|
}
|
|
|
|
sobj.tables = ts;
|
|
|
|
} else {
|
|
|
|
form[key] = val;
|
|
|
|
}
|
|
|
|
console.log('ts', sobj.tables,this.checkedTables);
|
|
|
|
//console.log(e.type,key,val,form);
|
|
|
|
sobj.form = form;
|
|
|
|
sobj.buttonhide = this.data.buttonhide;
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
CustomRemark:CustomRemark,
|
|
|
|
form:form,
|
|
|
|
})
|
|
|
|
this.conditionInfo()
|
|
|
|
},
|
|
|
|
CustomRemarkMore(){
|
|
|
|
this.setData({
|
|
|
|
CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
|
|
|
|
})
|
|
|
|
},
|
|
|
|
conditionInfo: function () {
|
|
|
|
var form = this.data.form
|
|
|
|
if (form.tid.length > 0 && form.rname.length > 0) {
|
|
|
|
sobj.buttonhide = false;
|
|
|
|
}else{
|
|
|
|
sobj.buttonhide = true;
|
|
|
|
}
|
|
|
|
let displayTimes = false;
|
|
|
|
if (key == 'time') {
|
|
|
|
if (util.attr(e, 'display') == 'block') {
|
|
|
|
displayTimes = true;
|
|
|
|
sobj.timePickerMask = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {
|
|
|
|
sobj.hasUseDefDtime = true
|
|
|
|
let ntime = parseInt(new Date() / 1000)
|
|
|
|
let xtime =ntime
|
|
|
|
if(key == 'time'){
|
|
|
|
xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
xtime=util.timetouUnix(xtime)
|
|
|
|
}
|
|
|
|
this.setDateStr(xtime,sobj.hasUseDefDtime);
|
|
|
|
}
|
|
|
|
if (this.data.form.date == 0) {//
|
|
|
|
let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
|
|
if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {
|
|
|
|
sobj.hasUseDefDtime = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {
|
|
|
|
if (!displayTimes) {
|
|
|
|
//sobj.form.tid = []; //切换日期时间清空桌位
|
|
|
|
//sobj.buttonhide = true;
|
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
if (key == 'date') {
|
|
|
|
let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);
|
|
|
|
}
|
|
|
|
this.data.buttonhide = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData(sobj)
|
|
|
|
this.setData({
|
|
|
|
buttonhide: this.data.buttonhide
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
async getTables(){
|
|
|
|
let form = this.data.form;
|
|
|
|
let tableid = util.cache('tableid');
|
|
...
|
...
|
@@ -491,16 +196,14 @@ Page({ |
|
|
|
}
|
|
|
|
console.log('getTables-tableid', tableid, tableid.length);
|
|
|
|
try {
|
|
|
|
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);
|
|
|
|
console.log('rdate', this.data.dateStr[this.data.form.date], rdate);
|
|
|
|
App.Reserve.GetTableList({
|
|
|
|
sid: util.cache('enter_params')['seller_id'],
|
|
|
|
//pnum_str:form.pnum_str,
|
|
|
|
pnum: form.pnum,
|
|
|
|
rdate: util.unixtoTime(rdate.substr(0,10),'YYYYMMDD'),
|
|
|
|
rdate: util.unixtoTime(this.time,'YYYYMMDD'),
|
|
|
|
tid: form.tabid,
|
|
|
|
rid: this.reserve_id,
|
|
|
|
ddate_solt:parseInt(form.time)+1
|
|
|
|
ddate_solt:this.ddate_solt
|
|
|
|
}).then(res => {
|
|
|
|
let tables = [];
|
|
|
|
let tablesLength = 0;
|
|
...
|
...
|
@@ -569,17 +272,108 @@ Page({ |
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selectphone: function (e) {
|
|
|
|
this.data.form.phone = e.detail.phone;
|
|
|
|
this.data.form.rname = e.detail.rname;
|
|
|
|
this.data.form.cusdem = e.detail.cusdem;
|
|
|
|
var form = this.data.form
|
|
|
|
this.data.form.sex = e.detail.sex;
|
|
|
|
this.setData({
|
|
|
|
form: this.data.form,
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
this.conditionInfo();
|
|
|
|
},
|
|
|
|
selectdesk(){
|
|
|
|
wx.navigateTo({
|
|
|
|
url: 'b_desk?rdate=' + this.time + '&tid=' + this.data.form.tabid
|
|
|
|
//+'&pnum_str='+this.data.form.pnum_str
|
|
|
|
+ '&pnum=' + this.data.form.pnum
|
|
|
|
+ '&checked_tids=' + this.data.form.tid
|
|
|
|
+ '&rid=' + this.reserve_id
|
|
|
|
+ '&ddate_solt='+this.ddate_solt
|
|
|
|
})
|
|
|
|
},
|
|
|
|
selectedValue(e){
|
|
|
|
console.log(e);
|
|
|
|
let key = util.attr(e, 'key');
|
|
|
|
let val;
|
|
|
|
let sobj = {};
|
|
|
|
if (e.type == 'input' || e.type == 'confirm') {
|
|
|
|
val = util.val(e);
|
|
|
|
if (key == 'phone') {
|
|
|
|
var that = this;
|
|
|
|
if (e.detail.value != '' && e.detail.value.length >= 3) {
|
|
|
|
App.Reserve.GetReserveUser(
|
|
|
|
{
|
|
|
|
keywords: e.detail.value,
|
|
|
|
sid: this.sellerid
|
|
|
|
}
|
|
|
|
).then(function (json) {
|
|
|
|
if (json.ret == 200 && json.data.length > 0) {
|
|
|
|
that.setData({
|
|
|
|
searchlist: json.data
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
that.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key == 'pnum') {
|
|
|
|
sobj.pnumInputFocus = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = util.attr(e, 'value');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let form = this.data.form;
|
|
|
|
|
|
|
|
if (key == 'tid') {
|
|
|
|
let ts = this.data.tables;
|
|
|
|
if (ts[val].isselect) {
|
|
|
|
ts[val].isselect = false;
|
|
|
|
form.tid.remove(ts[val].id);
|
|
|
|
delete this.checkedTables[ts[val].id]
|
|
|
|
} else {
|
|
|
|
ts[val].isselect = true;
|
|
|
|
form.tid.push(ts[val].id);
|
|
|
|
this.checkedTables[ts[val].id]=ts[val].name
|
|
|
|
}
|
|
|
|
sobj.tables = ts;
|
|
|
|
} else {
|
|
|
|
form[key] = val;
|
|
|
|
}
|
|
|
|
console.log('ts', sobj.tables,this.checkedTables);
|
|
|
|
//console.log(e.type,key,val,form);
|
|
|
|
sobj.form = form;
|
|
|
|
sobj.buttonhide = this.data.buttonhide;
|
|
|
|
if (form.tid.length > 0 && form.rname.length > 0){
|
|
|
|
sobj.buttonhide = false;
|
|
|
|
}else{
|
|
|
|
sobj.buttonhide = true;
|
|
|
|
}
|
|
|
|
let displayTimes = false;
|
|
|
|
|
|
|
|
if ('pnum,pnum_str,tabid'.indexOf(key) > -1) {
|
|
|
|
if (!displayTimes) {
|
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData(sobj)
|
|
|
|
},
|
|
|
|
|
|
|
|
async formsubmit(){
|
|
|
|
if (this.data.buttonhide) return;
|
|
|
|
try {
|
|
|
|
let d_stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];
|
|
|
|
let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
this.data.form.time, d_stimestr,null,this.year);
|
|
|
|
let stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[0]];
|
|
|
|
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
this.data.form.time, stimestr,null,this.year);
|
|
|
|
console.log('stimestr', stimestr, this.data.form.time, this.data.timePickerIndex);
|
|
|
|
console.log('rdate', rdate);
|
|
|
|
this.setData({
|
|
|
|
buttonhide: true,
|
|
|
|
})
|
|
...
|
...
|
@@ -589,6 +383,9 @@ Page({ |
|
|
|
let tid = new Set(form.tid);//tid 去重
|
|
|
|
form.tid = [...tid].toString();
|
|
|
|
}
|
|
|
|
if(this.ddate_solt<1){
|
|
|
|
return util.toast('请选择时段', 'none');
|
|
|
|
}
|
|
|
|
if (!form.tid) {
|
|
|
|
return util.toast('请选择桌子', 'none');
|
|
|
|
}
|
|
...
|
...
|
@@ -596,7 +393,7 @@ Page({ |
|
|
|
return util.toast('请填写预订人', 'none');
|
|
|
|
}
|
|
|
|
form.sid = this.sellerid;
|
|
|
|
form.rdate = rdate
|
|
|
|
form.rdate = this.timeDur
|
|
|
|
|
|
|
|
try {
|
|
|
|
let enter_params = util.cache('enter_params');
|
|
...
|
...
|
@@ -610,26 +407,24 @@ Page({ |
|
|
|
form.note_name = note_name || '';
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
form.ddate = d_rdate.substr(0, 10);
|
|
|
|
if (this.data.hasUseDefDtime && this.data.form.time > 0) {//转为默认时间
|
|
|
|
let ddateStr = util.unixtoTime(form.ddate, "YYYY-MM-DD " + this.data.defDtime[this.data.form.time] + ":00");
|
|
|
|
form.ddate = util.timetouUnix(ddateStr);
|
|
|
|
form.ddate = this.time;
|
|
|
|
form.ddate_solt=this.ddate_solt
|
|
|
|
if(this.hasManual){
|
|
|
|
form.is_set_ddate=1
|
|
|
|
}
|
|
|
|
//App.Customer.SetReserveInfoById
|
|
|
|
form.ddate_solt=parseInt(form.time)+1
|
|
|
|
App.Customer.SetReserveInfoById(form).then(res => {
|
|
|
|
App.Reserve.SetReserveInfo(form).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
this.getCustomRemark()
|
|
|
|
let _id = (res.data.id || res.data)
|
|
|
|
this.setData({
|
|
|
|
form: JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
tables: [],
|
|
|
|
timePickerIndex: [0, 0, 0],
|
|
|
|
runTime:parseInt(new Date()/1000),
|
|
|
|
type:1
|
|
|
|
})
|
|
|
|
this.initLoad();
|
|
|
|
this.checkedTables={};
|
|
|
|
App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
|
|
|
|
wx.redirectTo({
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({id:_id,tplid:1},'b_invitation'),
|
|
|
|
});
|
|
|
|
} else {
|
|
...
|
...
|
@@ -639,138 +434,25 @@ Page({ |
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selectphone: function (e) {
|
|
|
|
this.data.form.phone = e.detail.phone;
|
|
|
|
this.data.form.rname = e.detail.rname;
|
|
|
|
this.data.form.cusdem = e.detail.cusdem;
|
|
|
|
var form = this.data.form
|
|
|
|
this.data.form.sex = e.detail.sex;
|
|
|
|
this.setData({
|
|
|
|
form: this.data.form,
|
|
|
|
searchlist: null
|
|
|
|
})
|
|
|
|
this.conditionInfo();
|
|
|
|
},
|
|
|
|
calendarShow(){
|
|
|
|
this.setData({
|
|
|
|
calendarMask: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
dateChange(event){
|
|
|
|
console.log(event);
|
|
|
|
//let cktime=util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day)
|
|
|
|
let cktime = util.timetouUnix(event.detail.date)
|
|
|
|
this.year=event.detail.date.substr(0, 4);
|
|
|
|
console.log('this.year',this.year);
|
|
|
|
let day0 = parseInt(new Date(new Date().setHours(0, 0, 0, 0)) / 1000);
|
|
|
|
// if (cktime < day0) {
|
|
|
|
// util.toast('请选择有效日期', 'none');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
let clickDay = event.detail.date.substr(8, 2);
|
|
|
|
let changeDay = `dayStyle[1].day`;
|
|
|
|
let changeBg = `dayStyle[1].background`;
|
|
|
|
this.setData({
|
|
|
|
[changeDay]: clickDay,
|
|
|
|
[changeBg]: "#84e7d0",
|
|
|
|
//[`form.tid`]: [], //切换日期时间清空桌位
|
|
|
|
//buttonhide: true,
|
|
|
|
})
|
|
|
|
console.log('cktime',cktime,util.unixtoTime(cktime,'YYYY-MM-DD'))
|
|
|
|
if(cktime == day0){//今天
|
|
|
|
this.setDateStr( new Date() / 1000 )
|
|
|
|
}else{
|
|
|
|
let xtime=util.unixtoTime(new Date() / 1000, event.detail.date + ' HH:II:SS');
|
|
|
|
xtime=util.timetouUnix(xtime)
|
|
|
|
this.setDateStr(xtime,true)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.calendarClose();
|
|
|
|
setTimeout(res=>{
|
|
|
|
this.getTables();
|
|
|
|
},10)
|
|
|
|
|
|
|
|
},
|
|
|
|
calendarClose(){
|
|
|
|
this.setData({
|
|
|
|
calendarMask: false,
|
|
|
|
timePickerMask: false,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async selectdesk(){
|
|
|
|
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);
|
|
|
|
console.log(this.data.form)
|
|
|
|
wx.navigateTo({
|
|
|
|
url: 'b_desk?rdate=' + rdate + '&tid=' + this.data.form.tabid
|
|
|
|
//+'&pnum_str='+this.data.form.pnum_str
|
|
|
|
+ '&pnum=' + this.data.form.pnum
|
|
|
|
+ '&checked_tids=' + this.data.form.tid
|
|
|
|
+ '&rid=' + this.reserve_id
|
|
|
|
+ '&ddate_solt='+(this.data.form.time+1)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
conditionInfo: function () {
|
|
|
|
var form = this.data.form
|
|
|
|
if (form.tid.length > 0 && form.rname.length > 0) {
|
|
|
|
this.data.buttonhide = false;
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
buttonhide: this.data.buttonhide
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 选中时间区域
|
|
|
|
*/
|
|
|
|
bindTimePickerChange(e){
|
|
|
|
let timeIndex = util.attr(e, 'timeIndex');
|
|
|
|
if (timeIndex < 0) return;
|
|
|
|
let timePickerIndex = this.data.timePickerIndex;
|
|
|
|
//timePickerIndex[timeIndex]=util.val(e);
|
|
|
|
timePickerIndex[timeIndex] = util.attr(e, 'val');
|
|
|
|
|
|
|
|
console.log(e, timeIndex, util.attr(e, 'val'));
|
|
|
|
this.setData({
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
hasUseDefDtime: false,
|
|
|
|
[`form.is_set_ddate`]:1,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 修改初始化
|
|
|
|
*/
|
|
|
|
is_set_ddate:0,
|
|
|
|
async initModify(id){
|
|
|
|
async initModify(){
|
|
|
|
try {
|
|
|
|
let res = await App.Reserve.Detail({rid: id, openid: ''});
|
|
|
|
this.is_set_ddate=res.data.is_set_ddate
|
|
|
|
console.log('initModify', res);
|
|
|
|
//设置日期
|
|
|
|
let obj = await this.setDateStr(res.data.ddate,null,res.data.ddate_solt-1);
|
|
|
|
//设置时间
|
|
|
|
let nd = util.unixtoTime(res.data.ddate, 'HH:II');
|
|
|
|
let timePickerIndex = this.data.timePickerIndex
|
|
|
|
console.log('initModify-', this.data.timePickerArray, obj.form.time, nd)
|
|
|
|
this.data.timePickerArray[obj.form.time].forEach((dd, ii) => {
|
|
|
|
console.log('initModify-', nd, dd)
|
|
|
|
if (nd == dd) {
|
|
|
|
timePickerIndex[obj.form.time] = ii;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log('initModify-timePickerIndex', timePickerIndex);
|
|
|
|
//obj.form.pnum_str=res.data.pnum_str;
|
|
|
|
obj.form.pnum = res.data.pnum || 6;
|
|
|
|
obj.form.rname = res.data.rname;
|
|
|
|
obj.form.phone = res.data.phone || "";
|
|
|
|
obj.form.sex = res.data.sex;
|
|
|
|
obj.form.cusdem = res.data.cusdem;
|
|
|
|
obj.form.is_set_ddate=res.data.is_set_ddate
|
|
|
|
obj.form.rid = id;
|
|
|
|
obj.form.tid = [];
|
|
|
|
let res = await App.Reserve.Detail({rid: this.options.id, openid: ''});
|
|
|
|
let form=this.data.form
|
|
|
|
form.pnum = res.data.pnum || 6;
|
|
|
|
form.rname = res.data.rname;
|
|
|
|
form.phone = res.data.phone || "";
|
|
|
|
form.sex = res.data.sex;
|
|
|
|
form.cusdem = res.data.cusdem;
|
|
|
|
form.rid = this.options.id;
|
|
|
|
form.tid = [];
|
|
|
|
form.is_set_ddate=res.data.is_set_ddate
|
|
|
|
let tablesed = [];
|
|
|
|
res.data.tables.forEach((t, ti) => {
|
|
|
|
obj.form.tid.push(t.id)
|
|
|
|
form.tid.push(t.id)
|
|
|
|
if (ti >= 3) return;
|
|
|
|
t.isselect = true
|
|
|
|
t["isselected"] = 1
|
|
...
|
...
|
@@ -778,79 +460,15 @@ Page({ |
|
|
|
this.checkedTables[t.id]=t.name;
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
form: obj.form,
|
|
|
|
//tablesed:tablesed,
|
|
|
|
hasUseDefDtime: false,
|
|
|
|
type:2,//修改
|
|
|
|
runTime: res.data.ddate,//到店时间
|
|
|
|
ddate_solt:res.data.ddate_solt,
|
|
|
|
form: form,
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getTables();
|
|
|
|
}, 300)
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
console.log('initModify', e)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pnumInputFocusEvent(e){
|
|
|
|
console.log(e);
|
|
|
|
this.setData({
|
|
|
|
pnumInputFocus: 'focus' == e.type
|
|
|
|
})
|
|
|
|
},
|
|
|
|
inputFocusTime: 0,
|
|
|
|
blurTime: 0,
|
|
|
|
inputFocus(e){
|
|
|
|
console.log(e, this.inputFocusTime);
|
|
|
|
return;
|
|
|
|
if (e.timeStamp > this.inputFocusTime) {
|
|
|
|
this.inputFocusTime = e.timeStamp;
|
|
|
|
if (e.type == 'focus' && this.data.pageMarginBottom == 0) {
|
|
|
|
this.setData({
|
|
|
|
pageMarginBottom: 300
|
|
|
|
})
|
|
|
|
setTimeout(res => {
|
|
|
|
this.pageScrollToBottom();
|
|
|
|
}, 100)
|
|
|
|
} else {
|
|
|
|
if (this.blurTime > 5) {
|
|
|
|
this.blurTime = 0;
|
|
|
|
this.setData({
|
|
|
|
pageMarginBottom: 0
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
setTimeout(res => {
|
|
|
|
this.blurTime += 1;
|
|
|
|
this.inputFocus(e);
|
|
|
|
}, 300)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pageScrollToBottom: function () {
|
|
|
|
wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {
|
|
|
|
// 使页面滚动到底部
|
|
|
|
wx.pageScrollTo({
|
|
|
|
scrollTop: rect.bottom
|
|
|
|
})
|
|
|
|
}).exec()
|
|
|
|
},
|
|
|
|
gotoday(e){
|
|
|
|
this.setData({
|
|
|
|
[`calendar.nextNum`]: 0
|
|
|
|
})
|
|
|
|
},
|
|
|
|
nextMonth(e){
|
|
|
|
this.setData({
|
|
|
|
[`calendar.nextNum`]: this.data.calendar.nextNum + 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
prevMonth(e){
|
|
|
|
this.setData({
|
|
|
|
[`calendar.nextNum`]: this.data.calendar.nextNum - 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 快速预订初始化
|
|
|
|
* tid
|
|
...
|
...
|
@@ -858,64 +476,13 @@ Page({ |
|
|
|
* ddate
|
|
|
|
* pnum
|
|
|
|
*/
|
|
|
|
async initQuick(options){
|
|
|
|
try {
|
|
|
|
console.log('initQuick', options);
|
|
|
|
this.checkedTables[options.tid]=options.tname
|
|
|
|
this.year=util.unixtoTime(options.ddate.substr(0,10),'YYYY');
|
|
|
|
let form=this.data.form
|
|
|
|
form.tid=[options.tid]
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
form: form,
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getTables();
|
|
|
|
}, 300)
|
|
|
|
} catch (e) {
|
|
|
|
console.log('initQuick', e)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getCustomRemark(){
|
|
|
|
App.User.GetCustomRemark({
|
|
|
|
uid:util.cache('enter_params')['manager_id'],
|
|
|
|
}).then(res=>{
|
|
|
|
let CustomRemark=[];
|
|
|
|
res.data.forEach(r=>{
|
|
|
|
if(r.often_use){
|
|
|
|
CustomRemark.push(r);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
CustomRemark:CustomRemark,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
oftenUse(e){
|
|
|
|
let id=util.attr(e,'id');
|
|
|
|
let val=util.attr(e,'value');
|
|
|
|
let CustomRemark=this.data.CustomRemark;
|
|
|
|
let form=this.data.form;
|
|
|
|
CustomRemark.forEach(r=>{
|
|
|
|
if(id==r.id){
|
|
|
|
if(r.active){
|
|
|
|
form.cusdem=form.cusdem.replace(val+'、','')
|
|
|
|
}
|
|
|
|
r.active=!r.active
|
|
|
|
if(r.active){
|
|
|
|
form.cusdem+=val+'、'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
initQuick(){
|
|
|
|
let options=this.options
|
|
|
|
this.checkedTables[options.tid]=options.tname
|
|
|
|
this.setData({
|
|
|
|
CustomRemark:CustomRemark,
|
|
|
|
form:form,
|
|
|
|
[`form.tid`]: [options.tid],
|
|
|
|
runTime:options.ddate.substr(0,10),
|
|
|
|
type:3
|
|
|
|
})
|
|
|
|
this.conditionInfo()
|
|
|
|
},
|
|
|
|
CustomRemarkMore(){
|
|
|
|
this.setData({
|
|
|
|
CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|