Sfoglia il codice sorgente

feat: 新增大会员购买使用优惠券

cuiyalong 3 anni fa
parent
commit
6bce608970

+ 5 - 11
src/web/staticres/big-member/css/pc_buy_commit.css

@@ -292,16 +292,6 @@ input[type="radio"] {
   margin-top: 40px;
 }
 
-.page--big--buycommit .main_footer .should_pay {
-  display: flex;
-  justify-content: flex-end;
-  align-items: center;
-  padding-right: 20px;
-  width: 100%;
-  height: 64px;
-  background: #F5F5FB;
-}
-
 .page--big--buycommit .main_footer .should_pay .original_price {
   margin-right: 24px;
   text-decoration: line-through;
@@ -504,7 +494,11 @@ input[type="radio"] {
   justify-content: space-between;
 }
 .sticky-footer .main_footer .should_pay {
-  height: unset;
+  display: flex;
+  justify-content: flex-end;
+  align-items: center;
+  padding: 16px 20px;
+  width: 100%;
   background-color: transparent;
   order: 2;
   flex: 4;

+ 7 - 0
src/web/staticres/js/coupon/coupon.js

@@ -104,6 +104,10 @@ var vComponent = {
       this.showPopver = false
       this.check = true
       this.coupon = this.couponList[this.selectIndex].reduce
+
+      try {
+        window.refreshStickyInfo && window.refreshStickyInfo()
+      } catch (error) {}
     },
     getList: function () {
       var _this = this
@@ -133,6 +137,9 @@ var vComponent = {
           } else {
             _this.couponList = []
           }
+          try {
+            window.refreshStickyInfo && window.refreshStickyInfo()
+          } catch (error) {}
         }).fail(function () {
           _this.couponList = []
         })

+ 130 - 86
src/web/templates/big-member/pc/page_buy_commit.html

@@ -20,6 +20,7 @@
     type="text/css" />
   <link href='{{Msg "seo" "cdn"}}/big-member/css/page_index.css?v={{Msg "seo" "version"}}' rel="stylesheet"
     type="text/css" />
+  <link rel="stylesheet" type="text/css" href='{{Msg "seo" "cdn"}}/css/coupon/coupon.css?v={{Msg "seo" "version"}}'/>
   <!--S-手机号输入样式-->
   <style>
     .order-phone-group {
@@ -198,7 +199,7 @@
           <div class="main_meal">
             <div class="meal_content">
               <div class="meal_title">选择会员套餐</div>
-              <div class="setmeal meal_sj active" mealdata="6">
+              <div class="setmeal meal_sj active" mealdata="6" production-id="1045">
                 <div class="meal_top">
                   <div class="edition">商机版2.0</div>
                   <div class="edition_price">
@@ -257,7 +258,7 @@
                   </div>
                 </div>
               </div>
-              <div class="setmeal meal_zj" mealdata="7">
+              <div class="setmeal meal_zj" mealdata="7" production-id="1046">
                 <div class="meal_top">
                   <div class="edition">专家版2.0</div>
                   <div class="edition_price">
@@ -340,15 +341,10 @@
           <!--E-手机号输入-->
 
           <div class="main_footer basic-sticky">
-            <div class="should_pay">
-              <div class="original_price">
-                原价:¥19,999
-              </div>
-              <div class="should_price">
-                应付总额:
-                <span class="should_num">¥15,999</span>
-              </div>
+            <div class="pc-coupon-w1200">
+              <pc-coupon-component  ref="pcCoupon"></pc-coupon-component>
             </div>
+            
             <div class="read_agren">
               <input type="checkbox" class="agren_ipt" disabled="disabled" />
               <span class="agren_text">我已阅读,理解并接受<span class="agren_link">《剑鱼标讯线上购买与服务条款》</span></span>
@@ -551,10 +547,11 @@
         <div class="main_footer w1200">
           <div class="should_pay">
             <div class="original_price">
-              原价:¥19,999
+              商品总价:
+              <span class="original_num">¥19,999</span>
             </div>
             <div class="should_price">
-              应付总额:
+              实付金额:
               <span class="should_num">¥15,999</span>
             </div>
           </div>
@@ -576,6 +573,9 @@
   <script src=//cdn-common.jianyu360.com/cdn/lib/vue/2.6.11/vue.min.js> </script>
   <script src='{{Msg "seo" "cdn"}}/js/jquery.cookie.js?v={{Msg "seo" "version"}}' type="text/javascript"></script>
   <script src='{{Msg "seo" "cdn"}}/js/swiper.min.js'></script>
+
+  <script src=//cdn-common.jianyu360.com/cdn/lib/vue/2.6.11/vue.min.js></script>
+  <script src='{{Msg "seo" "cdn"}}/js/coupon/coupon.js?v={{Msg "seo" "version"}}'></script>
   <script>
   var vNode = {
         delimiters: ['@@', '@@'],
@@ -622,7 +622,18 @@
             }
             vNode.data.SCFX.push(dataArr)
           })
