Jelajahi Sumber

fix: 免费用户infoType选择逻辑调整

cuiyalong 3 tahun lalu
induk
melakukan
9c6fe1f8be

+ 1 - 4
src/web/staticres/common-module/vipsubscribe/css/vip-subscribe-set-template.css

@@ -495,7 +495,7 @@
   border-radius: 0.08rem 0.08rem 0.08rem 0.08rem;
   font-size: 0.32rem;
   font-weight: 500;
-  color: #C0C4CC;
+  color: #5f5e64;
   line-height: 0.8rem;
   text-align: center;
 }
@@ -520,9 +520,6 @@
   background-size: 100% 100%;
   z-index: 2;
 }
-.thisChange {
-  color:#5f5e64 !important;
-}
 @keyframes bottomUp {
   0% {
     transform: translateY(100%);

+ 29 - 88
src/web/staticres/common-module/vipsubscribe/js/vip-subscribe-set-template.js

@@ -159,14 +159,14 @@ var subScribeTemplate = `
         <div class="close-btn" @click="closeInfoType"></div>
       </div>
       <div class="menu-content">
-        <div class="infoType-btn" @click="changeBtnType('全部')" :class="infoTypeData.indexOf('全部') !== -1 ? 'infoTypeActive' : ''">全部</div>
+        <div class="infoType-btn" @click="changeBtnType('all')" :class="infoTypeData.length === 0 ? 'infoTypeActive' : ''">全部</div>
         <div v-for="(item, index) in infoTypeList" :key="index" class="infoType-item">
           <div class="infoType-btn" @click="changeBtnType(item.value)" :class="infoTypeData.indexOf(item.value) !== -1 ? 'infoTypeActive' : ''">{{item.title}}</div>
           <div class="infoType-msg">{{item.desc}}</div>
         </div>
       </div>
       <div class="bottom-btn-wrap">
-        <div class="bottom-btn cancel" @click="reset" :class="isChange?'thisChange':''">重置</div>
+        <button class="bottom-btn cancel" @click="reset" :disabled="infoTypeData.length === 0">重置</button>
         <div class="bottom-btn enter" @click="confirm">确认</div>
       </div>
     </div>
@@ -255,8 +255,7 @@ var subComponent = {
       userType: false, // 用户是否为付费用户
       userAreaAllNum: 1, // 用户可修改地区总次数
       infoTypeMenu: false, // 信息类型弹窗状态
-      infoTypeData: ['全部'], // 信息类型选择列表
-      isChange: false, // 信息类型是否做过更改
+      infoTypeData: [], // 信息类型选择列表
       conf: {}, // 信息类型数据
       noAreaFreeType: false, // 免费用户未设置地区时显示弹窗
       backTipShowCount: 0, // 离开页面展示弹窗次数
@@ -288,7 +287,6 @@ var subComponent = {
       }
     },
     vSwitch: function (val) {
-      sessionStorage.setItem('infoTypeVswitch', val)
       if (val === 'f') {
         this.getUserSubscribe()
       }
@@ -730,25 +728,31 @@ var subComponent = {
     },
     // 重置信息类型
     reset: function () {
-      if (this.isChange) {
-        this.infoTypeData = ['全部']
-        this.isChange = false
-      }
+      this.infoTypeData = []
     },
     // 确认信息类型
     confirm: function () {
       this.infoTypeMenu = false
-      // var callback = utils.getParam('callback')
-      // 如果有callback,则使用页面内部自己定义的方法来恢复和保存数据
-      if (true) {
-          try {
-              custom['_setting_save'](this.infoTypeData)
-          } catch (error) {
-              console.log(error)
+      this.saveInfoTypeChange()
+    },
+    saveInfoTypeChange: function () {
+      var _this = this
+      $.ajax({
+        type:'POST',
+        url:'/publicapply/subscribe/setUserInfo',
+        data: {
+          pageType: 'infoType',
+          infoTypeArr: this.infoTypeData.join(','),
+          vSwitch: this.vSwitch
+        },
+        success:function(res){
+          if(res.flag) {
+            location.reload()
+          } else {
+            _this.$toast(res.data.error_msg)
           }
-      } else {
-          setInfoTypeFn.saveToSessionStorage(this.infoTypeData)
-      }
+        }
+      })
     },
     // 关闭信息类型菜单
     closeInfoType: function () {
@@ -756,23 +760,15 @@ var subComponent = {
     },
     // 点击按钮改变按钮状态
     changeBtnType: function (item) {
-      this.isChange = true
-      let thisIndex = this.infoTypeData.indexOf(item)
-      let allType = this.infoTypeData.indexOf('全部')
-      if (allType !== -1) {
-        this.infoTypeData.splice(allType,1)
-      }
-      if (item === '全部') {
-        this.infoTypeData = ['全部']
+      if (item === 'all') {
+        this.infoTypeData = []
       } else {
+        let thisIndex = this.infoTypeData.indexOf(item)
         if (thisIndex !== -1) {
-          this.infoTypeData.splice(thisIndex,1)
+          this.infoTypeData.splice(thisIndex, 1)
         } else {
           this.infoTypeData.push(item)
         }
-        if (this.infoTypeData.length === 0 || this.infoTypeData.length === this.infoTypeList.length) {
-          this.infoTypeData = ['全部']
-        }
       }
     },
     // 跳转地区选择
@@ -798,8 +794,8 @@ var subComponent = {
               _this.userType = res.data.provincenum === 0 ? false : true
               _this.userAreaAllNum = res.data.provincenum
               _this.initdata.infotype = res.data.infotype || []
-              _this.info.infoType = _this.initdata.infotype.join('、')
-              // _this.$emit('UserSubscribe',res)
+              _this.infoTypeData = res.data.infotype || []
+              _this.info.infoType = _this.infoTypeData.length === 0 ? '全部类型' : _this.infoTypeData.join('、')
 
               // let proStr = ''
               // Object.keys(res.data.area).forEach(function(item,index) {
@@ -832,7 +828,6 @@ var subComponent = {
                 }
               }
               $('#menuArea').text('已选:'+ areaArr.join('、'))
-              _this.info.infoType = sessionStorage.getItem('thisUserInfoType')
           }
       })
     },
@@ -922,57 +917,3 @@ var subComponent = {
     },
   },
 }
-
-var setInfoTypeFn = {
-  conf: {
-      sKey: 'big-setInfoType'
-  },
-  init: function () {
-      var setKey = ''
-      if (setKey) {
-          this.conf.sKey = setKey
-      }
-
-      var initData = sessionStorage.getItem(this.conf.sKey)
-      if (initData) {
-          initData = JSON.parse(initData)
-          console.log(initData)
-          // vNode.data.initInfoType = initData
-          // vueComponent.setInfoTypeState(vNode.data.initInfoType)
-      }
-  },
-  saveToSessionStorage: function (data) {
-      sessionStorage.setItem(this.conf.sKey, JSON.stringify(data))
-  }
-}
-
-var custom = {
-  _setting_save: function (setdata) {
-      if(setdata.length == 0) {
-          setdata = ''
-      } else {
-          setdata = setdata.join(',')
-      }
-      sessionStorage.setItem('thisUserInfoType', setdata)
-      let vswitch = sessionStorage.getItem('infoTypeVswitch')
-      $.ajax({
-          type:'POST',
-          url:'/publicapply/subscribe/setUserInfo',
-          data: {
-              pageType: 'infoType',
-              infoTypeArr: setdata,
-              vSwitch: vswitch
-          },
-          success:function(res){
-            sessionStorage.removeItem('infoTypeVswitch')
-              if(res.flag) {
-                  sessionStorage.removeItem('big-setInfoType')
-                  location.reload()
-              } else {
-                  vueComponent.$toast(res.data.error_msg)
-              }
-          }
-      })
-  }
-}
-setInfoTypeFn.init()