Commit 5a491db8fe7d04ee9e8b9bcf95574570e2b42413

Authored by yvan.ni
1 parent 77d548a0

1、项目剩余1次,第二次预约时提示:当前项目已有预约是否修改?是变动,否不变取消;

2、项目剩余多次时,多次预约直至预约次数结束时,提示当前项目预约次数已超出项目剩余数请先修改?
packageA/pages/my_service2/appment_main.js
... ... @@ -53,6 +53,9 @@ Page({
53 53 wp:[],
54 54 datet:null,
55 55 s_top:0,
  56 +
  57 + cur_sele_i:-1,
  58 + cur_sele_j:-1
56 59  
57 60 },
58 61 //控制备注输入
... ... @@ -605,48 +608,7 @@ Page({
605 608 write: position
606 609 });
607 610 },
608   -
609   - touchend:function(e){
610   - var that = this,th=that;
611   - if(!that.data.copy_btn) return false;
612   - var position =th.data.write;
613   - var arr=th.data.col_arr;
614   - for(var i=0;i<this.data.md.length;i++){//i是列
615   - var item=this.data.md[i];
616   -
617   - for(var j=0; j<this.data.timeArr.length;j++){//j是行
618   - if(arr.indexOf(j)!=-1) continue;
619   - var tn=this.data.timeArr[j];
620   -
621   - //如果坐标在网格内
622   - if( position[0]>th.data.f_x+i*th.data.f_width && position[0]<th.data.f_x+ (i+1)*th.data.f_width &&
623   - position[1]>th.data.f_y +j*th.data.f_hei && position[1]<th.data.f_y+(j+1)*th.data.f_hei){
624   -
625   - for(var i in item.listtime){
626   -
627   - //判断一下有没有在时间内,可以不可以预约
628   - if(tn==item.listtime[i].stime && item.listtime[i].iskyy){
629   - th.checK_is_can_yy(item,tn,function(){
630   - var txt="v["+i+"]["+j+"]";
631   - arr.push(j);
632   - th.setData({
633   - [txt]: th.data.sele_project,
634   - col_arr:arr
635   - });
636   -
637   - })
638   - return true
639   - }
640   - }
641   -
642   -
643   - }
644   -
645   - }
646   - }
647   - th.setData({copy_btn:0})
648   - },
649   -
  611 +
