|
|
|
// 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,
|
|
|
|
|
|
|
|
rname: '',
|
|
|
|
phone: '',
|
|
|
|
sex: 1,
|
|
|
|
cusdem: '',
|
|
|
|
|
|
|
|
tid: [],
|
|
|
|
|
|
|
|
}
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
dateStr: [],
|
|
|
|
form: JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
tables: [],
|
|
|
|
grand: [
|
|
|
|
{
|
|
|
|
sex: 1,
|
|
|
|
grand_title: '先生',
|
|
|
|
isselect: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sex: 2,
|
|
|
|
grand_title: '女士',
|
|
|
|
isselect: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sex: 3,
|
|
|
|
grand_title: '公司',
|
|
|
|
isselect: false
|
|
|
|
}
|
|
|
|
],
|
|
|
|
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:{},//已选中的桌子集合
|
|
|
|
onLoad: async function (options) {
|
|
|
|
this.initLoad(options)
|
|
|
|
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 || '';
|
|
|
|
await this.setDateStr();
|
|
|
|
this.sellerid = util.cache('enter_params')['seller_id'];
|
|
|
|
let timePickerArray = await comm.getDayTimeSpace();
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
let hasUseDefDtime = true;
|
|
|
|
let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
|
|
if (mmii > this.data.defDtime[this.data.form.time]) {
|
|
|
|
hasUseDefDtime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
timePickerArray: timePickerArray,
|
|
|
|
speciallist: speciallist,
|
|
|
|
hasUseDefDtime: hasUseDefDtime,
|
|
|
|
})
|
|
|
|
if (this.reserve_id > 0) {
|
|
|
|
this.initModify(this.reserve_id);
|
|
|
|
} else if(options.hasQuick==1){
|
|
|
|
this.initQuick(options);
|
|
|
|
} else {
|
|
|
|
this.getTables();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param d
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
async setDateStr(d = new Date() / 1000){
|
|
|
|
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);
|
|
|
|
//form.time=await comm.getTimeSpaceIndex(d);
|
|
|
|
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;
|
|
|
|
let obj = {
|
|
|
|
dateStr: dateStr,
|
|
|
|
form: form,
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
timeOpt: timeObj.timeOpt,
|
|
|
|
};
|
|
|
|
this.setData(obj)
|
|
|
|
return obj;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
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()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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, 'YYYY-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
this.setDateStr(util.timetouUnix(xtime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//判断hasUseDefDtime
|
|
|
|
if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {
|
|
|
|
sobj.hasUseDefDtime = true
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setData(sobj)
|
|
|
|
},
|
|
|
|
async getTables(){
|
|
|
|
let form = this.data.form;
|
|
|
|
let tableid = util.cache('tableid');
|
|
|
|
console.log('getTables-tableid', tableid.length, this.reserve_id);
|
|
|
|
//if (tableid.length < 1 && this.reserve_id) {
|
|
|
|
if (tableid.length < 1) {
|
|
|
|
tableid = this.data.form.tid;
|
|
|
|
}
|
|
|
|
console.log('getTables-tableid', tableid, tableid.length);
|
|
|
|
try {
|
|
|
|
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time);
|
|
|
|
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: rdate,
|
|
|
|
tid: form.tabid,
|
|
|
|
rid: this.reserve_id,
|
|
|
|
}).then(res => {
|
|
|
|
let tables = [];
|
|
|
|
let tablesLength = 0;
|
|
|
|
if (tableid.length > 0) {
|
|
|
|
let toastTables={...this.checkedTables}
|
|
|
|
let resData=res.data.slice(1,res.data.length);
|
|
|
|
console.log('resData',resData)
|
|
|
|
resData.forEach(p => {
|
|
|
|
//if(tables.length>=3) return true;
|
|
|
|
p.list.forEach(t => {
|
|
|
|
delete toastTables[t.id]
|
|
|
|
tablesLength++;
|
|
|
|
if (tables.length >= 3) return true;
|
|
|
|
if (tableid._indexOf(t.id) > -1) {
|
|
|
|
t.isselect = true;
|
|
|
|
tables.push(t);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log('toastTables',toastTables,this.data.form.tid,this.checkedTables);
|
|
|
|
//清理已选中的桌位
|
|
|
|
let toastTablesInfo=[];
|
|
|
|
let tid=this.data.form.tid
|
|
|
|
Object.keys(this.checkedTables).forEach(ckid=>{
|
|
|
|
if(toastTables[ckid]){
|
|
|
|
delete this.checkedTables[ckid]
|
|
|
|
tid.remove(ckid);
|
|
|
|
toastTablesInfo.push(toastTables[ckid]);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(toastTablesInfo.length>0){
|
|
|
|
this.setData({
|
|
|
|
[`form.tid`]:tid,
|
|
|
|
})
|
|
|
|
util.toast(toastTablesInfo.toString()+'已被占用啦','none');
|
|
|
|
}
|
|
|
|
wx.removeStorage({key: 'tableid'})
|
|
|
|
}
|
|
|
|
console.log('tables-first',tables);
|
|
|
|
if(tables.length<1){
|
|
|
|
tablesLength=0;
|
|
|
|
let fortids=[];
|
|
|
|
res.data.forEach((p,ri) => {
|
|
|
|
p.list.forEach(t => {
|
|
|
|
if(fortids._indexOf(t.id)<0) {
|
|
|
|
tablesLength++;
|
|
|
|
tables.push(t);
|
|
|
|
fortids.push(t.id);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if (tables.length >= 3) {
|
|
|
|
tables = tables.slice(0, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.tablesLength = tablesLength;
|
|
|
|
this.setData({
|
|
|
|
tables: tables,
|
|
|
|
tablesLength: tablesLength
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} catch (e) {
|
|
|
|
this.setData({
|
|
|
|
tables: []
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
console.log('stimestr', stimestr, this.data.form.time, this.data.timePickerIndex);
|
|
|
|
console.log('rdate', rdate);
|
|
|
|
this.setData({
|
|
|
|
buttonhide: true,
|
|
|
|
})
|
|
|
|
let form = JSON.parse(JSON.stringify(this.data.form));
|
|
|
|
console.log('typeof form.tid', typeof form.tid);
|
|
|
|
if (typeof form.tid == 'object') {
|
|
|
|
let tid = new Set(form.tid);//tid 去重
|
|
|
|
form.tid = [...tid].toString();
|
|
|
|
}
|
|
|
|
if (!form.tid) {
|
|
|
|
return util.toast('请选择桌子', 'none');
|
|
|
|
}
|
|
|
|
if (!form.rname) {
|
|
|
|
return util.toast('请填写预订人', 'none');
|
|
|
|
}
|
|
|
|
form.sid = this.sellerid;
|
|
|
|
form.rdate = rdate
|
|
|
|
|
|
|
|
try {
|
|
|
|
let enter_params = util.cache('enter_params');
|
|
|
|
let sc = (await App.Reserve.SellerInfo(enter_params)).data
|
|
|
|
let note_openid = enter_params.seller_openid;
|
|
|
|
let note_name = sc.seller_user.nick_name || sc.seller_user.nickname;
|
|
|
|
form.note_openid = note_openid || '';
|
|
|
|
if (form.rid) {//修改时传递uid
|
|
|
|
form.note_openid = enter_params.manager_id || '';
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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],
|
|
|
|
})
|
|
|
|
this.initLoad();
|
|
|
|
this.checkedTables={};
|
|
|
|
App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({id:_id,tplid:1},'b_invitation'),
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
util.toast(res.msg, 'none')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} 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)
|
|
|
|
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'))
|
|
|
|
this.setDateStr(cktime == day0 ? new Date() / 1000 : cktime)
|
|
|
|
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);
|
|
|
|
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
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 修改初始化
|
|
|
|
*/
|
|
|
|
async initModify(id){
|
|
|
|
try {
|
|
|
|
let res = await App.Reserve.Detail({rid: id, openid: ''});
|
|
|
|
|
|
|
|
console.log('initModify', res);
|
|
|
|
//设置日期
|
|
|
|
let obj = await this.setDateStr(res.data.ddate);
|
|
|
|
//设置时间
|
|
|
|
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.rid = id;
|
|
|
|
obj.form.tid = [];
|
|
|
|
let tablesed = [];
|
|
|
|
res.data.tables.forEach((t, ti) => {
|
|
|
|
obj.form.tid.push(t.id)
|
|
|
|
if (ti >= 3) return;
|
|
|
|
t.isselect = true
|
|
|
|
t["isselected"] = 1
|
|
|
|
tablesed.push(t);
|
|
|
|
this.checkedTables[t.id]=t.name;
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
form: obj.form,
|
|
|
|
//tablesed:tablesed,
|
|
|
|
hasUseDefDtime: false,
|
|
|
|
})
|
|
|
|
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
|
|
|
|
* tname
|
|
|
|
* ddate
|
|
|
|
* pnum
|
|
|
|
*/
|
|
|
|
async initQuick(options){
|
|
|
|
try {
|
|
|
|
console.log('initQuick', options);
|
|
|
|
this.checkedTables[options.tid]=options.tname
|
|
|
|
options.ddate=options.ddate.substr(0,10);
|
|
|
|
//设置日期
|
|
|
|
let obj = await this.setDateStr(options.ddate);
|
|
|
|
//设置时间
|
|
|
|
let nd = util.unixtoTime(options.ddate, 'HH:II');
|
|
|
|
let timePickerIndex = this.data.timePickerIndex
|
|
|
|
console.log('initQuick-', this.data.timePickerArray, obj.form.time, nd)
|
|
|
|
this.data.timePickerArray[obj.form.time].forEach((dd, ii) => {
|
|
|
|
console.log('initQuick-', nd, dd)
|
|
|
|
if (nd == dd) {
|
|
|
|
timePickerIndex[obj.form.time] = ii;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log('initQuick-timePickerIndex', timePickerIndex);
|
|
|
|
obj.form.pnum = options.pnum || 6;
|
|
|
|
obj.form.rname = "";
|
|
|
|
obj.form.phone = "";
|
|
|
|
obj.form.sex = 1;
|
|
|
|
obj.form.cusdem = "";
|
|
|
|
obj.form.rid = "";
|
|
|
|
obj.form.tid = [options.tid];
|
|
|
|
this.setData({
|
|
|
|
timePickerIndex: timePickerIndex,
|
|
|
|
form: obj.form,
|
|
|
|
hasUseDefDtime: false,
|
|
|
|
})
|
|
|
|
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+'、'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
CustomRemark:CustomRemark,
|
|
|
|
form:form,
|
|
|
|
})
|
|
|
|
this.conditionInfo()
|
|
|
|
},
|
|
|
|
CustomRemarkMore(){
|
|
|
|
this.setData({
|
|
|
|
CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}) |
|
|
\ No newline at end of file |