-          console.log(this.SCFX)
+        },
+        mounted () {
+          window.windowScrollFn && window.windowScrollFn()
+        },
+        methods: {
+          getValue: function () {
+            return this.$refs.pcCoupon.getValue()
+          },
+          // 初始化优惠券列表
+          refreshProductionId: function (data) {
+            this.$refs.pcCoupon.setValue(data)
+          },
         }
       }
     var vm = new Vue(vNode)
@@ -747,6 +758,68 @@
         }
     });
 
+    // 参数
+    var getParams = {
+      level: 6,
+      cycle: 1
+    }
+    var sjbsPrice = 0,
+      sjafPrice = 0,
+      zjbsPrice = 0,
+      zjafPrice = 0
+
+    // 金额用逗号隔开
+    function numFormat(num) {
+      var c = (num.toString().indexOf('.') !== -1) ? num.toLocaleString() : num.toString().replace(
+        /(\d)(?=(?:\d{3})+$)/g, '$1,');
+      return c;
+    }
+
+    // 确定购买原价
+    function getPayPrice(n, m) {
+      var beforeprice = 0
+      var beforeall = 0
+      if (n == 6) {
+        beforeprice = sjbsPrice
+      } else if (n == 7) {
+        beforeprice = zjbsPrice
+      }
+      return beforeall = beforeprice * m
+    }
+
+    // 确定折扣价格
+    function getDisPrice(n, m) {
+      var afterprice = 0
+      var afterall = 0
+      if (n == 6) {
+        afterprice = sjafPrice
+      } else if (n == 7) {
+        afterprice = zjafPrice
+      }
+      return afterall = afterprice * m
+    }
+
+    //获取url参数
+    function getParam(name) {
+      var search = document.location.search;
+      // alert(search);
+      var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
+      var matcher = pattern.exec(search);
+      var items = null;
+      if (null != matcher) {
+        try {
+          items = decodeURIComponent(decodeURIComponent(matcher[1]));
+        } catch (e) {
+          try {
+            items = decodeURIComponent(matcher[1]);
+          } catch (e) {
+            items = matcher[1];
+          }
+        }
+      }
+      return items;
+    };
+
     // 是否某个dom有部分离开当前屏
     function isDOMLeave (el) {
       if (!el) return
@@ -866,16 +939,6 @@
         }
       })
 
-
-      // 参数
-      var getParams = {
-        level: 6,
-        cycle: 1
-      }
-      var sjbsPrice = 0,
-          sjafPrice = 0,
-          zjbsPrice = 0,
-          zjafPrice = 0
       $.ajax({
         type: 'POST',
         url: '/jypay/bigmember/price',
@@ -910,8 +973,8 @@
               zjbsPrice = num
             }
           })
-          $('.should_num').html('¥' + numFormat(getDisPrice(getParams.level, getParams.cycle)))
-          $('.original_price').html('原价:¥' + numFormat(getPayPrice(getParams.level, getParams.cycle)))
+          refreshCouponInfo()
+          refreshStickyInfo()
         },
         error: function(err) {
           console.log(err)
@@ -928,8 +991,8 @@
         } else if (numbers == 7) {
           sessionStorage.setItem('pc_big_buy_type', '7')
         }
-        $('.should_num').html('¥' + numFormat(getDisPrice(getParams.level, getParams.cycle)))
-        $('.original_price').html('原价:¥' + numFormat(getPayPrice(getParams.level, getParams.cycle)))
+        refreshCouponInfo()
+        refreshStickyInfo()
       })
       var buyType = sessionStorage.getItem('pc_big_buy_type') || '6'
       sessionStorage.removeItem('pc_big_buy_type')
