diff --git a/packageA/pages/my_service2/appment_main.js b/packageA/pages/my_service2/appment_main.js index 458fa0c..ed5dba1 100644 --- a/packageA/pages/my_service2/appment_main.js +++ b/packageA/pages/my_service2/appment_main.js @@ -53,6 +53,9 @@ Page({ wp:[], datet:null, s_top:0, + + cur_sele_i:-1, + cur_sele_j:-1 }, //控制备注输入 @@ -605,48 +608,7 @@ Page({ write: position }); }, - - touchend:function(e){ - var that = this,th=that; - if(!that.data.copy_btn) return false; - var position =th.data.write; - var arr=th.data.col_arr; - for(var i=0;ith.data.f_x+i*th.data.f_width && position[0]th.data.f_y +j*th.data.f_hei && position[1]1){ + wx.showToast({ + title: '当前项目预约次数已超出项目剩余数,请先修改', icon: 'none', duration: 2000 + }); + return false; + } + wx.showModal({ + title: "当前项目已有预约是否修改?", + success: function (res) { + if(res.confirm){ + delete th.data.v[i][sj]; + if(!th.data.v[i]) + th.data.v[i]={} + th.data.v[i][j]=th.data.sele_project; + var ind=arr.indexOf(sj); + arr.splice(ind, 1); + arr.push(j); + th.setData({ + v: th.data.v,col_arr:arr + }); + + } + } + }) + return false; + }else{ + var txt="v["+i+"]["+j+"]"; + arr.push(j); + th.setData({ + [txt]: th.data.sele_project, + col_arr:arr + }); + return false; + } + }) + } } + } - th.checK_is_can_yy(item,tn,function(){ - - var txt="v["+i+"]["+j+"]"; - arr.push(j); - th.setData({ - [txt]: th.data.sele_project, - col_arr:arr - }); + th.checK_is_can_yy(item,tn,function(res){ + if(res){ + if(res>1){ + wx.showToast({ + title: '当前项目预约次数已超出项目剩余数,请先修改', icon: 'none', duration: 2000 + }); + return false; + } + + wx.showModal({ + title: "当前项目已有预约是否修改?", + success: function (res) { + if(res.confirm){ + + var ii=th.data.cur_sele_i; + var jj=th.data.cur_sele_j; + delete th.data.v[ii][jj]; + if(!th.data.v[i]) + th.data.v[i]={} + th.data.v[i][j]=th.data.sele_project; + var ind=arr.indexOf(jj); + arr.splice(ind, 1); + arr.push(j); + th.setData({ + v: th.data.v,col_arr:arr + }); + } + } + }) + + }else{ + var txt="v["+i+"]["+j+"]"; + arr.push(j); + th.setData({ + [txt]: th.data.sele_project, + col_arr:arr + }); + } + + + }); }, + + + + //删除响应的预约 close_this:function (e){ var txt=e.currentTarget.dataset.txt; @@ -764,58 +776,65 @@ Page({ onPageScroll(e) { this.data.scrolltop = e.scrollTop;}, //确认有没有预约 - checK_is_can_yy(item,tn,back){ - var th=this; - var req={ - beauticianId:encodeURIComponent(item.staffid), - seekTime:this.data.datet+" "+tn+":00", - serviceId:encodeURIComponent(this.data.sele_project.ServiceID), - storageId:encodeURIComponent(this.data.storageId), - storeId:os.stoid - } - getApp().request.get("/api/weshop/marketing/reservation/can/reservation/countnew",{ - data:req, - success:function(res){ - th.setData({copy_btn:0}); - if(res.data.code==0){ - if(!th.data.v){ back(); return false; } - - var arr = Object.keys(th.data.v); - if(arr.length==0){ back(); return false; } - - var num=0; - for(var i in th.data.v){ - if(!th.data.v[i]) continue; - for(var j in th.data.v[i]){ - if(th.data.v[i][j] && th.data.v[i][j].ProjectID==th.data.sele_project.ProjectID){ - num++; - } - } - } - - if(!num){ back(); return false; } - - //如果已经超出次数的时候,就不能预约了 - if(num>=parseInt(res.data.data.CanReservation) ){ - wx.showToast({ - title: "已经超出可预约次数", - icon: 'none', - duration: 2000 - }) - return false; + checK_is_can_yy(item, tn, back) { + var th = this; + var req = { + beauticianId: encodeURIComponent(item.staffid), + seekTime: this.data.datet + " " + tn + ":00", + serviceId: encodeURIComponent(this.data.sele_project.ServiceID), + storageId: encodeURIComponent(this.data.storageId), + storeId: os.stoid + } + getApp().request.get("/api/weshop/marketing/reservation/can/reservation/countnew", { + data: req, + success: function (res) { + th.setData({ copy_btn: 0 }); + if (res.data.code == 0) { + if (!res.data.data.CanReservation && parseInt(res.data.data.canReservation) <= 0) { + wx.showToast({ + title: '该项目不可以预约', icon: 'none', duration: 2000 + }); + return false; + } + + if (!th.data.v) { back(); return false; } + + var arr = Object.keys(th.data.v); + if (arr.length == 0) { back(); return false; } + + var num = 0; + var sele_arr=[]; + for (var i in th.data.v) { + if (!th.data.v[i]) continue; + for (var j in th.data.v[i]) { + if (th.data.v[i][j] && th.data.v[i][j].ProjectID == th.data.sele_project.ProjectID) { + num++; + th.data.cur_sele_i=i; + th.data.cur_sele_j=j; + } + } + } + + if (!num) { back(); return false; } + + //如果已经超出次数的时候,就不能预约了 + if (num >= parseInt(res.data.data.CanReservation)) { + + back(num); + return false; + } + back(); + + } else { + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 2000 + }) } - back(); - - }else{ - wx.showToast({ - title: res.data.msg, - icon: 'none', - duration: 2000 - }) - } - } - }) - }, + } + }) + }, //声明节点查询的方法 queryMultipleNodes: function() {