Commit a55ed7a6de5688ef6c643433f4b3a4986db8750d

Authored by vking
2 parents 3d7e0561 f6ba7bcb

合并预订备注&重写商家预订

  1 +// pack-book/components/book/time/add-date.js
  2 +import util from '../../../../utils/util'
  3 +import PubSub from '../../../../utils/PubSub';
  4 +Component({
  5 + /**
  6 + * 组件的属性列表
  7 + */
  8 + properties: {
  9 + type:Number,
  10 + time:Number,
  11 + },
  12 + lifetimes: {
  13 + // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  14 + attached: function () {},
  15 + moved: function () { },
  16 + detached: function () { },
  17 + },
  18 + observers:{
  19 + time:function(time){
  20 + if(time>0){
  21 + this.initView()
  22 + }
  23 + },
  24 + },
  25 + /**
  26 + * 组件的初始数据
  27 + */
  28 + data: {
  29 + checked:-1,
  30 + list:[
  31 + {
  32 + time:new Date()/1000,
  33 + },
  34 + {
  35 + time:new Date()/1000+86400,
  36 + },
  37 + {
  38 + time:0,
  39 + }
  40 + ],
  41 +
  42 + calendarMaskLoad: false,
  43 + calendarMask: false,
  44 + },
  45 + checked:-1,
  46 + /**
  47 + * 组件的方法列表
  48 + */
  49 + methods: {
  50 + initView(){
  51 + //console.log('add-date',this.data.nowtime,this.data.today)
  52 + setTimeout(() => {
  53 + this.setData({
  54 + calendarMaskLoad: true,
  55 + })
  56 + }, 1000);
  57 + this.HHIISS=util.unixtoTime(this.data.time,'HH:II:SS')
  58 + this.initChecked(this.data.time)
  59 + setTimeout(() => {
  60 + this.trigger()
  61 + }, 800);
  62 + },
  63 + initChecked(nowtime){
  64 + let nowStr=util.unixtoTime(nowtime,"YYYY-MM-DD");
  65 + let list=this.data.list
  66 + this.checked=2
  67 + this.checkedTime=nowtime
  68 + if(nowStr==util.unixtoTime(list[0].time,"YYYY-MM-DD")){
  69 + this.checked=0
  70 + }else if(nowStr==util.unixtoTime(list[1].time,"YYYY-MM-DD")){
  71 + this.checked=1
  72 + }
  73 + this.setData({
  74 + checked:this.checked,
  75 + [`list[2].time`]:nowtime,
  76 + })
  77 +
  78 + },
  79 + selectedValue(e){
  80 + this.checked=util.attr(e,'value')
  81 + this.checkedTime=this.data.list[this.checked].time
  82 + this.setData({
  83 + checked:this.checked,
  84 + })
  85 + this.trigger()
  86 + },
  87 + trigger(){
  88 + let date=util.unixtoTime(this.checkedTime,"YYYY-MM-DD")
  89 + let dur_time=util.timetouUnix(date+' '+this.HHIISS);
  90 + let data={
  91 + type:this.data.type,
  92 + date:date,
  93 + dur_time:dur_time,
  94 + dateIndex:this.checked,
  95 + }
  96 + console.log('add-date.trigger',data)
  97 + // this.triggerEvent('event',{
  98 + // checked:this.checked,
  99 + // checkedTime:this.checkedTime,
  100 + // })
  101 + PubSub.emit('add-time-dur',data)
  102 + },
  103 + calendarShow(e){
  104 + this.setData({
  105 + calendarMask: true
  106 + })
  107 + },
  108 + calendarClose(){
  109 + this.setData({
  110 + calendarMask: false,
  111 + })
  112 + },
  113 + dateChange(event){
  114 + let cktime = util.timetouUnix(event.detail.date)
  115 + this.initChecked(cktime)
  116 + this.trigger()
  117 + this.calendarClose();
  118 + },
  119 + }
  120 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "calendar": "plugin://bmCalendar/calendar"
  5 + }
  6 +}
  1 +<!--pack-book/components/book/time/add-date.wxml-->
  2 +<wxs src="../../../../utils/util.wxs" module="util" />
  3 +<view class="tab flex-ll">
  4 + <view class="item {{checked==0?'checked':''}}"
  5 + bindtap="selectedValue" data-key="date" data-value="0">
  6 + {{util.unixtoTime(list[0].time,"MM-DD DAY")}}
  7 + </view>
  8 + <view class="item {{checked==1?'checked':''}}"
  9 + bindtap="selectedValue" data-key="date" data-value="1">
  10 + {{util.unixtoTime(list[1].time,"MM-DD DAY")}}
  11 + </view>
  12 + <view class="item {{checked==2?'checked':''}} flex-lr"
  13 + bindtap="calendarShow">
  14 + <view style="width: 80%" class="item-text">{{checked==2?util.unixtoTime(list[2].time,"MM-DD"):'其他'}}</view>
  15 + <image
  16 + src="http://qn.colorcun.com/custom/lite-yd/image/date{{checked==2?'.selected':''}}.png"
  17 + style="min-width: 36rpx;width: 36rpx;height: 36rpx; margin-right: 22rpx;"></image>
  18 + </view>
  19 +</view>
  20 +<view class="calendar-mask" bindtap="calendarClose"
  21 + style="height:{{calendarMask?'100%':0}};" wx:if="{{calendarMaskLoad}}">
  22 + <view style="width: 100%; height:{{calendarMask?'100%':0}};overflow: hidden;position: relative;">
  23 + <calendar catchtap="catchtap"
  24 + isTodaybtn="{{true}}" todaybtn_txt="回到今天"
  25 + custom="{{false}}"
  26 + switchover="{{['上一月','下个月']}}"
  27 + active-coloro="active-coloro"
  28 + active-colort="active-colort"
  29 + speciallist="{{speciallist}}"
  30 + txt_style="txt-style"
  31 + calendar-style="calendar"
  32 + header-style="calendar-header"
  33 + weektitle-style="weektitle-style"
  34 + restcolor-style="restcolor-style"
  35 + txt_type="cn-d"
  36 +
  37 + datefont-style="datefont-style"
  38 + todaybtn-style="todaybtn-style"
  39 +
  40 + bindnextMonth="nextMonth"
  41 + bindprevMonth="prevMonth"
  42 + bindselectDate="dateChange"
  43 + bindgotoday="gotoday"
  44 +
  45 + prev="{{true||calendar.nextNum>0}}"
  46 + circle_show="{{false}}"
  47 + closelaststyle="{{true}}"
  48 + ></calendar>
  49 + </view>
  50 +</view>
  1 +/* pack-book/components/book/time/add-date.wxss */
  2 +@import "../../../pages/book/common/calendar.wxss";
  3 +@import "../../../app.wxss";
  4 +.tab{
  5 + font-size: 34rpx;
  6 + color: #199095;
  7 +}
  8 +.tab .item{
  9 + height: 50rpx;
  10 + line-height: 49rpx;
  11 + width: 210rpx !important;
  12 + min-width: 210rpx !important;
  13 + border-radius: 10rpx;
  14 + border: 2rpx solid #199095;
  15 + margin-right: 20rpx;
  16 + text-align: center;
  17 +}
  18 +.tab .item .item-text,.tab .item .picker{
  19 + height: 46rpx;
  20 + line-height: 46rpx;
  21 +}
  22 +.tab .item .picker{
  23 + width:210rpx;
  24 + text-align: center;
  25 +}
  26 +.tab .item-pnum{
  27 + height: 50rpx;
  28 + line-height: 50rpx;
  29 + width: 60rpx !important;
  30 + min-width: 60rpx !important;
  31 + border-radius: 10rpx;
  32 + border: 2rpx solid #199095;
  33 + margin-right: 32rpx;
  34 + text-align: center;
  35 +}
  36 +.tab .item-pnum .pnum,.tab .item .pnum input{
  37 + height: 46rpx;
  38 + line-height: 46rpx;
  39 + font-size: 34rpx;
  40 +}
  41 +.tab .item:last-child{
  42 + margin-right: 0;
  43 +}
  44 +.tab .item-pnum:last-child{
  45 + margin-right: 0;
  46 +}
  47 +.tab .checked{
  48 + background-color:#199095;
  49 + color: #FEFEFE;
  50 + border: 2rpx solid #199095;
  51 +}
  52 +.tab .disabled{
  53 + background-color:#999999;
  54 + color: #efefef;
  55 + border: 2rpx solid #999999;
  56 +}
  1 +// pack-book/components/book/time/add-time-dur-items.js
  2 +import util from'../../../../utils/util.js'
  3 +import PubSub from '../../../../utils/PubSub';
  4 +Component({
  5 + /**
  6 + * 组件的属性列表
  7 + */
  8 + properties: {
  9 +
  10 + },
  11 + lifetimes: {
  12 + attached: function () {
  13 + PubSub.on('dur-items',(check)=>{
  14 + //{ddate_solt: 1, list: Array(9), listIndex: 8}
  15 + console.log('dur-items.PubSub',check)
  16 + this.ddate_solt=check.ddate_solt
  17 + this.dur_list=check.dur_list
  18 + this.dur_list_checked=check.dur_list_checked
  19 + this.setData(check)
  20 + this.trigger()
  21 + })
  22 + },
  23 + moved: function () { },
  24 + detached: function () {
  25 + PubSub.off('du-items')
  26 + },
  27 + },
  28 + /**
  29 + * 组件的初始数据
  30 + */
  31 + data: {
  32 + dur_list:[],
  33 + timePickerMask:false,
  34 + ddate_solt:-1,
  35 + },
  36 +
  37 + /**
  38 + * 组件的方法列表
  39 + */
  40 + methods: {
  41 + calendarShow(){
  42 + this.setData({
  43 + timePickerMask:true,
  44 + })
  45 + },
  46 + calendarClose(){
  47 + this.setData({
  48 + timePickerMask:false,
  49 + })
  50 + },
  51 + bindTimePickerChange(e){
  52 + this.dur_list_checked=util.attr(e,'index')
  53 + this.setData({
  54 + dur_list_checked:this.dur_list_checked,
  55 + })
  56 + this.trigger(true)
  57 + this.calendarClose()
  58 + },
  59 + trigger(hasManual=false){
  60 + if(this.dur_list.length<1){
  61 + return this.triggerEvent('event',{
  62 + time:0,
  63 + ddate_solt:-1,
  64 + timeDur:'0-0'
  65 + })
  66 + }
  67 + this.triggerEvent('event',{
  68 + hasManual:hasManual,
  69 + time:this.dur_list[this.dur_list_checked].time,
  70 + ddate_solt:parseInt(this.ddate_solt)+1,
  71 + timeDur:this.dur_list[0].time+'-'+this.dur_list[this.dur_list.length-1].time
  72 + })
  73 + },
  74 + }
  75 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--pack-book/components/book/time/add-time-dur-items.wxml-->
  2 +<wxs src="../../../../utils/util.wxs" module="util" />
  3 +<view bindtap="calendarShow">
  4 + <slot></slot>
  5 +</view>
  6 +<view class="calendar-mask" bindtap="calendarClose"
  7 + style="height:100%;" wx:if="{{timePickerMask}}">
  8 + <view class="timePicker">
  9 + <view class="flex-rr">
  10 + <image class="close" src="http://qn.colorcun.com/custom/lite-yd/image/add-act.png" bindtap="calendarClose"></image>
  11 + </view>
  12 + <view class="flex-cc" style="margin-bottom: 56rpx; font-size: 30rpx;">
  13 + <view bindtap="calendarClose">{{ddate_solt==1?'午市':ddate_solt==2?'晚市':'早市'}}</view>
  14 + </view>
  15 + <view class="flex-ll" style="flex-wrap:wrap">
  16 + <view class="time-item {{index==dur_list_checked?'checked':''}} {{item.disabled?'disabled':''}}"
  17 + style="{{(index+1)%3==0?'margin-right:0;':''}}"
  18 + wx:for="{{dur_list}}" wx:key="listkey"
  19 + catchtap="{{item.disabled?'miss':'bindTimePickerChange'}}"
  20 + data-index="{{index}}"
  21 + >{{util.unixtoTime(item.time,"HH:II")}}</view>
  22 + </view>
  23 + </view>
  24 +</view>
  1 +/* pack-book/components/book/time/add-time-dur-items.wxss */
  2 +@import "../../../app.wxss";
  3 +.calendar-mask{
  4 + position: fixed;
  5 + z-index: 99;
  6 + width: 100%;
  7 + height: 100%;
  8 + left:0;
  9 + top:0;
  10 + background-color: rgba(0,0,0,.5);
  11 +}
  12 +.timePicker{
  13 + width: 80%;
  14 + overflow: hidden;
  15 + position: absolute;
  16 + bottom: 0;
  17 + border-top: 2rpx solid #ccc;
  18 + background-color: #FEFEFE;
  19 + padding: 20rpx 10% 80rpx;
  20 +}
  21 +.timePicker .time-item{
  22 + width: 150rpx;
  23 + height: 60rpx;
  24 + line-height: 60rpx;
  25 + font-size: 40rpx;
  26 + font-weight: bold;
  27 + color:#199095;
  28 + border: 2rpx solid #199095;
  29 + border-radius: 10rpx;
  30 + text-align: center;
  31 + margin-right: 66rpx;
  32 + margin-bottom: 60rpx;
  33 +}
  34 +.timePicker .time-item.checked{
  35 + background-color: #199095;
  36 + color:#fefefe;
  37 +}
  38 +.timePicker .time-item.disabled{
  39 + background-color:#999999;
  40 + color: #efefef;
  41 + border: 2rpx solid #999999;
  42 +}
  43 +.timePicker .close{
  44 + width: 50rpx;
  45 + height: 50rpx;
  46 + transform:rotate(45deg);
  47 + margin-top: -10rpx;
  48 + margin-right: -10%;
  49 +}
  1 +// pack-book/components/book/time/add-time-dur.js
  2 +import util from'../../../../utils/util.js'
  3 +import App from '../../../../utils/api';
  4 +import PubSub from '../../../../utils/PubSub';
  5 +const timeSort=['morning', 'noon', 'night'];
  6 +const timeConfig= {
  7 + 'morning':{
  8 + name:'早市',
  9 + defTime:'',
  10 + },
  11 + 'noon':{
  12 + name:'午市',
  13 + defTime:'12:00',
  14 + },
  15 + 'night': {
  16 + name: '晚市',
  17 + defTime: '18:30'
  18 + },
  19 +}
  20 +Component({
  21 + /**
  22 + * 组件的属性列表
  23 + */
  24 + properties: {
  25 +
  26 + },
  27 + lifetimes: {
  28 + attached: function () {
  29 + //event {type: 1, date: "2019-12-31", dur_time: "NaN", dateIndex: 0}
  30 + PubSub.on('add-time-dur',(event)=>{
  31 + console.log('add-time-dur.PubSub',event)
  32 + this.hasManual=false
  33 + this.config=null
  34 + this.ddate_solt=-1
  35 + this.date=event.date
  36 + this.dateIndex=event.dateIndex
  37 + this.dur_time=event.dur_time
  38 + this.type=event.type
  39 + this.initSolt()//初始化solt
  40 + })
  41 + },
  42 + moved: function () { },
  43 + detached: function () {
  44 + PubSub.off('add-time-dur')
  45 + },
  46 + },
  47 + observers:{},
  48 + /**
  49 + * 组件的初始数据
  50 + */
  51 + data: {
  52 + ddate_solt:-1,
  53 + config:[],
  54 + },
  55 +
  56 + /**
  57 + * 组件的方法列表
  58 + */
  59 + methods: {
  60 + async initSolt(){//初始化solt
  61 + if(this.initSoltIng) return false
  62 + this.initSoltIng=true
  63 + await this.getConfig();//时段配置
  64 + this.initSoltIng=false
  65 + },
  66 + async getConfig(){//时段配置
  67 + let res = await App.Reserve.SellerInfo(util.cache('enter_params'));
  68 + let daily = res.data.daily;
  69 + console.log('add-time-dur.daily',daily)
  70 + this.initUserTime(daily)
  71 + setTimeout(()=>{
  72 + this.trigger();
  73 + },0)
  74 + },
  75 + initUserTime(daily){
  76 + let config=[]
  77 + let datetime=util.unixtoTime(this.dur_time,"YYYY-MM-DD,HH:II").split(',')
  78 + let TODAY=datetime[0]
  79 + let HHII=datetime[1]
  80 + this.ddate_solt=-1
  81 + let ddate_solt_bak=-1;
  82 + timeSort.forEach((en_name,ti)=>{
  83 + let dur=daily[en_name];
  84 + let min='',max='',hasShow=false,hasDisabled=false,hasChecked=false
  85 + if(dur){
  86 + if(ddate_solt_bak==-1){
  87 + ddate_solt_bak=ti
  88 + }
  89 + hasShow=true
  90 + dur=dur.split('-');
  91 + min=dur[0];
  92 + max=dur[1];
  93 + if(HHII<=max && this.ddate_solt==-1){
  94 + hasChecked=true
  95 + this.ddate_solt=ti
  96 + }
  97 + if(HHII>max && this.dateIndex==0 && this.type==1){//灰掉今天过期时间
  98 + hasDisabled=true
  99 + }
  100 + }
  101 + config.push({
  102 + name:timeConfig[en_name].name,
  103 + en_name:en_name,
  104 + hasShow:hasShow,
  105 + min:min,
  106 + max:max,
  107 + hasDisabled:hasDisabled,
  108 + hasChecked:hasChecked,
  109 + defTime:timeConfig[en_name].defTime
  110 + });
  111 + })
  112 + if(this.ddate_solt==-1 && this.dateIndex!=0){
  113 + //不是今天,过了时间,选中第一时段
  114 + this.ddate_solt=ddate_solt_bak
  115 + config[ddate_solt_bak].hasChecked=true
  116 + }
  117 + this.config=config;
  118 + console.log('add-time-dur.initUserTime',this.ddate_solt,this.config)
  119 + this.setData({
  120 + config:this.config,
  121 + ddate_solt:this.ddate_solt,
  122 + })
  123 + },
  124 + selectedValue(e){
  125 + console.log('add-time-dur.selectedValue',e)
  126 + let ddate_solt=util.attr(e,'value')
  127 + if(this.ddate_solt==ddate_solt) return;
  128 + this.ddate_solt=ddate_solt
  129 + this.hasManual=true //手动选择时段
  130 + this.config.forEach((t,ti)=>{
  131 + //t.hasDisabled=false
  132 + t.hasChecked=ti==this.ddate_solt
  133 + })
  134 + this.setData({
  135 + config:this.config,
  136 + ddate_solt:this.ddate_solt,
  137 + })
  138 + this.trigger();
  139 + },
  140 + initTimeSpaceIndex(){//对选中时段进行展开
  141 + if(this.ddate_solt<0) return {list:[],listIndex:-1};
  142 + let nowtime=parseInt(new Date()/1000)
  143 + let min=this.config[this.ddate_solt].min
  144 + let max=this.config[this.ddate_solt].max
  145 + let defTime=this.config[this.ddate_solt].defTime
  146 + let time=this.dur_time
  147 + if(this.type==3 && nowtime>time){//对桌位过来时间进行修复
  148 + time=nowtime
  149 + }
  150 + min=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+min+":00"))
  151 + max=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+max+":00"))
  152 + let hasUseDeftime=false
  153 + if(defTime && (this.type!=2 || this.hasManual)){//非修改时或手动选择,优先默认时间
  154 + defTime=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+defTime+":00"))
  155 + if(defTime>time || this.dateIndex>0){
  156 + time=defTime
  157 + hasUseDeftime=true
  158 + }
  159 + }
  160 + console.log('add-time-dur.ttime',hasUseDeftime,util.unixtoTime(time,"YYYY-MM-DD HH:II:SS"))
  161 + let dur,timeCheckedIndex=-1,list=[];
  162 + for(dur=parseInt(min);dur<=max;dur+=1800){
  163 + let t={
  164 + hasChecked:time<=dur,
  165 + time:dur,
  166 + disabled:this.dateIndex==0 && this.type==1 && nowtime>dur,//新增 &&今天 && 过期 时 disabled
  167 + }
  168 + list.push(t)
  169 + if(dur<=time){
  170 + timeCheckedIndex++
  171 + }
  172 + }
  173 + if(this.dateIndex==0 && this.type!=2 && !hasUseDeftime){//非修改 &&今天 &&未使用默认时间,+1
  174 + timeCheckedIndex+=1
  175 + }
  176 + timeCheckedIndex=timeCheckedIndex>=list.length?list.length-1:timeCheckedIndex
  177 + console.log('add-time-dur.tindex',list,timeCheckedIndex)
  178 + return {list:list,listIndex:timeCheckedIndex}
  179 + },
  180 + trigger(){
  181 + let timeList=this.initTimeSpaceIndex()
  182 + let data={
  183 + ddate_solt:this.ddate_solt,
  184 + dur_list:timeList.list,
  185 + dur_list_checked:timeList.listIndex,
  186 + }
  187 + //this.triggerEvent('event',data)
  188 + console.log('dur-items.trigger',data)
  189 + PubSub.emit('dur-items',data)
  190 + }
  191 + }
  192 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--pack-book/components/book/time/add-time-dur.wxml-->
  2 +<view class="tab flex-ll">
  3 + <block wx:for="{{config}}" wx:key="configkey">
  4 + <view class="item {{item.hasChecked?'checked':''}} {{item.hasDisabled?'disabled':''}}"
  5 + wx:if="{{item.hasShow}}"
  6 + bindtap="{{item.hasDisabled?'':'selectedValue'}}" data-value="{{index}}">
  7 + <view class="picker">{{item.name}}</view>
  8 + </view>
  9 + </block>
  10 +</view>
  1 +/* pack-book/components/book/time/add-time-dur.wxss */
  2 +@import "../../../app.wxss";
  3 +.tab{
  4 + font-size: 34rpx;
  5 + color: #199095;
  6 +}
  7 +.tab .item{
  8 + height: 50rpx;
  9 + line-height: 49rpx;
  10 + width: 210rpx !important;
  11 + min-width: 210rpx !important;
  12 + border-radius: 10rpx;
  13 + border: 2rpx solid #199095;
  14 + margin-right: 20rpx;
  15 + text-align: center;
  16 +}
  17 +.tab .item .item-text,.section .tab .item .picker{
  18 + height: 46rpx;
  19 + line-height: 46rpx;
  20 +}
  21 +.tab .item .picker{
  22 + width:210rpx;
  23 + text-align: center;
  24 +}
  25 +.tab .item-pnum{
  26 + height: 50rpx;
  27 + line-height: 50rpx;
  28 + width: 60rpx !important;
  29 + min-width: 60rpx !important;
  30 + border-radius: 10rpx;
  31 + border: 2rpx solid #199095;
  32 + margin-right: 32rpx;
  33 + text-align: center;
  34 +}
  35 +.tab .item-pnum .pnum,.tab .item .pnum input{
  36 + height: 46rpx;
  37 + line-height: 46rpx;
  38 + font-size: 34rpx;
  39 +}
  40 +.tab .item:last-child{
  41 + margin-right: 0;
  42 +}
  43 +.tab .item-pnum:last-child{
  44 + margin-right: 0;
  45 +}
  46 +.tab .checked{
  47 + background-color:#199095;
  48 + color: #FEFEFE;
  49 + border: 2rpx solid #199095;
  50 +}
  51 +.tab .disabled{
  52 + background-color:#999999;
  53 + color: #efefef;
  54 + border: 2rpx solid #999999;
  55 +}
