Sfoglia il codice sorgente

Merge branch 'dev4.6.2.1' of http://192.168.3.207:8080/qmx/jy into dev4.6.2.1

yangfeng 3 anni fa
parent
commit
15bcf698c5
31 ha cambiato i file con 519 aggiunte e 370 eliminazioni
  1. 2 9
      src/jfw/front/front.go
  2. 1 0
      src/jfw/front/login.go
  3. 1 0
      src/jfw/front/otherAct.go
  4. 1 0
      src/jfw/front/pchelper.go
  5. 2 9
      src/jfw/modules/app/src/app/front/front.go
  6. 3 0
      src/jfw/modules/app/src/app/front/login.go
  7. 1 1
      src/jfw/modules/app/src/app/front/wxkeyset.go
  8. 3 0
      src/jfw/modules/app/src/web/staticres/jyapp/big-member/js/set_area.js
  9. 15 20
      src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_index_new.js
  10. 173 150
      src/jfw/modules/app/src/web/templates/areaPack/page_set_area.html
  11. 5 1
      src/jfw/modules/app/src/web/templates/commonPay/areaPack/orderDetail.html
  12. 1 1
      src/jfw/modules/app/src/web/templates/vipsubscribe/vip_index_new.html
  13. 4 3
      src/jfw/modules/bigmember/src/entity/analysis.go
  14. 6 5
      src/jfw/modules/bigmember/src/entity/analysisEntName.go
  15. 4 1
      src/jfw/modules/bigmember/src/service/analysis/forecastproject.go
  16. 4 3
      src/jfw/modules/common/src/qfw/util/jy/bigVipPower.go
  17. 4 2
      src/jfw/modules/publicapply/src/subscribePush/entity/setting.go
  18. 2 0
      src/jfw/modules/subscribepay/src/service/areaPack.go
  19. 2 0
      src/jfw/modules/subscribepay/src/service/dataExportPay.go
  20. 2 2
      src/jfw/modules/subscribepay/src/service/dataexportPack.go
  21. 2 0
      src/jfw/modules/subscribepay/src/service/integral.go
  22. 13 1
      src/jfw/modules/subscribepay/src/service/orderListDetails.go
  23. 5 3
      src/jfw/modules/subscribepay/src/service/userAccountInfo.go
  24. 2 0
      src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go
  25. 4 0
      src/jfw/modules/subscribepay/src/service/vipSubscribePay.go
  26. 2 0
      src/jfw/modules/weixin/src/wx/wx.go
  27. 3 0
      src/web/staticres/big-member/js/set_area.js
  28. 48 1
      src/web/staticres/common-module/order-list/js/order-detail.js
  29. 28 15
      src/web/staticres/common-module/vipsubscribe/js/vip-subscribe-set-template.js
  30. 172 143
      src/web/templates/areaPack/wx/page_set_area.html
  31. 4 0
      src/web/templates/weixin/commonPay/areaPack/orderDetail.html

+ 2 - 9
src/jfw/front/front.go