@@ -947,65 +1010,13 @@
         } else if (cycles == 3) {
           sessionStorage.setItem('pc_big_buy_year', '2')
         }
-        $('.should_num').html('¥' + numFormat(getDisPrice(getParams.level, getParams.cycle)))
-        $('.original_price').html('原价:¥' + numFormat(getPayPrice(getParams.level, getParams.cycle)))
+        refreshCouponInfo()
+        refreshStickyInfo()
       })
       var buyYears = sessionStorage.getItem('pc_big_buy_year') || '0'
       sessionStorage.removeItem('pc_big_buy_year')
       $(".setyear").eq(buyYears).trigger('click')
 
-      // 确定购买原价
-      function getPayPrice(n, m) {
-        var beforeprice = 0
-        var beforeall = 0
-        if (n == 6) {
-          beforeprice = sjbsPrice
-        } else if (n == 7) {
-          beforeprice = zjbsPrice
-        }
-        return beforeall = beforeprice * m
-      }
-
-      // 确定折扣价格
-      function getDisPrice(n, m) {
-        var afterprice = 0
-        var afterall = 0
-        if (n == 6) {
-          afterprice = sjafPrice
-        } else if (n == 7) {
-          afterprice = zjafPrice
-        }
-        return afterall = afterprice * m
-      }
-
-      // 金额用逗号隔开
-      function numFormat(num) {
-        var c = (num.toString().indexOf('.') !== -1) ? num.toLocaleString() : num.toString().replace(
-          /(\d)(?=(?:\d{3})+$)/g, '$1,');
-        return c;
-      }
-
-      //获取url参数
-      function getParam(name) {
-        var search = document.location.search;
-        // alert(search);
-        var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
-        var matcher = pattern.exec(search);
-        var items = null;
-        if (null != matcher) {
-          try {
-            items = decodeURIComponent(decodeURIComponent(matcher[1]));
-          } catch (e) {
-            try {
-              items = decodeURIComponent(matcher[1]);
-            } catch (e) {
-              items = matcher[1];
-            }
-          }
-        }
-        return items;
-      };
-
       // 确认支付
       $('.go_pay').on('click', function () {
         if (!loginflag) {
@@ -1013,14 +1024,27 @@
         }
         var paramsMid = getParam('mid')
         var paramsUnit = getParam('unit')
-        $.ajax({
-          type: 'POST',
-          url: '/jypay/bigmember/createOrder',
+        var pcCouponInfo = vm.$refs.pcCoupon.getValue()
+        var lotteryId = ''
+        if (pcCouponInfo) {
+          lotteryId = pcCouponInfo.lotteryId
+        }
+        
+        var params = {
+          product: '大会员',
+          productId: $('.setmeal.active').attr('production-id'),
           data: {
             level: getParams.level,
             cycle: getParams.cycle,
-            order_phone: OrderPhoneCheck.phone
-          },
+            order_phone: OrderPhoneCheck.phone,
+            lotteryId: lotteryId
+          }
+        }
+        $.ajax({
+          type: 'POST',
+          url: '/jypay/common/createorder',
+          contentType: 'application/json',
+          data: JSON.stringify(params),
           success: function (res) {
             // 采购单位画像引流
             if (paramsUnit && res.data && res.data.order_code) {
@@ -1088,7 +1112,27 @@
         window.open('/front/staticPage/serviceterms.html')
       })
       windowScrollFn()
+
+      function refreshCouponInfo () {
+        vm.refreshProductionId({
+          id: $('.setmeal.active').attr('production-id'),
+          price: getDisPrice(getParams.level, getParams.cycle),
+          show: true
+        })
+      }
     })
+
+    function refreshStickyInfo () {
+      // $('.should_num').html('¥' + numFormat(getDisPrice(getParams.level, getParams.cycle)))
+      // $('.original_num').html('原价:¥' + numFormat(getPayPrice(getParams.level, getParams.cycle)))
+      setTimeout(function () {
+        var total = $('.pc-coupon-w1200 .original_price .text--money').text()
+        var pay = $('.pc-coupon-w1200 .should_pay .text--money').text()
+
+        $('.sticky-footer .original_price .original_num').text(total)
+        $('.sticky-footer .should_price .should_num').text(pay)
+      }, 0)
+    }
   </script>
   <!--S-百度统计-->
   {{include "/common/pcbottom.html"}}