Commit f7c1f848c6dbe66ed9eaab779ea5173d6f7a8454

Authored by vking
1 parent a55d33d9

master-rewrite-addnew

  1 +// pack-book/components/book/time/add-date.js
  2 +import util from '../../../../utils/util'
  3 +Component({
  4 + /**
  5 + * 组件的属性列表
  6 + */
  7 + properties: {
  8 + nowtime:Number,
  9 + },
  10 + lifetimes: {
  11 + // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  12 + attached: function () {
  13 + this.initView()
  14 + },
  15 + moved: function () { },
  16 + detached: function () { },
  17 + },
  18 + /**
  19 + * 组件的初始数据
  20 + */
  21 + data: {
  22 + checked:-1,
  23 + list:[
  24 + {
  25 + time:new Date()/1000,
  26 + },
  27 + {
  28 + time:new Date()/1000+86400,
  29 + },
  30 + {
  31 + time:0,
  32 + }
  33 + ],
  34 +
  35 + calendarMaskLoad: false,
  36 + calendarMask: false,
  37 + },
  38 + checked:-1,
  39 + /**
  40 + * 组件的方法列表
  41 + */
  42 + methods: {
  43 + initView(){
  44 + //console.log('add-date',this.data.nowtime,this.data.today)
  45 + setTimeout(() => {
  46 + this.setData({
  47 + calendarMaskLoad: true,
  48 + })
  49 + }, 1000);
  50 + this.initChecked(this.data.nowtime)
  51 +
  52 + },
  53 + initChecked(nowtime){
  54 + let nowStr=util.unixtoTime(nowtime,"YYYY-MM-DD");
  55 + let list=this.data.list
  56 + this.checked=2
  57 + this.checkedTime=nowtime
  58 + if(nowStr==util.unixtoTime(list[0].time,"YYYY-MM-DD")){
  59 + this.checked=0
  60 + }else if(nowStr==util.unixtoTime(list[1].time,"YYYY-MM-DD")){
  61 + this.checked=1
  62 + }
  63 + this.setData({
  64 + checked:this.checked,
  65 + [`list[2].time`]:nowtime,
  66 + })
  67 + this.trigger()
  68 + },
  69 + selectedValue(e){
  70 + this.checked=util.attr(e,'value')
  71 + this.checkedTime=this.data.list[this.checked].time
  72 + this.setData({
  73 + checked:this.checked,
  74 + })
  75 + this.trigger()
  76 + },
  77 + trigger(){
  78 + this.triggerEvent('event',{
  79 + checked:this.checked,
  80 + checkedTime:this.checkedTime,
  81 + })
  82 + },
  83 + calendarShow(e){
  84 + this.setData({
  85 + calendarMask: true
  86 + })
  87 + },
  88 + calendarClose(){
  89 + this.setData({
  90 + calendarMask: false,
  91 + })
  92 + },
  93 + dateChange(event){
  94 + let cktime = util.timetouUnix(event.detail.date)
  95 + this.initChecked(cktime)
  96 + this.calendarClose();
  97 + },
  98 + }
  99 +})
  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 + //console.log('add-time-dur.attached')
  14 + PubSub.on('dur-items',(check)=>{
  15 + //{ddate_solt: 1, list: Array(9), listIndex: 8}
  16 + this.ddate_solt=check.ddate_solt
  17 + this.list=check.list
  18 + this.listIndex=check.listIndex
  19 + console.log('add-time-dur-items',check)
  20 + this.setData(check)
  21 + this.trigger()
  22 + })
  23 + },
  24 + moved: function () { },
  25 + detached: function () {
  26 + PubSub.off('du-items')
  27 + },
  28 + },
  29 + /**
  30 + * 组件的初始数据
  31 + */
  32 + data: {
  33 + list:[],
  34 + timePickerMask:false,
  35 + ddate_solt:-1,
  36 + },
  37 +
  38 + /**
  39 + * 组件的方法列表
  40 + */
  41 + methods: {
  42 + calendarShow(){
  43 + this.setData({
  44 + timePickerMask:true,
  45 + })
  46 + },
  47 + calendarClose(){
  48 + this.setData({
  49 + timePickerMask:true,
  50 + })
  51 + },
  52 + bindTimePickerChange(e){
  53 + console.log('add-time-dur-items',e.detail)
  54 + },
  55 + trigger(){
  56 + this.triggerEvent('event',{
  57 + time:this.list[this.listIndex].time,
  58 + ddate_solt:this.ddate_solt
  59 + })
  60 + },
  61 + }
  62 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--pack-book/components/book/time/add-time-dur-items.wxml-->
  2 +<view bindtap="calendarShow">
  3 + <slot></slot>
  4 +</view>
  5 +<view class="calendar-mask" bindtap="calendarClose"
  6 + style="height:100%;" wx:if="{{timePickerMask}}">
  7 + <view class="timePicker">
  8 + <view class="flex-rr">
  9 + <image class="close" src="http://qn.colorcun.com/custom/lite-yd/image/add-act.png" bindtap="calendarClose"></image>
  10 + </view>
  11 + <view class="flex-cc" style="margin-bottom: 56rpx; font-size: 30rpx;">
  12 + <view bindtap="calendarClose">{{ddate_solt==1?'午市':ddate_solt==2?'晚市':'早市'}}</view>
  13 + </view>
  14 + <view class="flex-ll" style="flex-wrap:wrap">
  15 + <view class="time-item {{item.hasChecked?'checked':''}}"
  16 + style="{{(index+1)%3==0?'margin-right:0;':''}}"
  17 + wx:for="{{list}}" wx:key="listkey"
  18 + bindtap="bindTimePickerChange"
  19 + data-index="{{index}}"
  20 + data-time="{{item.time}}"
  21 + >{{item}}</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 .close{
  39 + width: 50rpx;
  40 + height: 50rpx;
  41 + transform:rotate(45deg);
  42 + margin-top: -10rpx;
  43 + margin-right: -10%;
  44 +}
