Explorar el Código

feat: 微信端续费、升级满赠满折活动

yangfeng hace 4 años
padre
commit
13e7c56f11

+ 4 - 2
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_purchase.html

@@ -1069,7 +1069,7 @@
                   $('.computed_price').html(showPrice);
                   $('.discount-price .dis-price').text(formatMoney(givePrice))
                 }
-                console.log(price, '计算的价格')
+                // console.log(price, '计算的价格')
                 var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
                 if (!size) {
                   goodsOrder.updatePrice(price) // 更新提交订单组件价格
@@ -1077,7 +1077,9 @@
                     goodsCoupon.updatePrice(price) // 更新商品优惠券价格(查询优惠券)
                   })
                 } else {
-
+                  purchase.getGiftList(function(){
+                    goodsCoupon.updatePrice(size.price) // 更新商品优惠券价格(查询优惠券)
+                  })
                 }
               }
             },

+ 132 - 24
src/web/staticres/vipsubscribe/js/vip_renew.js

@@ -131,6 +131,62 @@ var renew = {
     calcPrice: function (timeSelect) {
         return Calculation.GetTotal(undefined, timeSelect ? timeSelect : this.timeSelect)
     },
+    // 获取当前选择的商品有无满赠活动
+    getGiftList: function(callback) {
+      var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size')) || {}
+      console.log(size)
+      if (!size || Object.keys(size).length == 0) {
+        size.period = '1年'
+      }
+      var pId;
+      var _this = this
+      switch (size.period) {
+        case '1月':
+          pId = 1012
+          break;
+        case '1季':
+          pId = 1013
+          break;
+        case '1年':
+          pId = 1014
+          break;
+      }
+      goodsSize.props.giftCycle = null // 下次请求前将满赠周期清掉 请求成功后再赋值
+      // 先查有没有满赠
+      $.ajax({
+        type:'POST',
+        url:'/jyCoupon/giveInfo',
+        data:{
+          useProduct: pId,
+          useProductType: 0 // 商品类型 0普通的  1线上课程(除线上课程以外的都是0)
+        },
+        success:function(res) {
+          if(res.data && res.data.length > 0) {
+            res.data.forEach(function(item) {
+              // 处理展示文字(天、月、年)
+              if(item.timeType == 1) {
+                item.time = item.time + '天'
+              } else if (item.timeType == 2 && item.time < 12) {
+                item.time = item.time + '个月'
+              } else if (item.timeType == 2 && item.time == 12) {
+                item.time = '1年'
+              }
+              // 将赠品信息传递给商品订单提交子组件
+              goodsOrder.giftName = item.name // 满赠商品名称
+              goodsOrder.giftId = item.discountId // 满赠id
+              goodsSize.props.defaultSize.time = item.time
+              goodsSize.props.giftCycle = item.time
+            })
+          } else {
+            // 没有满赠活动再执行其他回调(优惠券)
+            callback && callback()
+          }
+        },
+        error:function(err) {
+          console.log(err)
+        }
+      })
+    },
     // 设置价格
     setPrice: function (price) {
         this.price = parseInt(price)
@@ -141,23 +197,35 @@ var renew = {
           // 新规则初始化价格
           if (size) {
             // 初始化上次选择的商品规格
-            coupon.updatePrice(size.price / 100)
+            goodsOrder.updatePrice(size.price / 100)
+            // 查有无满赠活动 有满赠不再请求优惠券接口
+            renew.getGiftList(function(){
+              goodsCoupon.updatePrice(size.price / 100)
+            })
             // 校验本次选择的周期是否达到3年的最大限制
             renew.checkOver3Years(goodsSize.getTimeSelect(size.period))
           } else {
             // 初始化默认一年*省份数量或全国价格
             sessionStorage.removeItem('$select-coupon')
             if (count >= 16) {
-              coupon.updatePrice(599900 / 100)
+              goodsOrder.updatePrice(599900 / 100)
+              renew.getGiftList(function(){
+                goodsCoupon.updatePrice(599900 / 100)
+              })
             } else {
-              coupon.updatePrice(38000*count / 100)
+              goodsOrder.updatePrice(38000*count / 100)
+              renew.getGiftList(function(){
+                goodsCoupon.updatePrice(38000*count / 100)
+              })
             }
             // 校验本次选择的周期是否达到3年的最大限制
             renew.checkOver3Years(goodsSize.getTimeSelect('1年'))
           }
         } else {
-          // 旧规则初始化价格
-          coupon.updatePrice(this.price / 100)
+            // 旧规则初始化订单价格
+            goodsOrder.updatePrice(this.price / 100)
+            // 旧规则初始化自动领券 旧规则无满赠活动可直接领券
+            goodsCoupon.updatePrice(this.price / 100)
         }
     },
     // 根据选中结果得到续费了多长时间的字符串
@@ -308,11 +376,11 @@ var renew = {
     flushSubmit: function () {
         if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true" && !this.isMaxTime) {
             $('.vip-footer.renew .confirm').prop('disabled', false)
-            coupon.checkboxStatus = true
-            coupon.$refs.couponRef.submitStatus = false
+            goodsOrder.checkboxStatus = true
+            goodsOrder.$refs.couponRef.submitStatus = false
         } else {
             $('.vip-footer.renew .confirm').prop('disabled', true)
-            coupon.$refs.couponRef.submitStatus = true
+            goodsOrder.$refs.couponRef.submitStatus = true
         }
     },
     initClickEvents: function () {
@@ -346,12 +414,12 @@ var renew = {
             console.log(upgrade,sizeTime, '新or老')
             //支付请求
             var data = {
-                userLotteryId :coupon.$refs.couponRef.coupon.userLotteryId,
-                lotteryId : coupon.$refs.couponRef.coupon.lotteryId,
+                userLotteryId :goodsCoupon.curSelectCoupon.userLotteryId,
+                lotteryId : goodsCoupon.curSelectCoupon.lotteryId,
                 time : upgrade == 0 ? _this.getDuration(_this.timeSelect).trim() : sizeTime,
                 orderType: 5,
                 disWord :GetQueryString('disWord'),
-                price: coupon.initPrice*10000/100
+                price: goodsOrder.initPrice*10000/100
             }
             $.ajax({
                 // url: '/subscribepay/vipsubscribe/createOrder',
@@ -577,13 +645,12 @@ var goodsSize = new Vue({
       props: {
         defaultSize: {},
         areaCount: 1,
-        priceInfo: {}
+        priceInfo: {},
+        giftCycle: null // 满赠周期
       }
     }
   },
-  created () {
-    
-  },
+  created () {},
   mounted () {
     this.getSizeStorage()
   },
@@ -612,7 +679,7 @@ var goodsSize = new Vue({
         this.$refs.goodsSize.goodsActive = size.index
         this.defaultSize = size
         this.$nextTick(function(){
-          coupon.updatePrice(size.price/100)
+          goodsOrder.updatePrice(size.price/100)
         })
       } else {
         // 默认选择1年
@@ -624,7 +691,11 @@ var goodsSize = new Vue({
       renew.checkOver3Years(this.getTimeSelect(data.period))
       sessionStorage.removeItem('$select-coupon')
       this.defaultSize = data
-      coupon.updatePrice(data.price/100)
+      goodsOrder.updatePrice(data.price/100)
+      // 查询有无满赠,无满赠执行回调查优惠券
+      renew.getGiftList(function(){
+        goodsCoupon.updatePrice(data.price/100)
+      })
     },
     getTimeSelect: function(data) {
       var time;
@@ -639,14 +710,39 @@ var goodsSize = new Vue({
           time = [1,1]
           break;
       }
-      console.log(time)
       return time
     }
   }
 })
+// vip优惠券
+var goodsCoupon = new Vue({
+  el:'#goods-coupon-vue',
+  data: function() {
+    return {
+      curSelectCoupon: {}
+    }
+  },
+  mounted () {},
+  methods: {
+    updatePrice: function(data){
+      this.$refs.goodsCoupon.getCoupon(data)
+    },
+    updateCoupon: function(data) {
+      console.log(data, '更新优惠券选择')
+      this.curSelectCoupon = data
+      var curSize = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
+      // 更新优惠券选择同时更新订单组件的价格及优惠金额
+      if (curSize) {
+        goodsOrder.updatePrice(curSize.price/100)
+      } else {
+        goodsOrder.updatePrice(goodsOrder.initPrice)
+      }
+    }
+  }
+})
 // 订单提交组件
-var coupon = new Vue({ 
-  el: '#coupon-vue',
+var goodsOrder  = new Vue({ 
+  el: '#goods-order-vue',
   data: function () {
     return {
       type: 'vip',
@@ -663,7 +759,10 @@ var coupon = new Vue({
         ],
         buttons: {
           submit: this.submitOrder
-        }
+        },
+        hideCoupon: true,
+        giftName: '', // 赠品名称
+        giftId: '' // 赠品id
     }
   },
   mounted () {
@@ -672,10 +771,19 @@ var coupon = new Vue({
   methods: {
     // 更新价格相关
     updatePrice: function (before) {
-      console.log( '原价:' + before)
+      var curCoupon = JSON.parse(sessionStorage.getItem('vip-cur-select-coupon'))
+      // 处理优惠金额 主要作用为展示优惠明细弹框立得优惠金额
+      if (curCoupon) {
+        if(curCoupon.lotteryAttribute == '折扣券') {
+          // disCount为折扣率 优惠金额 = 原价*优惠了多少比例(100 - disCount)
+          this.$refs.couponRef.coupon.value = Number(before*((100 - curCoupon.disCount)/100)).toFixed(2)
+        } else if (curCoupon.lotteryAttribute == '满减券') {
+          this.$refs.couponRef.coupon.value = curCoupon.reduce
+        }
+      } else {
+        this.$refs.couponRef.coupon.value = 0
+      }
       this.initPrice = before;
-      // 调用子组件查询最优卡券
-      this.$refs.couponRef.getCoupon();
     },
     // 初始化及回显相关
     init: function () {},

+ 66 - 27
src/web/staticres/vipsubscribe/js/vip_upgrade.js

@@ -95,20 +95,6 @@ var purchase = {
           }
         }
       }, false)
-      var areaSelect = JSON.parse(sessionStorage.getItem('vipSubSelectArea'))
-      var industrySelect = JSON.parse(sessionStorage.getItem('vipSubSelectIndustry'))
-      var endTime = sessionStorage.getItem('endTime')
-      var readSelect = sessionStorage.getItem('vipSub_read') === 'true' ? true : false
-      if (readSelect) {
-        coupon.checkboxStatus = true
-      }
-      // console.log(areaSelect && industrySelect && readSelect,'22222',coupon.$refs.couponRef.submitStatus)
-      if (areaSelect && industrySelect && readSelect) {
-        coupon.$refs.couponRef.submitStatus = false
-        // console.log(coupon.$refs.couponRef.submitStatus)
-      } else {
-        coupon.$refs.couponRef.submitStatus = true
-      }
     } catch (e) {
       console.log(e)
     }
@@ -281,7 +267,9 @@ var purchase = {
       $('.now-price .dis-price').text(formatMoney(price));
     }
     this.flushSelectTime(times, flag === undefined ? 1 : flag);
-    coupon.updatePrice(Number(price) < 0 ? 0 : price)
+    // 更新优惠券、订单价格
+    goodsOrder.updatePrice(Number(price) < 0 ? 0 : price)
+    goodsCoupon.updatePrice(Number(price) < 0 ? 0 : price)
   },
   flushSelectTime(thisValue, flag) {
     if (this.endTime) {
@@ -339,11 +327,12 @@ var purchase = {
   flushSubmit() {//是否可提交
     if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true") {
       $('.vip-footer.renew .confirm').prop('disabled', false)
-      console.log(coupon.initPrice, 'coupon.initPrice')
+      goodsOrder.checkboxStatus = true
+      goodsOrder.$refs.couponRef.submitStatus = false
       if (!$('.error-update-tips').is(':hidden')) {
-        coupon.$refs.couponRef.submitStatus = true
+        goodsOrder.$refs.couponRef.submitStatus = true
       } else {
-        coupon.$refs.couponRef.submitStatus = false
+        goodsOrder.$refs.couponRef.submitStatus = false
       }
     } else {
       $('.vip-footer.renew .confirm').prop('disabled', true)
@@ -583,12 +572,12 @@ $(function () {
     }
     //付费用户
     var param = {
-      "userLotteryId":coupon.$refs.couponRef.coupon.userLotteryId,
-      "lotteryId": coupon.$refs.couponRef.coupon.lotteryId,
+      "userLotteryId":goodsCoupon.curSelectCoupon.userLotteryId,
+      "lotteryId": goodsCoupon.curSelectCoupon.lotteryId,
       "area": flag ? JSON.stringify(area) : '',
       'area_count': flag ? 0 : areaCount,
       // "industry": industry.join(","),
-      'price': parseInt(coupon.initPrice*10000/100),
+      'price': parseInt(goodsOrder.initPrice*10000/100),
       // "time": purchase.timeValue.trim(),
       // "orderType": 5,
       "activeCode": activeCodes,
@@ -712,8 +701,29 @@ document.body.addEventListener("focusout", function () {
 })
 
 /* vue 代码 start */
-var coupon = new Vue({ 
-  el: '#coupon-vue',
+// 商品优惠券
+var goodsCoupon = new Vue({
+  el:'#goods-coupon-vue',
+  data: function() {
+    return {
+      curSelectCoupon: {}
+    }
+  },
+  mounted () {},
+  methods: {
+    updatePrice: function(data){
+      this.$refs.goodsCoupon.getCoupon(data)
+    },
+    updateCoupon: function(data) {
+      console.log(data, '更新优惠券选择')
+      this.curSelectCoupon = data
+      goodsOrder.updatePrice(goodsOrder.initPrice)
+    }
+  }
+})
+// 订单提交
+var goodsOrder = new Vue({ 
+  el: '#goods-order-vue',
   data: function () {
     return {
       type: 'vip',
@@ -724,25 +734,52 @@ var coupon = new Vue({
       links: [
         {
           text: '《剑鱼标讯线上购买与服务条款》',
-          url: '/front/staticPage/wx-serviceterms.html',
+          url: '',
           event: this.readEvent
         }
       ],
       buttons: {
         submit: this.submitOrder
       },
+      hideCoupon: true // 是否隐藏订单提交组件上的选择优惠券
     }
   },
+  watch: {
+    initPrice: {
+      handler: function(newVal, oldVal) {
+        var beforePrice = parseInt(sessionStorage.getItem('jump-before-price'))
+        sessionStorage.removeItem('jump-before-price')
+        if (beforePrice != newVal) {
+          sessionStorage.removeItem('vip-cur-select-coupon')
+          goodsOrder.updatePrice(goodsOrder.initPrice)
+        }
+        console.log(newVal,beforePrice, oldVal, 'watch')
+      },
+    },
+    deep: true
+  },
   mounted () {
     this.init()
   }, 
   methods: {
     // 更新价格相关
     updatePrice: function (before) {
-      console.log( '原价:' + before)
+      var curCoupon = JSON.parse(sessionStorage.getItem('vip-cur-select-coupon'))
+      // 处理优惠金额 主要作用为展示优惠明细弹框立得优惠金额
+      if (curCoupon) {
+        if(curCoupon.lotteryAttribute == '折扣券') {
+          // disCount为折扣率 优惠金额 = 原价*优惠了多少比例(100 - disCount)
+          this.$refs.couponRef.coupon.value = Number(before*((100 - curCoupon.disCount)/100)).toFixed(2)
+        } else if (curCoupon.lotteryAttribute == '满减券') {
+          this.$refs.couponRef.coupon.value = curCoupon.reduce
+        }
+      } else {
+        this.$refs.couponRef.coupon.value = 0
+      }
+      console.log('原价:' + before)
       this.initPrice = before;
       // 调用子组件查询最优卡券
-      this.$refs.couponRef.getCoupon();
+      // this.$refs.couponRef.getCoupon();
     },
     // 初始化及回显相关
     init: function () {},
@@ -764,7 +801,9 @@ var coupon = new Vue({
       // sessionStorage.setItem("vipSub_read", 0)
     },
     // 阅读协议点击事件
-    readEvent: function () {},
+    readEvent: function () {
+      toRead()
+    },
     // 订单提交事件
     submitOrder: function () {
       this.$refs.couponRef.submitStatus = true

+ 4 - 0
src/web/templates/frontRouter/wx/coupon/free/myCoupon.html

@@ -130,6 +130,10 @@
       computed: {},
       created () {
         this.tabClick(4)
+        // 清除商品规格当前选择
+        sessionStorage.removeItem("vip-cur-select-size")
+        // 清除商品优惠券当前选择
+        sessionStorage.removeItem("vip-cur-select-coupon")
       },
       mounted() {
         this.getDomOffsetTop()

+ 13 - 3
src/web/templates/weixin/vipsubscribe/vip_UpgradePage.html

@@ -15,6 +15,7 @@
   <link rel="stylesheet" href='/vipsubscribe/css/public.css?v={{Msg "seo" "version"}}' />
   <link rel="stylesheet" href='/css/wxbutton.css?v={{Msg "seo" "version"}}'>
   <link rel="stylesheet" href='/vipsubscribe/css/vip_upgrade.css?v={{Msg "seo" "version"}}'>
+  <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/vipsubscribe/css/vip-coupon-template.css?v={{Msg "seo" "version"}}' />
   <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/coupon/css/pay-order-template.css?v={{Msg "seo" "version"}}' />
   <style>
     .vip-header {
@@ -109,11 +110,15 @@
           </div>
         </li>
       </ul>
+      <!-- 商品优惠券 -->
+      <div id="goods-coupon-vue">
+        <goods-coupon-template ref="goodsCoupon" @update-coupon="updateCoupon"></goods-coupon-template>
+      </div>
       <!-- 超级订阅专属权益 封装为公共页面-->
       {{include "/common/commonRules.html"}}
     </div>
-    <!-- vue组件 -->
-    <div class="vip-footer renew" id="coupon-vue">
+    <!-- vue订单提交组件 -->
+    <div class="vip-footer renew" id="goods-order-vue">
       <pay-order-template ref="couponRef" :config="$data" @update="updateS" @save="saveEvent"></pay-order-template>
     </div>
     <div class="vip-footer renew" style="display: none;">
@@ -141,7 +146,7 @@
         </div>
         <div class="clause-box">
           <span class="checkbox"></span>
-          <span class="clause-read">我已阅读,理解并接受<a href="/front/staticPage/wx-serviceterms.html">《剑鱼标讯线上购买与服务条款》</a>
+          <span class="clause-read">我已阅读,理解并接受<a href="javascript:;" onclick="toRead()">《剑鱼标讯线上购买与服务条款》</a>
           </span>
         </div>
       </div>
@@ -377,6 +382,7 @@
   <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
   <script src="/vipsubscribe/js/UpgradePrice.js?v={{Msg "seo" "version"}}"></script>
   <script src="/vipsubscribe/js/price.js?v={{Msg "seo" "version"}}"></script>
+  <script src='{{Msg "seo" "cdn"}}/common-module/vipsubscribe/js/vip-coupon-template.js?v={{Msg "seo" "version"}}'></script>
   <script src='{{Msg "seo" "cdn"}}/common-module/coupon/js/pay-order-template.js?v={{Msg "seo" "version"}}'></script>
   {{include "/common/weixin.html"}}
   <script>
@@ -429,6 +435,10 @@
         // $(".origin-price").hide()
       }
     }
+    function toRead() {
+      sessionStorage.setItem('jump-before-price', goodsOrder.initPrice)
+      window.location.href = "/front/staticPage/wx-serviceterms.html";
+    }
 
     $(window).bind("pageshow", function (event) {
       if (event.originalEvent.persisted) {

+ 114 - 30
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -254,7 +254,7 @@
                 </div>
             </div>
             <!-- vue组件 -->
-            <div class="fixed-bottom-box p15" id="coupon-vue">
+            <div class="fixed-bottom-box p15" id="goods-order-vue">
               <pay-order-template ref="couponRef" :config="$data" @update="updateS"></pay-order-template>
             </div>
             <div class="fixed-bottom-box p15" style="display: none;">
@@ -651,7 +651,8 @@
                   props: {
                     defaultSize: {},
                     areaCount: 1,
-                    priceInfo: {}
+                    priceInfo: {},
+                    giftCycle: null
                   }
                 }
               },
@@ -682,10 +683,9 @@
                   var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
                   if (size) {
                     this.$refs.goodsSize.goodsActive = size.index
-                    this.defaultSize = size
+                    this.props.defaultSize = size
                     this.$nextTick(function(){
-                      console.log(size.price, 'size.price')
-                      coupon.updatePrice(size.price/100)
+                      goodsOrder.updatePrice(size.price/100)
                       goodsCoupon.updatePrice(size.price/100)
                     })
                   } else {
@@ -695,41 +695,46 @@
                 },
                 getGoodSize: function(data) {
                   console.log(data, '父组件接收子组件传来的商品规格')
-                  this.defaultSize = data
-                  coupon.updatePrice(data.price/100)
-                  goodsCoupon.updatePrice(data.price/100)
+                  this.props.defaultSize = data
+                  goodsOrder.updatePrice(data.price/100)
+                  // 查询有无满赠,无满赠执行回调查优惠券
+                  purchase.getGiftList(function(){
+                    goodsCoupon.updatePrice(data.price/100)
+                  })
                 }
               }
             })
-            // vip优惠券
+            // 商品优惠券组件
             var goodsCoupon = new Vue({
               el:'#goods-coupon-vue',
               data: function() {
                 return {
-                  curSelectCoupon: {}
+                  curSelectCoupon: {} // 当前选择的商品优惠券
                 }
               },
               mounted () {},
               methods: {
+                // 传入价格查询优惠券
                 updatePrice: function(data){
                   this.$refs.goodsCoupon.getCoupon(data)
                 },
+                // 切换优惠券 更新价格
                 updateCoupon: function(data) {
                   console.log(data, '更新优惠券选择')
                   this.curSelectCoupon = data
                   var curSize = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
                   // 更新优惠券选择同时更新订单组件的价格及优惠金额
                   if (curSize) {
-                    coupon.updatePrice(curSize.price/100)
+                    goodsOrder.updatePrice(curSize.price/100)
                   } else {
-                    coupon.updatePrice(coupon.initPrice)
+                    goodsOrder.updatePrice(goodsOrder.initPrice)
                   }
                 }
               }
             })
-            // 订单提交组件
-            var coupon = new Vue({
-              el: '#coupon-vue',
+            // 商品订单提交组件
+            var goodsOrder = new Vue({
+              el: '#goods-order-vue',
               data: function () {
                 return {
                   type: 'vip',
@@ -748,20 +753,27 @@
                   buttons: {
                     submit: this.submitOrder
                   },
-                  hideCoupon: true //超级订阅购买隐藏订单提交组件的优惠券部分
+                  hideCoupon: true, //超级订阅购买隐藏订单提交组件的优惠券部分
+                  giftName: '', // 赠品名称
+                  giftId: '' // 赠品id
                 }
               },
               mounted () {
-                this.init()
+                this.init(this.$data)
               },
               methods: {
                 // 更新价格相关
                 updatePrice: function (before) {
                   console.log( '原价:' + before)
                   var curCoupon = JSON.parse(sessionStorage.getItem('vip-cur-select-coupon'))
-                  console.log(curCoupon, '当前选择的优惠券')
+                  // 处理优惠金额 主要作用为展示优惠明细弹框立得优惠金额
                   if (curCoupon) {
-                    this.$refs.couponRef.coupon.value = curCoupon.reduce
+                    if(curCoupon.lotteryAttribute == '折扣券') {
+                      // disCount为折扣率 优惠金额 = 原价*优惠了多少比例(100 - disCount)
+                      this.$refs.couponRef.coupon.value = Number(before*((100 - curCoupon.disCount)/100)).toFixed(2)
+                    } else if (curCoupon.lotteryAttribute == '满减券') {
+                      this.$refs.couponRef.coupon.value = curCoupon.reduce
+                    }
                   } else {
                     this.$refs.couponRef.coupon.value = 0
                   }
@@ -772,11 +784,9 @@
                   }
                 },
                 // 初始化及回显相关
-                init: function () {
+                init: function (data) {
                   var areaStorage = sessionStorage.getItem('vipSubSelectArea');
-                  // var industryStorage = sessionStorage.getItem('vipSubSelectIndustry');
                   var readStorage = sessionStorage.getItem('vipSub_read') == 'true' ? true : false;
-                  // console.log(areaStorage, industryStorage, readStorage)
                   if(readStorage) {
                     this.checkboxStatus = true
                   }
@@ -794,7 +804,6 @@
                 checkSubmitStatus: function (checkStatus) {
                   $('#buy').prop('checked', checkStatus)
                   var areaStorage = sessionStorage.getItem('vipSubSelectArea');
-                  // var industryStorage = sessionStorage.getItem('vipSubSelectIndustry');
                   var readStorage = sessionStorage.getItem('vipSub_read');
                   return areaStorage && readStorage && OrderPhoneCheck.status
                 },
@@ -889,7 +898,7 @@
                         if (sessionStorage.getItem("vipSub_read") === "true") $("#buy").prop("checked", true);
                         //是否试用界面
                         if (sessionStorage.getItem("vipSubisTrial")) this.vipSubisTrial = true;
-
+                        var _this = this
                         //加载价格
                         $DoPost("/subscribepay/vipsubscribe/getPrice", {}, function (r) {
                             if (r) {
@@ -900,7 +909,7 @@
                                 //     showGiveStatus(false)
                                 // }
                                 Calculation.Init(false, undefined, [], 0)
-                                // 将价格列表传至商品规格组件
+                                // 将价格信息传递给商品规格组件  用户渲染商品规格
                                 goodsSize.props.priceInfo = r.new
                             }
                         }, false)
@@ -1035,11 +1044,73 @@
                         var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
                         // 首次进入没有选择商品规格 默认
                         if (!size) {
-                          coupon.updatePrice(price)
-                          goodsCoupon.updatePrice(price)
+                          goodsOrder.updatePrice(price) // 更新提交订单组件价格
+                          purchase.getGiftList(function(){
+                            goodsCoupon.updatePrice(price) // 更新商品优惠券价格(查询优惠券)
+                          })
+                        } else {
+                          purchase.getGiftList(function(){
+                            goodsCoupon.updatePrice(size.price) // 更新商品优惠券价格(查询优惠券)
+                          })
                         }
                     }
-                }
+                },
+                // 获取当前选择的商品有无满赠活动
+                getGiftList: function(callback) {
+                  var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size')) || {}
+                  console.log(size)
+                  if (!size || Object.keys(size).length == 0) {
+                    size.period = '1年'
+                  }
+                  var pId;
+                  var _this = this
+                  switch (size.period) {
+                    case '1月':
+                      pId = 1012
+                      break;
+                    case '1季':
+                      pId = 1013
+                      break;
+                    case '1年':
+                      pId = 1014
+                      break;
+                  }
+                  goodsSize.props.giftCycle = null // 下次请求前将满赠周期清掉 请求成功后再赋值
+                  // 先查有没有满赠
+                  $.ajax({
+                    type:'POST',
+                    url:'/jyCoupon/giveInfo',
+                    data:{
+                      useProduct: pId,
+                      useProductType: 0 // 商品类型 0普通的  1线上课程(除线上课程以外的都是0)
+                    },
+                    success:function(res) {
+                      if(res.data && res.data.length > 0) {
+                        res.data.forEach(function(item) {
+                          // 处理展示文字(天、月、年)
+                          if(item.timeType == 1) {
+                            item.time = item.time + '天'
+                          } else if (item.timeType == 2 && item.time < 12) {
+                            item.time = item.time + '个月'
+                          } else if (item.timeType == 2 && item.time == 12) {
+                            item.time = '1年'
+                          }
+                          // 将赠品信息传递给商品订单提交子组件
+                          goodsOrder.giftName = item.name // 满赠商品名称
+                          goodsOrder.giftId = item.discountId // 满赠id
+                          goodsSize.props.defaultSize.time = item.time
+                          goodsSize.props.giftCycle = item.time
+                        })
+                      } else {
+                        // 没有满赠活动再执行其他回调(优惠券)
+                        callback && callback()
+                      }
+                    },
+                    error:function(err) {
+                      console.log(err)
+                    }
+                  })
+                },
             };
 
 
@@ -1258,7 +1329,19 @@
                         activeCodes = couponInfo.code;
                     }
                     var size = goodsSize.defaultSize
+                    var pId;
                     if (size && size.period) {
+                      switch (size.period) {
+                        case '1月':
+                          pId = 1012
+                          break;
+                        case '1季':
+                          pId = 1013
+                          break;
+                        case '1年':
+                          pId = 1014
+                          break;
+                      }
                       if(size.period.indexOf('月') > -1) {
                         size.period = size.period.replace('月', '个月')
                       }
@@ -1266,14 +1349,15 @@
                     } else {
                       sizeTime = '1年'
                     }
-                    console.log(sizeTime, '选择的周期')
                     var param = {
                       "userLotteryId":goodsCoupon.curSelectCoupon.userLotteryId,
                       "lotteryId": goodsCoupon.curSelectCoupon.lotteryId,
                         "area": JSON.stringify(area),
                         // "industry": industry.join(","),
                         "time": sizeTime,
-                        "price": Number((coupon.initPrice*100).toFixed(2)),
+                        "discountId": goodsOrder.giftId, // 满赠id
+                        "useProduct": pId, // 商品类型
+                        "price": parseInt(goodsOrder.initPrice*10000/100),
                         "orderType":{{.T.orderType}},
                         "activeCode": activeCodes,
                         "disWord": getParam("disWord")//分销系统

+ 7 - 1
src/web/templates/weixin/vipsubscribe/vip_renew.html

@@ -17,6 +17,7 @@
     <link rel="stylesheet" href="/css/wxbutton.css?v={{Msg "seo" "version"}}">
     <link rel="stylesheet" href="/vipsubscribe/css/vip_renew.css?v={{Msg "seo" "version"}}">
     <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/vipsubscribe/css/vip-size-template.css?v={{Msg "seo" "version"}}' />
+    <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/coupon/css/vip-coupon-template.css?v={{Msg "seo" "version"}}' />
     <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/coupon/css/pay-order-template.css?v={{Msg "seo" "version"}}' />
     <style>
       .vip-header {
@@ -91,6 +92,10 @@
             <!-- 商品规格 -->
           <div id="goods-size-vue" data-new-vip style="display: none;">
             <goods-size-template ref="goodsSize" :config="props" @select-vip-size="getGoodSize"></goods-size-template>
+          </div>
+          <!-- 商品优惠券 -->
+          <div id="goods-coupon-vue">
+            <goods-coupon-template ref="goodsCoupon" @update-coupon="updateCoupon"></goods-coupon-template>
           </div>
             <ul style="padding: .16rem .24rem;" data-old-vip>
                 <li class="body-item area-industry">
@@ -153,7 +158,7 @@
             </div>
         </div>
         <!-- vue组件 -->
-        <div class="vip-footer renew" id="coupon-vue">
+        <div class="vip-footer renew" id="goods-order-vue">
           <pay-order-template ref="couponRef" :config="$data" @update="updateS" @save="saveEvent"></pay-order-template>
         </div>
         <div class="vip-footer renew" style="display: none;">
@@ -380,6 +385,7 @@
     <script src="/vipsubscribe/js/jquery-2.1.4.js?v={{Msg "seo" "version"}}"></script>
     <script src=//cdn-common.jianyu360.com/cdn/lib/vue/2.6.11/vue.min.js></script>
     <script src='{{Msg "seo" "cdn"}}/common-module/vipsubscribe/js/vip-size-template.js?v={{Msg "seo" "version"}}'></script>
+    <script src='{{Msg "seo" "cdn"}}/common-module/coupon/js/vip-coupon-template.js.js?v={{Msg "seo" "version"}}'></script>
     <script src='{{Msg "seo" "cdn"}}/common-module/coupon/js/pay-order-template.js?v={{Msg "seo" "version"}}'></script>
     <script src="/vipsubscribe/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>