@@ -1033,7 +1033,7 @@ func (f *Front) TSGuide() error {
 		return f.Render("/weixin/wxtsguide.html")
 	} else {
 		reqType := f.GetString("reqType")
-		index, _ := f.GetInteger("index")
+		// index, _ := f.GetInteger("index")
 		result := make(bson.M)
 		if reqType == "save" {
 			var keyMaps []map[string]interface{}
@@ -1070,14 +1070,7 @@ func (f *Front) TSGuide() error {
 			}
 		} else if reqType == "over" {
 			saveData := bson.M{
-				"o_jy.o_area":       map[string]interface{}{},
-				"o_jy.l_modifydate": time.Now().Unix(),
-				"i_ts_guide":        1,
-			}
-			if index > 2 {
-				saveData = bson.M{
-					"i_ts_guide": 1,
-				}
+				"i_ts_guide": 1,
 			}
 			result["flag"] = mongodb.UpdateById("user", userid, bson.M{"$set": saveData})
 		} else if reqType == "preview" {

+ 1 - 0
src/jfw/front/login.go

@@ -115,6 +115,7 @@ func (l *Login) Login() error {
 						"s_company":     s_company,
 						"o_jy": map[string]interface{}{
 							"i_apppush":    1,
+							"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 							"i_ratemode":   2,
 							"l_modifydate": time.Now().Unix(),
 						},

+ 1 - 0
src/jfw/front/otherAct.go

@@ -135,6 +135,7 @@ func (f *Front) Lpsubmit() error {
 				"i_ts_guide":    2,
 				"o_jy": map[string]interface{}{
 					"i_apppush":    1,
+					"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 					"i_ratemode":   2,
 					"l_modifydate": time.Now().Unix(),
 				},

+ 1 - 0
src/jfw/front/pchelper.go

@@ -128,6 +128,7 @@ func (l *PcHelper) Login() error {
 							"o_jy": map[string]interface{}{
 								"i_apppush":    1,
 								"i_ratemode":   2,
+								"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 								"l_modifydate": time.Now().Unix(),
 							},
 							"s_regsource": "pchelper",

+ 2 - 9
src/jfw/modules/app/src/app/front/front.go

@@ -291,7 +291,7 @@ func (f *Front) TSGuide() error {
 		return f.Render("/weixin/wxtsguide.html")
 	} else {
 		reqType := f.GetString("reqType")
-		index, _ := f.GetInteger("index")
+		// index, _ := f.GetInteger("index")
 		result := make(bson.M)
 		if reqType == "save" {
 			var keyMaps []map[string]interface{}
@@ -328,14 +328,7 @@ func (f *Front) TSGuide() error {
 			}
 		} else if reqType == "over" {
 			saveData := bson.M{
-				"o_jy.o_area":       map[string]interface{}{},
-				"o_jy.l_modifydate": time.Now().Unix(),
-				"i_ts_guide":        1,
-			}
-			if index > 2 {
-				saveData = bson.M{
-					"i_ts_guide": 1,
-				}
+				"i_ts_guide": 1,
 			}
 			result["flag"] = mongodb.UpdateById("user", userid, bson.M{"$set": saveData})
 		} else if reqType == "preview" {

+ 3 - 0
src/jfw/modules/app/src/app/front/login.go

@@ -206,6 +206,7 @@ func (l *Login) Login() error {
 						"o_jy": map[string]interface{}{
 							"i_apppush":    1,
 							"i_ratemode":   2,
+							"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 							"l_modifydate": time.Now().Unix(),
 						},
 					}
@@ -462,6 +463,7 @@ func (l *Login) Register() error {
 					data["o_jy"] = map[string]interface{}{
 						"i_apppush":    1,
 						"i_ratemode":   2,
+						"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 						"l_modifydate": time.Now().Unix(),
 					}
 					data["s_regsource"] = isAndroidOrIOS(l.Header("User-Agent"))
@@ -605,6 +607,7 @@ func (l *Login) WxLogin() {
 				"o_jy": map[string]interface{}{
 					"i_apppush":    1,
 					"i_ratemode":   2,
+					"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
 					"l_modifydate": time.Now().Unix(),
 				},
 			}

+ 1 - 1
src/jfw/modules/app/src/app/front/wxkeyset.go

@@ -27,7 +27,7 @@ func (m *Front) WxKeyset(tpl string) error {
 	//到新订阅设置
 	vipMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW)
 	if vipMsg.IsUpgrade {
-		return m.Redirect("/front/vipsubscribe/toSubVipSetPage")
+		return m.Redirect("/jyapp/vipsubscribe/toSubVipSetPage")
 	}
 	if tpl == "seniorset" {
 		data, ok := mongodb.FindById("user", userid, `{"o_jy":1}`)

+ 3 - 0
src/jfw/modules/app/src/web/staticres/jyapp/big-member/js/set_area.js

@@ -437,6 +437,7 @@ var vNode = {
             try {
                 onChange && onChange(selectedCity)
             } catch (error) {
+                console.warn(error)
                 console.warn(arguments.callee.name + '必须定义为函数')
             }
         },
@@ -445,6 +446,7 @@ var vNode = {
             try {
                 onReset && onReset(this.initCityMap)
             } catch (error) {
+                console.log(error)
                 console.error(arguments.callee.name + '必须定义为函数')
             }
         },
@@ -453,6 +455,7 @@ var vNode = {
             try {
                 onConfirm && onConfirm(selectedCity)
             } catch (error) {
+                console.log(error)
                 console.error(arguments.callee.name + '必须定义为函数')
             }
         }

+ 15 - 20
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_index_new.js

@@ -33,19 +33,18 @@ var subNode = new Vue({
       }
       this.switchShow()
       this.switehAjax()
-      this.getUserSubscribe()
     },
-    mounted () { 
+    mounted () {
         // this.userAreaNum = 0
         // this.userType = true
         // this.userAreaAllNum = 1
     },
     methods: {
-        // 省份订阅包续费 
+        // 省份订阅包续费
         renewBtn: function () {
             location.href = '/jyapp/areaPack/page/buy?type=renew'
         },
-        // 省份订阅包升级 
+        // 省份订阅包升级
         updateBtn: function () {
             location.href = '/jyapp/areaPack/page/buy?type=upgrade&area=' +  encodeURIComponent(JSON.stringify(this.freeUserArea))
         },
@@ -144,7 +143,10 @@ var subNode = new Vue({
                     console.log(res)
                     if(res.data) {
                         _this.vSwitch = res.data.vt || 'f'
+                        // f 免费 m 大会员 v 超级订阅
                         if (_this.vSwitch === 'f') {
+                            // 判断是否购买省份订阅包
+                            _this.getUserSubscribe()
                             $('.update_renew').hide()
                         }
                         if(res.data.vt == 'm') {
@@ -334,7 +336,7 @@ $(function () {
               } else if (switchProduct == 'free') {
                 subNode.initData = r.data
               } else {
-                res = resObj
+                res = r
               }
           }
           if(!res.data.industry) {
@@ -357,19 +359,12 @@ $(function () {
   }
   var resObj = {}
   // 每次请求接口
-  console.log(document.referrer)
-  let subUrl
-  if (subNode.vSwitch === 'v') {
-    subUrl = '/subscribepay/vipsubscribe/getSubBuyMsg'
-  } else if (subNode.vSwitch === 'm') {
-    subUrl = '/bigmember/use/info?t=' + new Date().getTime()
-  } else {
-    subUrl = '/publicapply/free/subscribe'
-  }
+    let subUrl = '/subscribepay/vipsubscribe/getSubBuyMsg'
     $DoPost(subUrl, {}, function(sum) {
-        console.info('sum',sum)
-        resObj = sum
-        getDataWitXHR()
+        if(sum.success) {
+            resObj = sum
+            getDataWitXHR()
+        }
     })
 
   // 设置已选择的区域和行业
@@ -640,12 +635,12 @@ $(function () {
       checkmerge(state.industry, state.isread)
       // init 已选择的区域和行业
       // var selectedAreaAndInd = getBuySet(state.area, state.industry);
-      // 2021-5-21修改 初始化已选择的区域和行业 
+      // 2021-5-21修改 初始化已选择的区域和行业
       var selectedAreaAndInd = getSelectBuyset(state.area, state.industry)
       setSelectedAreaAndInd(selectedAreaAndInd);
       // 初始化,已购买的城市和行业
-        // setBuyAreaAndInd(state.buyset);
-      
+      setBuyAreaAndInd(state.buyset);
+
       //是否提示即将到期
       showTimeOut(state.endTime, state.isTrial);
       selectTime = sessionStorage.getItem("vip_change_time");

+ 173 - 150
src/jfw/modules/app/src/web/templates/areaPack/page_set_area.html

@@ -36,7 +36,6 @@
             font-weight: 500;
             color: #FA483C;
             box-sizing: border-box;
-            display: none;
         }
         .selectChange {
             font-size: 0.24rem;
@@ -119,191 +118,215 @@
     <div id="set-header-template" v-cloak>
         <div class="wrapper-header" id="thisAreaTips">
             <div class="content">
-                <div class="selectNumMax">可选择<span class="numColor" id="canSelect">1个省</span></div>
+                <div class="selectNumMax">可选择<span class="numColor" id="canSelect">${ maxSelectText }</span></div>
                 <div class="string"></div>
                 <div class="selectNumList">
-                    <span>已选择<span class="numColor" id="thisSelect">1个省</span></span>
-                    <span class="moreTips">超出可订阅省份数量,前往购买省份订阅包 ></span>
+                    <span>已选择<span class="numColor" id="thisSelect">${ selectedAreaText }</span></span>
+                    <span class="moreTips" v-show="moreThanSubCount">超出可订阅省份数量,前往${ buyType }省份订阅包 &gt;</span>
                 </div>
                 <div class="selectChange"></div>
             </div>
-            <div class="popup-wrap" v-show="popupType">
+            <div class="popup-wrap" v-show="popupTip">
                 <div class="popup-content">
-                    <div class="popup-text" id="tips-text">您当前仅可订阅1个省,如需增加请购买【省份订阅包】</div>
+                    <div class="popup-text" id="tips-text">您当前仅可订阅${ maxSelectText },如需增加请${ buyType }【省份订阅包】</div>
                     <div class="popup-btnWrap">
-                        <div class="popup-btn" id="cancel" @click="hiddenTips">取消</div>
+                        <div class="popup-btn" id="cancel" @click="hideTips">取消</div>
                         <div class="popup-line"></div>
-                        <div class="popup-btn levelUp" id="btn-text" @click="toPay">去购买</div>
+                        <div class="popup-btn levelUp" id="btn-text" @click="toPay">去${ buyType }</div>
                     </div>
                 </div>
             </div>
         </div>
     </div>
     <script>
-        var setAreaFn = {
-            conf: {
-                sKey: 'sub_free_state'
-            },
-            buyPageInfo: {},
-            init: function () {
-                // 恢复页面状态
-                var pageInfo = sessionStorage.getItem(this.conf.sKey)
-                if (pageInfo) {
-                    this.buyPageInfo = JSON.parse(pageInfo)
-                    var areaInfo = this.buyPageInfo.area
-                    if (this.buyPageInfo && areaInfo && Object.keys(areaInfo).length !== 0) {
-                        vNode.data.initCityMap = areaInfo
-                        vueComponent.setCitySelected(areaInfo)
-                    }
-                }
-            },
-            saveToSessionStorage: function (data) {
-                sessionStorage.setItem(this.conf.sKey, JSON.stringify(data))
-            }
-        }
-        setAreaFn.init()
         var vm = new Vue({
             delimiters: ['${', '}'],
             el: '#set-header',
             template: '#set-header-template',
             data: {
-                popupType: false,
-                popupText: '您当前仅可订阅1个省,如需增加请购买【省份订阅包】',
-                popupPayBtn: '去购买'
+                sessKey: 'sub_free_set_area',
+                selectedArea: '',
+                userSubInfo: {
+                    area: '',
+                    areanum: 0, // 可修改次数
+                    basenum: 1,
+                    provincenum: 0, // 购买的省份数量
+                },
+                popupTip: false
             },
-            created: function () {},
-            methods: {
-                hiddenTips: function () {
-                    this.popupType = false
+            computed: {
+                moreThanSubCount: function () {
+                    var max = this.maxSelectCount
+                    var sel = this.selectedAreaCount
+                    if (max === -1) return false
+                    if (sel === -1) return true
+                    if (sel > max) return true
                 },
-                toPay: function () {
-                    this.popupType = false
-                    if (userType) {
-                        // /jyapp/areaPack/page/buy?type=buy&area= + encodeURIComponent(JSON.stringify())
-                        location.href = '/jyapp/areaPack/page/buy?type=renew&area=' +  encodeURIComponent(JSON.stringify(thisData))
+                maxSelectCount: function () {
+                    var baseNum = this.userSubInfo.basenum || 1
+                    var provincenum = this.userSubInfo.provincenum
+                    if (provincenum === -1) {
+                        return provincenum
                     } else {
-                        location.href = '/jyapp/areaPack/page/buy?type=buy&area=' +  encodeURIComponent(JSON.stringify(thisData))
+                        return provincenum + baseNum
                     }
                 },
-                
-            }
-        })
-        var maxSelect = 1
-        var thisSelectNum = 0
-        var userType = true // 用户是否购买过省份包
-        var vSwitch = 'f' // 用户版本,''免费版,m大会员,v超级订阅
-        // 获取用户权限
-        function getUserMsg() {
-            $.ajax({
-                url: '/bigmember/use/isAdd',
-                type: 'POST',
-                success: function (res) {
-                    if (res.data.memberStatus > 0 && res.data.vipStatus <= 0) {
-                        vSwitch = 'm'
-                        $('#thisAreaTips').hide()
-                    } else if (res.data.memberStatus <= 0 && res.data.vipStatus > 0) {
-                        vSwitch = 'v'
-                        $('#thisAreaTips').hide()
-                    } else if (res.data.memberStatus <= 0 && res.data.vipStatus <= 0) {
-                        vSwitch = 'f'
-                        $('#thisAreaTips').show()
+                maxSelectText: function () {
+                    if (this.maxSelectCount === -1) {
+                        return '全国'
+                    } else {
+                        return this.maxSelectCount + '个省'
                     }
-                }
-            })
-        }
-        getUserMsg()
-        // 获取用户购买省份包信息
-        function getUserSubscribe() {
-            $.ajax({
-                url: '/publicapply/free/subscribe',
-                type: 'POST',
-                success: function (res) {
-                    let freeArea = JSON.stringify(res.data)
-                    sessionStorage.setItem('sub_free_state', freeArea)
-                    setAreaFn.init()
-                    onChange(res.data.area)
-                    userType = res.data.provincenum === 0 ? false : true
-                    maxSelect = res.data.provincenum + res.data.basenum
-                    // _this.$emit('UserSubscribe',res)
-                    if (maxSelect === -1) {
-                        $('#canSelect').text(`全国`)
-                    } else if (res.data.provincenum === 0 && res.data.areanum === 1) {
-                        vueComponent.provinceListMap['#'][0].selectedState = ''
+                },
+                selectedAreaCount: function () {
+                    var area = this.selectedArea
+                    if (area) {
+                        var keys = Object.keys(area)
+                        if (keys.length === 0) {
+                            return -1
+                        } else {
+                            return keys.length
+                        }
                     } else {
-                        $('#canSelect').text(`${maxSelect}个省`)
+                        return 0
                     }
-                }
-            })
-        }
-        getUserSubscribe()
-        function userUpdate(obj) {
-            let _this = this
-            $.ajax({
-                url: '/publicapply/subscribe/update',
-                type: 'POST',
-                data: {
-                    vSwitch: vSwitch,
-                    area:obj
                 },
-                success: function (res) {
-                    console.info(res)  
-                    window.history.back()           
+                selectedAreaText: function () {
+                    if (this.selectedAreaCount === -1) {
+                        return '全国'
+                    } else {
+                        return this.selectedAreaCount + '个省'
+                    }
+                },
+                // 是否购买了省份订阅包
+                userType: function () {
+                    if (this.userSubInfo.provincenum === -1) return true
+                    return this.userSubInfo.provincenum !== 0
+                },
+                buyType: function () {
+                    return this.userType ? '升级' : '购买'
+                },
+            },
+            mounted: function () {
+                var type = utils.getParam('type')
+                var restore = this.restoreState()
+
+                if (restore) {
+                    
+                } else {
+                    if (type === 'new') {
+                        this.setAreaAllNotSelected()
+                    } else {
+                        this.getUserSubscribe()
+                    } 
                 }
-            })
-        }
-        $('#thisSelect').text(`${thisSelectNum}个省`)
-        $('#canSelect').text(`${maxSelect}个省`)
-        // 以下均为示例:具体使用时候请删除
-        // 定义重置方法:方法名必须为onReset/onConfirm
-        // 参数,是被初始化的数据
+            },
+            methods: {
+                setAreaAllNotSelected: function () {
+                    vueComponent.setCitySelected()
+                    vueComponent.provinceListMap['#'][0].selectedState = ''
+                    $('#set-area .j-button-confirm').prop('disabled', true)
+                },
+                // 获取用户订阅信息
+                getUserSubscribe: function () {
+                    var _this = this
+                    $.ajax({
+                        url: '/publicapply/free/subscribe',
+                        type: 'POST',
+                        success: function (res) {
+                            if (res && res.error_code === 0) {
+                                if (res.data) {
+                                    if (res.data.area === null || res.data.area === undefined) {
+                                        _this.setAreaAllNotSelected()
+                                    } else {
+                                        Object.assign(_this.userSubInfo, res.data)
+                                    }
+                                }
+                            } else {
+                                if (res.error_msg) {
+                                    _this.$toast(res.error_msg)
+                                }
+                            }
+                        }
+                    })
+                },
+                userUpdate: function (area) {
+                    var _this = this
+                    $.ajax({
+                        url: '/publicapply/subscribe/update',
+                        type: 'POST',
+                        data: {
+                            vSwitch: 'f',
+                            area: JSON.stringify(area)
+                        },
+                        success: function (res) {
+                            if (res && res.success) {
+                                history.back()           
+                            } else {
+                                if (res.errMsg) {
+                                    _this.$toast(res.errMsg)
+                                }
+                            }
+                        }
+                    })
+                },
+                setAreaSelected: function (area) {
+                    this.$set(this, 'selectedArea', area)
+                },
+                confirmed: function (area) {
+                    this.setAreaSelected(area)
+                    if (this.moreThanSubCount) {
+                        this.popupTip = true
+                    } else {
+                        this.userUpdate(area)
+                    }
+                },
+                hideTips: function () {
+                    this.popupTip = false
+                },
+                toPay: function () {
+                    this.popupTip = false
+                    var area = this.selectedArea
+                    var urlBase = '/jyapp/areaPack/page/buy'
+                    var areaJSON = encodeURIComponent(JSON.stringify(area))
+                    this.savePageState()
+                    if (this.userType) {
+                        location.href = urlBase + '?type=upgrade&area=' +  areaJSON
+                    } else {
+                        location.href = urlBase +  '?type=buy&area=' +  areaJSON
+                    }
+                },
+                restoreState: function () {
+                    var $data = sessionStorage.getItem(this.sessKey)
+                    if ($data) {
+                        $data = JSON.parse($data)
+
+                        for (var key in $data) {
+                            Object.assign(this.$data[key], $data[key])
+                        }
+
+                        sessionStorage.removeItem(this.sessKey)
+                    }
+                    return !!$data
+                },
+                savePageState: function () {
+                    var data = JSON.stringify(this.$data)
+                    sessionStorage.setItem(this.sessKey, JSON.stringify(data))
+                },
+            }
+        })
+
         function onReset (initData) {
-            $('.selectChange').text('')
-            $('#thisSelect').text(`${thisSelectNum}个省`)
-            $('.moreTips').hide()
+            vm.setAreaSelected(initData)
         }
         // 被选中的数据
         function onConfirm (selectedData) {
-            var selectDataList = []
-            for (const key in selectedData) {
-                selectDataList.push(key)
-            }
-            if (selectDataList.length > maxSelect && maxSelect !== -1 && vSwitch === 'f') {
-                vm.popupType = true
-                if (!userType) {
-                    $('#tips-text').text('您当前仅可订阅1个省,如需增加请购买【省份订阅包】')
-                    $('#btn-text').text('去购买')
-                } else {
-                    $('#tips-text').text('已超出您可订阅的省份数量,是否升级【省份订阅包】')
-                    $('#btn-text').text('去升级')
-                }
-            } else {
-                var areaData = {}
-                selectDataList.forEach(function (item, index) {
-                    areaData[item] = []
-                })
-                areaData = JSON.stringify(areaData)
-                userUpdate(areaData)
-                sessionStorage.setItem('sub_vip_state', areaData)
-                
-            }
+            vm.confirmed(selectedData)
         }
-        var thisData = []
         // 页面选中状态改变时触发
         function onChange (selectedData) {
-            thisData = selectedData
-            var selectDataList = []
-            for (const key in selectedData) {
-                selectDataList.push(key)
-            }
-            var arr = selectDataList.join('、')
-            $('.selectChange').text(`${arr}`)
-            thisSelectNum = selectDataList.length
-            $('#thisSelect').text(`${selectDataList.length}个省`)
-            if (thisSelectNum > maxSelect) {
-                $('.moreTips').show()
-            } else {
-                $('.moreTips').hide()
-            }
+            vm.setAreaSelected(selectedData)
+            $('#set-area .j-button-confirm').prop('disabled', false)
         }
     </script>
 </body>

+ 5 - 1
src/jfw/modules/app/src/web/templates/commonPay/areaPack/orderDetail.html

@@ -89,6 +89,10 @@
                         class="j-button-confirm buy-again"
                         v-if="orderStateMap[orderInfo.state].bottomButtonShow.buyAgain"
                         @click="buyAgain">再次购买</button>
+                    <button
+                            class="j-button-confirm renew"
+                            v-if="orderStateMap[orderInfo.state].bottomButtonShow.renew"
+                            @click="renew">续费</button>
                 </div>
             </div>
         </div>
@@ -110,4 +114,4 @@
     {{include "/common/baiducc.html"}}
 </body>
 
-</html>
+</html>

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

@@ -332,7 +332,7 @@
           </li>
         </ul>
         <!-- 升级 -->
-        <div class="update_renew">
+        <div class="update_renew" v-if="thisvSwitch === 'v'">
           <div class="update-tips" data-update-tips>因系统升级,已购买用户可选择原套餐续费,或升级到新版本享受更多权益。</div>
           <div class="footer-button-group j-button-group">
             <button class="j-button-confirm" data-bind-renew>续费</button>

+ 4 - 3
src/jfw/modules/bigmember/src/entity/analysis.go

@@ -43,7 +43,7 @@ func (this *AnalysisDec) DecQueryNewSimilarMsgByBW() (qstr string) {
 	bools := []string{}
 	musts := []string{}
 	shoulds := []string{}
-	var BWExists = 1
+	var BWExists = 0
 	//中标单位 类似项目合作历史||采购单位类似项目
 	if this.Winner != "" {
 		BWExists += 1
@@ -70,8 +70,9 @@ func (this *AnalysisDec) DecQueryNewSimilarMsgByBW() (qstr string) {
 		buyerterms += `]}}`
 		musts = append(musts, buyerterms)
 	}
-	if BWExists > 1 && this.SearchType == 3 {
-		this.SearchType = 1
+	//searchType ==1; buyer & winner 不能为空
+	if BWExists < 2 && this.SearchType == 1 {
+		this.SearchType = 0
 	}
 	//省份
 	areaCity := []string{}

+ 6 - 5
src/jfw/modules/bigmember/src/entity/analysisEntName.go

@@ -188,7 +188,7 @@ type AnalysisDec struct {
 	MobileModel      string                 //手机型号
 	AppVersion       string                 //app版本号
 	Winner           string                 //中标企业
-	SearchType       int                    //默认0;1:中标企业||采购单位-类似项目明细;2:中标企业和采购单位类似项目明细;3:中标企业和采购单位其他项目明细
+	SearchType       int                    //默认0:中标企业||采购单位||(中标企业&&采购单位)-类似项目明细;1:中标企业和采购单位其他项目明细
 	UserId           string                 //用户id
 	IsPower          bool                   //是否有权限
 	UserLock         sync.Mutex             //用户锁
@@ -225,17 +225,18 @@ func (this *AnalysisDec) GetProjectInfoByBW() (res []map[string]interface{}) {
 	this.BuyerContent = BuyerContentStruct(this.BuyerContent)
 	//中标企业和采购单位类似项目明细
 	decQuery := this.DecQueryNewSimilarMsgByBW()
+	// log.Println("decQuery:", decQuery)
 	similarMsg, _idMap := this.GetAllMsgByBW(decQuery)
-	// log.Println(decQuery)
+	// log.Println(len(similarMsg), _idMap, "ti--:", this.SearchType)
 	//其他项目明细
 	switch this.SearchType {
-	case 1, 2:
+	case 0:
 		res = similarMsg
-	case 3:
+	case 1:
 		//中标企业和采购单位 所有项目明细
 		allQuery := this.GetAllBWQueryByBW()
 		allMsg, _ := this.GetAllMsgByBW(allQuery)
-		// log.Println(allQuery)
+		// log.Println(allQuery, "----", len(allMsg))
 		if len(allMsg) > 0 {
 			for _, v := range allMsg {
 				id := qutil.ObjToString(v["_id"])

+ 4 - 1
src/jfw/modules/bigmember/src/service/analysis/forecastproject.go

@@ -93,7 +93,7 @@ func (this *Analysis) ForPList() {
 				if pageNum == 1 {
 					if (*o_member_jy)["a_items"] != nil {
 						a_items := qutil.ObjArrToMapArr((*o_member_jy)["a_items"].([]interface{}))
-						if len(a_items) == 0 {
+						if len(a_items) == 0 || a_items[0]["a_key"] == nil || len(a_items[0]["a_key"].([]interface{})) == 0 {
 							msg = "暂无设置订阅关键词,无法进行预测"
 							code = 1
 						} else if (list == nil || len(list) == 0) && len(flist) == 0 {
@@ -436,6 +436,9 @@ func getKeyWordArr(a_items []interface{}, item string, index int) (arr []util.Vi
 		if item != "" && index >= 0 && item != qutil.ObjToString(vm["s_item"]) {
 			continue
 		}
+		if vm["a_key"] == nil {
+			continue
+		}
 		kwsArr := vm["a_key"]
 		for i, k := range kwsArr.([]interface{}) {
 			if item != "" && index >= 0 && i != index {

+ 4 - 3
src/jfw/modules/common/src/qfw/util/jy/bigVipPower.go

@@ -98,7 +98,7 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 	if userId == "" {
 		return &userPower
 	}
-	userPower.IsUpgrade = true
+	userPower.IsUpgrade = false
 	userPower.Uid = userId
 	cacheKey := fmt.Sprintf(PowerCacheKey, userId)
 
@@ -141,8 +141,9 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 			userPower.FreeBuyerPort = redis.GetInt(PowerCacheDb, fmt.Sprintf(PowerCacheBuyerPortKey, userId))
 			userPower.FreeFile = redis.GetInt(PowerCacheDb, fmt.Sprintf(PowerCacheFileKey, userId))
 			o_jy := qutil.ObjToMap((*data)["o_jy"])
-			if _, ok := (*o_jy)["o_area"]; !ok {
-				userPower.IsUpgrade = false
+			//"i_newfree":    1, //新免费用户=>新订阅设置页面 20211122
+			if qutil.IntAll((*o_jy)["i_newfree"]) > 0 {
+				userPower.IsUpgrade = true
 			}
 		}
 	}

+ 4 - 2
src/jfw/modules/publicapply/src/subscribePush/entity/setting.go

@@ -68,11 +68,13 @@ func freeSet(area map[string]interface{}, industry []string, userId string) *Fun
 //免费用户地区调整
 func FreeSubChange(userId string, area *map[string]interface{}, industry []string, ppb, isfirst bool) bool {
 	setMap := map[string]interface{}{"$set": map[string]interface{}{
-		"o_jy.o_area": area, //设置地区
+		"o_jy.o_area":    area, //设置地区
+		"o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
 	}}
 	if ppb {
 		setMap = map[string]interface{}{"$set": map[string]interface{}{
-			"o_jy.o_area_p": area, //设置地区
+			"o_jy.o_area_p":  area, //设置地区
+			"o_jy.i_newfree": 1,    //老免费用户=>新订阅设置页面 20211122
 		}}
 	}
 	updateOk := db.Mgo.UpdateById("user", userId, setMap)

+ 2 - 0
src/jfw/modules/subscribepay/src/service/areaPack.go

@@ -89,6 +89,8 @@ func (this *AreaPack) CreateOrder() {
 						discount_price = totalfee - totalfee*disCount_int/1000
 						totalfee = totalfee * disCount_int / 1000
 					}
+				} else {
+					userLotteryId = ""
 				}
 			}
 		}

+ 2 - 0
src/jfw/modules/subscribepay/src/service/dataExportPay.go

@@ -166,6 +166,8 @@ func (p *DataExportPay) CreateOrder() {
 					discount_price = order_money - order_money*disCount_int/1000
 					order_money = order_money * disCount_int / 1000
 				}
+			} else {
+				userLotteryId = ""
 			}
 		}
 		log.Println(userLotteryId, "--discount_price:", discount_price)

+ 2 - 2
src/jfw/modules/subscribepay/src/service/dataexportPack.go

@@ -132,10 +132,8 @@ func (this *DataExportPack) CreateOrder() {
 			fullPrice, reducePrice, discount, userLotteryId = util.GetCouponInfo(userId, lotteryId, products)
 			if fullPrice <= orderMoney {
 				if discount == 100 {
-
 					orderMoney = orderMoney - reducePrice
 					discountPrice = reducePrice
-
 				} else {
 					//折扣
 					disCount_int := int(math.Ceil(discount * 100))
@@ -143,6 +141,8 @@ func (this *DataExportPack) CreateOrder() {
 					orderMoney = orderMoney * disCount_int / 1000
 				}
 				log.Printf("用户%s 购买数据流量包 使用卡券:%s 折扣金额:%d", userId, userLotteryId, discountPrice)
+			} else {
+				userLotteryId = ""
 			}
 		}
 		//赠品相关

+ 2 - 0
src/jfw/modules/subscribepay/src/service/integral.go

@@ -94,6 +94,8 @@ func (b *Integral) CreateOrder() {
 					discount_price = order_money - order_money*disCount_int/1000
 					order_money = order_money * disCount_int / 1000
 				}
+			} else {
+				userLotteryId = ""
 			}
 		}
 		log.Println(userLotteryId, "--discount_price:", discount_price)

+ 13 - 1
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -90,7 +90,19 @@ func (this *OrderListDetails) GetOrderPayAllMsg() {
 				(*oData)["return_type"] = (*returnRecord)["return_type"]
 			}
 		}
-
+		//获取最后一次购买的订单
+		lastOrderMap := LastOrder(qutil.ObjToString((*oData)["product_type"]), userId)
+		//最后一次够买的vip订单
+		for _, n := range lastOrderMap {
+			if n == orderCode {
+				(*oData)["lastbuy_code"] = n
+				if data, ok := util.MQFW.FindById("user", userId, `{"i_vip_status":1,"o_jy":1}`); data != nil && ok && len(*data) > 0 {
+					(*oData)["i_vip_status"] = qutil.Int64All((*data)["i_vip_status"])
+					ojy := qutil.ObjToMap((*data)["o_jy"])
+					(*oData)["i_pp_status"] = qutil.IntAllDef((*ojy)["i_ppstatus"], 0) //i_pp_status : -1 到期  0未购买 1已购买
+				}
+			}
+		}
 		//卡卷id加密
 		if (*oData)["d_relation_id"] != "" {
 			(*oData)["userLotteryId"] = qutil.SE.Encode2Hex(qutil.ObjToString((*oData)["d_relation_id"]))

+ 5 - 3
src/jfw/modules/subscribepay/src/service/userAccountInfo.go

@@ -7,9 +7,6 @@ import (
 	"database/sql"
 	"encoding/base64"
 	"fmt"
-	"github.com/dchest/captcha"
-	"github.com/go-xweb/httpsession"
-	"github.com/go-xweb/xweb"
 	"log"
 	"mongodb"
 	qutil "qfw/util"
@@ -19,6 +16,10 @@ import (
 	"strings"
 	"time"
 	"util"
+
+	"github.com/dchest/captcha"
+	"github.com/go-xweb/httpsession"
+	"github.com/go-xweb/xweb"
 )
 
 type UserAccount struct {
@@ -648,6 +649,7 @@ func (this *UserAccount) WxUnBind() {
 			(*unsetMap)["o_jy"] = map[string]interface{}{
 				"i_wxpush":   1,
 				"i_ratemode": 2,
+				"i_newfree":  1, //新免费用户=>新订阅设置页面 20211122
 			}
 			//公众号微信关注移至另一用户中  此时微信公众号用户session问题错乱
 			if saveId := util.MQFW.Save("user", unsetMap); saveId == "" {

+ 2 - 0
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -245,6 +245,8 @@ func (this *SubscribeChange) Upgrade() {
 					discount_price = final_price - final_price*disCount_int/1000
 					final_price = final_price * disCount_int / 1000
 				}
+			} else {
+				userLotteryId = ""
 			}
 		}
 		//测试打折

+ 4 - 0
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -188,6 +188,8 @@ func (this *SubVipPayOrder) CreateOrder() {
 					discount_price = totalfee - totalfee*disCount_int/1000
 					totalfee = totalfee * disCount_int / 1000
 				}
+			} else {
+				userLotteryId = ""
 			}
 		}
 		//赠品相关
@@ -402,6 +404,8 @@ func (this *SubVipPayOrder) Renew() {
 					discount_price = totalfee - totalfee*disCount_int/1000
 					totalfee = totalfee * disCount_int / 1000
 				}
+			} else {
+				userLotteryId = ""
 			}
 		}
 		filterStr, _ := json.Marshal(filter)

+ 2 - 0
src/jfw/modules/weixin/src/wx/wx.go

@@ -502,6 +502,7 @@ func saveUser(u *UserInfo, source, pre, RSource, CSource string) (bool, string,
 			newUser["i_ts_guide"] = 2
 			newUser["o_jy"] = map[string]interface{}{
 				"i_wxpush":   1,
+				"i_newfree":  1, //新免费用户=>新订阅设置页面 20211122
 				"i_ratemode": 2,
 			}
 		} else {
@@ -581,6 +582,7 @@ func saveUser(u *UserInfo, source, pre, RSource, CSource string) (bool, string,
 				"s_sourceid":      source,
 				"i_sourceid":      isourceid,
 				"o_jy.i_wxpush":   1,
+				"o_jy.i_newfree":  1, //新免费用户=>新订阅设置页面 20211122
 				"i_ispush":        1,
 				"s_headimageurl":  u.HeadImageUrl,
 				"s_nickname":      u.Nickname,

+ 3 - 0
src/web/staticres/big-member/js/set_area.js

@@ -437,6 +437,7 @@ var vNode = {
             try {
                 onChange && onChange(selectedCity)
             } catch (error) {
+                console.log(error)
                 console.warn(arguments.callee.name + '必须定义为函数')
             }
         },
@@ -445,6 +446,7 @@ var vNode = {
             try {
                 onReset && onReset(this.initCityMap)
             } catch (error) {
+                console.log(error)
                 console.error(arguments.callee.name + '必须定义为函数')
             }
         },
@@ -453,6 +455,7 @@ var vNode = {
             try {
                 onConfirm && onConfirm(selectedCity)
             } catch (error) {
+                console.log(error)
                 console.error(arguments.callee.name + '必须定义为函数')
             }
         }

+ 48 - 1
src/web/staticres/common-module/order-list/js/order-detail.js

@@ -45,7 +45,8 @@ var vm = new Vue({
           bottomButtonShow: {
             pay: false,
             invoke: true,
-            buyAgain: false
+            buyAgain: false,
+            renew: false
           }
         },
         '-2': {
@@ -237,6 +238,27 @@ var vm = new Vue({
 
       this.orderInfo.productInfoList = this.getProductInfoList(info)
       this.orderInfo.orderInfoList = this.getOrderInfoListList(info)
+      this.getOrderBottomButton(info.order)
+    },
+    getOrderBottomButton (order) {
+      switch (order.product_type) {
+        case '省份订阅包': {
+          // 续费升级的判断(再次购买按钮值修改)
+          // i_pp_status : -1 到期  0未购买 1已购买
+          this.orderStateMap[1].bottomButtonShow.buyAgain = false
+          this.orderStateMap[1].bottomButtonShow.renew = false
+          var vipStatus =  order.i_pp_status
+          if (order.lastbuy_code) {
+            if (vipStatus === -1 && order.pay_money > 0) {
+              this.orderStateMap[1].bottomButtonShow.buyAgain = true
+            }
+            if (vipStatus === 1) {
+              this.orderStateMap[1].bottomButtonShow.renew = true
+            }
+          }
+          break
+        }
+      }
     },
     getHeaderImg: function (order) {
       var productType = order.product_type
@@ -406,6 +428,24 @@ var vm = new Vue({
         }
       }
     },
+    renew: function () {
+      var order = this.reqOrder
+      var orderCode = order.order_code
+      var productType = order.product_type
+      var platform = this.platform
+      switch (productType) {
+        case '省份订阅包': {
+            var href = assetsConf.areaPackLink.renew[platform]
+            if (href) {
+              this.goToLink(`${href}&orderCode=${orderCode}`)
+            }
+            break
+        }
+        default: {
+          break
+        }
+      }
+    },
     buyAgain: function () {
       var _this = this
       var order = this.reqOrder
@@ -421,6 +461,13 @@ var vm = new Vue({
           }
           break
         }
+        case '省份订阅包': {
+          var href = assetsConf.areaPackLink.buyAgain[platform]
+          if (href) {
+            this.goToLink(`${href}&orderCode=${orderCode}`)
+          }
+          break
+        }
         default: {
           break
         }

+ 28 - 15
src/web/staticres/common-module/vipsubscribe/js/vip-subscribe-set-template.js

@@ -305,7 +305,7 @@ var subComponent = {
       this.iosBackRefresh()
     },
     // 判断用户权限
-    
+
     // 设置区域
     setArea: function() {
       let _this = this
@@ -513,6 +513,11 @@ var subComponent = {
       $iosActionsheet.removeClass('weui-actionsheet_toggle');
       $('.match-keywords-actionsheet').hide()
       $iosMask.fadeOut(200);
+      // 免费用户
+      if (this.thisvSwitch === 'f') {
+        return
+      }
+      // 超级订阅升级提示
       if(update_renew) {
         if(this.accStatus == 2) {
           update_renew.hide()
@@ -552,6 +557,11 @@ var subComponent = {
         }
         location.href = href
       } else {
+
+        if (this.vSwitch === 'f') {
+          return this.hideActionSheet()
+        }
+
         if(_this.accStatus == 2) {
           vswitch = 'm'
         } else if(_this.accStatus == 1)  {
@@ -641,6 +651,7 @@ var subComponent = {
     },
     // 修改地区无次数点击事件
     userNumOver: function () {
+      var _this = this
       if (this.vSwitch === 'f' && this.userAreaNum === 0) {
         this.linkobj.area = 'javascript:;'
         if (this.userAreaAllNum > 0) {
@@ -655,9 +666,9 @@ var subComponent = {
                 label: '取消',
                 type: 'default'
             },{
-              label: this.userType ? '去升级' : '去购买',
+              label: _this.userType ? '去升级' : '去购买',
               onClick: function(){
-                if (this.userType) {
+                if (_this.userType) {
                   if (location.href.indexOf('front') !== -1) {
                     var href = '/areaPack/wx/page/buy?type=upgrade'
                   } else {
@@ -674,7 +685,7 @@ var subComponent = {
               }
             }]
         });
-      } 
+      }
       else {
         // this.linkobj.area = '/jyapp/big/page/set_area?callback=setting_save'
         if (this.vSwitch === 'f') {
@@ -711,7 +722,7 @@ var subComponent = {
         } else {
           location.href = '/jyapp/vipsubscribe/toSetInfoTypePage'
         }
-        
+
       }
     },
     // 重置信息类型
@@ -764,9 +775,9 @@ var subComponent = {
     // 跳转地区选择
     gotoArea: function () {
       if (location.href.indexOf('front') !== -1) {
-        location.href = '/areaPack/wx/page/set_area'
+        location.href = '/areaPack/wx/page/set_area?type=new'
       } else {
-        location.href = '/jyapp/areaPack/page/set_area'
+        location.href = '/jyapp/areaPack/page/set_area?type=new'
       }
     },
     // 获取用户权限
@@ -783,7 +794,7 @@ var subComponent = {
               _this.userAreaNum = res.data.areanum
               _this.userType = res.data.provincenum === 0 ? false : true
               _this.userAreaAllNum = res.data.provincenum
-              _this.initdata.infotype = res.data.infotype || [] 
+              _this.initdata.infotype = res.data.infotype || []
               _this.info.infoType = _this.initdata.infotype.join('、')
               // _this.$emit('UserSubscribe',res)
 
@@ -808,11 +819,13 @@ var subComponent = {
               // _this.info.area = '已选:' + proStr
 
               let areaArr = []
-              if (res.data.area === {} || res.data.provincenum === 0) {
-                _this.noAreaFreeType = true
-              } else {
-                for (const key in res.data.area) {
-                  areaArr.push(key)
+              if (res.data) {
+                if (!res.data.area || res.data.provincenum === 0) {
+                  _this.noAreaFreeType = true
+                } else {
+                  for (const key in res.data.area) {
+                    areaArr.push(key)
+                  }
                 }
               }
               $('#menuArea').text('已选:'+ areaArr.join('、'))
@@ -839,7 +852,7 @@ var subComponent = {
         _this.backTipShowCount++
       })
     },
-    // 
+    //
     // 最近三个月推送结果预览总数
     getResultView: function () {
       let keyArr = []
@@ -959,4 +972,4 @@ var custom = {
       })
   }
 }
-setInfoTypeFn.init()
+setInfoTypeFn.init()

+ 172 - 143
src/web/templates/areaPack/wx/page_set_area.html

@@ -36,7 +36,6 @@
             font-weight: 500;
             color: #FA483C;
             box-sizing: border-box;
-            display: none;
         }
         .selectChange {
             font-size: 0.24rem;
@@ -119,185 +118,215 @@
     <div id="set-header-template" v-cloak>
         <div class="wrapper-header" id="thisAreaTips">
             <div class="content">
-                <div class="selectNumMax">可选择<span class="numColor" id="canSelect">1个省</span></div>
+                <div class="selectNumMax">可选择<span class="numColor" id="canSelect">${ maxSelectText }</span></div>
                 <div class="string"></div>
                 <div class="selectNumList">
-                    <span>已选择<span class="numColor" id="thisSelect">1个省</span></span>
-                    <span class="moreTips">超出可订阅省份数量,前往购买省份订阅包 ></span>
+                    <span>已选择<span class="numColor" id="thisSelect">${ selectedAreaText }</span></span>
+                    <span class="moreTips" v-show="moreThanSubCount">超出可订阅省份数量,前往${ buyType }省份订阅包 &gt;</span>
                 </div>
                 <div class="selectChange"></div>
             </div>
-            <div class="popup-wrap" v-show="popupType">
+            <div class="popup-wrap" v-show="popupTip">
                 <div class="popup-content">
-                    <div class="popup-text" id="tips-text">您当前仅可订阅1个省,如需增加请购买【省份订阅包】</div>
+                    <div class="popup-text" id="tips-text">您当前仅可订阅${ maxSelectText },如需增加请${ buyType }【省份订阅包】</div>
                     <div class="popup-btnWrap">
-                        <div class="popup-btn" id="cancel" @click="hiddenTips">取消</div>
+                        <div class="popup-btn" id="cancel" @click="hideTips">取消</div>
                         <div class="popup-line"></div>
-                        <div class="popup-btn levelUp" id="btn-text" @click="toPay">去购买</div>
+                        <div class="popup-btn levelUp" id="btn-text" @click="toPay">去${ buyType }</div>
                     </div>
                 </div>
             </div>
         </div>
     </div>
     <script>
-        var setAreaFn = {
-            conf: {
-                sKey: 'sub_free_state'
-            },
-            buyPageInfo: {},
-            init: function () {
-                // 恢复页面状态
-                var pageInfo = sessionStorage.getItem(this.conf.sKey)
-                if (pageInfo) {
-                    this.buyPageInfo = JSON.parse(pageInfo)
-                    var areaInfo = this.buyPageInfo.area
-                    if (this.buyPageInfo && areaInfo && Object.keys(areaInfo).length !== 0) {
-                        vNode.data.initCityMap = areaInfo
-                        vueComponent.setCitySelected(areaInfo)
-                    }
-                }
-            },
-            saveToSessionStorage: function (data) {
-                sessionStorage.setItem(this.conf.sKey, JSON.stringify(data))
-            }
-        }
-       var vm = new Vue({
+        var vm = new Vue({
             delimiters: ['${', '}'],
             el: '#set-header',
             template: '#set-header-template',
             data: {
-                popupType: false,
-                popupText: '您当前仅可订阅1个省,如需增加请购买【省份订阅包】',
-                popupPayBtn: '去购买'
+                sessKey: 'sub_free_set_area',
+                selectedArea: '',
+                userSubInfo: {
+                    area: '',
+                    areanum: 0, // 可修改次数
+                    basenum: 1,
+                    provincenum: 0, // 购买的省份数量
+                },
+                popupTip: false
             },
-            created: function () {},
-            methods: {
-                hiddenTips: function () {
-                    this.popupType = false
+            computed: {
+                moreThanSubCount: function () {
+                    var max = this.maxSelectCount
+                    var sel = this.selectedAreaCount
+                    if (max === -1) return false
+                    if (sel === -1) return true
+                    if (sel > max) return true
                 },
-                toPay: function () {
-                    if (userType) {
-                        location.href = '/areaPack/wx/page/buy?type=renew&area=' +  encodeURIComponent(JSON.stringify(thisData))
+                maxSelectCount: function () {
+                    var baseNum = this.userSubInfo.basenum || 1
+                    var provincenum = this.userSubInfo.provincenum
+                    if (provincenum === -1) {
+                        return provincenum
                     } else {
-                        location.href = '/areaPack/wx/page/buy?type=buy&area=' +  encodeURIComponent(JSON.stringify(thisData))
+                        return provincenum + baseNum
                     }
                 },
-                
-            }
-        })
-        var maxSelect = 1
-        var thisSelectNum = 0
-        var userType = true // 用户是否购买过省份包
-        var vSwitch = 'f' // 用户版本,'f'免费版,m大会员,v超级订阅
-        // 获取用户权限
-        function getUserMsg() {
-            $.ajax({
-                url: '/bigmember/use/isAdd',
-                type: 'POST',
-                success: function (res) {
-                    if (res.data.vipStatus <= 0) {
-                        vSwitch = 'f'
-                        $('#thisAreaTips').show()
+                maxSelectText: function () {
+                    if (this.maxSelectCount === -1) {
+                        return '全国'
                     } else {
-                        vSwitch = 'v'
-                        $('#thisAreaTips').hide()
+                        return this.maxSelectCount + '个省'
                     }
-                }
-            })
-        }
-        getUserMsg()
-        // 获取用户购买省份包信息
-        function getUserSubscribe() {
-            $.ajax({
-                url: '/publicapply/free/subscribe',
-                type: 'POST',
-                success: function (res) {
-                    let freeArea = JSON.stringify(res.data)
-                    sessionStorage.setItem('sub_free_state', freeArea)
-                    setAreaFn.init()
-                    onChange(res.data.area)
-                    userType = res.data.provincenum === 0 ? false : true
-                    maxSelect = res.data.provincenum  + res.data.basenum
-                    // _this.$emit('UserSubscribe',res)
-                    if (maxSelect === -1) {
-                        $('#canSelect').text(`全国`)
-                    } else if (res.data.provincenum === 0 && res.data.areanum === 1) {
-                        vueComponent.provinceListMap['#'][0].selectedState = ''
+                },
+                selectedAreaCount: function () {
+                    var area = this.selectedArea
+                    if (area) {
+                        var keys = Object.keys(area)
+                        if (keys.length === 0) {
+                            return -1
+                        } else {
+                            return keys.length
+                        }
                     } else {
-                        $('#canSelect').text(`${maxSelect}个省`)
+                        return 0
                     }
+                },
+                selectedAreaText: function () {
+                    if (this.selectedAreaCount === -1) {
+                        return '全国'
+                    } else {
+                        return this.selectedAreaCount + '个省'
+                    }
+                },
+                // 是否购买了省份订阅包
+                userType: function () {
+                    if (this.userSubInfo.provincenum === -1) return true
+                    return this.userSubInfo.provincenum !== 0
+                },
+                buyType: function () {
+                    return this.userType ? '升级' : '购买'
+                },
+            },
+            mounted: function () {
+                var type = utils.getParam('type')
+                var restore = this.restoreState()
+
+                if (restore) {
                     
+                } else {
+                    if (type === 'new') {
+                        this.setAreaAllNotSelected()
+                    } else {
+                        this.getUserSubscribe()
+                    } 
                 }
-            })
-        }
-        getUserSubscribe()
-        function userUpdate(obj) {
-            let _this = this
-            console.info(obj)
-            $.ajax({
-                url: '/publicapply/subscribe/update',
-                type: 'POST',
-                data: {
-                    vSwitch: vSwitch,
-                    area:obj
+            },
+            methods: {
+                setAreaAllNotSelected: function () {
+                    vueComponent.setCitySelected()
+                    vueComponent.provinceListMap['#'][0].selectedState = ''
+                    $('#set-area .j-button-confirm').prop('disabled', true)
                 },
-                success: function (res) {
-                    console.info(res)  
-                    window.history.back()           
-                }
-            })
-        }
-        $('#thisSelect').text(`${thisSelectNum}个省`)
-        $('#canSelect').text(`${maxSelect}个省`)
-        // 以下均为示例:具体使用时候请删除
-        // 定义重置方法:方法名必须为onReset/onConfirm
-        // 参数,是被初始化的数据
+                // 获取用户订阅信息
+                getUserSubscribe: function () {
+                    var _this = this
+                    $.ajax({
+                        url: '/publicapply/free/subscribe',
+                        type: 'POST',
+                        success: function (res) {
+                            if (res && res.error_code === 0) {
+                                if (res.data) {
+                                    if (res.data.area === null || res.data.area === undefined) {
+                                        _this.setAreaAllNotSelected()
+                                    } else {
+                                        Object.assign(_this.userSubInfo, res.data)
+                                    }
+                                }
+                            } else {
+                                if (res.error_msg) {
+                                    _this.$toast(res.error_msg)
+                                }
+                            }
+                        }
+                    })
+                },
+                userUpdate: function (area) {
+                    var _this = this
+                    $.ajax({
+                        url: '/publicapply/subscribe/update',
+                        type: 'POST',
+                        data: {
+                            vSwitch: 'f',
+                            area: JSON.stringify(area)
+                        },
+                        success: function (res) {
+                            if (res && res.success) {
+                                history.back()           
+                            } else {
+                                if (res.errMsg) {
+                                    _this.$toast(res.errMsg)
+                                }
+                            }
+                        }
+                    })
+                },
+                setAreaSelected: function (area) {
+                    this.$set(this, 'selectedArea', area)
+                },
+                confirmed: function (area) {
+                    this.setAreaSelected(area)
+                    if (this.moreThanSubCount) {
+                        this.popupTip = true
+                    } else {
+                        this.userUpdate(area)
+                    }
+                },
+                hideTips: function () {
+                    this.popupTip = false
+                },
+                toPay: function () {
+                    this.popupTip = false
+                    var area = this.selectedArea
+                    var urlBase = '/jyapp/areaPack/page/buy'
+                    var areaJSON = encodeURIComponent(JSON.stringify(area))
+                    this.savePageState()
+                    if (this.userType) {
+                        location.href = urlBase + '?type=upgrade&area=' +  areaJSON
+                    } else {
+                        location.href = urlBase +  '?type=buy&area=' +  areaJSON
+                    }
+                },
+                restoreState: function () {
+                    var $data = sessionStorage.getItem(this.sessKey)
+                    if ($data) {
+                        $data = JSON.parse($data)
+
+                        for (var key in $data) {
+                            Object.assign(this.$data[key], $data[key])
+                        }
+
+                        sessionStorage.removeItem(this.sessKey)
+                    }
+                    return !!$data
+                },
+                savePageState: function () {
+                    var data = JSON.stringify(this.$data)
+                    sessionStorage.setItem(this.sessKey, JSON.stringify(data))
+                },
+            }
+        })
+
         function onReset (initData) {
-            $('.selectChange').text('')
-            $('#thisSelect').text(`${thisSelectNum}个省`)
-            $('.moreTips').hide()
+            vm.setAreaSelected(initData)
         }
         // 被选中的数据
         function onConfirm (selectedData) {
-            var selectDataList = []
-            for (const key in selectedData) {
-                selectDataList.push(key)
-            }
-            if (selectDataList.length > maxSelect && maxSelect !== -1 && vSwitch === 'f') {
-                vm.popupType = true
-                if (!userType) {
-                    $('#tips-text').text('您当前仅可订阅1个省,如需增加请购买【省份订阅包】')
-                    $('#btn-text').text('去购买')
-                } else {
-                    $('#tips-text').text('已超出您可订阅的省份数量,是否升级【省份订阅包】')
-                    $('#btn-text').text('去升级')
-                }
-            } else {
-                var areaData = {}
-                selectDataList.forEach(function (item, index) {
-                    areaData[item] = []
-                })
-                areaData = JSON.stringify(areaData)
-                userUpdate(areaData)
-            }
+            vm.confirmed(selectedData)
         }
-        var thisData = []
         // 页面选中状态改变时触发
         function onChange (selectedData) {
-            thisData = selectedData
-            var selectDataList = []
-            for (const key in selectedData) {
-                selectDataList.push(key)
-            }
-            var arr = selectDataList.join('、')
-            $('.selectChange').text(`${arr}`)
-            thisSelectNum = selectDataList.length
-            $('#thisSelect').text(`${selectDataList.length}个省`)
-            if (thisSelectNum > maxSelect) {
-                $('.moreTips').show()
-            } else {
-                $('.moreTips').hide()
-            }
+            vm.setAreaSelected(selectedData)
+            $('#set-area .j-button-confirm').prop('disabled', false)
         }
     </script>
 </body>

+ 4 - 0
src/web/templates/weixin/commonPay/areaPack/orderDetail.html

@@ -92,6 +92,10 @@
                         class="j-button-confirm buy-again"
                         v-if="orderStateMap[orderInfo.state].bottomButtonShow.buyAgain"
                         @click="buyAgain">再次购买</button>
+                    <button
+                            class="j-button-confirm renew"
+                            v-if="orderStateMap[orderInfo.state].bottomButtonShow.renew"
+                            @click="renew">续费</button>
                 </div>
             </div>
         </div>