Commit 5a8e257f22419c021a47a79b8b991f029234d0f7

Authored by wangfan
1 parent 097258a8

v2 time

... ... @@ -3,6 +3,21 @@ import util from '../../utils/util';
import comm from '../../utils/bookCommon';
import App from '../../utils/api';
const {regeneratorRuntime} = global
const formTpl={
date:0,
time:0,
pnum_str:'1-4',
tabid:0,
rname:'',
phone:'',
sex:1,
cusdem:'',
tid:[],
}
Page({
/**
... ... @@ -10,21 +25,7 @@ Page({
*/
data: {
dateStr:[],
form:{
date:0,
time:0,
pnum_str:'1-4',
tabid:0,
rname:'',
phone:'',
sex:1,
cusdem:'',
tid:[],
},
form:JSON.parse(JSON.stringify(formTpl)),
tables:[],
grand:[
{
... ... @@ -58,11 +59,13 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: async function (options) {
this.setDateStr();
this.sellerid=util.cache('sellerid');
this.getTables()
comm.getDayTimeSpace();
let timePickerArray= await comm.getDayTimeSpace();
this.setData({
timePickerArray: timePickerArray,
})
},
/**
*
... ... @@ -90,6 +93,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getTables();
setTimeout(()=>{
this.setData({
calendarMaskLoad:true,
... ... @@ -222,7 +226,10 @@ Page({
async formsubmit(){
if(this.data.buttonhide) return;
try {
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time);
let stimestr=this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];
console.log('stimestr', stimestr,this.data.form.time,this.data.timePickerIndex);
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
this.data.form.time,stimestr);
console.log('rdate', rdate);
this.setData({
buttonhide: true,
... ... @@ -233,6 +240,9 @@ Page({
form.rdate =rdate
App.Reserve.SetReserveInfo(form).then(res => {
if(res.ret==200){
this.setData({
form:JSON.parse(JSON.stringify(formTpl))
})
wx.navigateTo({
url:'b_detail?id='+res.data.id,
});
... ...
... ... @@ -45,7 +45,7 @@ module.exports ={
return timedate;
},
//获得营业时段时间戳,用 - 链接
async getTimeSpace(mmdd='',timeIndex=0,sc=null){
async getTimeSpace(mmdd='',timeIndex=0,stimestr=null,sc=null){
try {
let d=new Date()/1000;
if(!mmdd){
... ... @@ -61,7 +61,12 @@ module.exports ={
let ti=['morning','noon','night'];
let ts=sc.daily[ti[timeIndex]].split('-');
console.log(ts);
let stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[0]+':00');
let stime
if(stimestr){
stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+stimestr);
}else{
stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[0]+':00');
}
console.log(stime);
let etime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[1]+':00');
return util.timetouUnix(stime)+'-'+util.timetouUnix(etime);
... ... @@ -72,7 +77,7 @@ module.exports ={
return false;
},
//获得早中晚时间分组,
async getDayTimeSpace(step=30,sc=null){
async getDayTimeSpace(sc=null){
try {
let d=new Date()/1000;
if(!sc){
... ... @@ -85,11 +90,21 @@ module.exports ={
ti.forEach((tx,ii)=>{
let ts=sc.daily[tx].split('-');
console.log(ts);
// while (ts[0]<ts[1]){
// dts[ii].push(ts[0]);
//
// }
while (ts[0]<=ts[1]){
dts[ii].push(ts[0]);
let _dt=ts[0].split(':');
if(_dt[1]=='30'){
_dt[0]=parseInt(_dt[0])+1;
_dt[1]='00';
}else{
_dt[0]=parseInt(_dt[0])+0;
_dt[1]='30';
}
_dt[0]=_dt[0]<10?'0'+_dt[0]:_dt[0];
ts[0]=_dt.join(':');
}
})
return dts;
}
}catch (e){
console.log(e);
... ...