1 // pages/book/b_addnew.js 1 // pages/book/b_addnew.js
2 import util from '../../../utils/util'; 2 import util from '../../../utils/util';
3 -import comm from '../../../utils/bookCommon';  
4 import App from '../../../utils/api'; 3 import App from '../../../utils/api';
5 -const {regeneratorRuntime} = global  
6 const formTpl = { 4 const formTpl = {
7 rid: '', 5 rid: '',
8 - date: 0,  
9 - time: 0,  
10 - //pnum_str:'1-4',  
11 pnum: 6, 6 pnum: 6,
12 tabid: 0, 7 tabid: 0,
13 8
@@ -20,12 +15,13 @@ const formTpl = { @@ -20,12 +15,13 @@ const formTpl = {
20 15
21 } 16 }
22 Page({ 17 Page({
23 -  
24 /** 18 /**
25 * 页面的初始数据 19 * 页面的初始数据
26 */ 20 */
27 data: { 21 data: {
28 - dateStr: [], 22 + type:1, // type 1/2/3 新增/修改/桌位
  23 + time:0,//组件最终构造的到店时间
  24 + runTime:0,//当前时间戳,或修改到店,或桌位预订时间
29 form: JSON.parse(JSON.stringify(formTpl)), 25 form: JSON.parse(JSON.stringify(formTpl)),
30 tables: [], 26 tables: [],
31 grand: [ 27 grand: [
@@ -46,141 +42,35 @@ Page({ @@ -46,141 +42,35 @@ Page({
46 } 42 }
47 ], 43 ],
48 buttonhide: true, 44 buttonhide: true,
49 -  
50 - calendarMaskLoad: false,  
51 - calendarMask: false,  
52 - dayStyle: [  
53 - {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'},  
54 - {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'}  
55 - ],  
56 - timePickerArray: [  
57 - [],  
58 - [],  
59 - [],  
60 - ],  
61 - timePickerIndex: [0, 0, 0],  
62 tablesLength: 0, 45 tablesLength: 0,
63 -  
64 - timePickerMask: false,  
65 pnumInputFocus: false, 46 pnumInputFocus: false,
66 pageMarginBottom: 0, 47 pageMarginBottom: 0,
67 speciallist: [], 48 speciallist: [],
68 - calendar: {  
69 - nextNum: 0,  
70 - },  
71 - defDtime: ['', '12:00', '18:30'],  
72 - hasUseDefDtime: true,  
73 CustomRemark:[], 49 CustomRemark:[],
74 CustomRemarkMoreMask:false, 50 CustomRemarkMoreMask:false,
75 }, 51 },
  52 + reserve_id: '',
  53 + checkedTables:{},//已选中的桌子集合
76 /** 54 /**
77 * 生命周期函数--监听页面加载 55 * 生命周期函数--监听页面加载
78 */ 56 */
79 - reserve_id: '',  
80 - checkedTables:{},//已选中的桌子集合  
81 - year:util.unixtoTime(new Date() / 1000,'YYYY'),  
82 onLoad: async function (options) { 57 onLoad: async function (options) {
83 this.options=options 58 this.options=options
84 - this.initLoad(options)  
85 - this.getCustomRemark();  
86 - },  
87 - async initLoad(options = {}){  
88 - let nt = new Date() / 1000;  
89 - let speciallist = [  
90 - {date: util.unixtoTime(nt, 'YYYY-MM-DD'), background: '', text: '今 天'},  
91 - {date: util.unixtoTime(nt + 86400, 'YYYY-MM-DD'), background: '', text: '明 天'},  
92 - {date: util.unixtoTime(nt + 86400 * 2, 'YYYY-MM-DD'), background: '', text: '后 天'},  
93 - ];  
94 - this.reserve_id = options.id || '';  
95 - let rev_time=parseInt(nt)  
96 this.sellerid = util.cache('enter_params')['seller_id']; 59 this.sellerid = util.cache('enter_params')['seller_id'];
97 - let timePickerArray = await comm.getDayTimeSpace();  
98 - this.setData({  
99 - timePickerArray: timePickerArray,  
100 - speciallist: speciallist,  
101 - //hasUseDefDtime: hasUseDefDtime,  
102 - })  
103 - if(options.hasQuick==1){  
104 - let rdate=options.ddate.split('-')  
105 - if(!(rev_time>=rdate[0] && rev_time<=rdate[1])){  
106 - rev_time=rdate[0]  
107 - }  
108 - }  
109 - await this.setDateStr(rev_time);  
110 - if (this.reserve_id > 0) {  
111 - this.initModify(this.reserve_id);  
112 - } else if(options.hasQuick==1){  
113 - this.initQuick(options);  
114 - } else {  
115 - this.getTables();  
116 - }  
117 - },  
118 -  
119 - hasInTimeSpace(hhii,timeIndex){  
120 - console.log('hasInTimeSpace',this.data.timePickerArray)  
121 - if(this.data.timePickerArray.length<1)return false  
122 - let timePickerArray=this.data.timePickerArray[timeIndex];  
123 - let tl=timePickerArray.length  
124 - if(tl<1) return false  
125 - console.log('hasInTimeSpace',hhii,timePickerArray[0],timePickerArray[tl-1],hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1])  
126 - if(hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1]) return true  
127 - return false  
128 - },  
129 - async setDateStr(d = new Date() / 1000,hasUseDefDtime=false,fouceTime=-1){  
130 - fouceTime=fouceTime>-1?fouceTime:this.data.form.time  
131 - hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[fouceTime],fouceTime)  
132 - if(hasUseDefDtime){//  
133 - let timestr=util.unixtoTime(d,'YYYY-MM-DD '+this.data.defDtime[fouceTime])  
134 - d=util.timetouUnix(timestr)  
135 - }  
136 - console.log('setDateStr',util.unixtoTime(d,'YYYY-MM-DD HH:II'),hasUseDefDtime,fouceTime)  
137 - this.year=util.unixtoTime(d,'YYYY');  
138 - let ns = new Date() / 1000;  
139 - let dateStr = [  
140 - util.unixtoTime(ns, 'MM-DD `DAY/周WW`'),  
141 - util.unixtoTime(parseInt(ns) + 86400, 'MM-DD `DAY/周WW`'),  
142 - ];  
143 - //let dateStr=this.data.dateStr;  
144 - let nowStr = util.unixtoTime(d, 'MM-DD `DAY/周WW`')  
145 - let form = this.data.form;  
146 -  
147 - let timeObj = await comm.getTimeSpaceIndexData(d,null,fouceTime);  
148 - if(fouceTime!=timeObj.timeIndex && fouceTime>0){  
149 - timeObj.timeIndex=fouceTime  
150 - }  
151 - //form.time=await comm.getTimeSpaceIndex(d);  
152 - //如果小于默认时间,使用默认时间  
153 - let mmii = util.unixtoTime(d,'HH:II')  
154 - console.log('setDateStr-timeObj',timeObj,mmii,this.data.defDtime[timeObj.timeIndex])  
155 - if (mmii < this.data.defDtime[timeObj.timeIndex]) {  
156 - hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[timeObj.timeIndex],timeObj.timeIndex)  
157 - if(hasUseDefDtime){  
158 - let str=util.unixtoTime(d, 'YYYY-MM-DD '+this.data.defDtime[timeObj.timeIndex]+':00')  
159 - timeObj = await comm.getTimeSpaceIndexData(util.timetouUnix(str));  
160 - } 60 + this.getCustomRemark();
  61 + if(options.id>0){
  62 + //修改
  63 + this.reserve_id=options.id
  64 + return this.initModify();
161 } 65 }
162 -  
163 - form.time = timeObj.timeIndex;  
164 - let ind = dateStr._indexOf(nowStr);  
165 - if (ind > -1) {  
166 - form.date = ind  
167 - } else {  
168 - dateStr.push(nowStr.substr(0, 5));  
169 - form.date = 2; 66 + if(options.hasQuick==1){
  67 + //桌位预订
  68 + return this.initQuick();
170 } 69 }
171 - let timePickerIndex = this.data.timePickerIndex;  
172 - timePickerIndex[timeObj.timeIndex] = timeObj.timeMatchIndex;  
173 - let obj = {  
174 - dateStr: dateStr,  
175 - form: form,  
176 - timePickerIndex: timePickerIndex,  
177 - timeOpt: timeObj.timeOpt,  
178 - hasUseDefDtime:hasUseDefDtime  
179 - };  
180 -  
181 - this.setData(obj)  
182 - return obj;  
183 - 70 + this.setData({
  71 + runTime:parseInt(new Date()/1000),
  72 + type:1
  73 + })
184 }, 74 },
185 75
186 /** 76 /**
@@ -194,16 +84,7 @@ Page({ @@ -194,16 +84,7 @@ Page({
194 * 生命周期函数--监听页面显示 84 * 生命周期函数--监听页面显示
195 */ 85 */
196 onShow: function () { 86 onShow: function () {
197 - //if(!this.reserve_id || util.cache('tableid').length>0){  
198 - //if (util.cache('tableid').length > 0) {  
199 - this.getTables();  
200 - //}  
201 - setTimeout(() => {  
202 - this.setData({  
203 - calendarMaskLoad: true,  
204 - })  
205 - }, 1000);  
206 - this.conditionInfo() 87 +
207 }, 88 },
208 89
209 /** 90 /**
@@ -240,239 +121,70 @@ Page({ @@ -240,239 +121,70 @@ Page({
240 onShareAppMessage: function () { 121 onShareAppMessage: function () {
241 122
242 }, 123 },
243 - async selectedValueAsync(e){  
244 - console.log(e);  
245 - let key = util.attr(e, 'key');  
246 - let val;  
247 - let sobj = {};  
248 - if (key == 'date') {  
249 - this.year=util.unixtoTime(new Date() / 1000,'YYYY');  
250 - }  
251 - if (e.type == 'input' || e.type == 'confirm') {  
252 - val = util.val(e);  
253 - if (key == 'phone') {  
254 - var that = this;  
255 - if (e.detail.value != '' && e.detail.value.length >= 3) {  
256 - App.Reserve.GetReserveUser(  
257 - {  
258 - keywords: e.detail.value,  
259 - sid: this.sellerid  
260 - }  
261 - ).then(function (json) {  
262 - if (json.ret == 200 && json.data.length > 0) {  
263 - that.setData({  
264 - searchlist: json.data  
265 - })  
266 - } else {  
267 - that.setData({  
268 - searchlist: null  
269 - })  
270 - }  
271 - })  
272 - } else {  
273 - this.setData({  
274 - searchlist: null  
275 - })  
276 - }  
277 - }  
278 - if (key == 'pnum') {  
279 - sobj.pnumInputFocus = true;  
280 - }  
281 - } else {  
282 - val = util.attr(e, 'value');  
283 - }  
284 - if (key == 'time') {  
285 - if (this.data.timeOpt[val]) return;  
286 - }  
287 - if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {  
288 - if (util.attr(e, 'display') != 'block') {  
289 - return;  
290 - }  
291 - }  
292 - let form = this.data.form;  
293 -  
294 - if (key == 'tid') {  
295 - let ts = this.data.tables;  
296 - if (ts[val].isselect) {  
297 - ts[val].isselect = false;  
298 - form.tid.remove(ts[val].id);  
299 - delete this.checkedTables[ts[val].id]  
300 - } else {  
301 - ts[val].isselect = true;  
302 - form.tid.push(ts[val].id);  
303 - this.checkedTables[ts[val].id]=ts[val].name  
304 - }  
305 - sobj.tables = ts;  
306 - } else {  
307 - form[key] = val;  
308 - }  
309 - console.log('ts', sobj.tables,this.checkedTables);  
310 - //console.log(e.type,key,val,form);  
311 - sobj.form = form;  
312 - sobj.buttonhide = this.data.buttonhide;  
313 - if (form.tid.length > 0 && form.rname.length > 0) {  
314 - sobj.buttonhide = false;  
315 - }else{  
316 - sobj.buttonhide = true;  
317 - }  
318 - let displayTimes = false;  
319 - if (key == 'time') {  
320 - if (util.attr(e, 'display') == 'block') {  
321 - displayTimes = true;  
322 - sobj.timePickerMask = true;  
323 - }  
324 - }  
325 - //判断hasUseDefDtime  
326 - if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {  
327 - sobj.hasUseDefDtime = true  
328 - let ntime = parseInt(new Date() / 1000)  
329 - let xtime =ntime  
330 - if(key == 'time'){  
331 - xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');  
332 - xtime=util.timetouUnix(xtime)  
333 - //if 当前时间在区间内 hasUseDefDtime 为 false  
334 - let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
335 - this.data.form.time, null,null,this.year);  
336 - d_rdate=d_rdate.split('-');  
337 - if(d_rdate[0] <= ntime && ntime<=d_rdate[1]){  
338 - sobj.hasUseDefDtime=false 124 + //到店时间选择通知
  125 + addTimeDurItemsEvent(e){
  126 + //{time: 1577788200, ddate_solt: 2, timeDur: "1577786400-1577804400"}
  127 + console.log('addTimeDurItemsEvent',e.detail,util.unixtoTime(e.detail.time))
  128 + this.time=e.detail.time
  129 + this.ddate_solt=e.detail.ddate_solt
  130 + this.timeDur=e.detail.timeDur//预订所在时段区间时间戳
  131 + this.setData({
  132 + ...e.detail,
  133 + })
  134 + this.getTables();
  135 + },
  136 + getCustomRemark(){
  137 + App.User.GetCustomRemark({
  138 + uid:util.cache('enter_params')['manager_id'],
  139 + }).then(res=>{
  140 + let CustomRemark=[];
  141 + res.data.forEach(r=>{
  142 + if(r.often_use){
  143 + CustomRemark.push(r);
339 } 144 }
340 - }  
341 - this.setDateStr(xtime,sobj.hasUseDefDtime,sobj.form.time);  
342 - }  
343 -  
344 - if (this.data.form.date == 0) {//  
345 - let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');  
346 - if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {  
347 - sobj.hasUseDefDtime = false;  
348 - }  
349 - }  
350 - if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {  
351 - if (!displayTimes) {  
352 - //sobj.form.tid = []; //切换日期时间清空桌位  
353 - //sobj.buttonhide = true;  
354 - this.getTables();  
355 - }  
356 - if (key == 'date') {  
357 - let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');  
358 - this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);  
359 - }  
360 - }  
361 - this.setData(sobj) 145 + })
  146 + this.setData({
  147 + CustomRemark:CustomRemark,
  148 + })
  149 + })
362 }, 150 },
363 - selectedValue(e){  
364 - console.log(e);  
365 - let key = util.attr(e, 'key');  
366 - let val;  
367 - let sobj = {};  
368 - if (key == 'date') {  
369 - this.year=util.unixtoTime(new Date() / 1000,'YYYY');  
370 - }  
371 - if (e.type == 'input' || e.type == 'confirm') {  
372 - val = util.val(e);  
373 - if (key == 'phone') {  
374 - var that = this;  
375 - if (e.detail.value != '' && e.detail.value.length >= 3) {  
376 - App.Reserve.GetReserveUser(  
377 - {  
378 - keywords: e.detail.value,  
379 - sid: this.sellerid  
380 - }  
381 - ).then(function (json) {  
382 - if (json.ret == 200 && json.data.length > 0) {  
383 - that.setData({  
384 - searchlist: json.data  
385 - })  
386 - } else {  
387 - that.setData({  
388 - searchlist: null  
389 - })  
390 - }  
391 - })  
392 - } else {  
393 - this.setData({  
394 - searchlist: null  
395 - }) 151 + oftenUse(e){
  152 + let id=util.attr(e,'id');
  153 + let val=util.attr(e,'value');
  154 + let CustomRemark=this.data.CustomRemark;
  155 + let form=this.data.form;
  156 + CustomRemark.forEach(r=>{
  157 + if(id==r.id){
  158 + if(r.active){
  159 + form.cusdem=form.cusdem.replace(val+'、','')
  160 + }
  161 + r.active=!r.active
  162 + if(r.active){
  163 + form.cusdem+=val+'、'
396 } 164 }
397 } 165 }
398 - if (key == 'pnum') {  
399 - sobj.pnumInputFocus = true;  
400 - }  
401 - } else {  
402 - val = util.attr(e, 'value');  
403 - }  
404 - if (key == 'time') {  
405 - if (this.data.timeOpt[val]) return;  
406 - }  
407 - if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {  
408 - if (util.attr(e, 'display') != 'block') {  
409 - return;  
410 - }  
411 - }  
412 - let form = this.data.form;  
413 -  
414 - if (key == 'tid') {  
415 - let ts = this.data.tables;  
416 - if (ts[val].isselect) {  
417 - ts[val].isselect = false;  
418 - form.tid.remove(ts[val].id);  
419 - delete this.checkedTables[ts[val].id]  
420 - } else {  
421 - ts[val].isselect = true;  
422 - form.tid.push(ts[val].id);  
423 - this.checkedTables[ts[val].id]=ts[val].name  
424 - }  
425 - sobj.tables = ts;  
426 - } else {  
427 - form[key] = val;  
428 - }  
429 - console.log('ts', sobj.tables,this.checkedTables);  
430 - //console.log(e.type,key,val,form);  
431 - sobj.form = form;  
432 - sobj.buttonhide = this.data.buttonhide;  
433 - if (form.tid.length > 0 && form.rname.length > 0 && this.data.timePickerArray[form.time].length>0){  
434 - sobj.buttonhide = false;  
435 - }else{  
436 - sobj.buttonhide = true;  
437 - }  
438 - let displayTimes = false;  
439 - if (key == 'time') {  
440 - if (util.attr(e, 'display') == 'block') {  
441 - displayTimes = true;  
442 - sobj.timePickerMask = true;  
443 - }  
444 - }  
445 - //判断hasUseDefDtime  
446 - if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {  
447 - sobj.hasUseDefDtime = true  
448 - let ntime = parseInt(new Date() / 1000)  
449 - let xtime =ntime  
450 - if(key == 'time'){  
451 - xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');  
452 - xtime=util.timetouUnix(xtime)  
453 - }  
454 - this.setDateStr(xtime,sobj.hasUseDefDtime);  
455 - }  
456 - if (this.data.form.date == 0) {//  
457 - let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');  
458 - if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {  
459 - sobj.hasUseDefDtime = false;  
460 - }  
461 - }  
462 - if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {  
463 - if (!displayTimes) {  
464 - //sobj.form.tid = []; //切换日期时间清空桌位  
465 - //sobj.buttonhide = true;  
466 - this.getTables();  
467 - }  
468 - if (key == 'date') {  
469 - let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');  
470 - this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);  
471 - } 166 + })
  167 + this.setData({
  168 + CustomRemark:CustomRemark,
  169 + form:form,
  170 + })
  171 + this.conditionInfo()
  172 + },
  173 + CustomRemarkMore(){
  174 + this.setData({
  175 + CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
  176 + })
  177 + },
  178 + conditionInfo: function () {
  179 + var form = this.data.form
  180 + if (form.tid.length > 0 && form.rname.length > 0) {
  181 + this.data.buttonhide = false;
472 } 182 }
473 -  
474 - this.setData(sobj) 183 + this.setData({
  184 + buttonhide: this.data.buttonhide
  185 + })
475 }, 186 },
  187 +
476 async getTables(){ 188 async getTables(){
477 let form = this.data.form; 189 let form = this.data.form;
478 let tableid = util.cache('tableid'); 190 let tableid = util.cache('tableid');
@@ -483,16 +195,14 @@ Page({ @@ -483,16 +195,14 @@ Page({
483 } 195 }
484 console.log('getTables-tableid', tableid, tableid.length); 196 console.log('getTables-tableid', tableid, tableid.length);
485 try { 197 try {
486 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);  
487 - console.log('rdate', this.data.dateStr[this.data.form.date], rdate);  
488 App.Reserve.GetTableList({ 198 App.Reserve.GetTableList({
489 sid: util.cache('enter_params')['seller_id'], 199 sid: util.cache('enter_params')['seller_id'],
490 //pnum_str:form.pnum_str, 200 //pnum_str:form.pnum_str,
491 pnum: form.pnum, 201 pnum: form.pnum,
492 - rdate: util.unixtoTime(rdate.substr(0,10),'YYYYMMDD'), 202 + rdate: util.unixtoTime(this.time,'YYYYMMDD'),
493 tid: form.tabid, 203 tid: form.tabid,
494 rid: this.reserve_id, 204 rid: this.reserve_id,
495 - ddate_solt:parseInt(form.time)+1 205 + ddate_solt:this.ddate_solt
496 }).then(res => { 206 }).then(res => {
497 let tables = []; 207 let tables = [];
498 let tablesLength = 0; 208 let tablesLength = 0;
@@ -561,17 +271,108 @@ Page({ @@ -561,17 +271,108 @@ Page({
561 }) 271 })
562 } 272 }
563 }, 273 },
  274 + selectphone: function (e) {
  275 + this.data.form.phone = e.detail.phone;
  276 + this.data.form.rname = e.detail.rname;
  277 + this.data.form.cusdem = e.detail.cusdem;
  278 + var form = this.data.form
  279 + this.data.form.sex = e.detail.sex;
  280 + this.setData({
  281 + form: this.data.form,
  282 + searchlist: null
  283 + })
  284 + this.conditionInfo();
  285 + },
  286 + selectdesk(){
  287 + wx.navigateTo({
  288 + url: 'b_desk?rdate=' + this.time + '&tid=' + this.data.form.tabid
  289 + //+'&pnum_str='+this.data.form.pnum_str
  290 + + '&pnum=' + this.data.form.pnum
  291 + + '&checked_tids=' + this.data.form.tid
  292 + + '&rid=' + this.reserve_id
  293 + + '&ddate_solt='+this.ddate_solt
  294 + })
  295 + },
  296 + selectedValue(e){
  297 + console.log(e);
  298 + let key = util.attr(e, 'key');
  299 + let val;
  300 + let sobj = {};
  301 + if (e.type == 'input' || e.type == 'confirm') {
  302 + val = util.val(e);
  303 + if (key == 'phone') {
  304 + var that = this;
  305 + if (e.detail.value != '' && e.detail.value.length >= 3) {
  306 + App.Reserve.GetReserveUser(
  307 + {
  308 + keywords: e.detail.value,
  309 + sid: this.sellerid
  310 + }
  311 + ).then(function (json) {
  312 + if (json.ret == 200 && json.data.length > 0) {
  313 + that.setData({
  314 + searchlist: json.data
  315 + })
  316 + } else {
  317 + that.setData({
  318 + searchlist: null
  319 + })
  320 + }
  321 + })
  322 + } else {
  323 + this.setData({
  324 + searchlist: null
  325 + })
  326 + }
  327 + }
  328 + if (key == 'pnum') {
  329 + sobj.pnumInputFocus = true;
  330 + }
  331 + } else {
  332 + val = util.attr(e, 'value');
  333 + }
  334 +
  335 +
  336 + let form = this.data.form;
  337 +
  338 + if (key == 'tid') {
  339 + let ts = this.data.tables;
  340 + if (ts[val].isselect) {
  341 + ts[val].isselect = false;
  342 + form.tid.remove(ts[val].id);
  343 + delete this.checkedTables[ts[val].id]
  344 + } else {
  345 + ts[val].isselect = true;
  346 + form.tid.push(ts[val].id);
  347 + this.checkedTables[ts[val].id]=ts[val].name
  348 + }
  349 + sobj.tables = ts;
  350 + } else {
  351 + form[key] = val;
  352 + }
  353 + console.log('ts', sobj.tables,this.checkedTables);
  354 + //console.log(e.type,key,val,form);
  355 + sobj.form = form;
  356 + sobj.buttonhide = this.data.buttonhide;
  357 + if (form.tid.length > 0 && form.rname.length > 0){
  358 + sobj.buttonhide = false;
  359 + }else{
  360 + sobj.buttonhide = true;
  361 + }
  362 + let displayTimes = false;
  363 +
  364 + if ('pnum,pnum_str,tabid'.indexOf(key) > -1) {
  365 + if (!displayTimes) {
  366 + this.getTables();
  367 + }
  368 + }
  369 +
  370 + this.setData(sobj)
  371 + },
  372 +
564 async formsubmit(){ 373 async formsubmit(){
565 if (this.data.buttonhide) return; 374 if (this.data.buttonhide) return;
566 try { 375 try {
567 - let d_stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];  
568 - let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
569 - this.data.form.time, d_stimestr,null,this.year);  
570 - let stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[0]];  
571 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
572 - this.data.form.time, stimestr,null,this.year);  
573 - console.log('stimestr', stimestr, this.data.form.time, this.data.timePickerIndex);  
574 - console.log('rdate', rdate);  
575 this.setData({ 376 this.setData({
576 buttonhide: true, 377 buttonhide: true,
577 }) 378 })
@@ -581,7 +382,7 @@ Page({ @@ -581,7 +382,7 @@ Page({
581 let tid = new Set(form.tid);//tid 去重 382 let tid = new Set(form.tid);//tid 去重
582 form.tid = [...tid].toString(); 383 form.tid = [...tid].toString();
583 } 384 }
584 - if(this.data.timePickerArray[form.time].length<1){ 385 + if(this.ddate_solt<1){
585 return util.toast('请选择时段', 'none'); 386 return util.toast('请选择时段', 'none');
586 } 387 }
587 if (!form.tid) { 388 if (!form.tid) {
@@ -591,7 +392,7 @@ Page({ @@ -591,7 +392,7 @@ Page({
591 return util.toast('请填写预订人', 'none'); 392 return util.toast('请填写预订人', 'none');
592 } 393 }
593 form.sid = this.sellerid; 394 form.sid = this.sellerid;
594 - form.rdate = rdate 395 + form.rdate = this.timeDur
595 396
596 try { 397 try {
597 let enter_params = util.cache('enter_params'); 398 let enter_params = util.cache('enter_params');
@@ -605,12 +406,8 @@ Page({ @@ -605,12 +406,8 @@ Page({
605 form.note_name = note_name || ''; 406 form.note_name = note_name || '';
606 } catch (e) {} 407 } catch (e) {}
607 408
608 - form.ddate = d_rdate.substr(0, 10);  
609 - if (this.data.hasUseDefDtime && this.data.form.time > 0) {//转为默认时间  
610 - let ddateStr = util.unixtoTime(form.ddate, "YYYY-MM-DD " + this.data.defDtime[this.data.form.time] + ":00");  
611 - form.ddate = util.timetouUnix(ddateStr);  
612 - }  
613 - form.ddate_solt=parseInt(form.time)+1 409 + form.ddate = this.time;
  410 + form.ddate_solt=this.ddate_solt
614 form.is_set_ddate=1 411 form.is_set_ddate=1
615 App.Reserve.SetReserveInfo(form).then(res => { 412 App.Reserve.SetReserveInfo(form).then(res => {
616 if (res.ret == 200) { 413 if (res.ret == 200) {
@@ -619,9 +416,9 @@ Page({ @@ -619,9 +416,9 @@ Page({
619 this.setData({ 416 this.setData({
620 form: JSON.parse(JSON.stringify(formTpl)), 417 form: JSON.parse(JSON.stringify(formTpl)),
621 tables: [], 418 tables: [],
622 - timePickerIndex: [0, 0, 0], 419 + runTime:parseInt(new Date()/1000),
  420 + type:1
623 }) 421 })
624 - this.initLoad();  
625 this.checkedTables={}; 422 this.checkedTables={};
626 App.Reserve.Detail({rid: _id, openid: ''}, 'clear') 423 App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
627 wx.navigateTo({ 424 wx.navigateTo({
@@ -634,135 +431,24 @@ Page({ @@ -634,135 +431,24 @@ Page({
634 } catch (e) { 431 } catch (e) {
635 } 432 }
636 }, 433 },
637 - selectphone: function (e) {  
638 - this.data.form.phone = e.detail.phone;  
639 - this.data.form.rname = e.detail.rname;  
640 - this.data.form.cusdem = e.detail.cusdem;  
641 - var form = this.data.form  
642 - this.data.form.sex = e.detail.sex;  
643 - this.setData({  
644 - form: this.data.form,  
645 - searchlist: null  
646 - })  
647 - this.conditionInfo();  
648 - },  
649 - calendarShow(){  
650 - this.setData({  
651 - calendarMask: true  
652 - })  
653 - },  
654 - dateChange(event){  
655 - console.log(event);  
656 - //let cktime=util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day)  
657 - let cktime = util.timetouUnix(event.detail.date)  
658 - this.year=event.detail.date.substr(0, 4);  
659 - console.log('this.year',this.year);  
660 - let day0 = parseInt(new Date(new Date().setHours(0, 0, 0, 0)) / 1000);  
661 - // if (cktime < day0) {  
662 - // util.toast('请选择有效日期', 'none');  
663 - // return;  
664 - // }  
665 - let clickDay = event.detail.date.substr(8, 2);  
666 - let changeDay = `dayStyle[1].day`;  
667 - let changeBg = `dayStyle[1].background`;  
668 - this.setData({  
669 - [changeDay]: clickDay,  
670 - [changeBg]: "#84e7d0",  
671 - //[`form.tid`]: [], //切换日期时间清空桌位  
672 - //buttonhide: true,  
673 - })  
674 - console.log('cktime',cktime,util.unixtoTime(cktime,'YYYY-MM-DD'))  
675 - if(cktime == day0){//今天  
676 - this.setDateStr( new Date() / 1000 )  
677 - }else{  
678 - let xtime=util.unixtoTime(new Date() / 1000, event.detail.date + ' HH:II:SS');  
679 - xtime=util.timetouUnix(xtime)  
680 - this.setDateStr(xtime,true)  
681 - }  
682 -  
683 - this.calendarClose();  
684 - setTimeout(res=>{  
685 - this.getTables();  
686 - },10)  
687 434
688 - },  
689 - calendarClose(){  
690 - this.setData({  
691 - calendarMask: false,  
692 - timePickerMask: false,  
693 - })  
694 - },  
695 - async selectdesk(){  
696 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);  
697 - console.log(this.data.form)  
698 - wx.navigateTo({  
699 - url: 'b_desk?rdate=' + rdate + '&tid=' + this.data.form.tabid  
700 - //+'&pnum_str='+this.data.form.pnum_str  
701 - + '&pnum=' + this.data.form.pnum  
702 - + '&checked_tids=' + this.data.form.tid  
703 - + '&rid=' + this.reserve_id  
704 - + '&ddate_solt='+(parseInt(this.data.form.time)+1)  
705 - })  
706 - },  
707 - conditionInfo: function () {  
708 - var form = this.data.form  
709 - if (form.tid.length > 0 && form.rname.length > 0) {  
710 - this.data.buttonhide = false;  
711 - }  
712 - this.setData({  
713 - buttonhide: this.data.buttonhide  
714 - })  
715 - },  
716 - /**  
717 - * 选中时间区域  
718 - */  
719 - bindTimePickerChange(e){  
720 - let timeIndex = util.attr(e, 'timeIndex');  
721 - if (timeIndex < 0) return;  
722 - let timePickerIndex = this.data.timePickerIndex;  
723 - //timePickerIndex[timeIndex]=util.val(e);  
724 - timePickerIndex[timeIndex] = util.attr(e, 'val');  
725 -  
726 - console.log(e, timeIndex, util.attr(e, 'val'));  
727 - this.setData({  
728 - timePickerIndex: timePickerIndex,  
729 - hasUseDefDtime: false,  
730 - })  
731 - },  
732 /** 435 /**
733 * 修改初始化 436 * 修改初始化
734 */ 437 */
735 - async initModify(id){ 438 + async initModify(){
736 try { 439 try {
737 - let res = await App.Reserve.Detail({rid: id, openid: ''});  
738 -  
739 - console.log('initModify', res);  
740 - //设置日期  
741 - let obj = await this.setDateStr(res.data.ddate,null,res.data.ddate_solt-1);  
742 - //设置时间  
743 - let nd = util.unixtoTime(res.data.ddate, 'HH:II');  
744 - let timePickerIndex = this.data.timePickerIndex  
745 - console.log('initModify-', this.data.timePickerArray, obj.form.time, nd)  
746 - this.data.timePickerArray[obj.form.time].forEach((dd, ii) => {  
747 - console.log('initModify-', nd, dd)  
748 - if (nd == dd) {  
749 - timePickerIndex[obj.form.time] = ii;  
750 - return true;  
751 - }  
752 - })  
753 -  
754 - console.log('initModify-timePickerIndex', timePickerIndex);  
755 - //obj.form.pnum_str=res.data.pnum_str;  
756 - obj.form.pnum = res.data.pnum || 6;  
757 - obj.form.rname = res.data.rname;  
758 - obj.form.phone = res.data.phone || "";  
759 - obj.form.sex = res.data.sex;  
760 - obj.form.cusdem = res.data.cusdem;  
761 - obj.form.rid = id;  
762 - obj.form.tid = []; 440 + let res = await App.Reserve.Detail({rid: this.options.id, openid: ''});
  441 + let form=this.data.form
  442 + form.pnum = res.data.pnum || 6;
  443 + form.rname = res.data.rname;
  444 + form.phone = res.data.phone || "";
  445 + form.sex = res.data.sex;
  446 + form.cusdem = res.data.cusdem;
  447 + form.rid = this.options.id;
  448 + form.tid = [];
763 let tablesed = []; 449 let tablesed = [];
764 res.data.tables.forEach((t, ti) => { 450 res.data.tables.forEach((t, ti) => {
765 - obj.form.tid.push(t.id) 451 + form.tid.push(t.id)
766 if (ti >= 3) return; 452 if (ti >= 3) return;
767 t.isselect = true 453 t.isselect = true
768 t["isselected"] = 1 454 t["isselected"] = 1
@@ -770,79 +456,15 @@ Page({ @@ -770,79 +456,15 @@ Page({
770 this.checkedTables[t.id]=t.name; 456 this.checkedTables[t.id]=t.name;
771 }) 457 })
772 this.setData({ 458 this.setData({
773 - timePickerIndex: timePickerIndex,  
774 - form: obj.form,  
775 - //tablesed:tablesed,  
776 - hasUseDefDtime: false, 459 + type:2,//修改
  460 + runTime: res.data.ddate,//到店时间
  461 + ddate_solt:res.data.ddate_solt,
  462 + form: form,
777 }) 463 })
778 - setTimeout(() => {  
779 - this.getTables();  
780 - }, 300)  
781 -  
782 } catch (e) { 464 } catch (e) {
783 console.log('initModify', e) 465 console.log('initModify', e)
784 } 466 }
785 }, 467 },
786 - pnumInputFocusEvent(e){  
787 - console.log(e);  
788 - this.setData({  
789 - pnumInputFocus: 'focus' == e.type  
790 - })  
791 - },  
792 - inputFocusTime: 0,  
793 - blurTime: 0,  
794 - inputFocus(e){  
795 - console.log(e, this.inputFocusTime);  
796 - return;  
797 - if (e.timeStamp > this.inputFocusTime) {  
798 - this.inputFocusTime = e.timeStamp;  
799 - if (e.type == 'focus' && this.data.pageMarginBottom == 0) {  
800 - this.setData({  
801 - pageMarginBottom: 300  
802 - })  
803 - setTimeout(res => {  
804 - this.pageScrollToBottom();  
805 - }, 100)  
806 - } else {  
807 - if (this.blurTime > 5) {  
808 - this.blurTime = 0;  
809 - this.setData({  
810 - pageMarginBottom: 0  
811 - })  
812 - } else {  
813 - setTimeout(res => {  
814 - this.blurTime += 1;  
815 - this.inputFocus(e);  
816 - }, 300)  
817 - }  
818 -  
819 - }  
820 -  
821 - }  
822 - },  
823 - pageScrollToBottom: function () {  
824 - wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {  
825 - // 使页面滚动到底部  
826 - wx.pageScrollTo({  
827 - scrollTop: rect.bottom  
828 - })  
829 - }).exec()  
830 - },  
831 - gotoday(e){  
832 - this.setData({  
833 - [`calendar.nextNum`]: 0  
834 - })  
835 - },  
836 - nextMonth(e){  
837 - this.setData({  
838 - [`calendar.nextNum`]: this.data.calendar.nextNum + 1  
839 - })  
840 - },  
841 - prevMonth(e){  
842 - this.setData({  
843 - [`calendar.nextNum`]: this.data.calendar.nextNum - 1  
844 - })  
845 - },  
846 /** 468 /**
847 * 快速预订初始化 469 * 快速预订初始化
848 * tid 470 * tid
@@ -850,64 +472,13 @@ Page({ @@ -850,64 +472,13 @@ Page({
850 * ddate 472 * ddate
851 * pnum 473 * pnum
852 */ 474 */
853 - async initQuick(options){  
854 - try {  
855 - console.log('initQuick', options);  
856 - this.checkedTables[options.tid]=options.tname  
857 - this.year=util.unixtoTime(options.ddate.substr(0,10),'YYYY');  
858 - let form=this.data.form  
859 - form.tid=[options.tid]  
860 -  
861 - this.setData({  
862 - form: form,  
863 - })  
864 - setTimeout(() => {  
865 - this.getTables();  
866 - }, 300)  
867 - } catch (e) {  
868 - console.log('initQuick', e)  
869 - }  
870 - },  
871 - getCustomRemark(){  
872 - App.User.GetCustomRemark({  
873 - uid:util.cache('enter_params')['manager_id'],  
874 - }).then(res=>{  
875 - let CustomRemark=[];  
876 - res.data.forEach(r=>{  
877 - if(r.often_use){  
878 - CustomRemark.push(r);  
879 - }  
880 - })  
881 - this.setData({  
882 - CustomRemark:CustomRemark,  
883 - })  
884 - })  
885 - },  
886 - oftenUse(e){  
887 - let id=util.attr(e,'id');  
888 - let val=util.attr(e,'value');  
889 - let CustomRemark=this.data.CustomRemark;  
890 - let form=this.data.form;  
891 - CustomRemark.forEach(r=>{  
892 - if(id==r.id){  
893 - if(r.active){  
894 - form.cusdem=form.cusdem.replace(val+'、','')  
895 - }  
896 - r.active=!r.active  
897 - if(r.active){  
898 - form.cusdem+=val+'、'  
899 - }  
900 - }  
901 - }) 475 + initQuick(){
  476 + let options=this.options
  477 + this.checkedTables[options.tid]=options.tname
902 this.setData({ 478 this.setData({
903 - CustomRemark:CustomRemark,  
904 - form:form, 479 + [`form.tid`]: [options.tid],
  480 + runTime:options.ddate.substr(0,10),
  481 + type:3
905 }) 482 })
906 - this.conditionInfo()  
907 }, 483 },
908 - CustomRemarkMore(){  
909 - this.setData({  
910 - CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask  
911 - })  
912 - }  
913 }) 484 })
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 "navigationBarBackgroundColor": "#fff", 3 "navigationBarBackgroundColor": "#fff",
4 "navigationBarTextStyle":"black", 4 "navigationBarTextStyle":"black",
5 "usingComponents": { 5 "usingComponents": {
6 - "nothingBook":"../../components/book/nothing/nothing",  
7 "nav":"/components/nav/nav", 6 "nav":"/components/nav/nav",
8 "tabBar":"../../components/book/tabBar/tabBar", 7 "tabBar":"../../components/book/tabBar/tabBar",
9 - "searchList":"/components/searchlist/searchlist",  
10 - "calendar": "plugin://bmCalendar/calendar",  
11 "board":"../../components/book/board/board", 8 "board":"../../components/book/board/board",
12 - "formids":"/components/formids/formids" 9 + "searchList":"/components/searchlist/searchlist",
  10 + "add-date": "../../components/book/time/add-date",
  11 + "add-time-dur":"../../components/book/time/add-time-dur",
  12 + "add-time-dur-items":"../../components/book/time/add-time-dur-items"
13 } 13 }
14 } 14 }
1 <!--pages/book/b_addnew.wxml--> 1 <!--pages/book/b_addnew.wxml-->
  2 +<wxs src="../../../utils/util.wxs" module="util" />
2 <nav>录入订座信息</nav> 3 <nav>录入订座信息</nav>
3 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page"> 4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page">
4 - <view class="base-info">  
5 - <!--  
6 - <view class="section flex-lr date">  
7 - <view class="flex-rr" style="width:100%;">  
8 - <item class="date-item {{form.date==0?'checked':''}}"  
9 - bindtap="selectedValue" data-key="date" data-value="0">  
10 - <view class="date-item-text">{{dateStr[0]}}</view>  
11 - </item>  
12 - <item class="date-item {{form.date==1?'checked':''}}"  
13 - bindtap="selectedValue" data-key="date" data-value="1">  
14 - <view class="date-item-text">{{dateStr[1]}}</view>  
15 - </item>  
16 - </view>  
17 - <view class="more flex-ll" bindtap="calendarShow">  
18 - <view></view>  
19 - <view></view>  
20 - <view></view>  
21 - </view>  
22 - </view>  
23 - --> 5 + <view class="base-info" wx:if="{{runTime}}">
24 <view class="section"> 6 <view class="section">
25 - <view class="tab flex-ll">  
26 - <formids class="item {{form.date==0?'checked':''}}"  
27 - bindtap="selectedValue" data-key="date" data-value="0">  
28 - {{dateStr[0]}}  
29 - </formids>  
30 - <formids class="item {{form.date==1?'checked':''}}"  
31 - bindtap="selectedValue" data-key="date" data-value="1">  
32 - {{dateStr[1]}}  
33 - </formids>  
34 - <view class="item {{form.date==2?'checked':''}} flex-lr"  
35 - bindtap="selectedValue" data-key="date" data-value="2" bindtap="calendarShow">  
36 - <view style="width: 80%" class="item-text">{{dateStr[2]||'其他'}}</view>  
37 - <image  
38 - src="http://qn.colorcun.com/custom/lite-yd/image/date{{dateStr[2]?'.selected':''}}.png"  
39 - style="min-width: 36rpx;width: 36rpx;height: 36rpx; margin-right: 22rpx;"></image>  
40 - </view>  
41 - </view> 7 + <add-date time="{{runTime}}" type="{{type}}"></add-date>
42 </view> 8 </view>
43 - <view class="section ">  
44 - <view class="tab flex-ll">  
45 - <formids class="item {{form.time==0?'checked':''}} {{timeOpt[0]}}"  
46 - wx:if="{{timePickerArray[0].length>0}}"  
47 - bindtap="selectedValueAsync" data-key="time" data-value="0">  
48 - <view class="picker">早市</view>  
49 - </formids>  
50 - <formids class="item {{form.time==1?'checked':''}} {{timeOpt[1]}}"  
51 - wx:if="{{timePickerArray[1].length>0}}"  
52 - bindtap="selectedValueAsync" data-key="time" data-value="1">  
53 - <view class="picker">午市</view>  
54 - </formids>  
55 - <formids class="item {{form.time==2?'checked':''}} {{timeOpt[2]}}"  
56 - wx:if="{{timePickerArray[2].length>0}}"  
57 - bindtap="selectedValueAsync" data-key="time" data-value="2">  
58 - <view class="picker">晚市</view>  
59 - </formids>  
60 - </view> 9 + <view class="section">
  10 + <add-time-dur></add-time-dur>
61 </view> 11 </view>
62 <view class="section" style="height: 90rpx;"> 12 <view class="section" style="height: 90rpx;">
63 <view class="tab flex-lr"> 13 <view class="tab flex-lr">
@@ -87,36 +37,6 @@ @@ -87,36 +37,6 @@
87 </view> 37 </view>
88 </view> 38 </view>
89 </view> 39 </view>
90 - <!--  
91 - <view class="section ">  
92 - <view class="tab flex-ll">  
93 - <view class="item {{form.pnum_str=='1-4'?'checked':''}}"  
94 - bindtap="selectedValue" data-key="pnum_str" data-value="1-4">  
95 - 4人以下  
96 - </view>  
97 - <view class="item {{form.pnum_str=='5-9'?'checked':''}}"  
98 - bindtap="selectedValue" data-key="pnum_str" data-value="5-9">  
99 - 5~9人  
100 - </view>  
101 - <view class="item {{form.pnum_str=='10-99'?'checked':''}}"  
102 - bindtap="selectedValue" data-key="pnum_str" data-value="10-99">  
103 - 10人以上  
104 - </view>  
105 - </view>  
106 - </view>  
107 - <view class="section ">  
108 - <view class="tab flex-ll">  
109 - <view class="item {{form.tabid=='2'?'checked':''}}"  
110 - bindtap="selectedValue" data-key="tabid" data-value="2">  
111 - 包间  
112 - </view>  
113 - <view class="item {{form.tabid=='1'?'checked':''}}"  
114 - bindtap="selectedValue" data-key="tabid" data-value="1">  
115 - 散台  
116 - </view>  
117 - </view>  
118 - </view>  
119 - -->  
120 </view> 40 </view>
121 41
122 <view class="page-full tables"> 42 <view class="page-full tables">
@@ -150,9 +70,12 @@ @@ -150,9 +70,12 @@
150 bindconfirm="selectedValue" 70 bindconfirm="selectedValue"
151 data-key="phone" 71 data-key="phone"
152 value="{{form.phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:{{reminder ? 400 : 680}}rpx;" cursor-spacing="260"/> 72 value="{{form.phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:{{reminder ? 400 : 680}}rpx;" cursor-spacing="260"/>
153 - <view bindtap="selectedValue" data-key="time" data-value="{{form.time}}" data-display="block" style="color:#199095">  
154 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:if="{{hasUseDefDtime && form.time>0}}">{{defDtime[form.time]}}</view>  
155 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:else="">{{timePickerArray[form.time][timePickerIndex[form.time]]}}</view> 73 + <view style="color:#199095;min-width: 150rpx; text-align: right">
  74 + <add-time-dur-items
  75 + bindevent="addTimeDurItemsEvent"
  76 + style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;">
  77 + {{util.unixtoTime(time,'HH:II')}}
  78 + </add-time-dur-items>
156 </view> 79 </view>
157 <block wx:if="{{searchlist}}"> 80 <block wx:if="{{searchlist}}">
158 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList> 81 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList>
@@ -205,58 +128,6 @@ @@ -205,58 +128,6 @@
205 </view> 128 </view>
206 </view> 129 </view>
207 <tabBar></tabBar> 130 <tabBar></tabBar>
208 -<view class="calendar-mask" bindtap="calendarClose"  
209 - style="height:{{calendarMask?'100%':0}};" wx:if="{{calendarMaskLoad}}">  
210 - <view style="width: 100%; height:{{calendarMask?'100%':0}};overflow: hidden;position: relative;">  
211 - <calendar catchtap="catchtap"  
212 - isTodaybtn="{{true}}" todaybtn_txt="回到今天"  
213 - custom="{{false}}"  
214 - switchover="{{['上一月','下个月']}}"  
215 - active-coloro="active-coloro"  
216 - active-colort="active-colort"  
217 - speciallist="{{speciallist}}"  
218 - txt_style="txt-style"  
219 - calendar-style="calendar"  
220 - header-style="calendar-header"  
221 - weektitle-style="weektitle-style"  
222 - restcolor-style="restcolor-style"  
223 - txt_type="cn-d"  
224 -  
225 - datefont-style="datefont-style"  
226 - todaybtn-style="todaybtn-style"  
227 -  
228 - bindnextMonth="nextMonth"  
229 - bindprevMonth="prevMonth"  
230 - bindselectDate="dateChange"  
231 - bindgotoday="gotoday"  
232 -  
233 - prev="{{true||calendar.nextNum>0}}"  
234 - circle_show="{{false}}"  
235 - closelaststyle="{{true}}"  
236 - ></calendar>  
237 - </view>  
238 -</view>  
239 -<view class="calendar-mask" bindtap="calendarClose"  
240 - style="height:100%;" wx:if="{{timePickerMask}}">  
241 - <view class="timePicker">  
242 - <view class="flex-rr">  
243 - <image class="close" src="http://qn.colorcun.com/custom/lite-yd/image/add-act.png" bindtap="calendarClose"></image>  
244 - </view>  
245 - <view class="flex-cc" style="margin-bottom: 56rpx; font-size: 30rpx;">  
246 - <view bindtap="calendarClose">{{form.time==1?'午市':form.time==2?'晚市':'早市'}}</view>  
247 - </view>  
248 - <view class="flex-ll" style="flex-wrap:wrap">  
249 - <view class="time-item {{timePickerIndex[form.time]==index?'checked':''}}"  
250 - style="{{(index+1)%3==0?'margin-right:0;':''}}"  
251 - wx:for="{{timePickerArray[form.time]}}" wx:key=""  
252 - bindtap="bindTimePickerChange"  
253 - data-time-index="{{form.time}}"  
254 - data-val="{{index}}"  
255 - >{{item}}</view>  
256 - </view>  
257 - </view>  
258 -</view>  
259 -  
260 <view class="calendar-mask" bindtap="CustomRemarkMore" 131 <view class="calendar-mask" bindtap="CustomRemarkMore"
261 style="height:100%;" wx:if="{{CustomRemarkMoreMask}}"> 132 style="height:100%;" wx:if="{{CustomRemarkMoreMask}}">
262 <view class="timePicker" catchtap="catchtap"> 133 <view class="timePicker" catchtap="catchtap">
1 // pages/book/b_addnew.js 1 // pages/book/b_addnew.js
2 import util from '../../../utils/util'; 2 import util from '../../../utils/util';
3 -import comm from '../../../utils/bookCommon';  
4 import App from '../../../utils/api'; 3 import App from '../../../utils/api';
5 -const {regeneratorRuntime} = global  
6 const formTpl = { 4 const formTpl = {
7 rid: '', 5 rid: '',
8 - date: 0,  
9 - time: 0,  
10 - //pnum_str:'1-4',  
11 pnum: 6, 6 pnum: 6,
12 tabid: 0, 7 tabid: 0,
13 8
@@ -17,16 +12,16 @@ const formTpl = { @@ -17,16 +12,16 @@ const formTpl = {
17 cusdem: '', 12 cusdem: '',
18 13
19 tid: [], 14 tid: [],
20 - is_set_ddate:0,  
21 15
22 } 16 }
23 Page({ 17 Page({
24 -  
25 /** 18 /**
26 * 页面的初始数据 19 * 页面的初始数据
27 */ 20 */
28 data: { 21 data: {
29 - dateStr: [], 22 + type:1, // type 1/2/3 新增/修改/桌位
  23 + time:0,//组件最终构造的到店时间
  24 + runTime:0,//当前时间戳,或修改到店,或桌位预订时间
30 form: JSON.parse(JSON.stringify(formTpl)), 25 form: JSON.parse(JSON.stringify(formTpl)),
31 tables: [], 26 tables: [],
32 grand: [ 27 grand: [
@@ -47,148 +42,35 @@ Page({ @@ -47,148 +42,35 @@ Page({
47 } 42 }
48 ], 43 ],
49 buttonhide: true, 44 buttonhide: true,
50 -  
51 - calendarMaskLoad: false,  
52 - calendarMask: false,  
53 - dayStyle: [  
54 - {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'},  
55 - {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'}  
56 - ],  
57 - timePickerArray: [  
58 - [],  
59 - [],  
60 - [],  
61 - ],  
62 - timePickerIndex: [0, 0, 0],  
63 tablesLength: 0, 45 tablesLength: 0,
64 -  
65 - timePickerMask: false,  
66 pnumInputFocus: false, 46 pnumInputFocus: false,
67 pageMarginBottom: 0, 47 pageMarginBottom: 0,
68 speciallist: [], 48 speciallist: [],
69 - calendar: {  
70 - nextNum: 0,  
71 - },  
72 - defDtime: ['', '12:00', '18:30'],  
73 - hasUseDefDtime: true,  
74 CustomRemark:[], 49 CustomRemark:[],
75 CustomRemarkMoreMask:false, 50 CustomRemarkMoreMask:false,
76 }, 51 },
  52 + reserve_id: '',
  53 + checkedTables:{},//已选中的桌子集合
77 /** 54 /**
78 * 生命周期函数--监听页面加载 55 * 生命周期函数--监听页面加载
79 */ 56 */
80 - reserve_id: '',  
81 - checkedTables:{},//已选中的桌子集合  
82 - year:util.unixtoTime(new Date() / 1000,'YYYY'),  
83 onLoad: async function (options) { 57 onLoad: async function (options) {
84 this.options=options 58 this.options=options
85 - this.initLoad(options) 59 + this.sellerid = util.cache('enter_params')['seller_id'];
86 this.getCustomRemark(); 60 this.getCustomRemark();
87 - },  
88 - async initLoad(options = {}){  
89 - let nt = new Date() / 1000;  
90 - let speciallist = [  
91 - {date: util.unixtoTime(nt, 'YYYY-MM-DD'), background: '', text: '今 天'},  
92 - {date: util.unixtoTime(nt + 86400, 'YYYY-MM-DD'), background: '', text: '明 天'},  
93 - {date: util.unixtoTime(nt + 86400 * 2, 'YYYY-MM-DD'), background: '', text: '后 天'},  
94 - ];  
95 - this.reserve_id = options.id || '';  
96 - let rev_time=parseInt(nt)  
97 - if(options.hasQuick==1){  
98 - let rdate=options.ddate.split('-')  
99 - if(!(rev_time>=rdate[0] && rev_time<=rdate[1])){  
100 - rev_time=rdate[0]  
101 - }  
102 - await this.setDateStr(rev_time); 61 + if(options.id>0){
  62 + //修改
  63 + this.reserve_id=options.id
  64 + return this.initModify();
103 } 65 }
104 - //判断hasUseDefDtime  
105 - let hasUseDefDtime = true;  
106 - let mmii = util.unixtoTime(rev_time, 'HH:II');  
107 - if (mmii > this.data.defDtime[this.data.form.time]) {  
108 - hasUseDefDtime = false; 66 + if(options.hasQuick==1){
  67 + //桌位预订
  68 + return this.initQuick();
109 } 69 }
110 - console.log('initLoad::setDateStr',util.unixtoTime(rev_time,'YYYY-MM-DD HH:II'),this.data.defDtime[this.data.form.time])  
111 - await this.setDateStr(rev_time,hasUseDefDtime);  
112 - this.sellerid = util.cache('enter_params')['seller_id'];  
113 - let timePickerArray = await comm.getDayTimeSpace();  
114 this.setData({ 70 this.setData({
115 - timePickerArray: timePickerArray,  
116 - speciallist: speciallist,  
117 - hasUseDefDtime: hasUseDefDtime, 71 + runTime:parseInt(new Date()/1000),
  72 + type:1
118 }) 73 })
119 - if (this.reserve_id > 0) {  
120 - this.initModify(this.reserve_id);  
121 - } else if(options.hasQuick==1){  
122 - this.initQuick(options);  
123 - } else {  
124 - this.getTables();  
125 - }  
126 - },  
127 -  
128 - hasInTimeSpace(hhii,timeIndex){  
129 - if(this.data.timePickerArray.length)return false  
130 - let timePickerArray=this.data.timePickerArray[timeIndex];  
131 - let tl=timePickerArray.length  
132 - if(tl<1) return false  
133 - console.log('hasInTimeSpace',hhii,timePickerArray[0],timePickerArray[tl-1],hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1])  
134 - if(hhii>=timePickerArray[0] && hhii<=timePickerArray[tl-1]) return true  
135 - return false  
136 - },  
137 - async setDateStr(d = new Date() / 1000,hasUseDefDtime=false,fouceTime=-1){  
138 - fouceTime=fouceTime>-1?fouceTime:this.data.form.time  
139 - hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[fouceTime],fouceTime)  
140 - if(hasUseDefDtime){//  
141 - let timestr=util.unixtoTime(d,'YYYY-MM-DD '+this.data.defDtime[this.data.form.time])  
142 - d=util.timetouUnix(timestr)  
143 - }  
144 - console.log('setDateStr',util.unixtoTime(d,'YYYY-MM-DD HH:II'),hasUseDefDtime)  
145 - this.year=util.unixtoTime(d,'YYYY');  
146 - let ns = new Date() / 1000;  
147 - let dateStr = [  
148 - util.unixtoTime(ns, 'MM-DD `DAY/周WW`'),  
149 - util.unixtoTime(parseInt(ns) + 86400, 'MM-DD `DAY/周WW`'),  
150 - ];  
151 - //let dateStr=this.data.dateStr;  
152 - let nowStr = util.unixtoTime(d, 'MM-DD `DAY/周WW`')  
153 - let form = this.data.form;  
154 -  
155 - let timeObj = await comm.getTimeSpaceIndexData(d);  
156 - if(fouceTime!=timeObj.timeIndex && fouceTime>0){  
157 - timeObj.timeIndex=fouceTime  
158 - }  
159 - //form.time=await comm.getTimeSpaceIndex(d);  
160 - //如果小于默认时间,使用默认时间  
161 - let mmii = util.unixtoTime(d,'HH:II')  
162 - if (mmii < this.data.defDtime[timeObj.timeIndex]) {  
163 - hasUseDefDtime=this.hasInTimeSpace(this.data.defDtime[timeObj.timeIndex],timeObj.timeIndex)  
164 - if(hasUseDefDtime) {  
165 - let str = util.unixtoTime(d, 'YYYY-MM-DD ' + this.data.defDtime[timeObj.timeIndex] + ':00')  
166 - timeObj = await comm.getTimeSpaceIndexData(util.timetouUnix(str));  
167 - }  
168 - }  
169 -  
170 - form.time = timeObj.timeIndex;  
171 - let ind = dateStr._indexOf(nowStr);  
172 - if (ind > -1) {  
173 - form.date = ind  
174 - } else {  
175 - dateStr.push(nowStr.substr(0, 5));  
176 - form.date = 2;  
177 - }  
178 - let timePickerIndex = this.data.timePickerIndex;  
179 - timePickerIndex[timeObj.timeIndex] = timeObj.timeMatchIndex;  
180 - form.is_set_ddate = this.is_set_ddate  
181 - let obj = {  
182 - dateStr: dateStr,  
183 - form: form,  
184 - timePickerIndex: timePickerIndex,  
185 - timeOpt: timeObj.timeOpt,  
186 - hasUseDefDtime:hasUseDefDtime  
187 - };  
188 -  
189 - this.setData(obj)  
190 - return obj;  
191 -  
192 }, 74 },
193 75
194 /** 76 /**
@@ -202,16 +84,7 @@ Page({ @@ -202,16 +84,7 @@ Page({
202 * 生命周期函数--监听页面显示 84 * 生命周期函数--监听页面显示
203 */ 85 */
204 onShow: function () { 86 onShow: function () {
205 - //if(!this.reserve_id || util.cache('tableid').length>0){  
206 - //if (util.cache('tableid').length > 0) {  
207 - this.getTables();  
208 - //}  
209 - setTimeout(() => {  
210 - this.setData({  
211 - calendarMaskLoad: true,  
212 - })  
213 - }, 1000);  
214 - this.conditionInfo() 87 +
215 }, 88 },
216 89
217 /** 90 /**
@@ -248,239 +121,71 @@ Page({ @@ -248,239 +121,71 @@ Page({
248 onShareAppMessage: function () { 121 onShareAppMessage: function () {
249 122
250 }, 123 },
251 - async selectedValueAsync(e){  
252 - console.log(e);  
253 - let key = util.attr(e, 'key');  
254 - let val;  
255 - let sobj = {};  
256 - if (key == 'date') {  
257 - this.year=util.unixtoTime(new Date() / 1000,'YYYY');  
258 - }  
259 - if (e.type == 'input' || e.type == 'confirm') {  
260 - val = util.val(e);  
261 - if (key == 'phone') {  
262 - var that = this;  
263 - if (e.detail.value != '' && e.detail.value.length >= 3) {  
264 - App.Reserve.GetReserveUser(  
265 - {  
266 - keywords: e.detail.value,  
267 - sid: this.sellerid  
268 - }  
269 - ).then(function (json) {  
270 - if (json.ret == 200 && json.data.length > 0) {  
271 - that.setData({  
272 - searchlist: json.data  
273 - })  
274 - } else {  
275 - that.setData({  
276 - searchlist: null  
277 - })  
278 - }  
279 - })  
280 - } else {  
281 - this.setData({  
282 - searchlist: null  
283 - })  
284 - }  
285 - }  
286 - if (key == 'pnum') {  
287 - sobj.pnumInputFocus = true;  
288 - }  
289 - } else {  
290 - val = util.attr(e, 'value');  
291 - }  
292 - if (key == 'time') {  
293 - if (this.data.timeOpt[val]) return;  
294 - }  
295 - if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {  
296 - if (util.attr(e, 'display') != 'block') {  
297 - return;  
298 - }  
299 - }  
300 - let form = this.data.form;  
301 -  
302 - if (key == 'tid') {  
303 - let ts = this.data.tables;  
304 - if (ts[val].isselect) {  
305 - ts[val].isselect = false;  
306 - form.tid.remove(ts[val].id);  
307 - delete this.checkedTables[ts[val].id]  
308 - } else {  
309 - ts[val].isselect = true;  
310 - form.tid.push(ts[val].id);  
311 - this.checkedTables[ts[val].id]=ts[val].name  
312 - }  
313 - sobj.tables = ts;  
314 - } else {  
315 - form[key] = val;  
316 - }  
317 - console.log('ts', sobj.tables,this.checkedTables);  
318 - //console.log(e.type,key,val,form);  
319 - sobj.form = form;  
320 - sobj.buttonhide = this.data.buttonhide;  
321 - if (form.tid.length > 0 && form.rname.length > 0) {  
322 - sobj.buttonhide = false;  
323 - }else{  
324 - sobj.buttonhide = true;  
325 - }  
326 - let displayTimes = false;  
327 - if (key == 'time') {  
328 - if (util.attr(e, 'display') == 'block') {  
329 - displayTimes = true;  
330 - sobj.timePickerMask = true;  
331 - }  
332 - }  
333 - //判断hasUseDefDtime  
334 - if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {  
335 - sobj.hasUseDefDtime = true  
336 - let ntime = parseInt(new Date() / 1000)  
337 - let xtime =ntime  
338 - if(key == 'time'){  
339 - xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');  
340 - xtime=util.timetouUnix(xtime)  
341 - //if 当前时间在区间内 hasUseDefDtime 为 false  
342 - let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
343 - this.data.form.time, null,null,this.year);  
344 - d_rdate=d_rdate.split('-');  
345 - if(d_rdate[0] <= ntime && ntime<=d_rdate[1]){  
346 - sobj.hasUseDefDtime=false 124 + //到店时间选择通知
  125 + addTimeDurItemsEvent(e){
  126 + //{time: 1577788200, ddate_solt: 2, timeDur: "1577786400-1577804400"}
  127 + console.log('addTimeDurItemsEvent',e.detail,util.unixtoTime(e.detail.time))
  128 + this.time=e.detail.time
  129 + this.ddate_solt=e.detail.ddate_solt
  130 + this.timeDur=e.detail.timeDur//预订所在时段区间时间戳
  131 + this.hasManual=e.detail.hasManual//手动设置时间
  132 + this.setData({
  133 + ...e.detail,
  134 + })
  135 + this.getTables();
  136 + },
  137 + getCustomRemark(){
  138 + App.User.GetCustomRemark({
  139 + uid:util.cache('enter_params')['manager_id'],
  140 + }).then(res=>{
  141 + let CustomRemark=[];
  142 + res.data.forEach(r=>{
  143 + if(r.often_use){
  144 + CustomRemark.push(r);
347 } 145 }
348 - }  
349 - this.setDateStr(xtime,sobj.hasUseDefDtime,sobj.form.time);  
350 - }  
351 - if (this.data.form.date == 0) {//  
352 - let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');  
353 - if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {  
354 - sobj.hasUseDefDtime = false;  
355 - }  
356 - }  
357 - if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {  
358 - if (!displayTimes) {  
359 - //sobj.form.tid = []; //切换日期时间清空桌位  
360 - //sobj.buttonhide = true;  
361 - this.getTables();  
362 - }  
363 - if (key == 'date') {  
364 - let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');  
365 - this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);  
366 - }  
367 - }  
368 -  
369 - this.setData(sobj) 146 + })
  147 + this.setData({
  148 + CustomRemark:CustomRemark,
  149 + })
  150 + })
370 }, 151 },
371 - selectedValue(e){  
372 - console.log(e);  
373 - let key = util.attr(e, 'key');  
374 - let val;  
375 - let sobj = {};  
376 - if (key == 'date') {  
377 - this.year=util.unixtoTime(new Date() / 1000,'YYYY');  
378 - }  
379 - if (e.type == 'input' || e.type == 'confirm') {  
380 - val = util.val(e);  
381 - if (key == 'phone') {  
382 - var that = this;  
383 - if (e.detail.value != '' && e.detail.value.length >= 3) {  
384 - App.Reserve.GetReserveUser(  
385 - {  
386 - keywords: e.detail.value,  
387 - sid: this.sellerid  
388 - }  
389 - ).then(function (json) {  
390 - if (json.ret == 200 && json.data.length > 0) {  
391 - that.setData({  
392 - searchlist: json.data  
393 - })  
394 - } else {  
395 - that.setData({  
396 - searchlist: null  
397 - })  
398 - }  
399 - })  
400 - } else {  
401 - this.setData({  
402 - searchlist: null  
403 - }) 152 + oftenUse(e){
  153 + let id=util.attr(e,'id');
  154 + let val=util.attr(e,'value');
  155 + let CustomRemark=this.data.CustomRemark;
  156 + let form=this.data.form;
  157 + CustomRemark.forEach(r=>{
  158 + if(id==r.id){
  159 + if(r.active){
  160 + form.cusdem=form.cusdem.replace(val+'、','')
  161 + }
  162 + r.active=!r.active
  163 + if(r.active){
  164 + form.cusdem+=val+'、'
404 } 165 }
405 } 166 }
406 - if (key == 'pnum') {  
407 - sobj.pnumInputFocus = true;  
408 - }  
409 - } else {  
410 - val = util.attr(e, 'value');  
411 - }  
412 - if (key == 'time') {  
413 - if (this.data.timeOpt[val]) return;  
414 - }  
415 - if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {  
416 - if (util.attr(e, 'display') != 'block') {  
417 - return;  
418 - }  
419 - }  
420 - let form = this.data.form;  
421 -  
422 - if (key == 'tid') {  
423 - let ts = this.data.tables;  
424 - if (ts[val].isselect) {  
425 - ts[val].isselect = false;  
426 - form.tid.remove(ts[val].id);  
427 - delete this.checkedTables[ts[val].id]  
428 - } else {  
429 - ts[val].isselect = true;  
430 - form.tid.push(ts[val].id);  
431 - this.checkedTables[ts[val].id]=ts[val].name  
432 - }  
433 - sobj.tables = ts;  
434 - } else {  
435 - form[key] = val;  
436 - }  
437 - console.log('ts', sobj.tables,this.checkedTables);  
438 - //console.log(e.type,key,val,form);  
439 - sobj.form = form;  
440 - sobj.buttonhide = this.data.buttonhide; 167 + })
  168 + this.setData({
  169 + CustomRemark:CustomRemark,
  170 + form:form,
  171 + })
  172 + this.conditionInfo()
  173 + },
  174 + CustomRemarkMore(){
  175 + this.setData({
  176 + CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
  177 + })
  178 + },
  179 + conditionInfo: function () {
  180 + var form = this.data.form
441 if (form.tid.length > 0 && form.rname.length > 0) { 181 if (form.tid.length > 0 && form.rname.length > 0) {
442 - sobj.buttonhide = false;  
443 - }else{  
444 - sobj.buttonhide = true;  
445 - }  
446 - let displayTimes = false;  
447 - if (key == 'time') {  
448 - if (util.attr(e, 'display') == 'block') {  
449 - displayTimes = true;  
450 - sobj.timePickerMask = true;  
451 - }  
452 - }  
453 - //判断hasUseDefDtime  
454 - if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {  
455 - sobj.hasUseDefDtime = true  
456 - let ntime = parseInt(new Date() / 1000)  
457 - let xtime =ntime  
458 - if(key == 'time'){  
459 - xtime=util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[this.data.form.date].substr(0, 5)) + ' HH:II:SS');  
460 - xtime=util.timetouUnix(xtime)  
461 - }  
462 - this.setDateStr(xtime,sobj.hasUseDefDtime);  
463 - }  
464 - if (this.data.form.date == 0) {//  
465 - let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');  
466 - if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {  
467 - sobj.hasUseDefDtime = false;  
468 - }  
469 - }  
470 - if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {  
471 - if (!displayTimes) {  
472 - //sobj.form.tid = []; //切换日期时间清空桌位  
473 - //sobj.buttonhide = true;  
474 - this.getTables();  
475 - }  
476 - if (key == 'date') {  
477 - let xtime = util.unixtoTime(new Date() / 1000, this.year+'-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');  
478 - this.setDateStr(util.timetouUnix(xtime),sobj.hasUseDefDtime);  
479 - } 182 + this.data.buttonhide = false;
480 } 183 }
481 -  
482 - this.setData(sobj) 184 + this.setData({
  185 + buttonhide: this.data.buttonhide
  186 + })
483 }, 187 },
  188 +
484 async getTables(){ 189 async getTables(){
485 let form = this.data.form; 190 let form = this.data.form;
486 let tableid = util.cache('tableid'); 191 let tableid = util.cache('tableid');
@@ -491,16 +196,14 @@ Page({ @@ -491,16 +196,14 @@ Page({
491 } 196 }
492 console.log('getTables-tableid', tableid, tableid.length); 197 console.log('getTables-tableid', tableid, tableid.length);
493 try { 198 try {
494 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);  
495 - console.log('rdate', this.data.dateStr[this.data.form.date], rdate);  
496 App.Reserve.GetTableList({ 199 App.Reserve.GetTableList({
497 sid: util.cache('enter_params')['seller_id'], 200 sid: util.cache('enter_params')['seller_id'],
498 //pnum_str:form.pnum_str, 201 //pnum_str:form.pnum_str,
499 pnum: form.pnum, 202 pnum: form.pnum,
500 - rdate: util.unixtoTime(rdate.substr(0,10),'YYYYMMDD'), 203 + rdate: util.unixtoTime(this.time,'YYYYMMDD'),
501 tid: form.tabid, 204 tid: form.tabid,
502 rid: this.reserve_id, 205 rid: this.reserve_id,
503 - ddate_solt:parseInt(form.time)+1 206 + ddate_solt:this.ddate_solt
504 }).then(res => { 207 }).then(res => {
505 let tables = []; 208 let tables = [];
506 let tablesLength = 0; 209 let tablesLength = 0;
@@ -569,17 +272,108 @@ Page({ @@ -569,17 +272,108 @@ Page({
569 }) 272 })
570 } 273 }
571 }, 274 },
  275 + selectphone: function (e) {
  276 + this.data.form.phone = e.detail.phone;
  277 + this.data.form.rname = e.detail.rname;
  278 + this.data.form.cusdem = e.detail.cusdem;
  279 + var form = this.data.form
  280 + this.data.form.sex = e.detail.sex;
  281 + this.setData({
  282 + form: this.data.form,
  283 + searchlist: null
  284 + })
  285 + this.conditionInfo();
  286 + },
  287 + selectdesk(){
  288 + wx.navigateTo({
  289 + url: 'b_desk?rdate=' + this.time + '&tid=' + this.data.form.tabid
  290 + //+'&pnum_str='+this.data.form.pnum_str
  291 + + '&pnum=' + this.data.form.pnum
  292 + + '&checked_tids=' + this.data.form.tid
  293 + + '&rid=' + this.reserve_id
  294 + + '&ddate_solt='+this.ddate_solt
  295 + })
  296 + },
  297 + selectedValue(e){
  298 + console.log(e);
  299 + let key = util.attr(e, 'key');
  300 + let val;
  301 + let sobj = {};
  302 + if (e.type == 'input' || e.type == 'confirm') {
  303 + val = util.val(e);
  304 + if (key == 'phone') {
  305 + var that = this;
  306 + if (e.detail.value != '' && e.detail.value.length >= 3) {
  307 + App.Reserve.GetReserveUser(
  308 + {
  309 + keywords: e.detail.value,
  310 + sid: this.sellerid
  311 + }
  312 + ).then(function (json) {
  313 + if (json.ret == 200 && json.data.length > 0) {
  314 + that.setData({
  315 + searchlist: json.data
  316 + })
  317 + } else {
  318 + that.setData({
  319 + searchlist: null
  320 + })
  321 + }
  322 + })
  323 + } else {
  324 + this.setData({
  325 + searchlist: null
  326 + })
  327 + }
  328 + }
  329 + if (key == 'pnum') {
  330 + sobj.pnumInputFocus = true;
  331 + }
  332 + } else {
  333 + val = util.attr(e, 'value');
  334 + }
  335 +
  336 +
  337 + let form = this.data.form;
  338 +
  339 + if (key == 'tid') {
  340 + let ts = this.data.tables;
  341 + if (ts[val].isselect) {
  342 + ts[val].isselect = false;
  343 + form.tid.remove(ts[val].id);
  344 + delete this.checkedTables[ts[val].id]
  345 + } else {
  346 + ts[val].isselect = true;
  347 + form.tid.push(ts[val].id);
  348 + this.checkedTables[ts[val].id]=ts[val].name
  349 + }
  350 + sobj.tables = ts;
  351 + } else {
  352 + form[key] = val;
  353 + }
  354 + console.log('ts', sobj.tables,this.checkedTables);
  355 + //console.log(e.type,key,val,form);
  356 + sobj.form = form;
  357 + sobj.buttonhide = this.data.buttonhide;
  358 + if (form.tid.length > 0 && form.rname.length > 0){
  359 + sobj.buttonhide = false;
  360 + }else{
  361 + sobj.buttonhide = true;
  362 + }
  363 + let displayTimes = false;
  364 +
  365 + if ('pnum,pnum_str,tabid'.indexOf(key) > -1) {
  366 + if (!displayTimes) {
  367 + this.getTables();
  368 + }
  369 + }
  370 +
  371 + this.setData(sobj)
  372 + },
  373 +
572 async formsubmit(){ 374 async formsubmit(){
573 if (this.data.buttonhide) return; 375 if (this.data.buttonhide) return;
574 try { 376 try {
575 - let d_stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];  
576 - let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
577 - this.data.form.time, d_stimestr,null,this.year);  
578 - let stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[0]];  
579 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],  
580 - this.data.form.time, stimestr,null,this.year);  
581 - console.log('stimestr', stimestr, this.data.form.time, this.data.timePickerIndex);  
582 - console.log('rdate', rdate);  
583 this.setData({ 377 this.setData({
584 buttonhide: true, 378 buttonhide: true,
585 }) 379 })
@@ -589,6 +383,9 @@ Page({ @@ -589,6 +383,9 @@ Page({
589 let tid = new Set(form.tid);//tid 去重 383 let tid = new Set(form.tid);//tid 去重
590 form.tid = [...tid].toString(); 384 form.tid = [...tid].toString();
591 } 385 }
  386 + if(this.ddate_solt<1){
  387 + return util.toast('请选择时段', 'none');
  388 + }
592 if (!form.tid) { 389 if (!form.tid) {
593 return util.toast('请选择桌子', 'none'); 390 return util.toast('请选择桌子', 'none');
594 } 391 }
@@ -596,7 +393,7 @@ Page({ @@ -596,7 +393,7 @@ Page({
596 return util.toast('请填写预订人', 'none'); 393 return util.toast('请填写预订人', 'none');
597 } 394 }
598 form.sid = this.sellerid; 395 form.sid = this.sellerid;
599 - form.rdate = rdate 396 + form.rdate = this.timeDur
600 397
601 try { 398 try {
602 let enter_params = util.cache('enter_params'); 399 let enter_params = util.cache('enter_params');
@@ -610,26 +407,24 @@ Page({ @@ -610,26 +407,24 @@ Page({
610 form.note_name = note_name || ''; 407 form.note_name = note_name || '';
611 } catch (e) {} 408 } catch (e) {}
612 409
613 - form.ddate = d_rdate.substr(0, 10);  
614 - if (this.data.hasUseDefDtime && this.data.form.time > 0) {//转为默认时间  
615 - let ddateStr = util.unixtoTime(form.ddate, "YYYY-MM-DD " + this.data.defDtime[this.data.form.time] + ":00");  
616 - form.ddate = util.timetouUnix(ddateStr); 410 + form.ddate = this.time;
  411 + form.ddate_solt=this.ddate_solt
  412 + if(this.hasManual){
  413 + form.is_set_ddate=1
617 } 414 }
618 - //App.Customer.SetReserveInfoById  
619 - form.ddate_solt=parseInt(form.time)+1  
620 - App.Customer.SetReserveInfoById(form).then(res => { 415 + App.Reserve.SetReserveInfo(form).then(res => {
621 if (res.ret == 200) { 416 if (res.ret == 200) {
622 this.getCustomRemark() 417 this.getCustomRemark()
623 let _id = (res.data.id || res.data) 418 let _id = (res.data.id || res.data)
624 this.setData({ 419 this.setData({
625 form: JSON.parse(JSON.stringify(formTpl)), 420 form: JSON.parse(JSON.stringify(formTpl)),
626 tables: [], 421 tables: [],
627 - timePickerIndex: [0, 0, 0], 422 + runTime:parseInt(new Date()/1000),
  423 + type:1
628 }) 424 })
629 - this.initLoad();  
630 this.checkedTables={}; 425 this.checkedTables={};
631 App.Reserve.Detail({rid: _id, openid: ''}, 'clear') 426 App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
632 - wx.redirectTo({ 427 + wx.navigateTo({
633 url: util.http_build_query({id:_id,tplid:1},'b_invitation'), 428 url: util.http_build_query({id:_id,tplid:1},'b_invitation'),
634 }); 429 });
635 } else { 430 } else {
@@ -639,138 +434,25 @@ Page({ @@ -639,138 +434,25 @@ Page({
639 } catch (e) { 434 } catch (e) {
640 } 435 }
641 }, 436 },
642 - selectphone: function (e) {  
643 - this.data.form.phone = e.detail.phone;  
644 - this.data.form.rname = e.detail.rname;  
645 - this.data.form.cusdem = e.detail.cusdem;  
646 - var form = this.data.form  
647 - this.data.form.sex = e.detail.sex;  
648 - this.setData({  
649 - form: this.data.form,  
650 - searchlist: null  
651 - })  
652 - this.conditionInfo();  
653 - },  
654 - calendarShow(){  
655 - this.setData({  
656 - calendarMask: true  
657 - })  
658 - },  
659 - dateChange(event){  
660 - console.log(event);  
661 - //let cktime=util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day)  
662 - let cktime = util.timetouUnix(event.detail.date)  
663 - this.year=event.detail.date.substr(0, 4);  
664 - console.log('this.year',this.year);  
665 - let day0 = parseInt(new Date(new Date().setHours(0, 0, 0, 0)) / 1000);  
666 - // if (cktime < day0) {  
667 - // util.toast('请选择有效日期', 'none');  
668 - // return;  
669 - // }  
670 - let clickDay = event.detail.date.substr(8, 2);  
671 - let changeDay = `dayStyle[1].day`;  
672 - let changeBg = `dayStyle[1].background`;  
673 - this.setData({  
674 - [changeDay]: clickDay,  
675 - [changeBg]: "#84e7d0",  
676 - //[`form.tid`]: [], //切换日期时间清空桌位  
677 - //buttonhide: true,  
678 - })  
679 - console.log('cktime',cktime,util.unixtoTime(cktime,'YYYY-MM-DD'))  
680 - if(cktime == day0){//今天  
681 - this.setDateStr( new Date() / 1000 )  
682 - }else{  
683 - let xtime=util.unixtoTime(new Date() / 1000, event.detail.date + ' HH:II:SS');  
684 - xtime=util.timetouUnix(xtime)  
685 - this.setDateStr(xtime,true)  
686 - }  
687 -  
688 - this.calendarClose();  
689 - setTimeout(res=>{  
690 - this.getTables();  
691 - },10)  
692 -  
693 - },  
694 - calendarClose(){  
695 - this.setData({  
696 - calendarMask: false,  
697 - timePickerMask: false,  
698 - })  
699 - },  
700 - async selectdesk(){  
701 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time,null,null,this.year);  
702 - console.log(this.data.form)  
703 - wx.navigateTo({  
704 - url: 'b_desk?rdate=' + rdate + '&tid=' + this.data.form.tabid  
705 - //+'&pnum_str='+this.data.form.pnum_str  
706 - + '&pnum=' + this.data.form.pnum  
707 - + '&checked_tids=' + this.data.form.tid  
708 - + '&rid=' + this.reserve_id  
709 - + '&ddate_solt='+(this.data.form.time+1)  
710 - })  
711 - },  
712 - conditionInfo: function () {  
713 - var form = this.data.form  
714 - if (form.tid.length > 0 && form.rname.length > 0) {  
715 - this.data.buttonhide = false;  
716 - }  
717 - this.setData({  
718 - buttonhide: this.data.buttonhide  
719 - })  
720 - },  
721 - /**  
722 - * 选中时间区域  
723 - */  
724 - bindTimePickerChange(e){  
725 - let timeIndex = util.attr(e, 'timeIndex');  
726 - if (timeIndex < 0) return;  
727 - let timePickerIndex = this.data.timePickerIndex;  
728 - //timePickerIndex[timeIndex]=util.val(e);  
729 - timePickerIndex[timeIndex] = util.attr(e, 'val');  
730 437
731 - console.log(e, timeIndex, util.attr(e, 'val'));  
732 - this.setData({  
733 - timePickerIndex: timePickerIndex,  
734 - hasUseDefDtime: false,  
735 - [`form.is_set_ddate`]:1,  
736 - })  
737 - },  
738 /** 438 /**
739 * 修改初始化 439 * 修改初始化
740 */ 440 */
741 - is_set_ddate:0,  
742 - async initModify(id){ 441 + async initModify(){
743 try { 442 try {
744 - let res = await App.Reserve.Detail({rid: id, openid: ''});  
745 - this.is_set_ddate=res.data.is_set_ddate  
746 - console.log('initModify', res);  
747 - //设置日期  
748 - let obj = await this.setDateStr(res.data.ddate,null,res.data.ddate_solt-1);  
749 - //设置时间  
750 - let nd = util.unixtoTime(res.data.ddate, 'HH:II');  
751 - let timePickerIndex = this.data.timePickerIndex  
752 - console.log('initModify-', this.data.timePickerArray, obj.form.time, nd)  
753 - this.data.timePickerArray[obj.form.time].forEach((dd, ii) => {  
754 - console.log('initModify-', nd, dd)  
755 - if (nd == dd) {  
756 - timePickerIndex[obj.form.time] = ii;  
757 - return true;  
758 - }  
759 - })  
760 -  
761 - console.log('initModify-timePickerIndex', timePickerIndex);  
762 - //obj.form.pnum_str=res.data.pnum_str;  
763 - obj.form.pnum = res.data.pnum || 6;  
764 - obj.form.rname = res.data.rname;  
765 - obj.form.phone = res.data.phone || "";  
766 - obj.form.sex = res.data.sex;  
767 - obj.form.cusdem = res.data.cusdem;  
768 - obj.form.is_set_ddate=res.data.is_set_ddate  
769 - obj.form.rid = id;  
770 - obj.form.tid = []; 443 + let res = await App.Reserve.Detail({rid: this.options.id, openid: ''});
  444 + let form=this.data.form
  445 + form.pnum = res.data.pnum || 6;
  446 + form.rname = res.data.rname;
  447 + form.phone = res.data.phone || "";
  448 + form.sex = res.data.sex;
  449 + form.cusdem = res.data.cusdem;
  450 + form.rid = this.options.id;
  451 + form.tid = [];
  452 + form.is_set_ddate=res.data.is_set_ddate
771 let tablesed = []; 453 let tablesed = [];
772 res.data.tables.forEach((t, ti) => { 454 res.data.tables.forEach((t, ti) => {
773 - obj.form.tid.push(t.id) 455 + form.tid.push(t.id)
774 if (ti >= 3) return; 456 if (ti >= 3) return;
775 t.isselect = true 457 t.isselect = true
776 t["isselected"] = 1 458 t["isselected"] = 1
@@ -778,79 +460,15 @@ Page({ @@ -778,79 +460,15 @@ Page({
778 this.checkedTables[t.id]=t.name; 460 this.checkedTables[t.id]=t.name;
779 }) 461 })
780 this.setData({ 462 this.setData({
781 - timePickerIndex: timePickerIndex,  
782 - form: obj.form,  
783 - //tablesed:tablesed,  
784 - hasUseDefDtime: false, 463 + type:2,//修改
  464 + runTime: res.data.ddate,//到店时间
  465 + ddate_solt:res.data.ddate_solt,
  466 + form: form,
785 }) 467 })
786 - setTimeout(() => {  
787 - this.getTables();  
788 - }, 300)  
789 -  
790 } catch (e) { 468 } catch (e) {
791 console.log('initModify', e) 469 console.log('initModify', e)
792 } 470 }
793 }, 471 },
794 - pnumInputFocusEvent(e){  
795 - console.log(e);  
796 - this.setData({  
797 - pnumInputFocus: 'focus' == e.type  
798 - })  
799 - },  
800 - inputFocusTime: 0,  
801 - blurTime: 0,  
802 - inputFocus(e){  
803 - console.log(e, this.inputFocusTime);  
804 - return;  
805 - if (e.timeStamp > this.inputFocusTime) {  
806 - this.inputFocusTime = e.timeStamp;  
807 - if (e.type == 'focus' && this.data.pageMarginBottom == 0) {  
808 - this.setData({  
809 - pageMarginBottom: 300  
810 - })  
811 - setTimeout(res => {  
812 - this.pageScrollToBottom();  
813 - }, 100)  
814 - } else {  
815 - if (this.blurTime > 5) {  
816 - this.blurTime = 0;  
817 - this.setData({  
818 - pageMarginBottom: 0  
819 - })  
820 - } else {  
821 - setTimeout(res => {  
822 - this.blurTime += 1;  
823 - this.inputFocus(e);  
824 - }, 300)  
825 - }  
826 -  
827 - }  
828 -  
829 - }  
830 - },  
831 - pageScrollToBottom: function () {  
832 - wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {  
833 - // 使页面滚动到底部  
834 - wx.pageScrollTo({  
835 - scrollTop: rect.bottom  
836 - })  
837 - }).exec()  
838 - },  
839 - gotoday(e){  
840 - this.setData({  
841 - [`calendar.nextNum`]: 0  
842 - })  
843 - },  
844 - nextMonth(e){  
845 - this.setData({  
846 - [`calendar.nextNum`]: this.data.calendar.nextNum + 1  
847 - })  
848 - },  
849 - prevMonth(e){  
850 - this.setData({  
851 - [`calendar.nextNum`]: this.data.calendar.nextNum - 1  
852 - })  
853 - },  
854 /** 472 /**
855 * 快速预订初始化 473 * 快速预订初始化
856 * tid 474 * tid
@@ -858,64 +476,13 @@ Page({ @@ -858,64 +476,13 @@ Page({
858 * ddate 476 * ddate
859 * pnum 477 * pnum
860 */ 478 */
861 - async initQuick(options){  
862 - try {  
863 - console.log('initQuick', options);  
864 - this.checkedTables[options.tid]=options.tname  
865 - this.year=util.unixtoTime(options.ddate.substr(0,10),'YYYY');  
866 - let form=this.data.form  
867 - form.tid=[options.tid]  
868 -  
869 - this.setData({  
870 - form: form,  
871 - })  
872 - setTimeout(() => {  
873 - this.getTables();  
874 - }, 300)  
875 - } catch (e) {  
876 - console.log('initQuick', e)  
877 - }  
878 - },  
879 - getCustomRemark(){  
880 - App.User.GetCustomRemark({  
881 - uid:util.cache('enter_params')['manager_id'],  
882 - }).then(res=>{  
883 - let CustomRemark=[];  
884 - res.data.forEach(r=>{  
885 - if(r.often_use){  
886 - CustomRemark.push(r);  
887 - }  
888 - })  
889 - this.setData({  
890 - CustomRemark:CustomRemark,  
891 - })  
892 - })  
893 - },  
894 - oftenUse(e){  
895 - let id=util.attr(e,'id');  
896 - let val=util.attr(e,'value');  
897 - let CustomRemark=this.data.CustomRemark;  
898 - let form=this.data.form;  
899 - CustomRemark.forEach(r=>{  
900 - if(id==r.id){  
901 - if(r.active){  
902 - form.cusdem=form.cusdem.replace(val+'、','')  
903 - }  
904 - r.active=!r.active  
905 - if(r.active){  
906 - form.cusdem+=val+'、'  
907 - }  
908 - }  
909 - }) 479 + initQuick(){
  480 + let options=this.options
  481 + this.checkedTables[options.tid]=options.tname
910 this.setData({ 482 this.setData({
911 - CustomRemark:CustomRemark,  
912 - form:form, 483 + [`form.tid`]: [options.tid],
  484 + runTime:options.ddate.substr(0,10),
  485 + type:3
913 }) 486 })
914 - this.conditionInfo()  
915 }, 487 },
916 - CustomRemarkMore(){  
917 - this.setData({  
918 - CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask  
919 - })  
920 - }  
921 }) 488 })
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 "navigationBarBackgroundColor": "#fff", 3 "navigationBarBackgroundColor": "#fff",
4 "navigationBarTextStyle":"black", 4 "navigationBarTextStyle":"black",
5 "usingComponents": { 5 "usingComponents": {
6 - "nothingBook":"../../components/book/nothing/nothing",  
7 "nav":"/components/nav/nav", 6 "nav":"/components/nav/nav",
8 "tabBar":"../../components/book/tabBar/tabBar", 7 "tabBar":"../../components/book/tabBar/tabBar",
9 - "searchList":"/components/searchlist/searchlist",  
10 - "calendar": "plugin://bmCalendar/calendar",  
11 "board":"../../components/book/board/board", 8 "board":"../../components/book/board/board",
12 - "formids":"/components/formids/formids" 9 + "searchList":"/components/searchlist/searchlist",
  10 + "add-date": "../../components/book/time/add-date",
  11 + "add-time-dur":"../../components/book/time/add-time-dur",
  12 + "add-time-dur-items":"../../components/book/time/add-time-dur-items"
13 } 13 }
14 } 14 }
1 <!--pages/book/b_addnew.wxml--> 1 <!--pages/book/b_addnew.wxml-->
  2 +<wxs src="../../../utils/util.wxs" module="util" />
2 <nav>录入订座信息</nav> 3 <nav>录入订座信息</nav>
3 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page"> 4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page">
4 - <view class="base-info">  
5 - <!--  
6 - <view class="section flex-lr date">  
7 - <view class="flex-rr" style="width:100%;">  
8 - <item class="date-item {{form.date==0?'checked':''}}"  
9 - bindtap="selectedValue" data-key="date" data-value="0">  
10 - <view class="date-item-text">{{dateStr[0]}}</view>  
11 - </item>  
12 - <item class="date-item {{form.date==1?'checked':''}}"  
13 - bindtap="selectedValue" data-key="date" data-value="1">  
14 - <view class="date-item-text">{{dateStr[1]}}</view>  
15 - </item>  
16 - </view>  
17 - <view class="more flex-ll" bindtap="calendarShow">  
18 - <view></view>  
19 - <view></view>  
20 - <view></view>  
21 - </view>  
22 - </view>  
23 - --> 5 + <view class="base-info" wx:if="{{runTime}}">
24 <view class="section"> 6 <view class="section">
25 - <view class="tab flex-ll">  
26 - <formids class="item {{form.date==0?'checked':''}}"  
27 - bindtap="selectedValue" data-key="date" data-value="0">  
28 - {{dateStr[0]}}  
29 - </formids>  
30 - <formids class="item {{form.date==1?'checked':''}}"  
31 - bindtap="selectedValue" data-key="date" data-value="1">  
32 - {{dateStr[1]}}  
33 - </formids>  
34 - <view class="item {{form.date==2?'checked':''}} flex-lr"  
35 - bindtap="selectedValue" data-key="date" data-value="2" bindtap="calendarShow">  
36 - <view style="width: 80%" class="item-text">{{dateStr[2]||'其他'}}</view>  
37 - <image  
38 - src="http://qn.colorcun.com/custom/lite-yd/image/date{{dateStr[2]?'.selected':''}}.png"  
39 - style="min-width: 36rpx;width: 36rpx;height: 36rpx; margin-right: 22rpx;"></image>  
40 - </view>  
41 - </view> 7 + <add-date time="{{runTime}}" type="{{type}}"></add-date>
42 </view> 8 </view>
43 - <view class="section ">  
44 - <view class="tab flex-ll">  
45 - <formids class="item {{form.time==0?'checked':''}} {{timeOpt[0]}}"  
46 - wx:if="{{timePickerArray[0].length>0}}"  
47 - bindtap="selectedValueAsync" data-key="time" data-value="0">  
48 - <view class="picker">早市</view>  
49 - </formids>  
50 - <formids class="item {{form.time==1?'checked':''}} {{timeOpt[1]}}"  
51 - wx:if="{{timePickerArray[1].length>0}}"  
52 - bindtap="selectedValueAsync" data-key="time" data-value="1">  
53 - <view class="picker">午市</view>  
54 - </formids>  
55 - <formids class="item {{form.time==2?'checked':''}} {{timeOpt[2]}}"  
56 - wx:if="{{timePickerArray[2].length>0}}"  
57 - bindtap="selectedValueAsync" data-key="time" data-value="2">  
58 - <view class="picker">晚市</view>  
59 - </formids>  
60 - </view> 9 + <view class="section">
  10 + <add-time-dur></add-time-dur>
61 </view> 11 </view>
62 <view class="section" style="height: 90rpx;"> 12 <view class="section" style="height: 90rpx;">
63 <view class="tab flex-lr"> 13 <view class="tab flex-lr">
64 <view class="tab flex-ll"> 14 <view class="tab flex-ll">
65 - <formids class="item-pnum {{form.pnum==item?'checked':''}}" wx:for="{{[6,7,8,9,10]}}" wx:key="pnum.key" 15 + <formids class="item-pnum {{form.pnum==item?'checked':''}}" wx:for="{{[6,7,8,9,10]}}" wx:key="pnumkey"
66 bindtap="selectedValue" data-key="pnum" data-value="{{item}}"> 16 bindtap="selectedValue" data-key="pnum" data-value="{{item}}">
67 <view class="pnum">{{item}}</view> 17 <view class="pnum">{{item}}</view>
68 </formids> 18 </formids>
@@ -87,36 +37,6 @@ @@ -87,36 +37,6 @@
87 </view> 37 </view>
88 </view> 38 </view>
89 </view> 39 </view>
90 - <!--  
91 - <view class="section ">  
92 - <view class="tab flex-ll">  
93 - <view class="item {{form.pnum_str=='1-4'?'checked':''}}"  
94 - bindtap="selectedValue" data-key="pnum_str" data-value="1-4">  
95 - 4人以下  
96 - </view>  
97 - <view class="item {{form.pnum_str=='5-9'?'checked':''}}"  
98 - bindtap="selectedValue" data-key="pnum_str" data-value="5-9">  
99 - 5~9人  
100 - </view>  
101 - <view class="item {{form.pnum_str=='10-99'?'checked':''}}"  
102 - bindtap="selectedValue" data-key="pnum_str" data-value="10-99">  
103 - 10人以上  
104 - </view>  
105 - </view>  
106 - </view>  
107 - <view class="section ">  
108 - <view class="tab flex-ll">  
109 - <view class="item {{form.tabid=='2'?'checked':''}}"  
110 - bindtap="selectedValue" data-key="tabid" data-value="2">  
111 - 包间  
112 - </view>  
113 - <view class="item {{form.tabid=='1'?'checked':''}}"  
114 - bindtap="selectedValue" data-key="tabid" data-value="1">  
115 - 散台  
116 - </view>  
117 - </view>  
118 - </view>  
119 - -->  
120 </view> 40 </view>
121 41
122 <view class="page-full tables"> 42 <view class="page-full tables">
@@ -129,7 +49,7 @@ @@ -129,7 +49,7 @@
129 </view> 49 </view>
130 </view> 50 </view>
131 <view class="advice-desk-detail flex-rr" wx:if="{{tables.length>0}}"> 51 <view class="advice-desk-detail flex-rr" wx:if="{{tables.length>0}}">
132 - <block wx:for="{{tablesed||tables}}" wx:key="tables.key"> 52 + <block wx:for="{{tablesed||tables}}" wx:key="tableskey">
133 <board width="160" height="180" board="{{item}}" 53 <board width="160" height="180" board="{{item}}"
134 style="margin: 20rpx 0 0 20rpx" 54 style="margin: 20rpx 0 0 20rpx"
135 event="boardChoose" className="noBottom" 55 event="boardChoose" className="noBottom"
@@ -150,12 +70,13 @@ @@ -150,12 +70,13 @@
150 bindconfirm="selectedValue" 70 bindconfirm="selectedValue"
151 data-key="phone" 71 data-key="phone"
152 value="{{form.phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:400rpx;" cursor-spacing="260"/> 72 value="{{form.phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:400rpx;" cursor-spacing="260"/>
153 - <view bindtap="selectedValue" data-key="time" data-value="{{form.time}}" data-display="block" style="color:#199095">  
154 - <block wx:if="{{form.is_set_ddate==1}}">  
155 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:if="{{hasUseDefDtime && form.time>0}}">{{defDtime[form.time]}}</view>  
156 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:else="">{{timePickerArray[form.time][timePickerIndex[form.time]]}}</view>  
157 - </block>  
158 - <view wx:else="" style="height: 100rpx;line-height: 100rpx;color:rgba(53,53,53,1);">未设置到店时间</view> 73 + <view style="color:#199095;min-width: 150rpx; text-align: right">
  74 + <add-time-dur-items
  75 + bindevent="addTimeDurItemsEvent"
  76 + style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;">
  77 + <view wx:if="{{form.is_set_ddate==1 || hasManual}}">{{util.unixtoTime(time,'HH:II')}}</view>
  78 + <view wx:else="" style="height: 100rpx;line-height: 100rpx;color:rgba(53,53,53,1);">未设置到店时间</view>
  79 + </add-time-dur-items>
159 </view> 80 </view>
160 <block wx:if="{{searchlist}}"> 81 <block wx:if="{{searchlist}}">
161 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList> 82 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList>
@@ -208,58 +129,6 @@ @@ -208,58 +129,6 @@
208 </view> 129 </view>
209 </view> 130 </view>
210 <tabBar></tabBar> 131 <tabBar></tabBar>
211 -<view class="calendar-mask" bindtap="calendarClose"  
212 - style="height:{{calendarMask?'100%':0}};" wx:if="{{calendarMaskLoad}}">  
213 - <view style="width: 100%; height:{{calendarMask?'100%':0}};overflow: hidden;position: relative;">  
214 - <calendar catchtap="catchtap"  
215 - isTodaybtn="{{true}}" todaybtn_txt="回到今天"  
216 - custom="{{false}}"  
217 - switchover="{{['上一月','下个月']}}"  
218 - active-coloro="active-coloro"  
219 - active-colort="active-colort"  
220 - speciallist="{{speciallist}}"  
221 - txt_style="txt-style"  
222 - calendar-style="calendar"  
223 - header-style="calendar-header"  
224 - weektitle-style="weektitle-style"  
225 - restcolor-style="restcolor-style"  
226 - txt_type="cn-d"  
227 -  
228 - datefont-style="datefont-style"  
229 - todaybtn-style="todaybtn-style"  
230 -  
231 - bindnextMonth="nextMonth"  
232 - bindprevMonth="prevMonth"  
233 - bindselectDate="dateChange"  
234 - bindgotoday="gotoday"  
235 -  
236 - prev="{{true||calendar.nextNum>0}}"  
237 - circle_show="{{false}}"  
238 - closelaststyle="{{true}}"  
239 - ></calendar>  
240 - </view>  
241 -</view>  
242 -<view class="calendar-mask" bindtap="calendarClose"  
243 - style="height:100%;" wx:if="{{timePickerMask}}">  
244 - <view class="timePicker">  
245 - <view class="flex-rr">  
246 - <image class="close" src="http://qn.colorcun.com/custom/lite-yd/image/add-act.png" bindtap="calendarClose"></image>  
247 - </view>  
248 - <view class="flex-cc" style="margin-bottom: 56rpx; font-size: 30rpx;">  
249 - <view bindtap="calendarClose">{{form.time==1?'午市':form.time==2?'晚市':'早市'}}</view>  
250 - </view>  
251 - <view class="flex-ll" style="flex-wrap:wrap">  
252 - <view class="time-item {{timePickerIndex[form.time]==index?'checked':''}}"  
253 - style="{{(index+1)%3==0?'margin-right:0;':''}}"  
254 - wx:for="{{timePickerArray[form.time]}}" wx:key=""  
255 - bindtap="bindTimePickerChange"  
256 - data-time-index="{{form.time}}"  
257 - data-val="{{index}}"  
258 - >{{item}}</view>  
259 - </view>  
260 - </view>  
261 -</view>  
262 -  
263 <view class="calendar-mask" bindtap="CustomRemarkMore" 132 <view class="calendar-mask" bindtap="CustomRemarkMore"
264 style="height:100%;" wx:if="{{CustomRemarkMoreMask}}"> 133 style="height:100%;" wx:if="{{CustomRemarkMoreMask}}">
265 <view class="timePicker" catchtap="catchtap"> 134 <view class="timePicker" catchtap="catchtap">
@@ -205,7 +205,7 @@ @@ -205,7 +205,7 @@
205 205
206 </view> 206 </view>
207 <as id="as" items="{{seller.seller_tel}}" bindclick="reservePhone" hasTip="{{false}}"></as> 207 <as id="as" items="{{seller.seller_tel}}" bindclick="reservePhone" hasTip="{{false}}"></as>
208 - <getpos bindpos="onpos" id="getpos"></getpos> 208 + <getpos bindpos="onpos" id="getpos" hasAllowLoading="{{false}}"></getpos>
209 <discount id="discount" seller="{{seller}}" bindhide="discountHide" bindshow="discountShow"></discount> 209 <discount id="discount" seller="{{seller}}" bindhide="discountHide" bindshow="discountShow"></discount>
210 <share id="share" seller_id="{{seller.id}}" seller="{{seller}}" wx:if="{{seller.id}}"></share> 210 <share id="share" seller_id="{{seller.id}}" seller="{{seller}}" wx:if="{{seller.id}}"></share>
211 </view> 211 </view>
@@ -228,7 +228,7 @@ Page({ @@ -228,7 +228,7 @@ Page({
228 onpos(e){ 228 onpos(e){
229 console.log('onpos',e); 229 console.log('onpos',e);
230 let res=e.detail; 230 let res=e.detail;
231 - if(!res.latitude) return; 231 + if(!res.latitude) return this.timeoutGetMarkers();
232 this.hasGetLocation=true; 232 this.hasGetLocation=true;
233 this.sellersIds=[] 233 this.sellersIds=[]
234 this.sellers=[] 234 this.sellers=[]
@@ -5,11 +5,14 @@ @@ -5,11 +5,14 @@
5 "es6": true, 5 "es6": true,
6 "enhance": true, 6 "enhance": true,
7 "postcss": true, 7 "postcss": true,
  8 + "preloadBackgroundData": false,
8 "minified": true, 9 "minified": true,
9 "newFeature": true, 10 "newFeature": true,
10 "coverView": true, 11 "coverView": true,
11 "nodeModules": true, 12 "nodeModules": true,
12 "autoAudits": false, 13 "autoAudits": false,
  14 + "showShadowRootInWxmlPanel": true,
  15 + "scopeDataCheck": false,
13 "uglifyFileName": false, 16 "uglifyFileName": false,
14 "checkInvalidKey": true, 17 "checkInvalidKey": true,
15 "checkSiteMap": true, 18 "checkSiteMap": true,
@@ -21,7 +24,7 @@ @@ -21,7 +24,7 @@
21 } 24 }
22 }, 25 },
23 "compileType": "miniprogram", 26 "compileType": "miniprogram",
24 - "libVersion": "2.9.4", 27 + "libVersion": "2.8.2",
25 "appid": "wxd3dc4206c76f14fc", 28 "appid": "wxd3dc4206c76f14fc",
26 "projectname": "c%E7%AB%AF%E9%A2%84%E5%AE%9A", 29 "projectname": "c%E7%AB%AF%E9%A2%84%E5%AE%9A",
27 "isGameTourist": false, 30 "isGameTourist": false,
@@ -55,7 +58,7 @@ @@ -55,7 +58,7 @@
55 "id": 0, 58 "id": 0,
56 "name": "预订本-商家1", 59 "name": "预订本-商家1",
57 "pathName": "pack-book/pages/book/b_index", 60 "pathName": "pack-book/pages/book/b_index",
58 - "query": "seller_id=1001&seller_openid=o9pcQ0cbjRKnRWczcOJaaSRGP1lE&manager_id=500", 61 + "query": "seller_id=1007&seller_openid=o9pcQ0cbjRKnRWczcOJaaSRGP1lE&manager_id=500",
59 "scene": 1001 62 "scene": 1001
60 }, 63 },
61 { 64 {
@@ -527,14 +530,14 @@ @@ -527,14 +530,14 @@
527 "id": 64, 530 "id": 64,
528 "name": "pack-book/pages/book/b_addnew 桌位进入", 531 "name": "pack-book/pages/book/b_addnew 桌位进入",
529 "pathName": "pack-book/pages/book/b_addnew", 532 "pathName": "pack-book/pages/book/b_addnew",
530 - "query": "id=43844", 533 + "query": "hasQuick=1&tid=487&tname=%E5%A4%A7%E5%8E%85%E4%B8%80&pnum=4&ddate=1578132000-1578150000",
531 "scene": null 534 "scene": null
532 }, 535 },
533 { 536 {
534 "id": 65, 537 "id": 65,
535 "name": "pack-book/pages/book/online_update", 538 "name": "pack-book/pages/book/online_update",
536 "pathName": "pack-book/pages/book/online_update", 539 "pathName": "pack-book/pages/book/online_update",
537 - "query": "id=45016", 540 + "query": "id=52340",
538 "scene": null 541 "scene": null
539 }, 542 },
540 { 543 {
@@ -566,9 +569,10 @@ @@ -566,9 +569,10 @@
566 "scene": null 569 "scene": null
567 }, 570 },
568 { 571 {
569 - "id": -1,  
570 - "name": "pages/reserve/remark",  
571 - "pathName": "pages/reserve/remark", 572 + "id": 70,
  573 + "name": "无参数 pack-book/pages/book/b_addnew",
  574 + "pathName": "pack-book/pages/book/b_addnew",
  575 + "query": "",
572 "scene": null 576 "scene": null
573 } 577 }
574 ] 578 ]
@@ -75,9 +75,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -75,9 +75,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
75 let param = ""; 75 let param = "";
76 for (let key in data) { 76 for (let key in data) {
77 let val = data[key]; 77 let val = data[key];
78 - if (val !== "" && val !== null) {  
79 - param += '&' + key + '=' + val  
80 - } 78 + //if (val !== "" && val !== null) {
  79 + param += '&' + key + '=' + val
  80 + //}
81 } 81 }
82 let cache_key = act; 82 let cache_key = act;
83 if (param) { 83 if (param) {
@@ -147,8 +147,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -147,8 +147,9 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
147 'content-type': 'application/x-www-form-urlencoded' 147 'content-type': 'application/x-www-form-urlencoded'
148 }, 148 },
149 success: function (res) { 149 success: function (res) {
150 - console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + ('&formids=' + formids.toString()) + '\nrequest.success', res.data); 150 + console.log('request.api[' + (new Date() - stime) + 'ms]==>', host + cache_key + '\nrequest.success', res.data);
151 // return; 151 // return;
  152 + //bot.msg({url: host + cache_key, res: res.data})
152 if (res.data) { 153 if (res.data) {
153 if (cachetime != 0 && res.data.ret == 200) { 154 if (cachetime != 0 && res.data.ret == 200) {
154 cache(cache_key, res.data, cachetime);//.then().catch(); 155 cache(cache_key, res.data, cachetime);//.then().catch();
@@ -158,7 +159,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -158,7 +159,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
158 res.data.msg = res.data.msg.replace('非法请求:', ''); 159 res.data.msg = res.data.msg.replace('非法请求:', '');
159 } catch (e) { 160 } catch (e) {
160 console.log('res-fail', res, e); 161 console.log('res-fail', res, e);
161 - bot.msg('接口错误', {url: host + cache_key, res: res.data}) 162 + bot.msg({url: host + cache_key, res: res.data})
162 if (wx.getRealtimeLogManager) { 163 if (wx.getRealtimeLogManager) {
163 const logger = wx.getRealtimeLogManager() 164 const logger = wx.getRealtimeLogManager()
164 logger.error('接口错误', {url: host + cache_key, res: res.data}) 165 logger.error('接口错误', {url: host + cache_key, res: res.data})
@@ -166,7 +167,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -166,7 +167,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
166 } 167 }
167 } 168 }
168 } else { 169 } else {
169 - bot.msg('接口错误', {url: host + cache_key, res: res}) 170 + bot.msg({url: host + cache_key, res: res})
170 if (wx.getRealtimeLogManager) { 171 if (wx.getRealtimeLogManager) {
171 const logger = wx.getRealtimeLogManager() 172 const logger = wx.getRealtimeLogManager()
172 logger.error('接口错误', {url: host + cache_key, res: res}) 173 logger.error('接口错误', {url: host + cache_key, res: res})
@@ -185,7 +186,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr @@ -185,7 +186,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
185 // }); 186 // });
186 //query.show(); 187 //query.show();
187 //console.log('net',query); 188 //console.log('net',query);
188 - bot.msg('接口错误', {url: host + cache_key, res: res}) 189 + bot.msg({url: host + cache_key, res: res})
189 if (wx.getRealtimeLogManager) { 190 if (wx.getRealtimeLogManager) {
190 const logger = wx.getRealtimeLogManager() 191 const logger = wx.getRealtimeLogManager()
191 logger.error('调用失败', {url: host + cache_key, res: res}) 192 logger.error('调用失败', {url: host + cache_key, res: res})
1 //https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9 1 //https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9
  2 +import util from './util'
2 export default { 3 export default {
3 - msg(message){ 4 + async msg (json){
  5 + let openid=await getApp().getOpenid()
  6 + if(!openid) return;
  7 + let pages = getCurrentPages();
  8 + //let p = pages[pages.length - 1];
  9 + let px='',pl=pages.length,str=''
  10 + for(let pi=pl-1,pj=0;pi>=0;pi--){
  11 + px+=">"+str+util.http_build_query(pages[pi].options,pages[pi].route)+"\n"
  12 + str+='→';
  13 + pj++
  14 + if(pj>2) break;
  15 + }
4 wx.request({ 16 wx.request({
5 url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9', 17 url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9094c8cc-ec7f-4221-b1d9-50e71e008aa9',
  18 + //url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6093c5ae-d02a-4708-99a2-e80b82280fd0',//测试用
6 method: 'POST', 19 method: 'POST',
7 data: { 20 data: {
8 - msgtype:'text',  
9 - text:{  
10 - content:message, 21 + msgtype:'markdown',
  22 + markdown:{
  23 + content:
  24 + "**"+util.unixtoTime(new Date()/1000,'YYYY-MM-DD HH:II:SS')+"**\n"+
  25 + px+
  26 + "><font color=\"red\">"+openid+"</font>\n"+
  27 + ">"+json.url+"\n\n"+
  28 + (typeof json.res == 'string'?json.res:JSON.stringify(json.res)).substr(0,500)+"\n\n"
11 }, 29 },
12 }, 30 },
13 header: { 31 header: {
@@ -26,11 +26,11 @@ function formatNumber(n) { @@ -26,11 +26,11 @@ function formatNumber(n) {
26 return n[1] ? n : '0' + n 26 return n[1] ? n : '0' + n
27 } 27 }
28 //时间戳转为时间 28 //时间戳转为时间
29 -function unixtoTime(ns,format) { 29 +function unixtoTime(ns,format='') {
30 var result; 30 var result;
31 var time = new Date(ns*1000); 31 var time = new Date(ns*1000);
32 //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW'; 32 //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW';
33 - result=format || 'YYYY年MM月DD日'; 33 + result=format || 'YYYY年MM月DD日 HH时II分SS秒';
34 //console.log(format); 34 //console.log(format);
35 result=result.toUpperCase(); 35 result=result.toUpperCase();
36 result=result.replace('YYYY',time.getFullYear()); 36 result=result.replace('YYYY',time.getFullYear());
1 //时间戳转为时间 1 //时间戳转为时间
2 function unixtoTime(ns,format="YYYY-MM-DD HH:II:SS") { 2 function unixtoTime(ns,format="YYYY-MM-DD HH:II:SS") {
  3 + if(!ns) return
3 var result; 4 var result;
4 var time = getDate(ns*1000); 5 var time = getDate(ns*1000);
5 //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW'; 6 //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW';