Commit 1cb3f8f0f53a316d8d0227b3527317b36cfb2b6e

Authored by wangfan
1 parent 1dff556b

快速预定

var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
var uri = require('../../../utils/uri.js');
Component({
properties:{
list:Array
},
data:{
},
methods:{
selectdesk:function(e){
var tebleid=e.currentTarget.dataset.id;
var tables=util.cache('tableid') ? util.cache('tableid') : [];
var list=this.data.list;
list.forEach(function(v,i){
if(v.id==tebleid){
if(v.isselect==true){
var thisindex=tables.indexOf(tebleid);
tables.splice(thisindex,1)
}else{
tables.push(tebleid)
}
v.isselect=!v.isselect
}
})
var pages = getCurrentPages();
pages[pages.length-2].data.form.tid=tables;
pages[pages.length-2].setData({
form:pages[pages.length-2].data.form
})
util.cache('tableid',tables);
this.triggerEvent("changedesk");
this.setData({
list:list
})
properties: {
list: Array
},
data: {},
methods: {
selectdesk: function (e) {
var tebleid = e.currentTarget.dataset.id;
var tables = util.cache('tableid') ? util.cache('tableid') : [];
var list = this.data.list;
var pages = getCurrentPages();
var addnewPage=pages[pages.length - 2];
list.forEach(function (v, i) {
if (v.id == tebleid) {
if (v.isselect == true) {
var thisindex = tables.indexOf(tebleid);
tables.splice(thisindex, 1)
delete addnewPage.checkedTables[tebleid]
} else {
tables.push(tebleid)
addnewPage.checkedTables[tebleid]=v.name;
}
v.isselect = !v.isselect
}
})
addnewPage.data.form.tid = tables;
addnewPage.setData({
form: addnewPage.data.form
})
console.log('checkedTables',addnewPage.checkedTables);
util.cache('tableid', tables);
this.triggerEvent("changedesk");
this.setData({
list: list
})
}
}
})
\ No newline at end of file
... ...
<view class="desk-list flex-rs">
<block wx:for="{{list}}">
<block wx:for="{{list}}" wx:key="list.key">
<board width="160" height="180" board="{{item}}"
style="margin: 20rpx 0 0 20rpx"
event="boardChoose" className="noBottom"
... ...
... ... @@ -3,20 +3,20 @@ 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,
const formTpl = {
rid: '',
date: 0,
time: 0,
//pnum_str:'1-4',
pnum: 6,
tabid: 0,
rname:'',
phone:'',
sex:1,
cusdem:'',
rname: '',
phone: '',
sex: 1,
cusdem: '',
tid:[],
tid: [],
}
Page({
... ... @@ -25,124 +25,125 @@ 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,
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,
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,
timePickerMask: false,
pnumInputFocus: false,
pageMarginBottom: 0,
speciallist: [],
calendar: {
nextNum: 0,
},
defDtime:['','12:00','18:30'],
hasUseDefDtime:true,
defDtime: ['', '12:00', '18:30'],
hasUseDefDtime: true,
},
/**
* 生命周期函数--监听页面加载
*/
reserve_id:'',
reserve_id: '',
checkedTables:{},//已选中的桌子集合
onLoad: async function (options) {
this.initLoad(options)
this.initLoad(options)
},
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||'';
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('sellerid');
let timePickerArray= await comm.getDayTimeSpace();
this.sellerid = util.cache('sellerid');
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;
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,
speciallist: speciallist,
hasUseDefDtime: hasUseDefDtime,
})
if(this.reserve_id>0){
if (this.reserve_id > 0) {
this.initModify(this.reserve_id);
}else{
} 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;
/**
*
* @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 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;
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;
},
... ... @@ -157,16 +158,16 @@ 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()
//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()
},
/**
... ... @@ -203,401 +204,429 @@ Page({
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');
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=='time'){
if(this.data.timeOpt[val]) return;
if (key == 'pnum') {
sobj.pnumInputFocus = true;
}
if((key=='time' && this.data.form.time==val) || (key=='date' && this.data.form.date==val) ){
if(util.attr(e,'display')!='block') {
return;
}
} 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;
}
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);
}else{
ts[val].isselect=true;
form.tid.push(ts[val].id);
}
sobj.tables=ts;
}else{
form[key]=val;
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
}
console.log('ts',sobj.tables);
//console.log(e.type,key,val,form);
sobj.form=form;
sobj.buttonhide=true;
if(form.tid.length>0 && form.rname.length>0){
sobj.buttonhide=false;
}
let displayTimes=false;
if(key=='time'){
if(util.attr(e,'display')=='block'){
displayTimes=true;
sobj.timePickerMask=true;
}
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 = true;
if (form.tid.length > 0 && form.rname.length > 0) {
sobj.buttonhide = false;
}
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));
}
}
if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {
if (!displayTimes) {
//sobj.form.tid = []; //切换日期时间清空桌位
sobj.buttonhide = true;
this.getTables();
}
//判断hasUseDefDtime
if((key=='time' || key=='date') && !sobj.timePickerMask){
sobj.hasUseDefDtime=true
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));
}
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;
}
}
//判断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){
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:this.sellerid,
//pnum_str:form.pnum_str,
pnum:form.pnum,
rdate:rdate,
tid:form.tabid,
rid:this.reserve_id,
}).then(res=>{
let tables=[],tables_tmp=[];
let tablesLength=0;
if(tableid.length>0){
res.data.forEach(p=>{
//if(tables.length>=3) return true;
p.list.forEach(t=>{
tablesLength++;
if(tables.length>=3) return true;
if(tableid._indexOf(t.id)>-1){
t.isselect=true;
tables.push(t);
}
})
})
wx.removeStorage({key:'tableid'})
}else{
res.data.forEach(p=>{
p.list.forEach(t=>{
tablesLength++;
//if(tables.length>=3) return true;
if(t.tid==2) {
tables.push(t);
}else{
tables_tmp.push(t);
}
})
})
if(tables.length<3){
tables=tables.concat(tables_tmp);
}
if(tables.length>=3){
tables=tables.slice(0,3);
}
}
this.tablesLength=tablesLength;
this.setData({
tables:tables,
tablesLength:tablesLength
})
}
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: this.sellerid,
//pnum_str:form.pnum_str,
pnum: form.pnum,
rdate: rdate,
tid: form.tabid,
rid: this.reserve_id,
}).then(res => {
let tables = [], tables_tmp = [];
let tablesLength = 0;
if (tableid.length > 0) {
let toastTables={...this.checkedTables}
res.data.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);
}
})
}catch (e){
})
console.log('toastTables',toastTables);
//清理已选中的桌位
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({
tables:[]
[`form.tid`]:tid,
})
util.toast(toastTablesInfo.toString()+'已被占用啦','none');
}
wx.removeStorage({key: 'tableid'})
}
},
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');
}
form.sid = this.sellerid;
form.rdate =rdate
if(!form.rid){
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.nickname;
form.note_openid=note_openid||'';
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){
let _id=(res.data.id || res.data)
this.setData({
form:JSON.parse(JSON.stringify(formTpl)),
tables:[],
timePickerIndex:[0,0,0],
})
this.initLoad();
App.Reserve.Detail({rid:_id,openid:''},'clear')
wx.navigateTo({
url:'b_detail?id='+_id,
});
}else{
util.toast(res.msg,'none')
}
if(tables.length<1){
tablesLength=0;
tables_tmp = [];
res.data.forEach(p => {
p.list.forEach(t => {
tablesLength++;
//if(tables.length>=3) return true;
if (t.tid == 2) {
tables.push(t);
} else {
tables_tmp.push(t);
}
})
}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;
})
if (tables.length < 3) {
tables = tables.concat(tables_tmp);
}
if (tables.length >= 3) {
tables = tables.slice(0, 3);
}
}
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,
})
this.setDateStr(cktime==day0?new Date()/1000:cktime)
this.getTables();
this.calendarClose();
},
calendarClose(){
this.tablesLength = tablesLength;
this.setData({
calendarMask:false,
timePickerMask:false,
tables: tables,
tablesLength: tablesLength
})
},
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;
})
} 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');
}
form.sid = this.sellerid;
form.rdate = rdate
if (!form.rid) {
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.nickname;
form.note_openid = note_openid || '';
form.note_name = note_name || '';
} catch (e) {
}
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;
}
})
}
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) {
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: 'b_detail?id=' + _id,
});
} 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,
})
this.setDateStr(cktime == day0 ? new Date() / 1000 : cktime)
this.getTables();
this.calendarClose();
},
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('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.setData({
timePickerIndex:timePickerIndex,
form:obj.form,
//tablesed:tablesed,
hasUseDefDtime:false,
})
setTimeout(()=>{
this.getTables();
},300)
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: ''});
}catch (e){
console.log('initModify',e)
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;
}
},
pnumInputFocusEvent(e){
console.log(e);
})
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.setData({
pnumInputFocus:'focus'==e.type
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,
inputFocusTime: 0,
blurTime: 0,
inputFocus(e){
console.log(e,this.inputFocusTime);
console.log(e, this.inputFocusTime);
return;
if(e.timeStamp>this.inputFocusTime){
this.inputFocusTime=e.timeStamp;
if(e.type=='focus' && this.data.pageMarginBottom==0){
if (e.timeStamp > this.inputFocusTime) {
this.inputFocusTime = e.timeStamp;
if (e.type == 'focus' && this.data.pageMarginBottom == 0) {
this.setData({
pageMarginBottom:300
pageMarginBottom: 300
})
setTimeout(res=>{
setTimeout(res => {
this.pageScrollToBottom();
},100)
}else{
if(this.blurTime>5){
this.blurTime=0;
}, 100)
} else {
if (this.blurTime > 5) {
this.blurTime = 0;
this.setData({
pageMarginBottom:0
pageMarginBottom: 0
})
}else{
setTimeout(res=>{
this.blurTime+=1;
} else {
setTimeout(res => {
this.blurTime += 1;
this.inputFocus(e);
},300)
}, 300)
}
}
}
},
pageScrollToBottom: function() {
wx.createSelectorQuery().select('#j_page').boundingClientRect(function(rect){
pageScrollToBottom: function () {
wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {
// 使页面滚动到底部
wx.pageScrollTo({
scrollTop: rect.bottom
... ... @@ -606,17 +635,17 @@ Page({
},
gotoday(e){
this.setData({
[`calendar.nextNum`]:0
[`calendar.nextNum`]: 0
})
},
nextMonth(e){
this.setData({
[`calendar.nextNum`]:this.data.calendar.nextNum+1
[`calendar.nextNum`]: this.data.calendar.nextNum + 1
})
},
prevMonth(e){
this.setData({
[`calendar.nextNum`]:this.data.calendar.nextNum-1
[`calendar.nextNum`]: this.data.calendar.nextNum - 1
})
},
})
\ No newline at end of file
... ...
... ... @@ -3,13 +3,14 @@
<view class="flex-lr" style="border-top:1rpx solid #E0E0E0">
<view class="menus" style="height: {{height}}px; overflow-y: auto;overflow-x: hidden;align-self:flex-start ">
<view class="menus-item flex-cc {{item.name==menu_active_id?'active':''}}"
wx:for="{{desklist}}" bindtap="switchMenu" data-id="{{item.name}}">
wx:for="{{desklist}}" wx:key="desklist.key"
bindtap="switchMenu" data-id="{{item.name}}">
<view class="name">{{item.name}}</view>
<view class="hip" wx:if="{{item.chenkNum>0}}">{{item.chenkNum}}</view>
</view>
</view>
<view style="height: {{height-80}}px;overflow-y: auto;padding-bottom: 160rpx;overflow-x: hidden;width: 100%;">
<block wx:for="{{desklist}}">
<block wx:for="{{desklist}}" wx:key="desklist.key">
<orderDesk list="{{item.list}}" bind:changedesk="changedesk" wx:if="{{item.name==menu_active_id}}"></orderDesk>
</block>
... ...
//正式
var uri={
HOST__LINE:'https://xt05.colorcun.com/?s=',
HOST__LINE:'https://xt04.colorcun.com/?s=',
//获取商家信息
CGI__USER_GETSELLERBYID: 'App.Seller.GetSellerById',
... ...