Commit 5a8e257f22419c021a47a79b8b991f029234d0f7

Authored by wangfan
1 parent 097258a8

v2 time

@@ -3,6 +3,21 @@ import util from '../../utils/util'; @@ -3,6 +3,21 @@ import util from '../../utils/util';
3 import comm from '../../utils/bookCommon'; 3 import comm from '../../utils/bookCommon';
4 import App from '../../utils/api'; 4 import App from '../../utils/api';
5 const {regeneratorRuntime} = global 5 const {regeneratorRuntime} = global
  6 +const formTpl={
  7 +
  8 + date:0,
  9 + time:0,
  10 + pnum_str:'1-4',
  11 + tabid:0,
  12 +
  13 + rname:'',
  14 + phone:'',
  15 + sex:1,
  16 + cusdem:'',
  17 +
  18 + tid:[],
  19 +
  20 +}
6 Page({ 21 Page({
7 22
8 /** 23 /**
@@ -10,21 +25,7 @@ Page({ @@ -10,21 +25,7 @@ Page({
10 */ 25 */
11 data: { 26 data: {
12 dateStr:[], 27 dateStr:[],
13 - form:{  
14 -  
15 - date:0,  
16 - time:0,  
17 - pnum_str:'1-4',  
18 - tabid:0,  
19 -  
20 - rname:'',  
21 - phone:'',  
22 - sex:1,  
23 - cusdem:'',  
24 -  
25 - tid:[],  
26 -  
27 - }, 28 + form:JSON.parse(JSON.stringify(formTpl)),
28 tables:[], 29 tables:[],
29 grand:[ 30 grand:[
30 { 31 {
@@ -58,11 +59,13 @@ Page({ @@ -58,11 +59,13 @@ Page({
58 /** 59 /**
59 * 生命周期函数--监听页面加载 60 * 生命周期函数--监听页面加载
60 */ 61 */
61 - onLoad: function (options) { 62 + onLoad: async function (options) {
62 this.setDateStr(); 63 this.setDateStr();
63 this.sellerid=util.cache('sellerid'); 64 this.sellerid=util.cache('sellerid');
64 - this.getTables()  
65 - comm.getDayTimeSpace(); 65 + let timePickerArray= await comm.getDayTimeSpace();
  66 + this.setData({
  67 + timePickerArray: timePickerArray,
  68 + })
66 }, 69 },
67 /** 70 /**
68 * 71 *
@@ -90,6 +93,7 @@ Page({ @@ -90,6 +93,7 @@ Page({
90 * 生命周期函数--监听页面显示 93 * 生命周期函数--监听页面显示
91 */ 94 */
92 onShow: function () { 95 onShow: function () {
  96 + this.getTables();
93 setTimeout(()=>{ 97 setTimeout(()=>{
94 this.setData({ 98 this.setData({
95 calendarMaskLoad:true, 99 calendarMaskLoad:true,
@@ -222,7 +226,10 @@ Page({ @@ -222,7 +226,10 @@ Page({
222 async formsubmit(){ 226 async formsubmit(){
223 if(this.data.buttonhide) return; 227 if(this.data.buttonhide) return;
224 try { 228 try {
225 - let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time); 229 + let stimestr=this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];
  230 + console.log('stimestr', stimestr,this.data.form.time,this.data.timePickerIndex);
  231 + let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
  232 + this.data.form.time,stimestr);
226 console.log('rdate', rdate); 233 console.log('rdate', rdate);
227 this.setData({ 234 this.setData({
228 buttonhide: true, 235 buttonhide: true,
@@ -233,6 +240,9 @@ Page({ @@ -233,6 +240,9 @@ Page({
233 form.rdate =rdate 240 form.rdate =rdate
234 App.Reserve.SetReserveInfo(form).then(res => { 241 App.Reserve.SetReserveInfo(form).then(res => {
235 if(res.ret==200){ 242 if(res.ret==200){
  243 + this.setData({
  244 + form:JSON.parse(JSON.stringify(formTpl))
  245 + })
236 wx.navigateTo({ 246 wx.navigateTo({
237 url:'b_detail?id='+res.data.id, 247 url:'b_detail?id='+res.data.id,
238 }); 248 });
@@ -45,7 +45,7 @@ module.exports ={ @@ -45,7 +45,7 @@ module.exports ={
45 return timedate; 45 return timedate;
46 }, 46 },
47 //获得营业时段时间戳,用 - 链接 47 //获得营业时段时间戳,用 - 链接
48 - async getTimeSpace(mmdd='',timeIndex=0,sc=null){ 48 + async getTimeSpace(mmdd='',timeIndex=0,stimestr=null,sc=null){
49 try { 49 try {
50 let d=new Date()/1000; 50 let d=new Date()/1000;
51 if(!mmdd){ 51 if(!mmdd){
@@ -61,7 +61,12 @@ module.exports ={ @@ -61,7 +61,12 @@ module.exports ={
61 let ti=['morning','noon','night']; 61 let ti=['morning','noon','night'];
62 let ts=sc.daily[ti[timeIndex]].split('-'); 62 let ts=sc.daily[ti[timeIndex]].split('-');
63 console.log(ts); 63 console.log(ts);
64 - let stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[0]+':00'); 64 + let stime
  65 + if(stimestr){
  66 + stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+stimestr);
  67 + }else{
  68 + stime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[0]+':00');
  69 + }
65 console.log(stime); 70 console.log(stime);
66 let etime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[1]+':00'); 71 let etime=util.unixtoTime(d,'YYYY-'+mmdd+' '+ts[1]+':00');
67 return util.timetouUnix(stime)+'-'+util.timetouUnix(etime); 72 return util.timetouUnix(stime)+'-'+util.timetouUnix(etime);
@@ -72,7 +77,7 @@ module.exports ={ @@ -72,7 +77,7 @@ module.exports ={
72 return false; 77 return false;
73 }, 78 },
74 //获得早中晚时间分组, 79 //获得早中晚时间分组,
75 - async getDayTimeSpace(step=30,sc=null){ 80 + async getDayTimeSpace(sc=null){
76 try { 81 try {
77 let d=new Date()/1000; 82 let d=new Date()/1000;
78 if(!sc){ 83 if(!sc){
@@ -85,11 +90,21 @@ module.exports ={ @@ -85,11 +90,21 @@ module.exports ={
85 ti.forEach((tx,ii)=>{ 90 ti.forEach((tx,ii)=>{
86 let ts=sc.daily[tx].split('-'); 91 let ts=sc.daily[tx].split('-');
87 console.log(ts); 92 console.log(ts);
88 - // while (ts[0]<ts[1]){  
89 - // dts[ii].push(ts[0]);  
90 - //  
91 - // } 93 + while (ts[0]<=ts[1]){
  94 + dts[ii].push(ts[0]);
  95 + let _dt=ts[0].split(':');
  96 + if(_dt[1]=='30'){
  97 + _dt[0]=parseInt(_dt[0])+1;
  98 + _dt[1]='00';
  99 + }else{
  100 + _dt[0]=parseInt(_dt[0])+0;
  101 + _dt[1]='30';
  102 + }
  103 + _dt[0]=_dt[0]<10?'0'+_dt[0]:_dt[0];
  104 + ts[0]=_dt.join(':');
  105 + }
92 }) 106 })
  107 + return dts;
93 } 108 }
94 }catch (e){ 109 }catch (e){
95 console.log(e); 110 console.log(e);