1 // pack-book/components/book/time/add-time-dur.js 1 // pack-book/components/book/time/add-time-dur.js
2 -var util = require('../../../../utils/util.js') 2 +import util from'../../../../utils/util.js'
3 import App from '../../../../utils/api'; 3 import App from '../../../../utils/api';
  4 +import PubSub from '../../../../utils/PubSub';
4 const timeSort=['morning', 'noon', 'night']; 5 const timeSort=['morning', 'noon', 'night'];
5 const timeConfig= { 6 const timeConfig= {
6 'morning':{ 7 'morning':{
@@ -21,13 +22,9 @@ Component({ @@ -21,13 +22,9 @@ Component({
21 * 组件的属性列表 22 * 组件的属性列表
22 */ 23 */
23 properties: { 24 properties: {
24 - solt:{//ddate_solt,时段,修改或从桌位过来使用  
25 - type:Number,  
26 - value:-1,  
27 - },  
28 - date:{//0今天,1明天,2其它  
29 - type:Number,  
30 - value:-1, 25 + date:{//YYYY-MM-DD
  26 + type:String,
  27 + value:'',
31 }, 28 },
32 ddate:{//到店时间 29 ddate:{//到店时间
33 type:Number, 30 type:Number,
@@ -42,8 +39,7 @@ Component({ @@ -42,8 +39,7 @@ Component({
42 detached: function () { }, 39 detached: function () { },
43 }, 40 },
44 observers:{ 41 observers:{
45 - "solt,date":async function(solt,date){  
46 - if(solt<0) return; 42 + "date":async function(date){
47 console.log('add-time-dur.observers',arguments) 43 console.log('add-time-dur.observers',arguments)
48 this.config=null 44 this.config=null
49 this.ddate_solt=-1 45 this.ddate_solt=-1
@@ -73,15 +69,14 @@ Component({ @@ -73,15 +69,14 @@ Component({
73 let daily = res.data.daily; 69 let daily = res.data.daily;
74 console.log('add-time-dur.daily',daily) 70 console.log('add-time-dur.daily',daily)
75 this.initUserTime(daily) 71 this.initUserTime(daily)
76 - if(this.data.solt>-1){  
77 - this.initSoltTime()  
78 - }  
79 this.trigger(); 72 this.trigger();
80 }, 73 },
81 initUserTime(daily){ 74 initUserTime(daily){
82 let config=[] 75 let config=[]
83 let time=parseInt(new Date()/1000); 76 let time=parseInt(new Date()/1000);
84 - let HHII=util.unixtoTime(time,"HH:II") 77 + let datetime=util.unixtoTime(time,"YYYY-MM-DD,HH:II").split(',')
  78 + let TODAY=datetime[0]
  79 + let HHII=datetime[1]
85 timeSort.forEach((en_name,ti)=>{ 80 timeSort.forEach((en_name,ti)=>{
86 let dur=daily[en_name]; 81 let dur=daily[en_name];
87 let min='',max='',hasShow=false,hasDisabled=false,hasChecked=false 82 let min='',max='',hasShow=false,hasDisabled=false,hasChecked=false
@@ -94,7 +89,7 @@ Component({ @@ -94,7 +89,7 @@ Component({
94 hasChecked=true 89 hasChecked=true
95 this.ddate_solt=ti 90 this.ddate_solt=ti
96 } 91 }
97 - if(HHII>max && this.data.date==0){ 92 + if(HHII>max && this.data.date==TODAY){
98 hasDisabled=true 93 hasDisabled=true
99 } 94 }
100 } 95 }
@@ -110,21 +105,12 @@ Component({ @@ -110,21 +105,12 @@ Component({
110 }); 105 });
111 }) 106 })
112 this.config=config; 107 this.config=config;
  108 + console.log('add-time-dur.initUserTime',this.config[0].hasDisabled)
113 this.setData({ 109 this.setData({
114 config:this.config, 110 config:this.config,
115 ddate_solt:this.ddate_solt, 111 ddate_solt:this.ddate_solt,
116 }) 112 })
117 - },  
118 - initSoltTime(){//修改或快速预订  
119 - this.ddate_solt=this.data.solt  
120 - this.config.forEach((t,ti)=>{  
121 - t.hasDisabled=false  
122 - t.hasChecked=ti==this.ddate_solt  
123 - })  
124 - this.setData({  
125 - config:this.config,  
126 - ddate_solt:this.ddate_solt,  
127 - }) 113 + console.log('add-time-dur.initUserTime',this.data.config[0].hasDisabled)
128 }, 114 },
129 selectedValue(e){ 115 selectedValue(e){
130 console.log('add-time-dur.selectedValue',e) 116 console.log('add-time-dur.selectedValue',e)
@@ -176,10 +162,12 @@ Component({ @@ -176,10 +162,12 @@ Component({
176 }, 162 },
177 trigger(){ 163 trigger(){
178 let timeList=this.initTimeSpaceIndex() 164 let timeList=this.initTimeSpaceIndex()
179 - this.triggerEvent('event',{ 165 + let data={
180 ddate_solt:this.ddate_solt, 166 ddate_solt:this.ddate_solt,
181 ...timeList, 167 ...timeList,
182 - }) 168 + }
  169 + //this.triggerEvent('event',data)
  170 + PubSub.emit('dur-items',data)
183 } 171 }
184 } 172 }
185 }) 173 })
1 <!--pack-book/components/book/time/add-time-dur.wxml--> 1 <!--pack-book/components/book/time/add-time-dur.wxml-->
2 <view class="tab flex-ll"> 2 <view class="tab flex-ll">
3 - <block wx:for="{{config}}" wx:key="config-key"> 3 + <block wx:for="{{config}}" wx:key="configkey">
4 <view class="item {{item.hasChecked?'checked':''}} {{item.hasDisabled?'disabled':''}}" 4 <view class="item {{item.hasChecked?'checked':''}} {{item.hasDisabled?'disabled':''}}"
5 wx:if="{{item.hasShow}}" 5 wx:if="{{item.hasShow}}"
6 bindtap="{{item.hasDisabled?'':'selectedValue'}}" data-value="{{index}}"> 6 bindtap="{{item.hasDisabled?'':'selectedValue'}}" data-value="{{index}}">
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 = {  
7 - rid: '',  
8 - date: 0,  
9 - time: 0,  
10 - //pnum_str:'1-4',  
11 - pnum: 6,  
12 - tabid: 0,  
13 -  
14 - rname: '',  
15 - phone: '',  
16 - sex: 1,  
17 - cusdem: '',  
18 -  
19 - tid: [],  
20 -  
21 -}  
22 Page({ 4 Page({
23 -  
24 /** 5 /**
25 * 页面的初始数据 6 * 页面的初始数据
26 */ 7 */
27 data: { 8 data: {
28 - dateStr: [],  
29 - form: JSON.parse(JSON.stringify(formTpl)),  
30 - tables: [],  
31 - grand: [  
32 - {  
33 - sex: 1,  
34 - grand_title: '先生',  
35 - isselect: true  
36 - },  
37 - {  
38 - sex: 2,  
39 - grand_title: '女士',  
40 - isselect: false  
41 - },  
42 - {  
43 - sex: 3,  
44 - grand_title: '公司',  
45 - isselect: false  
46 - }  
47 - ],  
48 - 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,  
63 -  
64 - timePickerMask: false,  
65 - pnumInputFocus: false,  
66 - pageMarginBottom: 0,  
67 - speciallist: [],  
68 - calendar: {  
69 - nextNum: 0,  
70 - },  
71 - defDtime: ['', '12:00', '18:30'],  
72 - hasUseDefDtime: true,  
73 - CustomRemark:[],  
74 - CustomRemarkMoreMask:false, 9 + nowtime:0,//当前时间戳,或修改到店,或桌位预订时间
  10 + date:'',//当前选择的日期
75 }, 11 },
76 /** 12 /**
77 * 生命周期函数--监听页面加载 13 * 生命周期函数--监听页面加载
78 */ 14 */
79 - reserve_id: '',  
80 - checkedTables:{},//已选中的桌子集合  
81 - year:util.unixtoTime(new Date() / 1000,'YYYY'),  
82 onLoad: async function (options) { 15 onLoad: async function (options) {
83 this.options=options 16 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'];  
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 - } 17 + if(options.id>0){
  18 + //修改
  19 + return;
161 } 20 }
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; 21 + if(options.tid){
  22 + //桌位预订
  23 + return;
170 } 24 }
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 - 25 + this.setData({
  26 + nowtime:parseInt(new Date()/1000)
  27 + })
184 }, 28 },
185 29
186 /** 30 /**
@@ -194,16 +38,7 @@ Page({ @@ -194,16 +38,7 @@ Page({
194 * 生命周期函数--监听页面显示 38 * 生命周期函数--监听页面显示
195 */ 39 */
196 onShow: function () { 40 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() 41 +
207 }, 42 },
208 43
209 /** 44 /**
@@ -240,680 +75,25 @@ Page({ @@ -240,680 +75,25 @@ Page({
240 onShareAppMessage: function () { 75 onShareAppMessage: function () {
241 76
242 }, 77 },
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  
339 - }  
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)  
362 - },  
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 - })  
396 - }  
397 - }  
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 - }  
472 - }  
473 -  
474 - this.setData(sobj)  
475 - },  
476 - async getTables(){  
477 - let form = this.data.form;  
478 - let tableid = util.cache('tableid');  
479 - console.log('getTables-tableid', tableid.length, this.reserve_id);  
480 - //if (tableid.length < 1 && this.reserve_id) {  
481 - if (tableid.length < 1) {  
482 - tableid = this.data.form.tid;  
483 - }  
484 - console.log('getTables-tableid', tableid, tableid.length);  
485 - 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({  
489 - sid: util.cache('enter_params')['seller_id'],  
490 - //pnum_str:form.pnum_str,  
491 - pnum: form.pnum,  
492 - rdate: util.unixtoTime(rdate.substr(0,10),'YYYYMMDD'),  
493 - tid: form.tabid,  
494 - rid: this.reserve_id,  
495 - ddate_solt:parseInt(form.time)+1  
496 - }).then(res => {  
497 - let tables = [];  
498 - let tablesLength = 0;  
499 - if (tableid.length > 0) {  
500 - let toastTables={...this.checkedTables}  
501 - let resData=res.data.slice(1,res.data.length);  
502 - console.log('resData',resData)  
503 - resData.forEach(p => {  
504 - //if(tables.length>=3) return true;  
505 - p.list.forEach(t => {  
506 - delete toastTables[t.id]  
507 - tablesLength++;  
508 - if (tables.length >= 3) return true;  
509 - if (tableid._indexOf(t.id) > -1) {  
510 - t.isselect = true;  
511 - tables.push(t);  
512 - }  
513 - })  
514 - })  
515 - console.log('toastTables',toastTables,this.data.form.tid,this.checkedTables);  
516 - //清理已选中的桌位  
517 - let toastTablesInfo=[];  
518 - let tid=this.data.form.tid  
519 - Object.keys(this.checkedTables).forEach(ckid=>{  
520 - if(toastTables[ckid]){  
521 - delete this.checkedTables[ckid]  
522 - tid.remove(ckid);  
523 - toastTablesInfo.push(toastTables[ckid]);  
524 - }  
525 - })  
526 - if(toastTablesInfo.length>0){  
527 - this.setData({  
528 - [`form.tid`]:tid,  
529 - })  
530 - util.toast(toastTablesInfo.toString()+'已被占用啦','none');  
531 - }  
532 - wx.removeStorage({key: 'tableid'})  
533 - }  
534 - console.log('tables-first',tables);  
535 - if(tables.length<1){  
536 - tablesLength=0;  
537 - let fortids=[];  
538 - res.data.forEach((p,ri) => {  
539 - p.list.forEach(t => {  
540 - if(fortids._indexOf(t.id)<0) {  
541 - tablesLength++;  
542 - tables.push(t);  
543 - fortids.push(t.id);  
544 - }  
545 - })  
546 - })  
547 - if (tables.length >= 3) {  
548 - tables = tables.slice(0, 3);  
549 - }  
550 - }  
551 - this.tablesLength = tablesLength;  
552 - this.setData({  
553 - tables: tables,  
554 - tablesLength: tablesLength  
555 - })  
556 - this.conditionInfo();  
557 - })  
558 - } catch (e) {  
559 - this.setData({  
560 - tables: []  
561 - })  
562 - }  
563 - },  
564 - async formsubmit(){  
565 - if (this.data.buttonhide) return;  
566 - 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({  
576 - buttonhide: true,  
577 - })  
578 - let form = JSON.parse(JSON.stringify(this.data.form));  
579 - console.log('typeof form.tid', typeof form.tid);  
580 - if (typeof form.tid == 'object') {  
581 - let tid = new Set(form.tid);//tid 去重  
582 - form.tid = [...tid].toString();  
583 - }  
584 - if(this.data.timePickerArray[form.time].length<1){  
585 - return util.toast('请选择时段', 'none');  
586 - }  
587 - if (!form.tid) {  
588 - return util.toast('请选择桌子', 'none');  
589 - }  
590 - if (!form.rname) {  
591 - return util.toast('请填写预订人', 'none');  
592 - }  
593 - form.sid = this.sellerid;  
594 - form.rdate = rdate  
595 -  
596 - try {  
597 - let enter_params = util.cache('enter_params');  
598 - let sc = (await App.Reserve.SellerInfo(enter_params)).data  
599 - let note_openid = enter_params.seller_openid;  
600 - let note_name = sc.seller_user.nick_name || sc.seller_user.nickname;  
601 - form.note_openid = note_openid || '';  
602 - if (form.rid) {//修改时传递uid  
603 - form.note_openid = enter_params.manager_id || '';  
604 - }  
605 - form.note_name = note_name || '';  
606 - } catch (e) {}  
607 -  
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  
614 - form.is_set_ddate=1  
615 - App.Reserve.SetReserveInfo(form).then(res => {  
616 - if (res.ret == 200) {  
617 - this.getCustomRemark()  
618 - let _id = (res.data.id || res.data)  
619 - this.setData({  
620 - form: JSON.parse(JSON.stringify(formTpl)),  
621 - tables: [],  
622 - timePickerIndex: [0, 0, 0],  
623 - })  
624 - this.initLoad();  
625 - this.checkedTables={};  
626 - App.Reserve.Detail({rid: _id, openid: ''}, 'clear')  
627 - wx.navigateTo({  
628 - url: util.http_build_query({id:_id,tplid:1},'b_invitation'),  
629 - });  
630 - } else {  
631 - util.toast(res.msg, 'none')  
632 - }  
633 - })  
634 - } catch (e) {  
635 - }  
636 - },  
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; 78 + //日期选择通知
  79 + addDateEvent(e){
  80 + //console.log('addDateEvent',e.detail)
  81 + //{checked: 1, checkedTime: 123456790}
643 this.setData({ 82 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 -  
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 - /**  
733 - * 修改初始化  
734 - */  
735 - async initModify(id){  
736 - 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 = [];  
763 - let tablesed = [];  
764 - res.data.tables.forEach((t, ti) => {  
765 - obj.form.tid.push(t.id)  
766 - if (ti >= 3) return;  
767 - t.isselect = true  
768 - t["isselected"] = 1  
769 - tablesed.push(t);  
770 - this.checkedTables[t.id]=t.name;  
771 - })  
772 - this.setData({  
773 - timePickerIndex: timePickerIndex,  
774 - form: obj.form,  
775 - //tablesed:tablesed,  
776 - hasUseDefDtime: false,  
777 - })  
778 - setTimeout(() => {  
779 - this.getTables();  
780 - }, 300)  
781 -  
782 - } catch (e) {  
783 - console.log('initModify', e)  
784 - }  
785 - },  
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 - /**  
847 - * 快速预订初始化  
848 - * tid  
849 - * tname  
850 - * ddate  
851 - * pnum  
852 - */  
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 - })  
902 - this.setData({  
903 - CustomRemark:CustomRemark,  
904 - form:form,  
905 - })  
906 - this.conditionInfo()  
907 - },  
908 - CustomRemarkMore(){  
909 - this.setData({  
910 - CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask 83 + date:util.unixtoTime(e.detail.checkedTime,'YYYY-MM-DD')
911 }) 84 })
912 }, 85 },
  86 + //时段选择通知
913 addTimeDurEvent(e){ 87 addTimeDurEvent(e){
914 - console.log('add-time-dur.event',e); 88 + //console.log('addTimeDurEvent',e.detail)
  89 + //{ddate_solt: 1, list: Array(9), listIndex: 4}
  90 + },
  91 + //到店时间选择通知
  92 + addTimeDurItemsEvent(e){
  93 + //{time: 1577689200, ddate_solt: 1}
  94 + //console.log('addTimeDurItemsEvent',e.detail)
915 this.setData({ 95 this.setData({
916 - [`form.time`]:e.detail.ddate_solt, 96 + ...e.detail,
917 }) 97 })
918 }, 98 },
919 }) 99 })
@@ -3,13 +3,11 @@ @@ -3,13 +3,11 @@
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", 8 + "add-date": "../../components/book/time/add-date",
11 "board":"../../components/book/board/board", 9 "board":"../../components/book/board/board",
12 - "formids":"/components/formids/formids",  
13 - "add-time-dur":"../../components/book/time/add-time-dur" 10 + "add-time-dur":"../../components/book/time/add-time-dur",
  11 + "add-time-dur-items":"../../components/book/time/add-time-dur-items"
14 } 12 }
15 } 13 }
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 - -->  
24 - <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>  
42 - </view> 5 + <view class="base-info" wx:if="{{nowtime}}">
43 <view class="section"> 6 <view class="section">
44 - <add-time-dur date="{{form.date}}" solt="{{detail.time.kk}}" bindevent="addTimeDurEvent"></add-time-dur> 7 + <add-date nowtime="{{nowtime}}" bindevent="addDateEvent"></add-date>
45 </view> 8 </view>
46 - <view class="section ">  
47 - <view class="tab flex-ll">  
48 - <formids class="item {{form.time==0?'checked':''}} {{timeOpt[0]}}"  
49 - wx:if="{{timePickerArray[0].length>0}}"  
50 - bindtap="selectedValueAsync" data-key="time" data-value="0">  
51 - <view class="picker">早市</view>  
52 - </formids>  
53 - <formids class="item {{form.time==1?'checked':''}} {{timeOpt[1]}}"  
54 - wx:if="{{timePickerArray[1].length>0}}"  
55 - bindtap="selectedValueAsync" data-key="time" data-value="1">  
56 - <view class="picker">午市</view>  
57 - </formids>  
58 - <formids class="item {{form.time==2?'checked':''}} {{timeOpt[2]}}"  
59 - wx:if="{{timePickerArray[2].length>0}}"  
60 - bindtap="selectedValueAsync" data-key="time" data-value="2">  
61 - <view class="picker">晚市</view>  
62 - </formids>  
63 - </view> 9 + <view class="section" wx:if="{{date}}">
  10 + <add-time-dur date="{{date}}" ddate="{{detail.ddate||''}}" bindevent="addTimeDurEvent"></add-time-dur>
64 </view> 11 </view>
65 <view class="section" style="height: 90rpx;"> 12 <view class="section" style="height: 90rpx;">
66 <view class="tab flex-lr"> 13 <view class="tab flex-lr">
@@ -90,36 +37,6 @@ @@ -90,36 +37,6 @@
90 </view> 37 </view>
91 </view> 38 </view>
92 </view> 39 </view>
93 - <!--  
94 - <view class="section ">  
95 - <view class="tab flex-ll">  
96 - <view class="item {{form.pnum_str=='1-4'?'checked':''}}"  
97 - bindtap="selectedValue" data-key="pnum_str" data-value="1-4">  
98 - 4人以下  
99 - </view>  
100 - <view class="item {{form.pnum_str=='5-9'?'checked':''}}"  
101 - bindtap="selectedValue" data-key="pnum_str" data-value="5-9">  
102 - 5~9人  
103 - </view>  
104 - <view class="item {{form.pnum_str=='10-99'?'checked':''}}"  
105 - bindtap="selectedValue" data-key="pnum_str" data-value="10-99">  
106 - 10人以上  
107 - </view>  
108 - </view>  
109 - </view>  
110 - <view class="section ">  
111 - <view class="tab flex-ll">  
112 - <view class="item {{form.tabid=='2'?'checked':''}}"  
113 - bindtap="selectedValue" data-key="tabid" data-value="2">  
114 - 包间  
115 - </view>  
116 - <view class="item {{form.tabid=='1'?'checked':''}}"  
117 - bindtap="selectedValue" data-key="tabid" data-value="1">  
118 - 散台  
119 - </view>  
120 - </view>  
121 - </view>  
122 - -->  
123 </view> 40 </view>
124 41
125 <view class="page-full tables"> 42 <view class="page-full tables">
@@ -154,8 +71,9 @@ @@ -154,8 +71,9 @@
154 data-key="phone" 71 data-key="phone"
155 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"/>
156 <view bindtap="selectedValue" data-key="time" data-value="{{form.time}}" data-display="block" style="color:#199095"> 73 <view bindtap="selectedValue" data-key="time" data-value="{{form.time}}" data-display="block" style="color:#199095">
157 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:if="{{hasUseDefDtime && form.time>0}}">{{defDtime[form.time]}}</view>  
158 - <view style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;" wx:else="">{{timePickerArray[form.time][timePickerIndex[form.time]]}}</view> 74 + <add-time-dur-items
  75 + bindevent="addTimeDurItemsEvent"
  76 + style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;">{{util.unixtoTime(time,'YYYY-MM-DD HH:II')}}</add-time-dur-items>
159 </view> 77 </view>
160 <block wx:if="{{searchlist}}"> 78 <block wx:if="{{searchlist}}">
161 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList> 79 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList>
@@ -209,37 +127,6 @@ @@ -209,37 +127,6 @@
209 </view> 127 </view>
210 <tabBar></tabBar> 128 <tabBar></tabBar>
211 <view class="calendar-mask" bindtap="calendarClose" 129 <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}}"> 130 style="height:100%;" wx:if="{{timePickerMask}}">
244 <view class="timePicker"> 131 <view class="timePicker">
245 <view class="flex-rr"> 132 <view class="flex-rr">
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';