Commit e15246ecd40686516ff67d77a44f49f9e9518f94

Authored by wangfan
1 parent 5a8e257f

v2 time

... ... @@ -4,7 +4,7 @@ import comm from '../../utils/bookCommon';
import App from '../../utils/api';
const {regeneratorRuntime} = global
const formTpl={
id:'',
date:0,
time:0,
pnum_str:'1-4',
... ... @@ -66,20 +66,29 @@ Page({
this.setData({
timePickerArray: timePickerArray,
})
if(options.id>0){
this.initModify(options.id);
}
},
/**
*
* @param d
*
*/
setDateStr(d=new Date()/1000){
async setDateStr(d=new Date()/1000){
let dateStr=[
util.unixtoTime(d,'MM-DD `DAY/周WW`'),
util.unixtoTime(parseInt(d)+86400,'MM-DD `DAY/周WW`'),
];
this.setData({
let form=this.data.form;
form.time=await comm.getTimeSpaceIndex(d);
let obj={
dateStr:dateStr,
})
form:form,
};
this.setData(obj)
return obj;
},
/**
... ... @@ -296,4 +305,48 @@ Page({
timePickerIndex:timePickerIndex,
})
},
/**
* 修改初始化
*/
async initModify(id){
try{
let res= await App.Reserve.Detail({rid:id,openid:''});
console.log('initModify',res);
//设置日期
let obj = await this.setDateStr(res.data.rdate);
//设置时间
let nd=util.unixtoTime(res.data.rdate,'HH:II');
let timePickerIndex=this.data.timePickerIndex
console.log('initModify-',this.data.timePickerArray,obj.form.time)
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.rname=res.data.rname;
obj.form.phone=res.data.phone;
obj.form.sex=res.data.sex;
obj.form.cusdem=res.data.cusdem;
obj.form.id=id;
obj.form.tid=[];
res.data.tables.forEach((t,ti)=>{
t.isselect=true
res.data.tables[ti]=t;
obj.form.tid.push(t.id)
})
this.setData({
timePickerIndex:timePickerIndex,
form:obj.form,
tablesed:res.data.tables,
})
}catch (e){
console.log('initModify',e)
}
}
})
\ No newline at end of file
... ...
... ... @@ -88,10 +88,10 @@
<view class="page-full tables">
<view class="page">
<view class="title">可订桌位</view>
<view class="title">可订桌位<text wx:if="{{tables.length>0}}"> ({{tables.length}})</text></view>
<view class="advice-desk-detail flex-lr" wx:if="{{tables.length>0}}">
<view class="flex-ll">
<block wx:for="{{tables}}" wx:key="tables.key">
<block wx:for="{{tablesed||tables}}" wx:key="tables.key">
<view class="order-desk-info"
bindtap="selectedValue"
data-value="{{index}}"
... ... @@ -113,7 +113,7 @@
</view>
</block>
</view>
<view class="flex-rr advice-more" bindtap="selectdesk">
<view class="flex-rr advice-more" bindtap="selectdesk" wx:if="{{tables.length>3 || form.id>0}}">
<view style="padding-right:30rpx;" class="gray-deep-font font26r">更多</view>
<image src="../image/click.png" class="icon12-22"></image>
</view>
... ...
... ... @@ -98,5 +98,10 @@ Page({
bookInfo:res.data,
})
})
},
gotoModify(){
wx.redirectTo({
url:'./b_addnew?id='+this.data.bookInfo.id
})
}
})
\ No newline at end of file
... ...
<nav>订座详情</nav>
<!--订单信息-->
<view class="order-info">
<view class="order-info" bindtap="gotoModify">
<view class="flex-lr order-detail">
<view class="gray-deep-font font30r">用餐时间</view>
<view class="black-font font34r">{{bookInfo.rdateStr}}</view>
... ...
... ... @@ -30,7 +30,7 @@
"list": []
},
"miniprogram": {
"current": 16,
"current": 17,
"list": [
{
"id": 0,
... ... @@ -162,6 +162,13 @@
"name": "预定本-发短信",
"pathName": "pages/book/b_sms",
"query": "id=25"
},
{
"id": -1,
"name": "预定本-编辑预定信息",
"pathName": "pages/book/b_addnew",
"query": "id=51",
"scene": "1001"
}
]
}
... ...
... ... @@ -59,8 +59,9 @@ module.exports ={
}
if (sc.daily){
let ti=['morning','noon','night'];
console.log('getTimeSpace',sc.daily[ti[timeIndex]],timeIndex);
let ts=sc.daily[ti[timeIndex]].split('-');
console.log(ts);
let stime
if(stimestr){
stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+stimestr);
... ... @@ -89,7 +90,7 @@ module.exports ={
let dts=[[],[],[]];
ti.forEach((tx,ii)=>{
let ts=sc.daily[tx].split('-');
console.log(ts);
console.log('getDayTimeSpace',ts);
while (ts[0]<=ts[1]){
dts[ii].push(ts[0]);
let _dt=ts[0].split(':');
... ... @@ -110,5 +111,32 @@ module.exports ={
console.log(e);
}
return false;
},
//获得时间戳在早中晚的索引
async getTimeSpaceIndex(d=new Date()/1000,sc=null){
try {
if(!sc){
let res = await App.Reserve.SellerInfo(util.cache('enter_params'));
sc = res.data;
}
if (sc.daily){
let ti=['morning','noon','night'];
let dti=0;
let date=util.unixtoTime(d,'HH:II')
ti.forEach((tx,ii)=>{
let ts=sc.daily[tx].split('-');
console.log('getTimeSpaceIndex',ts);
if(date>=ts[0] && ts[0]<=ts[1]){
dti=ii;
return dti;
}
})
return dti;
}
}catch (e){
console.log(e);
}
return 0;
}
}
... ...