Commit 6db64e0eb870dcffcc2980ea04a65a83962014d4

Authored by vking
1 parent f7c1f848

master-rewrite-addnew

1 // pack-book/components/book/time/add-date.js 1 // pack-book/components/book/time/add-date.js
2 import util from '../../../../utils/util' 2 import util from '../../../../utils/util'
  3 +import PubSub from '../../../../utils/PubSub';
3 Component({ 4 Component({
4 /** 5 /**
5 * 组件的属性列表 6 * 组件的属性列表
6 */ 7 */
7 properties: { 8 properties: {
8 - nowtime:Number, 9 + type:Number,
  10 + time:Number,
9 }, 11 },
10 lifetimes: { 12 lifetimes: {
11 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 13 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
@@ -47,8 +49,11 @@ Component({ @@ -47,8 +49,11 @@ Component({
47 calendarMaskLoad: true, 49 calendarMaskLoad: true,
48 }) 50 })
49 }, 1000); 51 }, 1000);
50 - this.initChecked(this.data.nowtime)  
51 - 52 + this.HHIISS=util.unixtoTime(this.data.time,'HH:II:SS')
  53 + this.initChecked(this.data.time)
  54 + setTimeout(() => {
  55 + this.trigger()
  56 + }, 800);
52 }, 57 },
53 initChecked(nowtime){ 58 initChecked(nowtime){
54 let nowStr=util.unixtoTime(nowtime,"YYYY-MM-DD"); 59 let nowStr=util.unixtoTime(nowtime,"YYYY-MM-DD");
@@ -64,7 +69,7 @@ Component({ @@ -64,7 +69,7 @@ Component({
64 checked:this.checked, 69 checked:this.checked,
65 [`list[2].time`]:nowtime, 70 [`list[2].time`]:nowtime,
66 }) 71 })
67 - this.trigger() 72 +
68 }, 73 },
69 selectedValue(e){ 74 selectedValue(e){
70 this.checked=util.attr(e,'value') 75 this.checked=util.attr(e,'value')
@@ -75,10 +80,20 @@ Component({ @@ -75,10 +80,20 @@ Component({
75 this.trigger() 80 this.trigger()
76 }, 81 },
77 trigger(){ 82 trigger(){
78 - this.triggerEvent('event',{  
79 - checked:this.checked,  
80 - checkedTime:this.checkedTime,  
81 - }) 83 + let date=util.unixtoTime(this.checkedTime,"YYYY-MM-DD")
  84 + let dur_time=util.timetouUnix(date+' '+this.HHIISS);
  85 + let data={
  86 + type:this.data.type,
  87 + date:date,
  88 + dur_time:dur_time,
  89 + dateIndex:this.checked,
  90 + }
  91 + console.log('add-date.trigger',data)
  92 + // this.triggerEvent('event',{
  93 + // checked:this.checked,
  94 + // checkedTime:this.checkedTime,
  95 + // })
  96 + PubSub.emit('add-time-dur',data)
82 }, 97 },
83 calendarShow(e){ 98 calendarShow(e){
84 this.setData({ 99 this.setData({
@@ -93,6 +108,7 @@ Component({ @@ -93,6 +108,7 @@ Component({
93 dateChange(event){ 108 dateChange(event){
94 let cktime = util.timetouUnix(event.detail.date) 109 let cktime = util.timetouUnix(event.detail.date)
95 this.initChecked(cktime) 110 this.initChecked(cktime)
  111 + this.trigger()
96 this.calendarClose(); 112 this.calendarClose();
97 }, 113 },
98 } 114 }
@@ -10,13 +10,12 @@ Component({ @@ -10,13 +10,12 @@ Component({
10 }, 10 },
11 lifetimes: { 11 lifetimes: {
12 attached: function () { 12 attached: function () {
13 - //console.log('add-time-dur.attached')  
14 PubSub.on('dur-items',(check)=>{ 13 PubSub.on('dur-items',(check)=>{
15 //{ddate_solt: 1, list: Array(9), listIndex: 8} 14 //{ddate_solt: 1, list: Array(9), listIndex: 8}
  15 + console.log('dur-items.PubSub',check)
16 this.ddate_solt=check.ddate_solt 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) 17 + this.dur_list=check.dur_list
  18 + this.dur_list_checked=check.dur_list_checked
20 this.setData(check) 19 this.setData(check)
21 this.trigger() 20 this.trigger()
22 }) 21 })
@@ -30,7 +29,7 @@ Component({ @@ -30,7 +29,7 @@ Component({
30 * 组件的初始数据 29 * 组件的初始数据
31 */ 30 */
32 data: { 31 data: {
33 - list:[], 32 + dur_list:[],
34 timePickerMask:false, 33 timePickerMask:false,
35 ddate_solt:-1, 34 ddate_solt:-1,
36 }, 35 },
@@ -46,16 +45,22 @@ Component({ @@ -46,16 +45,22 @@ Component({
46 }, 45 },
47 calendarClose(){ 46 calendarClose(){
48 this.setData({ 47 this.setData({
49 - timePickerMask:true, 48 + timePickerMask:false,
50 }) 49 })
51 }, 50 },
52 bindTimePickerChange(e){ 51 bindTimePickerChange(e){
53 - console.log('add-time-dur-items',e.detail) 52 + this.dur_list_checked=util.attr(e,'index')
  53 + this.setData({
  54 + dur_list_checked:this.dur_list_checked,
  55 + })
  56 + this.trigger()
  57 + this.calendarClose()
54 }, 58 },
55 trigger(){ 59 trigger(){
56 this.triggerEvent('event',{ 60 this.triggerEvent('event',{
57 - time:this.list[this.listIndex].time,  
58 - ddate_solt:this.ddate_solt 61 + time:this.dur_list[this.dur_list_checked].time,
  62 + ddate_solt:this.ddate_solt,
  63 + timeDur:this.dur_list[0].time+'-'+this.dur_list[this.dur_list.length-1].time
59 }) 64 })
60 }, 65 },
61 } 66 }
1 <!--pack-book/components/book/time/add-time-dur-items.wxml--> 1 <!--pack-book/components/book/time/add-time-dur-items.wxml-->
  2 +<wxs src="../../../../utils/util.wxs" module="util" />
2 <view bindtap="calendarShow"> 3 <view bindtap="calendarShow">
3 <slot></slot> 4 <slot></slot>
4 </view> 5 </view>
@@ -12,13 +13,12 @@ @@ -12,13 +13,12 @@
12 <view bindtap="calendarClose">{{ddate_solt==1?'午市':ddate_solt==2?'晚市':'早市'}}</view> 13 <view bindtap="calendarClose">{{ddate_solt==1?'午市':ddate_solt==2?'晚市':'早市'}}</view>
13 </view> 14 </view>
14 <view class="flex-ll" style="flex-wrap:wrap"> 15 <view class="flex-ll" style="flex-wrap:wrap">
15 - <view class="time-item {{item.hasChecked?'checked':''}}" 16 + <view class="time-item {{index==dur_list_checked?'checked':''}}"
16 style="{{(index+1)%3==0?'margin-right:0;':''}}" 17 style="{{(index+1)%3==0?'margin-right:0;':''}}"
17 - wx:for="{{list}}" wx:key="listkey"  
18 - bindtap="bindTimePickerChange" 18 + wx:for="{{dur_list}}" wx:key="listkey"
  19 + catchtap="bindTimePickerChange"
19 data-index="{{index}}" 20 data-index="{{index}}"
20 - data-time="{{item.time}}"  
21 - >{{item}}</view> 21 + >{{util.unixtoTime(item.time,"HH:II")}}</view>
22 </view> 22 </view>
23 </view> 23 </view>
24 </view> 24 </view>
@@ -22,30 +22,28 @@ Component({ @@ -22,30 +22,28 @@ Component({
22 * 组件的属性列表 22 * 组件的属性列表
23 */ 23 */
24 properties: { 24 properties: {
25 - date:{//YYYY-MM-DD  
26 - type:String,  
27 - value:'',  
28 - },  
29 - ddate:{//到店时间  
30 - type:Number,  
31 - value:-1,  
32 - } 25 +
33 }, 26 },
34 lifetimes: { 27 lifetimes: {
35 attached: function () { 28 attached: function () {
36 - //console.log('add-time-dur.attached') 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.config=null
  33 + this.ddate_solt=-1
  34 + this.date=event.date
  35 + this.dateIndex=event.dateIndex
  36 + this.dur_time=event.dur_time
  37 + this.type=this.type
  38 + this.initSolt()//初始化solt
  39 + })
37 }, 40 },
38 moved: function () { }, 41 moved: function () { },
39 - detached: function () { },  
40 - },  
41 - observers:{  
42 - "date":async function(date){  
43 - console.log('add-time-dur.observers',arguments)  
44 - this.config=null  
45 - this.ddate_solt=-1  
46 - this.initSolt()//初始化solt  
47 - } 42 + detached: function () {
  43 + PubSub.off('add-time-dur')
  44 + },
48 }, 45 },
  46 + observers:{},
49 /** 47 /**
50 * 组件的初始数据 48 * 组件的初始数据
51 */ 49 */
@@ -69,14 +67,16 @@ Component({ @@ -69,14 +67,16 @@ Component({
69 let daily = res.data.daily; 67 let daily = res.data.daily;
70 console.log('add-time-dur.daily',daily) 68 console.log('add-time-dur.daily',daily)
71 this.initUserTime(daily) 69 this.initUserTime(daily)
72 - this.trigger(); 70 + setTimeout(()=>{
  71 + this.trigger();
  72 + },0)
73 }, 73 },
74 initUserTime(daily){ 74 initUserTime(daily){
75 let config=[] 75 let config=[]
76 - let time=parseInt(new Date()/1000);  
77 - let datetime=util.unixtoTime(time,"YYYY-MM-DD,HH:II").split(',') 76 + let datetime=util.unixtoTime(this.dur_time,"YYYY-MM-DD,HH:II").split(',')
78 let TODAY=datetime[0] 77 let TODAY=datetime[0]
79 let HHII=datetime[1] 78 let HHII=datetime[1]
  79 + this.ddate_solt=-1
80 timeSort.forEach((en_name,ti)=>{ 80 timeSort.forEach((en_name,ti)=>{
81 let dur=daily[en_name]; 81 let dur=daily[en_name];
82 let min='',max='',hasShow=false,hasDisabled=false,hasChecked=false 82 let min='',max='',hasShow=false,hasDisabled=false,hasChecked=false
@@ -85,11 +85,11 @@ Component({ @@ -85,11 +85,11 @@ Component({
85 dur=dur.split('-'); 85 dur=dur.split('-');
86 min=dur[0]; 86 min=dur[0];
87 max=dur[1]; 87 max=dur[1];
88 - if(HHII>=min && HHII<=max){ 88 + if(HHII<=max && this.ddate_solt==-1){
89 hasChecked=true 89 hasChecked=true
90 this.ddate_solt=ti 90 this.ddate_solt=ti
91 } 91 }
92 - if(HHII>max && this.data.date==TODAY){ 92 + if(HHII>max && this.dateIndex==0){//灰掉今天过期时间
93 hasDisabled=true 93 hasDisabled=true
94 } 94 }
95 } 95 }
@@ -105,12 +105,11 @@ Component({ @@ -105,12 +105,11 @@ Component({
105 }); 105 });
106 }) 106 })
107 this.config=config; 107 this.config=config;
108 - console.log('add-time-dur.initUserTime',this.config[0].hasDisabled) 108 + console.log('add-time-dur.initUserTime',this.ddate_solt,this.config)
109 this.setData({ 109 this.setData({
110 config:this.config, 110 config:this.config,
111 ddate_solt:this.ddate_solt, 111 ddate_solt:this.ddate_solt,
112 }) 112 })
113 - console.log('add-time-dur.initUserTime',this.data.config[0].hasDisabled)  
114 }, 113 },
115 selectedValue(e){ 114 selectedValue(e){
116 console.log('add-time-dur.selectedValue',e) 115 console.log('add-time-dur.selectedValue',e)
@@ -127,46 +126,43 @@ Component({ @@ -127,46 +126,43 @@ Component({
127 }, 126 },
128 initTimeSpaceIndex(){//对选中时段进行展开 127 initTimeSpaceIndex(){//对选中时段进行展开
129 if(this.ddate_solt<0) return; 128 if(this.ddate_solt<0) return;
130 - console.log('add-time-dur.tindex',this.ddate_solt,this.config[this.ddate_solt])  
131 let min=this.config[this.ddate_solt].min 129 let min=this.config[this.ddate_solt].min
132 let max=this.config[this.ddate_solt].max 130 let max=this.config[this.ddate_solt].max
133 let defTime=this.config[this.ddate_solt].defTime 131 let defTime=this.config[this.ddate_solt].defTime
134 - let time  
135 - if(this.data.ddate>0){  
136 - time=parseInt(this.data.ddate);  
137 - }else{  
138 - time=parseInt(new Date()/1000);  
139 - } 132 + let time=this.dur_time
140 min=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+min+":00")) 133 min=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+min+":00"))
141 max=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+max+":00")) 134 max=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+max+":00"))
142 - if(defTime && !this.data.ddate){//非修改时,优先默认时间 135 + if(defTime && this.type!=1){//非修改时,优先默认时间
143 defTime=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+defTime+":00")) 136 defTime=util.timetouUnix(util.unixtoTime(time,"YYYY-MM-DD "+defTime+":00"))
144 - if(defTime>time){ 137 + if(defTime>time || this.dateIndex>0){
145 time=defTime 138 time=defTime
146 } 139 }
147 } 140 }
148 - let dur,timeCheckedIndex=0,list=[]; 141 +
  142 + let dur,timeCheckedIndex=-1,list=[];
149 for(dur=parseInt(min);dur<=max;dur+=1800){ 143 for(dur=parseInt(min);dur<=max;dur+=1800){
150 let t={ 144 let t={
151 hasChecked:time<=dur, 145 hasChecked:time<=dur,
152 time:dur, 146 time:dur,
153 - //timeStr:util.unixtoTime(dur,"YYYY-MM-DD HH:II:SS") 147 + disabled:this.dateIndex==0,//disabled 今天过期时间?
154 } 148 }
155 list.push(t) 149 list.push(t)
156 if(dur<=time){ 150 if(dur<=time){
157 timeCheckedIndex++ 151 timeCheckedIndex++
158 } 152 }
159 } 153 }
160 - console.log('add-time-dur.tindex',timeCheckedIndex,list) 154 + console.log('add-time-dur.tindex',list,timeCheckedIndex)
161 return {list:list,listIndex:timeCheckedIndex} 155 return {list:list,listIndex:timeCheckedIndex}
162 }, 156 },
163 trigger(){ 157 trigger(){
164 let timeList=this.initTimeSpaceIndex() 158 let timeList=this.initTimeSpaceIndex()
165 let data={ 159 let data={
166 ddate_solt:this.ddate_solt, 160 ddate_solt:this.ddate_solt,
167 - ...timeList, 161 + dur_list:timeList.list,
  162 + dur_list_checked:timeList.listIndex,
168 } 163 }
169 //this.triggerEvent('event',data) 164 //this.triggerEvent('event',data)
  165 + console.log('dur-items.trigger',data)
170 PubSub.emit('dur-items',data) 166 PubSub.emit('dur-items',data)
171 } 167 }
172 } 168 }
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 App from '../../../utils/api'; 3 import App from '../../../utils/api';
  4 +const formTpl = {
  5 + rid: '',
  6 + pnum: 6,
  7 + tabid: 0,
  8 +
  9 + rname: '',
  10 + phone: '',
  11 + sex: 1,
  12 + cusdem: '',
  13 +
  14 + tid: [],
  15 +
  16 +}
4 Page({ 17 Page({
5 /** 18 /**
6 * 页面的初始数据 19 * 页面的初始数据
7 */ 20 */
8 data: { 21 data: {
9 - nowtime:0,//当前时间戳,或修改到店,或桌位预订时间  
10 - date:'',//当前选择的日期 22 + type:1, // type 1/2/3 新增/修改/桌位
  23 + time:0,//当前时间戳,或修改到店,或桌位预订时间
  24 + form: JSON.parse(JSON.stringify(formTpl)),
  25 + tables: [],
  26 + grand: [
  27 + {
  28 + sex: 1,
  29 + grand_title: '先生',
  30 + isselect: true
  31 + },
  32 + {
  33 + sex: 2,
  34 + grand_title: '女士',
  35 + isselect: false
  36 + },
  37 + {
  38 + sex: 3,
  39 + grand_title: '公司',
  40 + isselect: false
  41 + }
  42 + ],
  43 + buttonhide: true,
  44 + tablesLength: 0,
  45 + pnumInputFocus: false,
  46 + pageMarginBottom: 0,
  47 + speciallist: [],
  48 + CustomRemark:[],
  49 + CustomRemarkMoreMask:false,
11 }, 50 },
  51 + reserve_id: '',
  52 + checkedTables:{},//已选中的桌子集合
12 /** 53 /**
13 * 生命周期函数--监听页面加载 54 * 生命周期函数--监听页面加载
14 */ 55 */
15 onLoad: async function (options) { 56 onLoad: async function (options) {
16 this.options=options 57 this.options=options
  58 + this.sellerid = util.cache('enter_params')['seller_id'];
  59 + this.getCustomRemark();
17 if(options.id>0){ 60 if(options.id>0){
18 //修改 61 //修改
19 return; 62 return;
@@ -23,7 +66,8 @@ Page({ @@ -23,7 +66,8 @@ Page({
23 return; 66 return;
24 } 67 }
25 this.setData({ 68 this.setData({
26 - nowtime:parseInt(new Date()/1000) 69 + time:parseInt(new Date()/1000),
  70 + type:1
27 }) 71 })
28 }, 72 },
29 73
@@ -75,25 +119,314 @@ Page({ @@ -75,25 +119,314 @@ Page({
75 onShareAppMessage: function () { 119 onShareAppMessage: function () {
76 120
77 }, 121 },
78 - //日期选择通知  
79 - addDateEvent(e){  
80 - //console.log('addDateEvent',e.detail)  
81 - //{checked: 1, checkedTime: 123456790} 122 + //到店时间选择通知
  123 + addTimeDurItemsEvent(e){
  124 + //{time: 1577788200, ddate_solt: 2, timeDur: "1577786400-1577804400"}
  125 + console.log('addTimeDurItemsEvent',e.detail,util.unixtoTime(e.detail.time))
  126 + this.time=e.detail.time
  127 + this.ddate_solt=e.detail.ddate_solt
  128 + this.timeDur=e.detail.timeDur//预订所在时段区间时间戳
82 this.setData({ 129 this.setData({
83 - date:util.unixtoTime(e.detail.checkedTime,'YYYY-MM-DD') 130 + ...e.detail,
84 }) 131 })
  132 + this.getTables();
85 }, 133 },
86 - //时段选择通知  
87 - addTimeDurEvent(e){  
88 - //console.log('addTimeDurEvent',e.detail)  
89 - //{ddate_solt: 1, list: Array(9), listIndex: 4} 134 + getCustomRemark(){
  135 + App.User.GetCustomRemark({
  136 + uid:util.cache('enter_params')['manager_id'],
  137 + }).then(res=>{
  138 + let CustomRemark=[];
  139 + res.data.forEach(r=>{
  140 + if(r.often_use){
  141 + CustomRemark.push(r);
  142 + }
  143 + })
  144 + this.setData({
  145 + CustomRemark:CustomRemark,
  146 + })
  147 + })
90 }, 148 },
91 - //到店时间选择通知  
92 - addTimeDurItemsEvent(e){  
93 - //{time: 1577689200, ddate_solt: 1}  
94 - //console.log('addTimeDurItemsEvent',e.detail) 149 + oftenUse(e){
  150 + let id=util.attr(e,'id');
  151 + let val=util.attr(e,'value');
  152 + let CustomRemark=this.data.CustomRemark;
  153 + let form=this.data.form;
  154 + CustomRemark.forEach(r=>{
  155 + if(id==r.id){
  156 + if(r.active){
  157 + form.cusdem=form.cusdem.replace(val+'、','')
  158 + }
  159 + r.active=!r.active
  160 + if(r.active){
  161 + form.cusdem+=val+'、'
  162 + }
  163 + }
  164 + })
95 this.setData({ 165 this.setData({
96 - ...e.detail, 166 + CustomRemark:CustomRemark,
  167 + form:form,
  168 + })
  169 + this.conditionInfo()
  170 + },
  171 + CustomRemarkMore(){
  172 + this.setData({
  173 + CustomRemarkMoreMask:!this.data.CustomRemarkMoreMask
  174 + })
  175 + },
  176 + conditionInfo: function () {
  177 + var form = this.data.form
  178 + if (form.tid.length > 0 && form.rname.length > 0) {
  179 + this.data.buttonhide = false;
  180 + }
  181 + this.setData({
  182 + buttonhide: this.data.buttonhide
  183 + })
  184 + },
  185 +
  186 + async getTables(){
  187 + let form = this.data.form;
  188 + let tableid = util.cache('tableid');
  189 + console.log('getTables-tableid', tableid.length, this.reserve_id);
  190 + //if (tableid.length < 1 && this.reserve_id) {
  191 + if (tableid.length < 1) {
  192 + tableid = this.data.form.tid;
  193 + }
  194 + console.log('getTables-tableid', tableid, tableid.length);
  195 + try {
  196 + App.Reserve.GetTableList({
  197 + sid: util.cache('enter_params')['seller_id'],
  198 + //pnum_str:form.pnum_str,
  199 + pnum: form.pnum,
  200 + rdate: util.unixtoTime(this.time,'YYYYMMDD'),
  201 + tid: form.tabid,
  202 + rid: this.reserve_id,
  203 + ddate_solt:this.ddate_solt
  204 + }).then(res => {
  205 + let tables = [];
  206 + let tablesLength = 0;
  207 + if (tableid.length > 0) {
  208 + let toastTables={...this.checkedTables}
  209 + let resData=res.data.slice(1,res.data.length);
  210 + console.log('resData',resData)
  211 + resData.forEach(p => {
  212 + //if(tables.length>=3) return true;
  213 + p.list.forEach(t => {
  214 + delete toastTables[t.id]
  215 + tablesLength++;
  216 + if (tables.length >= 3) return true;
  217 + if (tableid._indexOf(t.id) > -1) {
  218 + t.isselect = true;
  219 + tables.push(t);
  220 + }
  221 + })
  222 + })
  223 + console.log('toastTables',toastTables,this.data.form.tid,this.checkedTables);
  224 + //清理已选中的桌位
  225 + let toastTablesInfo=[];
  226 + let tid=this.data.form.tid
  227 + Object.keys(this.checkedTables).forEach(ckid=>{
  228 + if(toastTables[ckid]){
  229 + delete this.checkedTables[ckid]
  230 + tid.remove(ckid);
  231 + toastTablesInfo.push(toastTables[ckid]);
  232 + }
  233 + })
  234 + if(toastTablesInfo.length>0){
  235 + this.setData({
  236 + [`form.tid`]:tid,
  237 + })
  238 + util.toast(toastTablesInfo.toString()+'已被占用啦','none');
  239 + }
  240 + wx.removeStorage({key: 'tableid'})
  241 + }
  242 + console.log('tables-first',tables);
  243 + if(tables.length<1){
  244 + tablesLength=0;
  245 + let fortids=[];
  246 + res.data.forEach((p,ri) => {
  247 + p.list.forEach(t => {
  248 + if(fortids._indexOf(t.id)<0) {
  249 + tablesLength++;
  250 + tables.push(t);
  251 + fortids.push(t.id);
  252 + }
  253 + })
  254 + })
  255 + if (tables.length >= 3) {
  256 + tables = tables.slice(0, 3);
  257 + }
  258 + }
  259 + this.tablesLength = tablesLength;
  260 + this.setData({
  261 + tables: tables,
  262 + tablesLength: tablesLength
  263 + })
  264 + this.conditionInfo();
  265 + })
  266 + } catch (e) {
  267 + this.setData({
  268 + tables: []
  269 + })
  270 + }
  271 + },
  272 + selectphone: function (e) {
  273 + this.data.form.phone = e.detail.phone;
  274 + this.data.form.rname = e.detail.rname;
  275 + this.data.form.cusdem = e.detail.cusdem;
  276 + var form = this.data.form
  277 + this.data.form.sex = e.detail.sex;
  278 + this.setData({
  279 + form: this.data.form,
  280 + searchlist: null
  281 + })
  282 + this.conditionInfo();
  283 + },
  284 + selectdesk(){
  285 + wx.navigateTo({
  286 + url: 'b_desk?rdate=' + this.time + '&tid=' + this.data.form.tabid
  287 + //+'&pnum_str='+this.data.form.pnum_str
  288 + + '&pnum=' + this.data.form.pnum
  289 + + '&checked_tids=' + this.data.form.tid
  290 + + '&rid=' + this.reserve_id
  291 + + '&ddate_solt='+this.ddate_solt
97 }) 292 })
98 }, 293 },
  294 + selectedValue(e){
  295 + console.log(e);
  296 + let key = util.attr(e, 'key');
  297 + let val;
  298 + let sobj = {};
  299 + if (e.type == 'input' || e.type == 'confirm') {
  300 + val = util.val(e);
  301 + if (key == 'phone') {
  302 + var that = this;
  303 + if (e.detail.value != '' && e.detail.value.length >= 3) {
  304 + App.Reserve.GetReserveUser(
  305 + {
  306 + keywords: e.detail.value,
  307 + sid: this.sellerid
  308 + }
  309 + ).then(function (json) {
  310 + if (json.ret == 200 && json.data.length > 0) {
  311 + that.setData({
  312 + searchlist: json.data
  313 + })
  314 + } else {
  315 + that.setData({
  316 + searchlist: null
  317 + })
  318 + }
  319 + })
  320 + } else {
  321 + this.setData({
  322 + searchlist: null
  323 + })
  324 + }
  325 + }
  326 + if (key == 'pnum') {
  327 + sobj.pnumInputFocus = true;
  328 + }
  329 + } else {
  330 + val = util.attr(e, 'value');
  331 + }
  332 +
  333 +
  334 + let form = this.data.form;
  335 +
  336 + if (key == 'tid') {
  337 + let ts = this.data.tables;
  338 + if (ts[val].isselect) {
  339 + ts[val].isselect = false;
  340 + form.tid.remove(ts[val].id);
  341 + delete this.checkedTables[ts[val].id]
  342 + } else {
  343 + ts[val].isselect = true;
  344 + form.tid.push(ts[val].id);
  345 + this.checkedTables[ts[val].id]=ts[val].name
  346 + }
  347 + sobj.tables = ts;
  348 + } else {
  349 + form[key] = val;
  350 + }
  351 + console.log('ts', sobj.tables,this.checkedTables);
  352 + //console.log(e.type,key,val,form);
  353 + sobj.form = form;
  354 + sobj.buttonhide = this.data.buttonhide;
  355 + if (form.tid.length > 0 && form.rname.length > 0){
  356 + sobj.buttonhide = false;
  357 + }else{
  358 + sobj.buttonhide = true;
  359 + }
  360 + let displayTimes = false;
  361 +
  362 + if ('pnum,pnum_str,tabid'.indexOf(key) > -1) {
  363 + if (!displayTimes) {
  364 + this.getTables();
  365 + }
  366 + }
  367 +
  368 + this.setData(sobj)
  369 + },
  370 +
  371 + async formsubmit(){
  372 + if (this.data.buttonhide) return;
  373 + try {
  374 + this.setData({
  375 + buttonhide: true,
  376 + })
  377 + let form = JSON.parse(JSON.stringify(this.data.form));
  378 + console.log('typeof form.tid', typeof form.tid);
  379 + if (typeof form.tid == 'object') {
  380 + let tid = new Set(form.tid);//tid 去重
  381 + form.tid = [...tid].toString();
  382 + }
  383 + if(this.ddate_solt<0){
  384 + return util.toast('请选择时段', 'none');
  385 + }
  386 + if (!form.tid) {
  387 + return util.toast('请选择桌子', 'none');
  388 + }
  389 + if (!form.rname) {
  390 + return util.toast('请填写预订人', 'none');
  391 + }
  392 + form.sid = this.sellerid;
  393 + //form.rdate = rdate
  394 +
  395 + try {
  396 + let enter_params = util.cache('enter_params');
  397 + let sc = (await App.Reserve.SellerInfo(enter_params)).data
  398 + let note_openid = enter_params.seller_openid;
  399 + let note_name = sc.seller_user.nick_name || sc.seller_user.nickname;
  400 + form.note_openid = note_openid || '';
  401 + if (form.rid) {//修改时传递uid
  402 + form.note_openid = enter_params.manager_id || '';
  403 + }
  404 + form.note_name = note_name || '';
  405 + } catch (e) {}
  406 +
  407 + form.ddate = this.time;
  408 + form.ddate_solt=this.ddate_solt
  409 + form.is_set_ddate=1
  410 + App.Reserve.SetReserveInfo(form).then(res => {
  411 + if (res.ret == 200) {
  412 + this.getCustomRemark()
  413 + let _id = (res.data.id || res.data)
  414 + this.setData({
  415 + form: JSON.parse(JSON.stringify(formTpl)),
  416 + tables: [],
  417 + timePickerIndex: [0, 0, 0],
  418 + })
  419 + this.initLoad();
  420 + this.checkedTables={};
  421 + App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
  422 + wx.navigateTo({
  423 + url: util.http_build_query({id:_id,tplid:1},'b_invitation'),
  424 + });
  425 + } else {
  426 + util.toast(res.msg, 'none')
  427 + }
  428 + })
  429 + } catch (e) {
  430 + }
  431 + },
99 }) 432 })
@@ -5,8 +5,9 @@ @@ -5,8 +5,9 @@
5 "usingComponents": { 5 "usingComponents": {
6 "nav":"/components/nav/nav", 6 "nav":"/components/nav/nav",
7 "tabBar":"../../components/book/tabBar/tabBar", 7 "tabBar":"../../components/book/tabBar/tabBar",
8 - "add-date": "../../components/book/time/add-date",  
9 "board":"../../components/book/board/board", 8 "board":"../../components/book/board/board",
  9 + "searchList":"/components/searchlist/searchlist",
  10 + "add-date": "../../components/book/time/add-date",
10 "add-time-dur":"../../components/book/time/add-time-dur", 11 "add-time-dur":"../../components/book/time/add-time-dur",
11 "add-time-dur-items":"../../components/book/time/add-time-dur-items" 12 "add-time-dur-items":"../../components/book/time/add-time-dur-items"
12 } 13 }
@@ -2,12 +2,12 @@ @@ -2,12 +2,12 @@
2 <wxs src="../../../utils/util.wxs" module="util" /> 2 <wxs src="../../../utils/util.wxs" module="util" />
3 <nav>录入订座信息</nav> 3 <nav>录入订座信息</nav>
4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page"> 4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page">
5 - <view class="base-info" wx:if="{{nowtime}}"> 5 + <view class="base-info" wx:if="{{time}}">
6 <view class="section"> 6 <view class="section">
7 - <add-date nowtime="{{nowtime}}" bindevent="addDateEvent"></add-date> 7 + <add-date time="{{time}}" type="{{type}}"></add-date>
8 </view> 8 </view>
9 - <view class="section" wx:if="{{date}}">  
10 - <add-time-dur date="{{date}}" ddate="{{detail.ddate||''}}" bindevent="addTimeDurEvent"></add-time-dur> 9 + <view class="section">
  10 + <add-time-dur></add-time-dur>
11 </view> 11 </view>
12 <view class="section" style="height: 90rpx;"> 12 <view class="section" style="height: 90rpx;">
13 <view class="tab flex-lr"> 13 <view class="tab flex-lr">
@@ -73,7 +73,9 @@ @@ -73,7 +73,9 @@
73 <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">
74 <add-time-dur-items 74 <add-time-dur-items
75 bindevent="addTimeDurItemsEvent" 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> 76 + style="font-size: 34rpx;height: 100rpx;line-height: 100rpx;">
  77 + {{util.unixtoTime(time,'HH:II')}}
  78 + </add-time-dur-items>
77 </view> 79 </view>
78 <block wx:if="{{searchlist}}"> 80 <block wx:if="{{searchlist}}">
79 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList> 81 <searchList searchlist="{{searchlist}}" bind:selectphone="selectphone"></searchList>
@@ -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());