瀏覽代碼

feat: 关键词按照修改时间排序

cuiyalong 4 年之前
父節點
當前提交
09adf1ca25

+ 57 - 12
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyWord.js

@@ -26,6 +26,11 @@ var vm = new Vue({
     }
   },
   computed: {
+    keyListSorted: function () {
+      return this.filter.keywordsList.sort(function (a, b) {
+        return b.updatetime - a.updatetime
+      })
+    },
     fastImportTipShow: function () {
       return this.filter.allKeywordsList.length === 0 && this.filter.loaded && this.tip.fastImport
     },
@@ -135,33 +140,54 @@ var vm = new Vue({
     },
     // 向关键词中添加一些信息
     addInfoToKeyItem: function (groupList) {
+      var _this = this
       if (!Array.isArray(groupList)) return []
+      var arr = []
 
       groupList.forEach(function (keywordsList, index) {
-        if (Array.isArray(keywordsList.a_key)) {
+        if (keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
+          keywordsList.updatetime = _this.getMaxUpdateTime(keywordsList.a_key)
           keywordsList.a_key.forEach(function (keyword, iindex) {
             // 添加一些其他信息
             keyword.groupName = keywordsList.s_item // 分类名
             keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
             keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
           })
+          arr.push(keywordsList)
         }
       })
 
-      return groupList
+      return arr
     },
     getGroupNameList: function (keywordsGroupList) {
       var groupNameList = []
       if (!Array.isArray(keywordsGroupList)) return groupNameList
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          count: count // 分类下有多少个关键词
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex
+          })
+        }
       })
       return groupNameList
     },
