浏览代码

fix: bugs

cuiyalong 4 年之前
父节点
当前提交
a3977e14ce

+ 50 - 13
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyset-detail.js

@@ -323,7 +323,8 @@ var keySetDetail = new Vue({
     // 限制数组最大长度
     conf: {
       maxKeyLength: 10,
-      recommendTagsCount: 6
+      recommendTagsCount: 6,
+      i_new: 1 // 1新用户 0老用户
     },
     // 是编辑(查看详情)还是添加
     modeType: 'add',
@@ -509,6 +510,13 @@ var keySetDetail = new Vue({
     }, 100)
   },
   methods: {
+    showToast: function (message) {
+      return this.$toast({
+        duration: 1500,
+        forbidClick: true,
+        message: message,
+      })
+    },
     showDialog: function (conf) {
       var defaultConf = {
         title: '提示',
@@ -550,6 +558,14 @@ var keySetDetail = new Vue({
           }
           _this.keysetReq = r
 
+          if (r) {
+            _this.conf.i_new = r.i_new
+            if (r.i_new == 1) {
+              delete _this.provinceListMap['#']
+              _this.initIndexBar()
+            }
+          }
+
           // 如果不是数组,则直接返回
           if (!(r.a_key instanceof Array)) {
             return
@@ -883,12 +899,12 @@ var keySetDetail = new Vue({
         case 'area': {
           if (info) {
             if ((info instanceof Array) && info.length === 0) {
-              text = '全国'
+              text = this.conf.i_new == 1 ? '请选择地区' : '全国'
             } else {
               text = info.join('、')
             }
           } else {
-            text = '全国'
+            text = this.conf.i_new == 1 ? '请选择地区' : '全国'
           }
           break
         }
@@ -976,9 +992,10 @@ var keySetDetail = new Vue({
     initIndexBar: function () {
       // 整理数据得到indexListMap(),同时获得indexList
       var map = {}
+      var indexList = []
       for (var key in this.provinceListMap) {
         var areaArr = []
-        this.indexList.push(key)
+        indexList.push(key)
         this.provinceListMap[key].forEach(function (item) {
           areaArr.push({
             name: item,
@@ -987,6 +1004,7 @@ var keySetDetail = new Vue({
         })
         map[key] = areaArr
       }
+      this.indexList = indexList
       this.indexListMap = map
       // 给map赋值
       // for (var k in map) {
@@ -1000,16 +1018,25 @@ var keySetDetail = new Vue({
         this.setAllAreaDisSelected(false)
         item.selected = true
       } else {
-        this.indexListMap['#'][0].selected = false
+        if (this.conf.i_new != 1) {
+          // 老用户
+          this.indexListMap['#'][0].selected = false
+        } else {
+          // 新用户
+          this.setAllAreaDisSelected(false)
+        }
         item.selected = !item.selected
       }
 
-      // 此处判断是否全部选中
-      var state = this.getAllAreaStateExceptCountryWide()
-      if (state !== 0) {
-        // 全国选中
-        this.setAllAreaDisSelected(false)
-        this.indexListMap['#'][0].selected = true
+      if (this.conf.i_new != 1) {
+        // 老用户
+        // 此处判断是否全部选中
+        var state = this.getAllAreaStateExceptCountryWide()
+        if (state !== 0) {
+          // 全国选中
+          this.setAllAreaDisSelected(false)
+          this.indexListMap['#'][0].selected = true
+        }
       }
     },
     // 获得所有选中的省份名字的数组
@@ -1060,7 +1087,9 @@ var keySetDetail = new Vue({
     },
     resetAreaAll: function () {
       this.setAllAreaDisSelected(false)
-      this.indexListMap['#'][0].selected = true
+      if (this.conf.i_new != 1) {
+        this.indexListMap['#'][0].selected = true
+      }
     },
     areaConfirm: function () {
       this.currentInfo.area = this.getSelectedAreaArr()
@@ -1071,7 +1100,9 @@ var keySetDetail = new Vue({
       var _this = this
       if (!areaArr) areaArr = this.currentInfo.area
       if (!(areaArr instanceof Array) || areaArr.length === 0) return
-      this.indexListMap['#'][0].selected = false
+      if (this.conf.i_new != 1) {
+        this.indexListMap['#'][0].selected = false
+      }
       areaArr.forEach(function (item) {
         for (var key in _this.indexListMap) {
           _this.indexListMap[key].forEach(function (iitem) {
@@ -1222,6 +1253,12 @@ var keySetDetail = new Vue({
         notkey: t.notkey,
         keyWords: t.key
       }
+      if (this.conf.i_new == 1) {
+        // 新用户
+        if (!data.area || data.area.length === 0) {
+          return this.showToast('请选择一个区域')
+        }
+      }
       this.saveKeyList(data, true)
     },
     // 检查数据是否更新了

+ 8 - 3
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyword-info.js

@@ -108,6 +108,11 @@ var vm = new Vue({
   },
   mounted: function () {},
   methods: {
+    // 输入内容格式化
+    formatter(value) {
+      // 过滤输入的前后空格
+      return value.trim()
+    },
     showLoading: function () {
       return this.$toast.loading({
         duration: 0,
@@ -437,7 +442,7 @@ var vm = new Vue({
     },
     saveKeyWord: function () {
       var _this = this
-      if (!this.keyInfo.key) {
+      if (!this.keyInfo.key.trim()) {
         return this.showDialog({
           title: '',
           message: '关键词不能为空',
@@ -521,7 +526,7 @@ var vm = new Vue({
 
       if (this.keyInfo.key.replace(/\s+/g, '')) {
         filterArr.push({
-          key: this.keyInfo.key.split(/\s+/),
+          key: this.keyInfo.key.trim().split(/\s+/),
           matchway: this.keyInfo.matchWay
         })
       }
@@ -658,7 +663,7 @@ var vm = new Vue({
       return this.recListState.list
     },
     clickTag: function (item) {
-      var key = this.keyInfo.key
+      var key = this.keyInfo.key.trim()
       if (key) {
         var keyArr = this.keyInfo.key.split(/\s+/)
         keyArr.push(item)

+ 6 - 0
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyword-manage.js

@@ -14,6 +14,7 @@ var vm = new Vue({
       show: false,
       type: '', // 状态:add/edit
       value: '',
+      valueBackup: '',
       tipText: ''
     },
   },
@@ -347,9 +348,11 @@ var vm = new Vue({
       this.editGroupNameDialog.tipText = ''
       if (editType === 'edit') {
         this.editGroupNameDialog.value = item.name
+        this.editGroupNameDialog.valueBackup = item.name
         this.editGroupNameDialog.gIndex = index
       } else if (editType === 'add') {
         this.editGroupNameDialog.value = ''
+        this.editGroupNameDialog.valueBackup = ''
       }
       this.$nextTick(function () {
         $('.group-name-edit .van-dialog__confirm').prop('disabled', !this.editGroupNameDialog.value)
@@ -359,6 +362,9 @@ var vm = new Vue({
       if (action === 'cancel') {
         done()
       } else if (action === 'confirm') {
+        if (this.editGroupNameDialog.value === this.editGroupNameDialog.valueBackup) {
+          return done()
+        }
         // 关键词分类名判重
         var classNameArr = this.getAllGroupName()
         if (classNameArr.indexOf(this.editGroupNameDialog.value) === -1) {

+ 7 - 3
src/jfw/modules/app/src/web/templates/vipsubscribe/infoWord.html

@@ -35,7 +35,9 @@
                 </div>
                 <van-field
                     class="card-radius key-textarea"
-                    v-model.trim="keyInfo.key"
+                    v-model="keyInfo.key"
+                    :formatter="formatter"
+                    format-trigger="onBlur"
                     rows="3"
                     maxlength="200"
                     autosize
@@ -47,7 +49,7 @@
                 <div class="rec-cells card-radius" v-show="recListState.listAll.length">
                     <div class="rec-header">
                         <div class="rec-title">相似订阅推荐</div>
-                        <div class="rec-change" @click="nextPageRec">
+                        <div class="rec-change" @click="nextPageRec" v-show="recListState.listAll.length > recListState.pageSize">
                             <van-icon :class="recListState.loading ? 'active' : ''" name="replay"></van-icon>
                             <span class="text">换一批</span>
                         </div>
@@ -83,7 +85,9 @@
                 </div>
                 <van-field
                     class="card-radius key-textarea"
-                    v-model.trim="keyInfo.notKey"
+                    v-model="keyInfo.notKey"
+                    :formatter="formatter"
+                    format-trigger="onBlur"
                     rows="3"
                     maxlength="200"
                     autosize

+ 3 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/manageWord.html

@@ -56,6 +56,9 @@
             color: #FB483D;
             margin: .1rem 0;
         }
+        .footer-tip .van-notice-bar__content {
+            text-align: center;
+        }
     </style>
 </head>
 

+ 1 - 1
src/jfw/modules/app/src/web/templates/weixin/wxkeyset/filterset.html

@@ -37,7 +37,7 @@
             <div class="j-cells with-sub-info rec-cells" v-if="recListState.listAll.length">
                 <div class="j-cell rec-header">
                     <div class="rec-title">相似订阅推荐</div>
-                    <div class="rec-change" @click="nextPageRec">
+                    <div class="rec-change" @click="nextPageRec" v-show="recListState.listAll.length > recListState.pageSize">
                         <van-icon :class="recListState.loading ? 'active' : ''" name="replay"></van-icon>
                         <span class="text">换一批</span>
                     </div>

+ 50 - 13
src/web/staticres/vipsubscribe/js/keyset-detail.js

@@ -323,7 +323,8 @@ var keySetDetail = new Vue({
     // 限制数组最大长度
     conf: {
       maxKeyLength: 10,
-      recommendTagsCount: 6
+      recommendTagsCount: 6,
+      i_new: 1 // 1新用户 0老用户
     },
     // 是编辑(查看详情)还是添加
     modeType: 'add',
@@ -511,6 +512,13 @@ var keySetDetail = new Vue({
     }, 100)
   },
   methods: {
+    showToast: function (message) {
+      return this.$toast({
+        duration: 1500,
+        forbidClick: true,
+        message: message,
+      })
+    },
     showDialog: function (conf) {
       var defaultConf = {
         title: '提示',
@@ -562,6 +570,14 @@ var keySetDetail = new Vue({
           }
           _this.keysetReq = r
 
+          if (r) {
+            _this.conf.i_new = r.i_new
+            if (r.i_new == 1) {
+              delete _this.provinceListMap['#']
+              _this.initIndexBar()
+            }
+          }
+
           // 如果不是数组,则直接返回
           if (!(r.a_key instanceof Array)) {
             return
@@ -895,12 +911,12 @@ var keySetDetail = new Vue({
         case 'area': {
           if (info) {
             if ((info instanceof Array) && info.length === 0) {
-              text = '全国'
+              text = this.conf.i_new == 1 ? '请选择地区' : '全国'
             } else {
               text = info.join('、')
             }
           } else {
-            text = '全国'
+            text = this.conf.i_new == 1 ? '请选择地区' : '全国'
           }
           break
         }
@@ -988,15 +1004,17 @@ var keySetDetail = new Vue({
     initIndexBar: function () {
       // 整理数据得到indexListMap(),同时获得indexList
       var map = {}
+      var indexList = []
       for (var key in this.provinceListMap) {
         var areaArr = []
-        this.indexList.push(key)
+        indexList.push(key)
         this.provinceListMap[key].forEach(function (item) {
           areaArr.push({
             name: item,
             selected: item === '全国'
           })
         })
+        this.indexList = indexList
         map[key] = areaArr
       }
       this.indexListMap = map
@@ -1012,16 +1030,25 @@ var keySetDetail = new Vue({
         this.setAllAreaDisSelected(false)
         item.selected = true
       } else {
-        this.indexListMap['#'][0].selected = false
+        if (this.conf.i_new != 1) {
+          // 老用户
+          this.indexListMap['#'][0].selected = false
+        } else {
+          // 新用户
+          this.setAllAreaDisSelected(false)
+        }
         item.selected = !item.selected
       }
 
-      // 此处判断是否全部选中
-      var state = this.getAllAreaStateExceptCountryWide()
-      if (state !== 0) {
-        // 全国选中
-        this.setAllAreaDisSelected(false)
-        this.indexListMap['#'][0].selected = true
+      if (this.conf.i_new != 1) {
+        // 老用户
+        // 此处判断是否全部选中
+        var state = this.getAllAreaStateExceptCountryWide()
+        if (state !== 0) {
+          // 全国选中
+          this.setAllAreaDisSelected(false)
+          this.indexListMap['#'][0].selected = true
+        }
       }
     },
     // 获得所有选中的省份名字的数组
@@ -1072,7 +1099,9 @@ var keySetDetail = new Vue({
     },
     resetAreaAll: function () {
       this.setAllAreaDisSelected(false)
-      this.indexListMap['#'][0].selected = true
+      if (this.conf.i_new != 1) {
+        this.indexListMap['#'][0].selected = true
+      }
     },
     areaConfirm: function () {
       this.currentInfo.area = this.getSelectedAreaArr()
@@ -1083,7 +1112,9 @@ var keySetDetail = new Vue({
       var _this = this
       if (!areaArr) areaArr = this.currentInfo.area
       if (!(areaArr instanceof Array) || areaArr.length === 0) return
-      this.indexListMap['#'][0].selected = false
+      if (this.conf.i_new != 1) {
+        this.indexListMap['#'][0].selected = false
+      }
       areaArr.forEach(function (item) {
         for (var key in _this.indexListMap) {
           _this.indexListMap[key].forEach(function (iitem) {
@@ -1234,6 +1265,12 @@ var keySetDetail = new Vue({
         notkey: t.notkey,
         keyWords: t.key
       }
+      if (this.conf.i_new == 1) {
+        // 新用户
+        if (!data.area || data.area.length === 0) {
+          return this.showToast('请选择一个区域')
+        }
+      }
       this.saveKeyList(data, true)
     },
     // 检查数据是否更新了

+ 8 - 3
src/web/staticres/vipsubscribe/js/keyword-info.js

@@ -108,6 +108,11 @@ var vm = new Vue({
   },
   mounted: function () {},
   methods: {
+    // 输入内容格式化
+    formatter(value) {
+      // 过滤输入的前后空格
+      return value.trim()
+    },
     showLoading: function () {
       return this.$toast.loading({
         duration: 0,
@@ -437,7 +442,7 @@ var vm = new Vue({
     },
     saveKeyWord: function () {
       var _this = this
-      if (!this.keyInfo.key) {
+      if (!this.keyInfo.key.trim()) {
         return this.showDialog({
           title: '',
           message: '关键词不能为空',
@@ -521,7 +526,7 @@ var vm = new Vue({
 
       if (this.keyInfo.key.replace(/\s+/g, '')) {
         filterArr.push({
-          key: this.keyInfo.key.split(/\s+/),
+          key: this.keyInfo.key.trim().split(/\s+/),
           matchway: this.keyInfo.matchWay
         })
       }
@@ -659,7 +664,7 @@ var vm = new Vue({
       return this.recListState.list
     },
     clickTag: function (item) {
-      var key = this.keyInfo.key
+      var key = this.keyInfo.key.trim()
       if (key) {
         var keyArr = this.keyInfo.key.split(/\s+/)
         keyArr.push(item)

+ 6 - 0
src/web/staticres/vipsubscribe/js/keyword-manage.js

@@ -14,6 +14,7 @@ var vm = new Vue({
       show: false,
       type: '', // 状态:add/edit
       value: '',
+      valueBackup: '',
       tipText: ''
     },
   },
@@ -347,9 +348,11 @@ var vm = new Vue({
       this.editGroupNameDialog.tipText = ''
       if (editType === 'edit') {
         this.editGroupNameDialog.value = item.name
+        this.editGroupNameDialog.valueBackup = item.name
         this.editGroupNameDialog.gIndex = index
       } else if (editType === 'add') {
         this.editGroupNameDialog.value = ''
+        this.editGroupNameDialog.valueBackup = ''
       }
       this.$nextTick(function () {
         $('.group-name-edit .van-dialog__confirm').prop('disabled', !this.editGroupNameDialog.value)
@@ -359,6 +362,9 @@ var vm = new Vue({
       if (action === 'cancel') {
         done()
       } else if (action === 'confirm') {
+        if (this.editGroupNameDialog.value === this.editGroupNameDialog.valueBackup) {
+          return done()
+        }
         // 关键词分类名判重
         var classNameArr = this.getAllGroupName()
         if (classNameArr.indexOf(this.editGroupNameDialog.value) === -1) {

+ 7 - 3
src/web/templates/weixin/vipsubscribe/infoWord.html

@@ -33,7 +33,9 @@
                     </div>
                     <van-field
                         class="card-radius key-textarea"
-                        v-model.trim="keyInfo.key"
+                        v-model="keyInfo.key"
+                        :formatter="formatter"
+                        format-trigger="onBlur"
                         rows="3"
                         maxlength="200"
                         autosize
@@ -45,7 +47,7 @@
                     <div class="rec-cells card-radius" v-show="recListState.listAll.length">
                         <div class="rec-header">
                             <div class="rec-title">相似订阅推荐</div>
-                            <div class="rec-change" @click="nextPageRec">
+                            <div class="rec-change" @click="nextPageRec"  v-show="recListState.listAll.length > recListState.pageSize">
                                 <van-icon :class="recListState.loading ? 'active' : ''" name="replay"></van-icon>
                                 <span class="text">换一批</span>
                             </div>
@@ -81,7 +83,9 @@
                     </div>
                     <van-field
                         class="card-radius key-textarea"
-                        v-model.trim="keyInfo.notKey"
+                        v-model="keyInfo.notKey"
+                        :formatter="formatter"
+                        format-trigger="onBlur"
                         rows="3"
                         maxlength="200"
                         autosize

+ 3 - 0
src/web/templates/weixin/vipsubscribe/manageWord.html

@@ -60,6 +60,9 @@
             color: #FB483D;
             margin: .1rem 0;
         }
+        .footer-tip .van-notice-bar__content {
+            text-align: center;
+        }
     </style>
 </head>
 

+ 1 - 1
src/web/templates/weixin/wxkeyset/filterset.html

@@ -36,7 +36,7 @@
             <div class="j-cells with-sub-info rec-cells" v-if="recListState.listAll.length">
                 <div class="j-cell rec-header">
                     <div class="rec-title">相似订阅推荐</div>
-                    <div class="rec-change" @click="nextPageRec">
+                    <div class="rec-change" @click="nextPageRec" v-show="recListState.listAll.length > recListState.pageSize">
                         <van-icon :class="recListState.loading ? 'active' : ''" name="replay"></van-icon>
                         <span class="text">换一批</span>
                     </div>