650 612 //-- 点击空格选择 --
651 613 sele_tab:function(e){
652 614 if(!this.data.sele_project){
... ... @@ -704,52 +666,102 @@ Page({
704 666 })
705 667 return false;
706 668 }
707   -
708   -
709   -
710   -
711   - //同一美导同一项目,不能选择两次,只能留一个
712   - if(this.data.v[i]){
  669 +
  670 + //同一美导同一项目,能选择两次,只要时间段不重复
  671 + if(this.data.v[i] && Object.keys(this.data.v[i]).length){
713 672 for(var sj in this.data.v[i]){
714   - if(this.data.v[i][sj] && this.data.v[i][sj].ProjectID==this.data.sele_project.ProjectID){
715   - wx.showModal({
716   - title: "您已经预约了同一个项目和导购,要修改吗?",
717   - success: function (res) {
718   - if (res.cancel) {
719   - //点击取消,默认隐藏弹框
720   - } else {
721   - th.checK_is_can_yy(item,tn,function(){
722   - delete th.data.v[i][sj];
723   - th.data.v[i][j]=th.data.sele_project;
724   - var ind=arr.indexOf(sj);
725   - arr.splice(ind, 1),
726   - arr.push(j),
727   - th.setData({
728   - v: th.data.v,
729   - col_arr:arr
730   - });
731   - })
732   -
733   - }
734   - },
735   -
736   - });
737   - return false;
  673 + if(this.data.v[i][sj] && this.data.v[i][sj].ProjectID==this.data.sele_project.ProjectID){
  674 + th.checK_is_can_yy(item,tn,function(res){
  675 + if(res){
  676 + if(res>1){
  677 + wx.showToast({
  678 + title: '当前项目预约次数已超出项目剩余数,请先修改', icon: 'none', duration: 2000
  679 + });
  680 + return false;
  681 + }
  682 + wx.showModal({
  683 + title: "当前项目已有预约是否修改?",
  684 + success: function (res) {
  685 + if(res.confirm){
  686 + delete th.data.v[i][sj];
  687 + if(!th.data.v[i])
  688 + th.data.v[i]={}
  689 + th.data.v[i][j]=th.data.sele_project;
  690 + var ind=arr.indexOf(sj);
  691 + arr.splice(ind, 1);
  692 + arr.push(j);
  693 + th.setData({
  694 + v: th.data.v,col_arr:arr
  695 + });
  696 +
  697 + }
  698 + }
  699 + })
  700 + return false;
  701 + }else{
  702 + var txt="v["+i+"]["+j+"]";
  703 + arr.push(j);
  704 + th.setData({
  705 + [txt]: th.data.sele_project,
  706 + col_arr:arr
  707 + });
  708 + return false;
  709 + }
  710 + })
  711 +
738 712 }
739 713 }
  714 +
740 715 }
741 716  
742   - th.checK_is_can_yy(item,tn,function(){
743   -
744   - var txt="v["+i+"]["+j+"]";
745   - arr.push(j);
746   - th.setData({
747   - [txt]: th.data.sele_project,
748   - col_arr:arr
749   - });
  717 + th.checK_is_can_yy(item,tn,function(res){
  718 + if(res){
  719 + if(res>1){
  720 + wx.showToast({
  721 + title: '当前项目预约次数已超出项目剩余数,请先修改', icon: 'none', duration: 2000
  722 + });
  723 + return false;
  724 + }
  725 +
  726 + wx.showModal({
  727 + title: "当前项目已有预约是否修改?",
  728 + success: function (res) {
  729 + if(res.confirm){
  730 +
  731 + var ii=th.data.cur_sele_i;
  732 + var jj=th.data.cur_sele_j;
  733 + delete th.data.v[ii][jj];
  734 + if(!th.data.v[i])
  735 + th.data.v[i]={}
  736 + th.data.v[i][j]=th.data.sele_project;
  737 + var ind=arr.indexOf(jj);
  738 + arr.splice(ind, 1);
  739 + arr.push(j);
  740 + th.setData({
  741 + v: th.data.v,col_arr:arr
  742 + });
  743 + }
  744 + }
  745 + })
  746 +
  747 + }else{
  748 + var txt="v["+i+"]["+j+"]";
  749 + arr.push(j);
  750 + th.setData({
  751 + [txt]: th.data.sele_project,
  752 + col_arr:arr
  753 + });
  754 + }
  755 +
  756 +
  757 +
750 758 });
751 759 },
752 760  
  761 +
  762 +
  763 +
  764 +
753 765 //删除响应的预约
754 766 close_this:function (e){
755 767 var txt=e.currentTarget.dataset.txt;
... ... @@ -764,58 +776,65 @@ Page({
764 776 onPageScroll(e) { this.data.scrolltop = e.scrollTop;},
765 777  
766 778 //确认有没有预约
767   - checK_is_can_yy(item,tn,back){
768   - var th=this;
769   - var req={
770   - beauticianId:encodeURIComponent(item.staffid),
771   - seekTime:this.data.datet+" "+tn+":00",
772   - serviceId:encodeURIComponent(this.data.sele_project.ServiceID),
773   - storageId:encodeURIComponent(this.data.storageId),
774   - storeId:os.stoid
775   - }
776   - getApp().request.get("/api/weshop/marketing/reservation/can/reservation/countnew",{
777   - data:req,
778   - success:function(res){
779   - th.setData({copy_btn:0});
780   - if(res.data.code==0){
781   - if(!th.data.v){ back(); return false; }
782   -
783   - var arr = Object.keys(th.data.v);
784   - if(arr.length==0){ back(); return false; }
785   -
786   - var num=0;
787   - for(var i in th.data.v){
788   - if(!th.data.v[i]) continue;
789   - for(var j in th.data.v[i]){
790   - if(th.data.v[i][j] && th.data.v[i][j].ProjectID==th.data.sele_project.ProjectID){
791   - num++;
792   - }
793   - }
794   - }
795   -
796   - if(!num){ back(); return false; }
797   -
798   - //如果已经超出次数的时候,就不能预约了
799   - if(num>=parseInt(res.data.data.CanReservation) ){
800   - wx.showToast({
801   - title: "已经超出可预约次数",
802   - icon: 'none',
803   - duration: 2000
804   - })
805   - return false;
  779 + checK_is_can_yy(item, tn, back) {
  780 + var th = this;
  781 + var req = {
  782 + beauticianId: encodeURIComponent(item.staffid),
  783 + seekTime: this.data.datet + " " + tn + ":00",
  784 + serviceId: encodeURIComponent(this.data.sele_project.ServiceID),
  785 + storageId: encodeURIComponent(this.data.storageId),
  786 + storeId: os.stoid
  787 + }
  788 + getApp().request.get("/api/weshop/marketing/reservation/can/reservation/countnew", {
  789 + data: req,
  790 + success: function (res) {
  791 + th.setData({ copy_btn: 0 });
  792 + if (res.data.code == 0) {
  793 + if (!res.data.data.CanReservation && parseInt(res.data.data.canReservation) <= 0) {
  794 + wx.showToast({
  795 + title: '该项目不可以预约', icon: 'none', duration: 2000
  796 + });
  797 + return false;
  798 + }
  799 +
  800 + if (!th.data.v) { back(); return false; }
  801 +
  802 + var arr = Object.keys(th.data.v);
  803 + if (arr.length == 0) { back(); return false; }
  804 +
  805 + var num = 0;
  806 + var sele_arr=[];
  807 + for (var i in th.data.v) {
  808 + if (!th.data.v[i]) continue;
  809 + for (var j in th.data.v[i]) {
  810 + if (th.data.v[i][j] && th.data.v[i][j].ProjectID == th.data.sele_project.ProjectID) {
  811 + num++;
  812 + th.data.cur_sele_i=i;
  813 + th.data.cur_sele_j=j;
  814 + }
  815 + }
  816 + }
  817 +
  818 + if (!num) { back(); return false; }
  819 +
  820 + //如果已经超出次数的时候,就不能预约了
  821 + if (num >= parseInt(res.data.data.CanReservation)) {
  822 +
  823 + back(num);
  824 + return false;
  825 + }
  826 + back();
  827 +
  828 + } else {
  829 + wx.showToast({
  830 + title: res.data.msg,
  831 + icon: 'none',
  832 + duration: 2000
  833 + })
806 834 }
807   - back();
808   -
809   - }else{
810   - wx.showToast({
811   - title: res.data.msg,
812   - icon: 'none',
813   - duration: 2000
814   - })
815   - }
816   - }
817   - })
818   - },
  835 + }
  836 + })
  837 + },
819 838  
820 839 //声明节点查询的方法
821 840 queryMultipleNodes: function() {
... ...