Parcourir la source

Merge branch 'hlg/20220512' of http://code.qutaovip.com/lihai/pad_spa into lihai

黎海 il y a 2 ans
Parent
commit
f5b8596482
2 fichiers modifiés avec 21417 ajouts et 52 suppressions
  1. 21167 37
      package-lock.json
  2. 250 15
      src/pages/confirmOrder/details/index.vue

Fichier diff supprimé car celui-ci est trop grand
+ 21167 - 37
package-lock.json


+ 250 - 15
src/pages/confirmOrder/details/index.vue

@@ -131,17 +131,37 @@
131 131
             </div>
132 132
             <div class="on-icon">></div>
133 133
           </div>
134
-          <div v-if="order_data.coupon_list&&order_data.coupon_list.length>0">
134
+
135
+
136
+          <!-- <div v-if="order_data.coupon_list&&order_data.coupon_list.length>0">
135 137
             <div class="coupon-ps"
136 138
                  v-for="item,index in order_data.coupon_list"
137 139
                  :key="index">
138 140
               <div>{{item.coupon_name}}</div>
139 141
               <div class="cou-price">-¥{{price}}</div>
140 142
             </div>
143
+          </div> -->
144
+
145
+          <div v-if="1==1">
146
+            <div class="coupon-ps"
147
+                 v-for="item,index in isSelectCoup"
148
+                 :key="index">
149
+              <div>{{item.coupon_name}}</div>
150
+      <div class="cou-price" v-if="item.type==4?true:false">抵扣{{item.projectName}}</div>
151
+      <div class="cou-price" v-if="item.type==3?true:false">抵扣全部项目(除升级包)</div>
152
+      <div class="cou-price" v-if="item.type==2?true:false">¥{{item.price}}</div>
153
+      <div class="cou-price" v-if="item.type==1?true:false">¥{{item.price}}</div>
154
+                    <!-- <div class="cou-price">-¥{{price}}</div> -->
155
+            </div>
141 156
           </div>
157
+
158
+
159
+
160
+
161
+
142 162
         </div>
143 163
         <div class="over-price">
144
-          合计: <span class="price-num"><span class="min-size">¥</span>399<span class="min-size">.00</span></span>
164
+          合计: <span class="price-num"><span class="min-size">¥</span>{{showMoney}}<span class="min-size"></span></span>
145 165
         </div>
146 166
       </div>
147 167
       <div class="payment"
@@ -158,9 +178,13 @@
158 178
           <li class="coupon-info"
159 179
               v-for="item,index in couponList"
160 180
               :key="index">
161
-            <div class="coupon-tips-text">{{item.type==1?'无条件抵扣券':item.type==2?'满减券':item.type==3?'全额券':'项目全减券'}}</div>
181
+  <!-- 1: '抵扣券',
182
+      2: '满减券',
183
+      3: '全额减免券',
184
+      4: '项目卡券' -->
185
+            <div class="coupon-tips-text">{{item.type==1?'抵扣券':item.type==2?'满减券':item.type==3?'全额减免券':'项目卡券'}}</div>
162 186
             <div class="top">
163
-              <div v-if="item.type!=2"
187
+              <div v-if="item.type==3"
164 188
                    class="discount-over">全免</div>
165 189
               <div v-else
166 190
                    class="discount">
@@ -172,7 +196,7 @@
172 196
                 <div class="tips-ts">有效期至{{item.ex_time}}</div>
173 197
               </div>
174 198
               <div class="choice-icon"
175
-                   @click="selectPupop(item,index)"><img :src="item.Select?select:unSelect"></div>
199
+                   @click="selectPupop(item,index)"><img :src="item.isSelect?select:unSelect"></div>
176 200
             </div>
177 201
             <div class="bottom">
178 202
               <div class="coupon-notes"
@@ -382,7 +406,19 @@ export default {
382 406
       isChange: false,//项目是否有改变
383 407
       isEditProject: false,//是否编辑项目
384 408
       page: 1,
385
-      limit: 20,
409
+      limit: 200,
410
+
411
+
412
+
413
+
414
+    needSelect: false,
415
+    coupSelectType: '',
416
+    productDiscount: '',
417
+    isSelectCoup: [], // 选择的优惠券
418
+    // 下面是支付的数据
419
+    showMoney: 0, // 价值总额
420
+    // showRuleText: 10086,
421
+
386 422
     };
387 423
   },
388 424
   computed: {
@@ -398,6 +434,7 @@ export default {
398 434
         this.remarks = res.data.remark
399 435
         this.programmeList = res.data.scheme_list
400 436
         this.order_data = res.data.order_data
437
+        this.showMoney=res.data.order_data.price
401 438
         this.poreList = res.data.detail_list
402 439
         this.calculationPrice()
403 440
       })
@@ -582,6 +619,12 @@ export default {
582 619
     },
