Browse Source

feat: 订阅首页订阅修改区域和行业实时提交、升级参数修改等

yangfeng 4 years ago
parent
commit
c7758969a4

+ 28 - 3
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/change_area.js

@@ -443,7 +443,8 @@ $(function () {
     }
 
     var subVipState = sessionStorage.getItem('sub_vip_state')
-    if (subVipState) {
+    // 2021-5-21修改 需要每次都从接口里查询订阅条件 加上url参数判断
+    if (subVipState && !getParam('header')) {
         areaData.data = JSON.parse(subVipState)
         init()
     } else {
@@ -454,8 +455,32 @@ $(function () {
     $('.save-btn').on('click', function () {
         // 获取点亮的城市详情
         areaData.data.area = getActiveCityDetail()
-        sessionStorage.setItem('sub_vip_state', JSON.stringify(areaData.data))
-        history.back()
+        var params = {
+          area: JSON.stringify(areaData.data.area),
+          industry: (areaData.data.industry).join(',')
+        }
+        console.log(areaData, 'areaData')
+        if (getParam('header') === 'save') {
+          $DoPost('/subscribepay/vipsubscribe/saveChange', params, function (res) {
+            if (res.data && res.data.doSuccess) {
+              weui.toast('修改成功', {
+                duration: 2000,
+                className: 'custom-toast',
+                callback: function() {
+                  history.back()
+                }
+              });
+            } else {
+              weui.toast(res.errMsg, {
+                duration: 2000,
+                className: 'custom-toast'
+              });
+            }
+          })
+        } else {
+          sessionStorage.setItem('sub_vip_state', JSON.stringify(areaData.data))
+          history.back()
+        }
     })
 
     // 获取点亮的城市的列表详情(带省名和城市名)

+ 29 - 3
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/change_industry.js

@@ -262,11 +262,37 @@ $(function () {
         initData();
         showNeedPopver(false)
     })
+    
     // 确认按钮事件
     $('.save-btn').on('click', function () {
         data.data.industry = result
-        sessionStorage.setItem('sub_vip_state', JSON.stringify(data.data))
-        history.back()
+        console.log(data.data)
+        var params = {
+          area: JSON.stringify(data.data.area),
+          industry: data.data.industry.join(',')
+        }
+        // 超级订阅新套餐 修改订阅条件需要提交后台保存, 因是共用页面,为不影响其他页面逻辑,url加上参数进行判断
+        if (getParam('header') === 'save') {
+          $DoPost('/subscribepay/vipsubscribe/saveChange', params, function (res) {
+            if (res.data && res.data.doSuccess) {
+              weui.toast('修改成功', {
+                duration: 2000,
+                className: 'custom-toast',
+                callback: function() {
+                  history.back()
+                }
+              });
+            } else {
+              weui.toast(res.errMsg, {
+                duration: 2000,
+                className: 'custom-toast'
+              });
+            }
+          })
+        } else {
+          sessionStorage.setItem('sub_vip_state', JSON.stringify(data.data))
+          history.back()
+        }
     })
 
 
@@ -282,7 +308,7 @@ $(function () {
     }
 
     var subVipState = sessionStorage.getItem('sub_vip_state')
-    if (subVipState) {
+    if (subVipState && !getParam('header')) {
         data.data = JSON.parse(subVipState)
         initData();
     } else {

+ 10 - 5
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_index_new.js

@@ -786,10 +786,15 @@ $(function () {
   var selectTime = "";
 
   function init(state) {
-    console.log(state, 'state')
       checkmerge(state.industry, state.isread)
       // init 已选择的区域和行业
-      var selectedAreaAndInd = getBuySet(state.area, state.industry);
+      // var selectedAreaAndInd = getBuySet(state.area, state.industry);
+      // 2021-5-21修改 每次从接口buyset里取,不用通过common.js里公共函数处理 
+      var selectedAreaAndInd = {
+        areacount: state.buyset.areacount,
+        buyerclasscount: state.buyset.buyerclasscount,
+        citys: state.buyset.newcitys
+      }
       console.log(selectedAreaAndInd, 'selectedAreaAndInd')
       setSelectedAreaAndInd(selectedAreaAndInd);
       // 初始化,已购买的城市和行业
@@ -878,10 +883,10 @@ $(function () {
       var tmp1 = getAreaClassArr(reqData.oldArea);
       var tmp2 = getAreaClassArr(reqData.area);
       var areaNoChange = (JSON.stringify(tmp1[0].sort()) === JSON.stringify(tmp2[0].sort())) && (JSON.stringify(tmp1[1].sort()) === JSON.stringify(tmp2[1].sort()));
-      if (IndustryNoChange && areaNoChange && changeTime.length === 0) {
+      // if (IndustryNoChange && areaNoChange && changeTime.length === 0) {
           getDataWitXHR()
-          return
-      }
+          // return
+      // }
 
       //判断是否需要升级
       var status = getUpgradeFinalStatus(getBuySet(reqData.area, reqData.industry), {

+ 2 - 2
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_upgrade.js

@@ -523,10 +523,10 @@ $(function () {
       // "industry": industry.join(","),
       'price': Number(coupon.initPrice*100),
       "time": purchase.timeValue.trim(),
-      "orderType": 5,
+      // "orderType": 5,
       "disWord": GetQueryString("disWord"),
     };
-    $DoPost("/subscribepay/vipsubscribe/createOrder", param, function (r) {
+    $DoPost("/subscribepay/vipsubscribe/upgrade", param, function (r) {
       if (r.success) {
         try {
           clearSessionStorage()

+ 5 - 5
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_index_new.html

@@ -166,13 +166,13 @@
             </a>
             <ul class="sub-info">
               <li class="area">
-                <a class="item-container" href="/jyapp/vipsubscribe/toChangeArea">
+                <a class="item-container" href="/jyapp/vipsubscribe/toChangeArea?header=save">
                   <div class="item">
                     <span class="item-l">
                       <span class="item-label">区域</span>
                     </span>
                     <span class="item-r">
-                      <span class="tip-need-upgrade tip">需升级</span>
+                      <!-- <span class="tip-need-upgrade tip">需升级</span> -->
                       <span class="iconfont icon-arrow"></span>
                     </span>
                   </div>
@@ -188,13 +188,13 @@
                 </a>
               </li>
               <li class="industry">
-                <a class="item-container" href="/jyapp/vipsubscribe/toChangeIndustry">
+                <a class="item-container" href="/jyapp/vipsubscribe/toChangeIndustry?header=save">
                   <div class="item">
                     <span class="item-l">
                       <span class="item-label">采购单位行业</span>
                     </span>
                     <span class="item-r">
-                      <span class="tip-need-upgrade tip">需升级</span>
+                      <!-- <span class="tip-need-upgrade tip">需升级</span> -->
                       <span class="iconfont icon-arrow"></span>
                     </span>
                   </div>
@@ -210,7 +210,7 @@
                 </a>
               </li>
               <li class="cycle">
-                <a class="item-container" href="/jyapp/vipsubscribe/toChangeTime">
+                <a class="item-container" href="/jyapp/vipsubscribe/vipsubscribe_renew">
                   <div class="item">
                     <span class="item-l">
                       <span class="item-label">订阅周期</span>

+ 1 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_purchase.html

@@ -1156,6 +1156,7 @@
               // "industry": industry.join(","),
               "time": $(".info:eq(2)").val().trim(),
               "orderType":{{.T.orderType}},
+              "price": Number(coupon.initPrice*100),
               "activeCode": activeCodes,
               "disWord":getParam("disWord"),//分销系统 口令
             };

+ 30 - 4
src/web/staticres/vipsubscribe/js/change_area.js

@@ -441,9 +441,9 @@ $(function () {
             init()
         })
     }
-
+    // 2021-5-21修改 需要每次都从接口里查询订阅条件
     var subVipState = sessionStorage.getItem('sub_vip_state')
-    if (subVipState) {
+    if (subVipState && !getParam('header')) {
         areaData.data = JSON.parse(subVipState)
         init()
     } else {
@@ -454,8 +454,34 @@ $(function () {
     $('.save-btn').on('click', function () {
         // 获取点亮的城市详情
         areaData.data.area = getActiveCityDetail()
-        sessionStorage.setItem('sub_vip_state', JSON.stringify(areaData.data))
-        history.back()
+
+        // 超级订阅新套餐 修改订阅条件需要提交后台保存, 因是共用页面,为不影响其他页面逻辑,url加上参数进行判断
+        var params = {
+          area: JSON.stringify(areaData.data.area),
+          industry: (areaData.data.industry).join(',')
+        }
+        if (getParam('header') === 'save') {
+          $DoPost('/subscribepay/vipsubscribe/saveChange', params, function (res) {
+            if (res.data && res.data.doSuccess) {
+              weui.toast('修改成功', {
+                duration: 2000,
+                className: 'custom-toast',
+                callback: function() {
+                  history.back()
+                }
+              });
+            } else {
+              weui.toast(res.errMsg, {
+                duration: 2000,
+                className: 'custom-toast'
+              });
+            }
+          })
+        } else {
+          sessionStorage.setItem('sub_vip_state', JSON.stringify(areaData.data))
+          history.back()
+        }
+        
     })
 
     // 获取点亮的城市的列表详情(带省名和城市名)

+ 28 - 3
src/web/staticres/vipsubscribe/js/change_industry.js

@@ -262,8 +262,33 @@ $(function () {
     // 确认按钮事件
     $('.save-btn').on('click', function () {
         data.data.industry = result
-        sessionStorage.setItem('sub_vip_state', JSON.stringify(data.data))
-        history.back()
+
+        var params = {
+          area: JSON.stringify(data.data.area),
+          industry: data.data.industry.join(',')
+        }
+        // 超级订阅新套餐 修改订阅条件需要提交后台保存, 因是共用页面,为不影响其他页面逻辑,url加上参数进行判断
+        if (getParam('header') === 'save') {
+          $DoPost('/subscribepay/vipsubscribe/saveChange', params, function (res) {
+            if (res.data && res.data.doSuccess) {
+              weui.toast('修改成功', {
+                duration: 2000,
+                className: 'custom-toast',
+                callback: function() {
+                  history.back()
+                }
+              });
+            } else {
+              weui.toast(res.errMsg, {
+                duration: 2000,
+                className: 'custom-toast'
+              });
+            }
+          })
+        } else {
+          sessionStorage.setItem('sub_vip_state', JSON.stringify(data.data))
+          history.back()
+        }
     })
 
 
@@ -279,7 +304,7 @@ $(function () {
     }
 
     var subVipState = sessionStorage.getItem('sub_vip_state')
-    if (subVipState) {
+    if (subVipState && !getParam('header')) {
         data.data = JSON.parse(subVipState)
         initData();
     } else {

+ 7 - 1
src/web/staticres/vipsubscribe/js/vip_index_new.js

@@ -789,7 +789,13 @@ $(function () {
     function init(state) {
         checkmerge(state.industry, state.isread)
         // init 已选择的区域和行业
-        var selectedAreaAndInd = getBuySet(state.area, state.industry);
+        // var selectedAreaAndInd = getBuySet(state.area, state.industry);
+        // 2021-5-21修改 每次从接口buyset里取,不用通过common.js里公共函数处理 
+        var selectedAreaAndInd = {
+          areacount: state.buyset.areacount,
+          buyerclasscount: state.buyset.buyerclasscount,
+          citys: state.buyset.newcitys
+        }
         setSelectedAreaAndInd(selectedAreaAndInd);
         // 初始化,已购买的城市和行业
         setBuyAreaAndInd(state.buyset);

+ 2 - 2
src/web/staticres/vipsubscribe/js/vip_upgrade.js

@@ -527,11 +527,11 @@ $(function () {
       // "industry": industry.join(","),
       'price': coupon.initPrice*100,
       "time": purchase.timeValue.trim(),
-      "orderType": 5,
+      // "orderType": 5,
       "activeCode": activeCodes,
       "disWord":GetQueryString("disWord"),
     };
-    $DoPost("/subscribepay/vipsubscribe/createOrder", param, function (r) {
+    $DoPost("/subscribepay/vipsubscribe/upgrade", param, function (r) {
       if (r.success) {
         clearSessionStorage();
         history.replaceState({}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);

+ 5 - 5
src/web/templates/weixin/vipsubscribe/vip_index_new.html

@@ -113,13 +113,13 @@
           </a>
           <ul class="sub-info">
             <li class="area">
-              <a class="item-container" href="/front/vipsubscribe/toChangeArea">
+              <a class="item-container" href="/front/vipsubscribe/toChangeArea?header=save">
                   <div class="item">
                       <span class="item-l">
                         <span class="item-label">区域</span>
                       </span>
                       <span class="item-r">
-                        <span class="tip-need-upgrade tip">需升级</span>
+                        <!-- <span class="tip-need-upgrade tip">需升级</span> -->
                         <span class="iconfont icon-arrow"></span>
                       </span>
                   </div>
@@ -135,13 +135,13 @@
               </a>
             </li>
             <li class="industry">
-                <a class="item-container" href="/front/vipsubscribe/toChangeIndustry">
+                <a class="item-container" href="/front/vipsubscribe/toChangeIndustry?header=save">
                     <div class="item">
                         <span class="item-l">
                           <span class="item-label">采购单位行业</span>
                         </span>
                         <span class="item-r">
-                          <span class="tip-need-upgrade tip">需升级</span>
+                          <!-- <span class="tip-need-upgrade tip">需升级</span> -->
                           <span class="iconfont icon-arrow"></span>
                         </span>
                     </div>
@@ -157,7 +157,7 @@
                 </a>
             </li>
             <li class="cycle">
-                <a class="item-container" href="/front/vipsubscribe/toChangeTime">
+                <a class="item-container" href="/front/vipsubscribe/vipsubscribe_renew">
                     <div class="item">
                       <span class="item-l">
                         <span class="item-label">订阅周期</span>

+ 1 - 0
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -1123,6 +1123,7 @@
                         "area": JSON.stringify(area),
                         // "industry": industry.join(","),
                         "time": $(".info:eq(2)").val().trim(),
+                        "price": Number(coupon.initPrice*100),
                         "orderType":{{.T.orderType}},
                         "activeCode": activeCodes,
                         "disWord": getParam("disWord")//分销系统