|
...
|
...
|
@@ -17,6 +17,7 @@ const formTpl = { |
|
|
|
cusdem: '',
|
|
|
|
|
|
|
|
tid: [],
|
|
|
|
is_set_ddate:0,
|
|
|
|
|
|
|
|
}
|
|
|
|
Page({
|
|
...
|
...
|
@@ -95,21 +96,21 @@ Page({ |
|
|
|
let rev_time=parseInt(nt)
|
|
|
|
if(options.hasQuick==1){
|
|
|
|
let rdate=options.ddate.split('-')
|
|
|
|
if(rev_time<rdate[0] || rev_time>rdate[1]){
|
|
|
|
if(!(rev_time>=rdate[0] && rev_time<=rdate[1])){
|
|
|
|
rev_time=rdate[0]
|
|
|
|
}
|
|
|
|
await this.setDateStr(rev_time);
|
|
|
|
}
|
|
|
|
await this.setDateStr(rev_time);
|
|
|
|
this.sellerid = util.cache('enter_params')['seller_id'];
|
|
|
|
let timePickerArray = await comm.getDayTimeSpace();
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
let hasUseDefDtime = true;
|
|
|
|
let mmii = util.unixtoTime(rev_time, 'HH:II');
|
|
|
|
console.log('initLoad',mmii,this.data.defDtime[this.data.form.time],this.data.defDtime)
|
|
|
|
console.log('initLoad',mmii > this.data.defDtime[this.data.form.time])
|
|
|
|
if (mmii > this.data.defDtime[this.data.form.time]) {
|
|
|
|
hasUseDefDtime = false;
|
|
|
|
}
|
|
|
|
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,
|
|
...
|
...
|
@@ -128,7 +129,12 @@ Page({ |
|
|
|
* @param d
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
async setDateStr(d = new Date() / 1000){
|
|
|
|
async setDateStr(d = new Date() / 1000,hasUseDefDtime=false){
|
|
|
|
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 = [
|
|
...
|
...
|
@@ -141,8 +147,14 @@ Page({ |
|
|
|
|
|
|
|
let timeObj = await comm.getTimeSpaceIndexData(d);
|
|
|
|
//form.time=await comm.getTimeSpaceIndex(d);
|
|
|
|
form.time = timeObj.timeIndex;
|
|
|
|
//如果小于默认时间,使用默认时间
|
|
|
|
let mmii = util.unixtoTime(d,'HH:II')
|
|
|
|
if (mmii < this.data.defDtime[timeObj.timeIndex]) {
|
|
|
|
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
|
|
...
|
...
|
@@ -158,6 +170,7 @@ Page({ |
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
timeOpt: timeObj.timeOpt,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setData(obj)
|
|
|
|
return obj;
|
|
|
|
|
|
...
|
...
|
@@ -176,7 +189,7 @@ Page({ |
|
|
|
onShow: function () {
|
|
|
|
//if(!this.reserve_id || util.cache('tableid').length>0){
|
|
|
|
//if (util.cache('tableid').length > 0) {
|
|
|
|
this.getTables();
|
|
|
|
this.getTables();
|
|
|
|
//}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setData({
|
|
...
|
...
|
@@ -220,7 +233,7 @@ Page({ |
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
selectedValue(e){
|
|
|
|
async selectedValueAsync(e){
|
|
|
|
console.log(e);
|
|
|
|
let key = util.attr(e, 'key');
|
|
|
|
let val;
|
|
...
|
...
|
@@ -302,6 +315,30 @@ Page({ |
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 = []; //切换日期时间清空桌位
|
|
...
|
...
|
@@ -309,13 +346,105 @@ Page({ |
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
if (key == 'date') {
|
|
|
|
let xtime = util.unixtoTime(new Date() / 1000, 'YYYY-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
this.setDateStr(util.timetouUnix(xtime));
|
|
|
|
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)
|
|
|
|
},
|
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
this.setDateStr(xtime,sobj.hasUseDefDtime);
|
|
|
|
}
|
|
|
|
if (this.data.form.date == 0) {//
|
|
|
|
let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
...
|
...
|
@@ -323,6 +452,18 @@ Page({ |
|
|
|
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)
|
|
|
|
},
|
|
|
|
async getTables(){
|
|
...
|
...
|
@@ -458,7 +599,8 @@ Page({ |
|
|
|
let ddateStr = util.unixtoTime(form.ddate, "YYYY-MM-DD " + this.data.defDtime[this.data.form.time] + ":00");
|
|
|
|
form.ddate = util.timetouUnix(ddateStr);
|
|
|
|
}
|
|
|
|
App.Reserve.SetReserveInfo(form).then(res => {
|
|
|
|
//App.Customer.SetReserveInfoById
|
|
|
|
App.Customer.SetReserveInfoById(form).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
this.getCustomRemark()
|
|
|
|
let _id = (res.data.id || res.data)
|
|
...
|
...
|
@@ -518,7 +660,14 @@ Page({ |
|
|
|
//buttonhide: true,
|
|
|
|
})
|
|
|
|
console.log('cktime',cktime,util.unixtoTime(cktime,'YYYY-MM-DD'))
|
|
|
|
this.setDateStr(cktime == day0 ? new Date() / 1000 : cktime)
|
|
|
|
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();
|
|
...
|
...
|
@@ -565,6 +714,7 @@ Page({ |
|
|
|
this.setData({
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
hasUseDefDtime: false,
|
|
|
|
[`form.is_set_ddate`]:1,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
...
|
...
|
@@ -596,6 +746,7 @@ Page({ |
|
|
|
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 tablesed = [];
|
|
...
|
...
|
@@ -695,6 +846,7 @@ Page({ |
|
|
|
this.year=util.unixtoTime(options.ddate.substr(0,10),'YYYY');
|
|
|
|
let form=this.data.form
|
|
|
|
form.tid=[options.tid]
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
form: form,
|
|
|
|
})
|
...
|
...
|
|