583 620
     //获取订单优惠券
584 621
     onCoupon () {
622
+
623
+      if(this.couponList.length>0){
624
+         this.isCoupun = true
625
+         return
626
+      }
627
+
585 628
       let params = {
586 629
         id: this.id,
587 630
         page: this.page,
@@ -590,29 +633,221 @@ export default {
590 633
       api.getOrderCoupon(params).then(res => {
591 634
         this.couponList = [...this.couponList, ...res.data.list]
592 635
         this.couponList.forEach(item => {
593
-          this.$set(item, 'Select', false)
636
+          this.$set(item, 'isSelect', false)
594 637
         })
595 638
         this.page++
596 639
         if (this.couponList.length < res.data.total) {
597 640
           this.onCoupon()
598 641
         }
599 642
       })
643
+      console.log(this.couponList)
600 644
       this.isCoupun = true
601 645
     },
646
+
647
+
602 648
     //数组包含关系
603 649
     includes (arr1, arr2) {
604 650
       return arr2.every(val => arr1.includes(val));
605 651
     },
606 652
     //选中优惠券
607
-    selectPupop (item, index) {
608
-      this.couponList[index].Select = !this.couponList[index].Select
609
-      this.selectCouponList = this.couponList.filter(res => {
610
-        return res.Select == true
611
-      })
612
-      this.selectCouponList.forEach(res => {
613
-      })
653
+    // selectPupop (item, index) {
654
+    //   this.couponList[index].Select = !this.couponList[index].Select
655
+    //   this.selectCouponList = this.couponList.filter(res => {
656
+    //     return res.Select == true
657
+    //   })
658
+    //   this.selectCouponList.forEach(res => {
659
+    //   })
660
+
661
+    // },
662
+
663
+
664
+// 不可以用的不显示,如果同时有项目劵、抵扣劵、满减劵,只能用一种类型,其他劵不显示
665
+// 1、针对单个项目,项目劵可以多选
666
+// 2、抵扣劵、满减劵针对的是整个订单,当用户已使用了单个项目劵时,抵扣劵、满减劵就不能使用
667
+// 3、优惠劵可以给多个项目抵扣,
668
+// 4、默认抵扣金额最高的
669
+// 5、优惠劵排序,到期时间倒叙
670
+
671
+
672
+/**
673
+   * 点击使用按钮、勾选按钮
674
+   */
675
+  selectPupop: function (item, index) {
676
+
677
+
678
+    let CouPonIndex = this.couponList
679
+
680
+    let selectIndex = index
681
+    let curreValue = !CouPonIndex[selectIndex].isSelect
682
+    let project_list = this.order_data.project_list //这里是项目列表
683
+
684
+    // 判断是否是不相同的项目券
685
+    if (this.couponList[selectIndex].type != 4) {
686
+      for (let i = 0; i < CouPonIndex.length; i++) {
687
+        CouPonIndex[i].isSelect = false
688
+      }
689
+      for (let i = 0; i < project_list.length; i++) {
690
+        project_list[i].cardId = ''
691
+      }
692
+
693
+    } else if (this.coupSelectType != 4) {
694
+      for (let i = 0; i < CouPonIndex.length; i++) {
695
+        CouPonIndex[i].isSelect = false
696
+      }
697
+      for (let i = 0; i < project_list.length; i++) {
698
+        project_list[i].cardId = ''
699
+      }
700
+    } else {
701
+      let numberSelect = 0
702
+      for (let i = 0; i < CouPonIndex.length; i++) {
703
+        if (CouPonIndex[i].isSelect) {
704
+          numberSelect = numberSelect + 1
705
+        }
706
+      }
707
+      console.log('numberSelect')
708
+      console.log(numberSelect)
709
+      if (numberSelect == this.order_data.project_list.length && curreValue) {
710
+            this.$message.error('最多选择' + this.order_data.project_list.length + '项目券!');
711
+        return
712
+      }
713
+    }
714
+    // 判断是否是取消选择项目券
715
+    CouPonIndex[selectIndex].isSelect = curreValue
716
+    if (!curreValue) {
717
+      for (let j = 0; j < project_list.length; j++) {
718
+        if (project_list[j].cardId && project_list[j].cardId == this.couponList[selectIndex].id) { // 如果是取消选择,那么也要取消绑定项目的id
719
+          project_list[j].cardId = ''
720
+        }
721
+      }
722
+      CouPonIndex[selectIndex].projectids = ''
723
+    }
724
+    let orderDetails1 = this.order_data
725
+    orderDetails1.project_list = project_list
726
+
727
+
728
+      this.order_data=orderDetails1
729
+      this.couponList=CouPonIndex
730
+      this.coupSelectType=this.couponList[selectIndex].type
731
+
732
+    console.log(this.order_data)
733
+    console.log(this.couponList)
734
+
735
+    this.selectCoup()
736
+
737
+  },
738
+
739
+// 选择项目进行绑定
740
+  selectCoup() {
741
+    let that = this
742
+    let isSelectCoups = []
743
+    for (let i = 0; i < this.couponList.length; i++) {
744
+      if (this.couponList[i].isSelect) {
745
+        let selectCoup = that.couponList[i]
746
+        isSelectCoups.push(selectCoup)
747
+      }
748
+    }
749
+      this.isSelectCoup=isSelectCoups
750
+    console.log(this.isSelectCoup)
751
+
752
+    // 抵扣顺序按照项目金额计算
753
+    that.theMoneyBest()
754
+  },
755
+
756
+  // 抵扣顺序按照项目金额计算
757
+  // 卡券,项目券数据包,id:订单项目ID,coupon_id:优惠券ID,如:[{"id":1220,coupon_id:199}]  
758
+  theMoneyBest() {
759
+    let that = this
760
+    let project_list = this.order_data.project_list //这里是项目列表
761
+    let isSelectCoup = this.isSelectCoup //这里选择了的卡券列表
762
+    let selectProjectList = [] // 适合的卡券列表
763
+    // let CouPonIndex = this.CouPonIndex // 卡券选择的Id
764
+    let productDiscount = this.couponList // 卡券列表
765
+    console.log(productDiscount)
766
+    // debugger
767
+    if (isSelectCoup[0].type == 4) {
768
+      for (let i = 0; i < isSelectCoup.length; i++) { // 首先遍历卡券
769
+        if (!isSelectCoup[i].projectids) { // 如果卡券没绑定项目
770
+          console.log('没绑定过!')
771
+
772
+          let selectIndexMoney = 0 // 初始值
773
+          let selectIndex = 111 // 初始金额
774
+          for (let j = 0; j < project_list.length; j++) { // 遍历项目
775
+            if (isSelectCoup[i].project_ids.indexOf(project_list[j].id) != -1 && !project_list[j].cardId) { // 如果卡券能够使用这个项目并且这个项目没有被绑定过
776
+              console.log('project_list[j].price')
777
+              console.log(project_list[j].price)
778
+              console.log(selectIndexMoney)
779
+              console.log(project_list[j].price > selectIndexMoney)
780
+              if (project_list[j].price * 1 > selectIndexMoney * 1) {
781
+                selectIndex = j
782
+                selectIndexMoney = project_list[j].price
783
+                console.log('--' + selectIndexMoney)
784
+              }
785
+              // selectProjectList.push(project_list[i])
786
+            }
787
+          }
788
+          if (selectIndex != 111) {
789
+            console.log('走了这里走了这里')
790
+            isSelectCoup[i].projectids = project_list[selectIndex].id
791
+            isSelectCoup[i].projectName = project_list[selectIndex].name
792
+            project_list[selectIndex].cardId = isSelectCoup[i].id
793
+          } else {
794
+            for (let k = 0; k < productDiscount.length; k++) {
795
+              if (productDiscount[k].id == isSelectCoup[i].id) {
796
+                // isSelectCoup.
797
+                productDiscount[k].isSelect = false
798
+                // isSelectCoup.splice(isSelectCoup.length-1,1);
799
+                this.$message.error('没有适合的项目!');
800
+              }
801
+            }
802
+          }
803
+
804
+        }
805
+      }
806
+      let orderDetails1 = this.order_data
807
+      orderDetails1.project_list = project_list
808
+        this.couponList= productDiscount
809
+        this.isSelectCoup= isSelectCoup
810
+        this.order_data= orderDetails1
811
+    }
812
+
813
+    this.calculateMoney() //计算总额
814
+  },
815
+
816
+  // 计算总额
817
+  calculateMoney() {
818
+    let that = this
819
+    let money = this.order_data.price
820
+    let isSelectCoup = this.isSelectCoup
821
+    let project_list = this.order_data.project_list //这里是项目列表
822
+
823
+    if (isSelectCoup.length == 0) {
824
+        this.showMoney=money.toFixed(2)
825
+      return
826
+    }
827
+
828
+    // 如果是项目
829
+    if (isSelectCoup[0].type == 4) {
830
+      for (let i = 0; i < project_list.length; i++) {
831
+        if (project_list[i].cardId) {
832
+          money = money - project_list[i].price
833
+        }
834
+      }
835
+        this.showMoney=money.toFixed(2)
836
+    } else if (isSelectCoup[0].type == 3) {
837
+      for (let i = 0; i < project_list.length; i++) {
838
+        money = money - project_list[i].price
839
+      }
840
+
841
+    } else {
842
+      money = money - isSelectCoup[0].price
843
+    }
844
+
845
+        this.showMoney=money.toFixed(2)
846
+
847
+
848
+  },
849
+
614 850
 
615
-    },
616 851
     changeActive (e) {
617 852
       this.active = e
618 853
     },