Commit 9bcb5dbe499324052d370fa2bf264ea64f4cebfa

Authored by wangfan
2 parents 3b508006 64d4b2ed

Merge remote-tracking branch 'remotes/origin/timespace'

# Conflicts:
#	pages/book/b_addnew.js
#	project.config.json
... ... @@ -3,286 +3,364 @@ import util from '../../utils/util';
import comm from '../../utils/bookCommon';
import App from '../../utils/api';
const {regeneratorRuntime} = global
Page({
/**
* 页面的初始数据
*/
data: {
dateStr:[],
form:{
const formTpl={
rid:'',
date:0,
time:0,
pnum_str:'1-4',
tabid:0,
date:0,
time:0,
pnum_str:'1-4',
tabid:0,
rname:'',
phone:'',
sex:1,
cusdem:'',
rname:'',
phone:'',
sex:1,
cusdem:'',
tid:[],
tid:[],
}
Page({
},
tables:[],
grand:[
{
sex:1,
grand_title:'先生',
isselect:true
},
{
sex:2,
grand_title:'女士',
isselect:false
}
],
buttonhide:true,
/**
* 页面的初始数据
*/
data: {
dateStr:[],
form:JSON.parse(JSON.stringify(formTpl)),
tables:[],
grand:[
{
sex:1,
grand_title:'先生',
isselect:true
},
{
sex:2,
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' }
],
},
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' }
],
},
tablesAll:[],
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setDateStr();
this.sellerid=util.cache('sellerid');
this.getTables()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setDateStr();
this.sellerid=util.cache('sellerid');
let timePickerArray= await comm.getDayTimeSpace();
this.setData({
timePickerArray: timePickerArray,
})
if(options.id>0){
this.initModify(options.id);
}
},
/**
*
* @param d
* @param d
*
*/
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({
dateStr:dateStr,
})
},
async setDateStr(d=new Date()/1000){
let dateStr=[
util.unixtoTime(d,'MM-DD `DAY/周WW`'),
util.unixtoTime(parseInt(d)+86400,'MM-DD `DAY/周WW`'),
];
let form=this.data.form;
form.time=await comm.getTimeSpaceIndex(d);
let obj={
dateStr:dateStr,
form:form,
};
this.setData(obj)
return obj;
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
setTimeout(()=>{
this.setData({
calendarMaskLoad:true,
})
},1000);
this.conditionInfo()
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getTables();
setTimeout(()=>{
this.setData({
calendarMaskLoad:true,
})
},1000);
this.conditionInfo()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
},
selectedValue(e){
//console.log(e);
let key=util.attr(e,'key');
//console.log(e);
let key=util.attr(e,'key');
let val;
if(e.type=='input'){
val=util.val(e);
if(e.currentTarget.dataset.key=='phone'){
var that=this;
if(e.detail.value!='' && e.detail.value.length>=3) {
App.Reserve.GetReserveUser({keywords:e.detail.value}).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
})
}
}
}else{
val=util.attr(e,'value');
}
if(e.type=='input'){
val=util.val(e);
if(e.currentTarget.dataset.key=='phone'){
var that=this;
if(e.detail.value!='' && e.detail.value.length>=3) {
App.Reserve.GetReserveUser({keywords:e.detail.value}).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
})
}
}
}else{
val=util.attr(e,'value');
}
let form=this.data.form;
let sobj={};
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;
}
//console.log(e.type,key,val,form);
let form=this.data.form;
let sobj={};
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;
}
//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;
}
this.setData(sobj)
if(form.tid.length>0 && form.rname.length>0){
sobj.buttonhide=false;
}
this.setData(sobj)
if('date,time,pnum_str,tabid'.indexOf(key)>-1){
this.getTables();
}
if('date,time,pnum_str,tabid'.indexOf(key)>-1){
this.getTables();
}
},
async getTables(){
let form=this.data.form;
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,
rdate:rdate,
tid:form.tabid,
}).then(res=>{
let tables=[];
res.data.forEach(p=>{
if(tables.length>=3) return true;
p.list.forEach(t=>{
if(tables.length>=3) return true;
tables.push(t);
})
})
this.tablesAll=res.data;
let form=this.data.form;
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,
rdate:rdate,
tid:form.tabid,
}).then(res=>{
let tables=[];
res.data.forEach(p=>{
if(tables.length>=3) return true;
p.list.forEach(t=>{
if(tables.length>=3) return true;
tables.push(t);
})
})
this.tablesAll=res.data;
this.setData({
tables:tables
})
})
}catch (e){
this.setData({
tables:[]
})
}
},
async formsubmit(){
if(this.data.buttonhide) return;
try {
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,
})
let form = this.data.form;
form.tid = form.tid.toString();
form.sid = this.sellerid;
form.rdate =rdate
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)),
tablesed:null,
})
App.Reserve.Detail({rid:_id,openid:''},true)
wx.navigateTo({
url:'b_detail?id='+res.data.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({
tables:tables
calendarMask:true
})
})
}catch (e){
},
dateChange(event){
console.log(event);
let clickDay = event.detail.day;
let changeDay = `dayStyle[1].day`;
let changeBg = `dayStyle[1].background`;
this.setData({
tables:[]
[changeDay]: clickDay,
[changeBg]: "#84e7d0"
})
}
},
async formsubmit(){
if(this.data.buttonhide) return;
try {
let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time);
console.log('rdate', rdate);
this.setDateStr(util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day))
this.getTables()
},
calendarClose(){
this.setData({
buttonhide: true,
calendarMask:false
})
let form = this.data.form;
form.tid = form.tid.toString();
form.sid = this.sellerid;
form.rdate =rdate
App.Reserve.SetReserveInfo(form).then(res => {
if(res.ret==200){
wx.navigateTo({
url:'b_detail?id='+res.data.id,
});
}else{
util.toast(res.msg,'none')
},
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
})
},
conditionInfo:function(){
var form=this.data.form
if(form.tid.length>0 && form.rname.length>0){
this.data.buttonhide=false;
}
})
}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.setData({
buttonhide:this.data.buttonhide
})
},
/**
* 选中时间区域
*/
bindTimePickerChange(e){
let timeIndex=util.attr(e,'timeIndex');
console.log(e,timeIndex);
let timePickerIndex=this.data.timePickerIndex;
timePickerIndex[timeIndex]=util.val(e);
this.setData({
timePickerIndex:timePickerIndex,
})
},
/**
* 修改初始化
*/
async initModify(id){
try{
let res= await App.Reserve.Detail({rid:id,openid:''});
})
this.conditionInfo();
},
calendarShow(){
this.setData({
calendarMask:true
})
},
dateChange(event){
console.log(event);
let clickDay = event.detail.day;
let changeDay = `dayStyle[1].day`;
let changeBg = `dayStyle[1].background`;
this.setData({
[changeDay]: clickDay,
[changeBg]: "#84e7d0"
})
this.setDateStr(util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day))
this.getTables()
},
calendarClose(){
this.setData({
calendarMask: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
})
},
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
})
}
})
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.rid=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
... ...
... ... @@ -23,15 +23,36 @@
<view class="tab">
<item class="item {{form.time==0?'checked':''}}"
bindtap="selectedValue" data-key="time" data-value="0">
早市
<picker bindchange="bindTimePickerChange"
data-time-index="0"
value="{{timePickerIndex[0]}}"
range="{{timePickerArray[0]}}">
<view class="picker">
早市 {{timePickerArray[0][timePickerIndex[0]]}}
</view>
</picker>
</item>
<item class="item {{form.time==1?'checked':''}}"
bindtap="selectedValue" data-key="time" data-value="1">
午市
<picker bindchange="bindTimePickerChange"
data-time-index="1"
value="{{timePickerIndex[1]}}"
range="{{timePickerArray[1]}}">
<view class="picker">
午市 {{timePickerArray[1][timePickerIndex[1]]}}
</view>
</picker>
</item>
<item class="item {{form.time==2?'checked':''}}"
bindtap="selectedValue" data-key="time" data-value="2">
晚市
<picker bindchange="bindTimePickerChange"
data-time-index="2"
value="{{timePickerIndex[2]}}"
range="{{timePickerArray[2]}}">
<view class="picker">
晚市 {{timePickerArray[2][timePickerIndex[2]]}}
</view>
</picker>
</item>
</view>
</view>
... ... @@ -67,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}}"
... ... @@ -92,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>
... ...
... ... @@ -56,14 +56,17 @@
.section .tab .item{
height: 50rpx;
line-height: 50rpx;
width: 150rpx !important;
min-width: 150rpx !important;
width: 180rpx !important;
min-width: 180rpx !important;
border-radius: 10rpx;
border: 2rpx solid #199095;
margin-right: 62rpx;
margin-right: 60rpx;
text-align: center;
display: inline-block;
}
.section .tab .item:last-child{
margin-right: 0;
}
.section .tab .checked{
background-color:#199095;
color: #FEFEFE;
... ...
... ... @@ -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>
... ...
... ... @@ -10,7 +10,7 @@
"compileType": "miniprogram",
"libVersion": "2.3.0",
"appid": "wxd3dc4206c76f14fc",
"projectname": "book",
"projectname": "xcx-book",
"isGameTourist": false,
"condition": {
"search": {
... ... @@ -30,7 +30,7 @@
"list": []
},
"miniprogram": {
"current": 14,
"current": 17,
"list": [
{
"id": 0,
... ... @@ -145,7 +145,7 @@
}
},
{
"id": 14,
"id": -1,
"name": "预定本-添加预定",
"pathName": "pages/book/b_addnew",
"query": "seller_id=1&seller_openid=o9pcQ0cbjRKnRWczcOJaaSRGP1lE&manager_id=500",
... ... @@ -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"
}
]
}
... ...
... ... @@ -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){
... ... @@ -59,16 +59,84 @@ 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=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);
}
}catch (e){
console(e);
console.log(e);
}
return false;
},
//获得早中晚时间分组,
async getDayTimeSpace(sc=null){
try {
let d=new Date()/1000;
if(!sc){
let res = await App.Reserve.SellerInfo(util.cache('enter_params'));
sc = res.data;
}
if (sc.daily){
let ti=['morning','noon','night'];
let dts=[[],[],[]];
ti.forEach((tx,ii)=>{
let ts=sc.daily[tx].split('-');
console.log('getDayTimeSpace',ts);
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);
}
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;
}
}
... ...