+    getMaxUpdateTime: function (arr) {
+      var max = 0
+      if (!Array.isArray(arr)) return max
+      arr.some(function (item) {
+        if (item.updatetime && item.updatetime > max) {
+          max = item.updatetime
+        }
+      })
+      return max
+    },
     calcKeyInfo: function (item) {
       // 匹配方式 item.matchway 0/null精准 1模糊
       var key = item.key
@@ -279,6 +305,7 @@ var vm = new Vue({
 
       for (var key in deleteKeyArr) {
         if (Array.isArray(deleteKeyArr[key])) {
+          deleteKeyArr[key] = deleteKeyArr[key].sort(function (a, b) { return a - b })
           deleteKey[key] = deleteKeyArr[key].join(',')
         }
       }
@@ -286,6 +313,7 @@ var vm = new Vue({
     },
     batchDeleteConfirmed: function () {
       var deleteKey = this.getDeleteKey()
+      if (Object.keys(deleteKey).length === 0) return
       var loading = this.showLoading()
       var _this = this
       $.ajax({
@@ -316,7 +344,7 @@ var vm = new Vue({
       // instance 为对应的 SwipeCell 实例
       var position = e.position
       var instance = e.instance
-      var index = e.name
+      var index = e.name // item.groupIndex-item.keyIndex
 
       switch (position) {
         case 'left': {
@@ -339,6 +367,19 @@ var vm = new Vue({
         }
       }
     },
+    getGroupFromIndex: function (gIndex, kIndex) {
+      var groupItem = {}
+      this.filter.keywordsList.some(function (item) {
+        if (item) {
+          var gotThis = item.groupIndex == gIndex && item.keyIndex == kIndex
+          if (gotThis) {
+            groupItem = item
+          }
+          return gotThis
+        }
+      })
+      return groupItem
+    },
     /**
      * 删除单个关键词
      * @param {number} index 当前关键词在列表中的index
@@ -347,7 +388,11 @@ var vm = new Vue({
     delThisKey: function (index, instance) {
       var _this = this
       // 需要找到当前关键词组的item
-      var key = this.filter.keywordsList[index]
+      var indexArr = index.split('-')
+      var gIndex = indexArr[0]
+      var kIndex = indexArr[1]
+      var key = this.getGroupFromIndex(gIndex, kIndex)
+
       this.showDialog({
         title: '',
         message: '确定删除当前关键词?',
@@ -364,9 +409,9 @@ var vm = new Vue({
     // 根据分类名,得到分类索引
     getGroupIndexWithGroupName: function (gn) {
       var groupIndex = -1
-      this.keywordsGroupList.forEach(function(item, index) {
+      this.keywordsGroupList.forEach(function(item) {
         if (gn === item.s_item) {
-          groupIndex = index
+          groupIndex = item.groupIndex
         }
       })
       return groupIndex

+ 18 - 10
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyword-info.js

@@ -192,31 +192,39 @@ var vm = new Vue({
     // 向关键词中添加一些信息
     addInfoToKeyItem: function (groupList) {
       if (!Array.isArray(groupList)) return []
+      var arr = []
 
       groupList.forEach(function (keywordsList, index) {
-        if (Array.isArray(keywordsList.a_key)) {
+        if (keywordsList && keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
           keywordsList.a_key.forEach(function (keyword, iindex) {
             // 添加一些其他信息
             keyword.groupName = keywordsList.s_item // 分类名
             keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
             keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
           })
+          arr.push(keywordsList)
         }
       })
 
-      return groupList
+      return arr
     },
     getGroupNameList: function (keywordsGroupList) {
       var groupNameList = []
       if (!Array.isArray(keywordsGroupList)) return groupNameList
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          checked: false,
-          count: count, // 分类下有多少个关键词
-          gIndex: index
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            checked: false,
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex
+          })
+        }
       })
       return groupNameList
     },

+ 76 - 18
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/keyword-manage.js

@@ -4,6 +4,7 @@ var vm = new Vue({
   data: {
     batchDeleteState: false, // 是否在批量删除状态
     userData: {}, // getUserInfo接口用户原始数据
+    keywordsGroupList: [],
     groupNameList: [],
     listState: {
       loaded: false
@@ -16,6 +17,11 @@ var vm = new Vue({
     },
   },
   computed: {
+    groupNameListSorted: function () {
+      return this.groupNameList.sort(function (a, b) {
+        return b.updatetime - a.updatetime
+      })
+    },
     listShow: function () {
       return this.groupNameList.length !== 0 && this.listState.loaded
     },
@@ -85,10 +91,10 @@ var vm = new Vue({
             _this.userData = res.userData
             if (res.userData && res.userData.o_vipjy) {
               // 整理数据
-              var list = _this.getGroupNameList(res.userData.o_vipjy.a_items)
-              if (Array.isArray(list)) {
-                _this.groupNameList = list
-              }
+              var groupList = _this.addInfoToKeyItem(res.userData.o_vipjy.a_items)
+              var groupNameList = _this.getGroupNameList(groupList)
+              _this.keywordsGroupList = groupList
+              _this.groupNameList = groupNameList
             }
           }
         },
@@ -102,20 +108,59 @@ var vm = new Vue({
         }
       })
     },
+    // 向关键词中添加一些信息
+    addInfoToKeyItem: function (groupList) {
+      var _this = this
+      if (!Array.isArray(groupList)) return []
+      var arr = []
+
+      groupList.forEach(function (keywordsList, index) {
+        if (keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
+          keywordsList.updatetime = _this.getMaxUpdateTime(keywordsList.a_key)
+          keywordsList.a_key.forEach(function (keyword, iindex) {
+            // 添加一些其他信息
+            keyword.groupName = keywordsList.s_item // 分类名
+            keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
+            keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
+          })
+          arr.push(keywordsList)
+        }
+      })
+
+      return arr
+    },
     getGroupNameList: function (keywordsGroupList) {
       if (!Array.isArray(keywordsGroupList)) return
       var groupNameList = []
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          checked: false,
-          deleteDisabled: count > 0, // 该分类是否能被删除
-          count: count // 分类下有多少个关键词
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            checked: false,
+            deleteDisabled: count > 0, // 该分类是否能被删除
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex,
+            updatetime: item.updatetime
+          })
+        }
       })
       return groupNameList
     },
+    getMaxUpdateTime: function (arr) {
+      var max = 0
+      if (!Array.isArray(arr)) return max
+      arr.some(function (item) {
+        if (item.updatetime && item.updatetime > max) {
+          max = item.updatetime
+        }
+      })
+      return max
+    },
     // 通过已有分类得到一个未分类名
     getNewClassName: function () {
       var conf = {
@@ -162,9 +207,9 @@ var vm = new Vue({
     },
     getSelectIndexArr: function () {
       var selectedIndexArr = []
-      this.groupNameList.forEach(function (item, index) {
+      this.groupNameList.forEach(function (item) {
         if (!item.deleteDisabled && item.checked) {
-          selectedIndexArr.push(index)
+          selectedIndexArr.push(item.groupIndex)
         }
       })
       return selectedIndexArr
@@ -214,7 +259,7 @@ var vm = new Vue({
         }
       })
     },
-    clickKeyCard: function (item, index) {
+    clickKeyCard: function (item) {
       if (this.batchDeleteState) {
         // 执行点击选中逻辑
         // 如果关键词组下有关键词,则不能点击
@@ -223,7 +268,7 @@ var vm = new Vue({
         }
       } else {
         // 显示修改关键词组名弹框
-        this.editGroupName('edit', item, index)
+        this.editGroupName('edit', item, item.groupIndex)
       }
     },
     beforeKeySwipeCellClose: function (e) {
@@ -231,7 +276,7 @@ var vm = new Vue({
       // instance 为对应的 SwipeCell 实例
       var position = e.position
       var instance = e.instance
-      var index = e.name
+      var index = e.name // item.groupIndex
 
       switch (position) {
         case 'left': {
@@ -254,6 +299,19 @@ var vm = new Vue({
         }
       }
     },
+    getGroupFromIndex: function (idx) {
+      var groupItem = {}
+      this.groupNameList.some(function (item) {
+        if (item) {
+          var gotThis = item.groupIndex == idx
+          if (gotThis) {
+            groupItem = item
+          }
+          return gotThis
+        }
+      })
+      return groupItem
+    },
     /**
      * 删除单个分类
      * @param {number} index 当前关键词在当前分组的index
@@ -262,7 +320,7 @@ var vm = new Vue({
     delThisKey: function (index, instance) {
       var _this = this
       // 需要找到当前分类的item
-      var group = this.groupNameList[index]
+      var group = this.getGroupFromIndex(index)
       this.showDialog({
         title: '',
         message: '确定删除当前分类?',

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

@@ -7,6 +7,7 @@
     <meta name="apple-mobile-web-app-capable" content="yes">
     <meta name="apple-mobile-web-app-status-bar-style" content="black">
     <title>订阅关键词</title>
+    <script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/rem.js'></script>
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/layout.css' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/font.css?v={{Msg "seo" "version"}}' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/css/base.css?v={{Msg "seo" "version"}}' />

+ 3 - 2
src/jfw/modules/app/src/web/templates/vipsubscribe/keyWord.html

@@ -7,6 +7,7 @@
     <meta name="apple-mobile-web-app-capable" content="yes" />
     <meta name="apple-mobile-web-app-status-bar-style" content="black" />
     <title>关键词</title>
+    <script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/rem.js'></script>
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/layout.css' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/font.css?v={{Msg "seo" "version"}}' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/css/base.css?v={{Msg "seo" "version"}}' />
@@ -52,7 +53,7 @@
             <div class="keyword-list" v-show="listShow">
                 <div
                     class="keywords-item"
-                    v-for="(item,index) in filter.keywordsList"
+                    v-for="(item,index) in keyListSorted"
                     :key="index">
                     <div class="checkbox-container" :class="{ w0: !batchDeleteState }">
                         <van-checkbox
@@ -62,7 +63,7 @@
                         </van-checkbox>
                     </div>
                     <van-swipe-cell
-                        :name="index"
+                        :name="item.groupIndex + '-' + item.keyIndex"
                         :disabled="batchDeleteState"
                         :before-close="beforeKeySwipeCellClose">
                         <div class="j-key-card" @click="clickKeyCard(item)">

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

@@ -4,6 +4,7 @@
 <head>
     {{include "/common/meta.html"}}
     <title>关键词分类管理</title>
+    <script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/rem.js'></script>
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/layout.css' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/font.css?v={{Msg "seo" "version"}}' />
     <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/css/base.css?v={{Msg "seo" "version"}}' />
@@ -73,7 +74,7 @@
                     <!-- 分类名称卡片 -->
                     <div
                         class="keywords-item"
-                        v-for="(item,index) in groupNameList"
+                        v-for="(item,index) in groupNameListSorted"
                         :key="index">
                         <div class="checkbox-container" :class="{ w0: !batchDeleteState }">
                             <van-checkbox
@@ -84,10 +85,10 @@
                             </van-checkbox>
                         </div>
                         <van-swipe-cell
-                            :name="index"
+                            :name="item.groupIndex"
                             :disabled="item.deleteDisabled || batchDeleteState"
                             :before-close="beforeKeySwipeCellClose">
-                            <div class="j-key-card" @click="clickKeyCard(item, index)">
+                            <div class="j-key-card" @click="clickKeyCard(item)">
                                 <div class="j-key-card-left">${ item.name }</div>
                                 <div class="j-key-card-right">
                                     <span class="text">${ item.count }组关键词</span>

+ 57 - 12
src/web/staticres/vipsubscribe/js/keyWord.js

@@ -26,6 +26,11 @@ var vm = new Vue({
     }
   },
   computed: {
+    keyListSorted: function () {
+      return this.filter.keywordsList.sort(function (a, b) {
+        return b.updatetime - a.updatetime
+      })
+    },
     fastImportTipShow: function () {
       return this.filter.allKeywordsList.length === 0 && this.filter.loaded && this.tip.fastImport
     },
@@ -135,33 +140,54 @@ var vm = new Vue({
     },
     // 向关键词中添加一些信息
     addInfoToKeyItem: function (groupList) {
+      var _this = this
       if (!Array.isArray(groupList)) return []
+      var arr = []
 
       groupList.forEach(function (keywordsList, index) {
-        if (Array.isArray(keywordsList.a_key)) {
+        if (keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
+          keywordsList.updatetime = _this.getMaxUpdateTime(keywordsList.a_key)
           keywordsList.a_key.forEach(function (keyword, iindex) {
             // 添加一些其他信息
             keyword.groupName = keywordsList.s_item // 分类名
             keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
             keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
           })
+          arr.push(keywordsList)
         }
       })
 
-      return groupList
+      return arr
     },
     getGroupNameList: function (keywordsGroupList) {
       var groupNameList = []
       if (!Array.isArray(keywordsGroupList)) return groupNameList
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          count: count // 分类下有多少个关键词
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex
+          })
+        }
       })
       return groupNameList
     },
+    getMaxUpdateTime: function (arr) {
+      var max = 0
+      if (!Array.isArray(arr)) return max
+      arr.some(function (item) {
+        if (item.updatetime && item.updatetime > max) {
+          max = item.updatetime
+        }
+      })
+      return max
+    },
     calcKeyInfo: function (item) {
       // 匹配方式 item.matchway 0/null精准 1模糊
       var key = item.key
@@ -279,6 +305,7 @@ var vm = new Vue({
 
       for (var key in deleteKeyArr) {
         if (Array.isArray(deleteKeyArr[key])) {
+          deleteKeyArr[key] = deleteKeyArr[key].sort(function (a, b) { return a - b })
           deleteKey[key] = deleteKeyArr[key].join(',')
         }
       }
@@ -286,6 +313,7 @@ var vm = new Vue({
     },
     batchDeleteConfirmed: function () {
       var deleteKey = this.getDeleteKey()
+      if (Object.keys(deleteKey).length === 0) return
       var loading = this.showLoading()
       var _this = this
       $.ajax({
@@ -316,7 +344,7 @@ var vm = new Vue({
       // instance 为对应的 SwipeCell 实例
       var position = e.position
       var instance = e.instance
-      var index = e.name
+      var index = e.name // item.groupIndex-item.keyIndex
 
       switch (position) {
         case 'left': {
@@ -339,6 +367,19 @@ var vm = new Vue({
         }
       }
     },
+    getGroupFromIndex: function (gIndex, kIndex) {
+      var groupItem = {}
+      this.filter.keywordsList.some(function (item) {
+        if (item) {
+          var gotThis = item.groupIndex == gIndex && item.keyIndex == kIndex
+          if (gotThis) {
+            groupItem = item
+          }
+          return gotThis
+        }
+      })
+      return groupItem
+    },
     /**
      * 删除单个关键词
      * @param {number} index 当前关键词在列表中的index
@@ -347,7 +388,11 @@ var vm = new Vue({
     delThisKey: function (index, instance) {
       var _this = this
       // 需要找到当前关键词组的item
-      var key = this.filter.keywordsList[index]
+      var indexArr = index.split('-')
+      var gIndex = indexArr[0]
+      var kIndex = indexArr[1]
+      var key = this.getGroupFromIndex(gIndex, kIndex)
+
       this.showDialog({
         title: '',
         message: '确定删除当前关键词?',
@@ -364,9 +409,9 @@ var vm = new Vue({
     // 根据分类名,得到分类索引
     getGroupIndexWithGroupName: function (gn) {
       var groupIndex = -1
-      this.keywordsGroupList.forEach(function(item, index) {
+      this.keywordsGroupList.forEach(function(item) {
         if (gn === item.s_item) {
-          groupIndex = index
+          groupIndex = item.groupIndex
         }
       })
       return groupIndex

+ 18 - 10
src/web/staticres/vipsubscribe/js/keyword-info.js

@@ -192,31 +192,39 @@ var vm = new Vue({
     // 向关键词中添加一些信息
     addInfoToKeyItem: function (groupList) {
       if (!Array.isArray(groupList)) return []
+      var arr = []
 
       groupList.forEach(function (keywordsList, index) {
-        if (Array.isArray(keywordsList.a_key)) {
+        if (keywordsList && keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
           keywordsList.a_key.forEach(function (keyword, iindex) {
             // 添加一些其他信息
             keyword.groupName = keywordsList.s_item // 分类名
             keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
             keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
           })
+          arr.push(keywordsList)
         }
       })
 
-      return groupList
+      return arr
     },
     getGroupNameList: function (keywordsGroupList) {
       var groupNameList = []
       if (!Array.isArray(keywordsGroupList)) return groupNameList
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          checked: false,
-          count: count, // 分类下有多少个关键词
-          gIndex: index
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            checked: false,
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex
+          })
+        }
       })
       return groupNameList
     },

+ 76 - 18
src/web/staticres/vipsubscribe/js/keyword-manage.js

@@ -5,6 +5,7 @@ var vm = new Vue({
     batchDeleteState: false, // 是否在批量删除状态
     userData: {}, // getUserInfo接口用户原始数据
     groupNameList: [],
+    keywordsGroupList: [],
     listState: {
       loaded: false
     },
@@ -16,6 +17,11 @@ var vm = new Vue({
     },
   },
   computed: {
+    groupNameListSorted: function () {
+      return this.groupNameList.sort(function (a, b) {
+        return b.updatetime - a.updatetime
+      })
+    },
     listShow: function () {
       return this.groupNameList.length !== 0 && this.listState.loaded
     },
@@ -85,10 +91,10 @@ var vm = new Vue({
             _this.userData = res.userData
             if (res.userData && res.userData.o_vipjy) {
               // 整理数据
-              var list = _this.getGroupNameList(res.userData.o_vipjy.a_items)
-              if (Array.isArray(list)) {
-                _this.groupNameList = list
-              }
+              var groupList = _this.addInfoToKeyItem(res.userData.o_vipjy.a_items)
+              var groupNameList = _this.getGroupNameList(groupList)
+              _this.keywordsGroupList = groupList
+              _this.groupNameList = groupNameList
             }
           }
         },
@@ -102,20 +108,59 @@ var vm = new Vue({
         }
       })
     },
+    // 向关键词中添加一些信息
+    addInfoToKeyItem: function (groupList) {
+      var _this = this
+      if (!Array.isArray(groupList)) return []
+      var arr = []
+
+      groupList.forEach(function (keywordsList, index) {
+        if (keywordsList && Array.isArray(keywordsList.a_key)) {
+          keywordsList.groupIndex = index
+          keywordsList.updatetime = _this.getMaxUpdateTime(keywordsList.a_key)
+          keywordsList.a_key.forEach(function (keyword, iindex) {
+            // 添加一些其他信息
+            keyword.groupName = keywordsList.s_item // 分类名
+            keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
+            keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
+            if (!keyword.updatetime) {
+              keyword.updatetime = 0
+            }
+          })
+          arr.push(keywordsList)
+        }
+      })
+
+      return arr
+    },
     getGroupNameList: function (keywordsGroupList) {
       if (!Array.isArray(keywordsGroupList)) return
       var groupNameList = []
-      keywordsGroupList.forEach(function (item, index) {
-        var count = Array.isArray(item.a_key) ? item.a_key.length : 0
-        groupNameList.push({
-          name: item.s_item, // 分类名
-          checked: false,
-          deleteDisabled: count > 0, // 该分类是否能被删除
-          count: count // 分类下有多少个关键词
-        })
+      keywordsGroupList.forEach(function (item) {
+        if (item) {
+          var count = Array.isArray(item.a_key) ? item.a_key.length : 0
+          groupNameList.push({
+            name: item.s_item, // 分类名
+            checked: false,
+            deleteDisabled: count > 0, // 该分类是否能被删除
+            count: count, // 分类下有多少个关键词
+            groupIndex: item.groupIndex,
+            updatetime: item.updatetime
+          })
+        }
       })
       return groupNameList
     },
+    getMaxUpdateTime: function (arr) {
+      var max = 0
+      if (!Array.isArray(arr)) return max
+      arr.some(function (item) {
+        if (item.updatetime && item.updatetime > max) {
+          max = item.updatetime
+        }
+      })
+      return max
+    },
     // 通过已有分类得到一个未分类名
     getNewClassName: function () {
       var conf = {
@@ -162,9 +207,9 @@ var vm = new Vue({
     },
     getSelectIndexArr: function () {
       var selectedIndexArr = []
-      this.groupNameList.forEach(function (item, index) {
+      this.groupNameList.forEach(function (item) {
         if (!item.deleteDisabled && item.checked) {
-          selectedIndexArr.push(index)
+          selectedIndexArr.push(item.groupIndex)
         }
       })
       return selectedIndexArr
@@ -214,7 +259,7 @@ var vm = new Vue({
         }
       })
     },
-    clickKeyCard: function (item, index) {
+    clickKeyCard: function (item) {
       if (this.batchDeleteState) {
         // 执行点击选中逻辑
         // 如果关键词组下有关键词,则不能点击
@@ -223,7 +268,7 @@ var vm = new Vue({
         }
       } else {
         // 显示修改关键词组名弹框
-        this.editGroupName('edit', item, index)
+        this.editGroupName('edit', item, item.groupIndex)
       }
     },
     beforeKeySwipeCellClose: function (e) {
@@ -231,7 +276,7 @@ var vm = new Vue({
       // instance 为对应的 SwipeCell 实例
       var position = e.position
       var instance = e.instance
-      var index = e.name
+      var index = e.name // item.groupIndex
 
       switch (position) {
         case 'left': {
@@ -254,6 +299,19 @@ var vm = new Vue({
         }
       }
     },
+    getGroupFromIndex: function (idx) {
+      var groupItem = {}
+      this.groupNameList.some(function (item) {
+        if (item) {
+          var gotThis = item.groupIndex == idx
+          if (gotThis) {
+            groupItem = item
+          }
+          return gotThis
+        }
+      })
+      return groupItem
+    },
     /**
      * 删除单个分类
      * @param {number} index 当前关键词在当前分组的index
@@ -262,7 +320,7 @@ var vm = new Vue({
     delThisKey: function (index, instance) {
       var _this = this
       // 需要找到当前分类的item
-      var group = this.groupNameList[index]
+      var group = this.getGroupFromIndex(index)
       this.showDialog({
         title: '',
         message: '确定删除当前分类?',

+ 2 - 2
src/web/templates/weixin/vipsubscribe/keyWord.html

@@ -46,7 +46,7 @@
             <div class="keyword-list" v-show="listShow">
                 <div
                     class="keywords-item"
-                    v-for="(item,index) in filter.keywordsList"
+                    v-for="(item,index) in keyListSorted"
                     :key="index">
                     <div class="checkbox-container" :class="{ w0: !batchDeleteState }">
                         <van-checkbox
@@ -56,7 +56,7 @@
                         </van-checkbox>
                     </div>
                     <van-swipe-cell
-                        :name="index"
+                        :name="item.groupIndex + '-' + item.keyIndex"
                         :disabled="batchDeleteState"
                         :before-close="beforeKeySwipeCellClose">
                         <div class="j-key-card" @click="clickKeyCard(item)">

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

@@ -72,7 +72,7 @@
                     <!-- 分类名称卡片 -->
                     <div
                         class="keywords-item"
-                        v-for="(item,index) in groupNameList"
+                        v-for="(item,index) in groupNameListSorted"
                         :key="index">
                         <div class="checkbox-container" :class="{ w0: !batchDeleteState }">
                             <van-checkbox
@@ -83,10 +83,10 @@
                             </van-checkbox>
                         </div>
                         <van-swipe-cell
-                            :name="index"
+                            :name="item.groupIndex"
                             :disabled="item.deleteDisabled || batchDeleteState"
                             :before-close="beforeKeySwipeCellClose">
-                            <div class="j-key-card" @click="clickKeyCard(item, index)">
+                            <div class="j-key-card" @click="clickKeyCard(item)">
                                 <div class="j-key-card-left">${ item.name }</div>
                                 <div class="j-key-card-right">
                                     <span class="text">${ item.count }组关键词</span>