Browse Source

处理帮助中心

wangcz 6 years ago
parent
commit
2723dadb14
3 changed files with 31 additions and 23 deletions
  1. 9 1
      components/help/left.vue
  2. 1 13
      pages/help/helpList/_id.vue
  3. 21 9
      pages/help/home.vue

+ 9 - 1
components/help/left.vue

@@ -50,7 +50,15 @@
     methods: {
       openList (data) {
         if (data.level !== 1) {
-          this.$router.push({ name: 'help-helpList-id', params: { id: data.id } })
+          // this.$router.push({ name: 'help-helpList-id', params: { id: data.id } })
+          this.$http.get('/api/help-service/issues', {params: {navId: data.id}}).then(res => {
+            let helpList = res.data || res.data.sort(compare('detno'))
+            if(helpList && helpList.length === 1) {
+              this.$router.push(`/help/helpDetail/${helpList[0].num}`)
+            } else {
+              this.$router.push(`/help/helpList/${data.id}`)
+            }
+          })
         }
       }
     }

+ 1 - 13
pages/help/helpList/_id.vue

@@ -1,5 +1,5 @@
 <template>
-  <div v-show="showAlone">
+  <div>
     <help-header></help-header>
   <div id="main">
     <div class="container" style="padding: 0; width: 1190px;">
@@ -48,11 +48,6 @@
   import { left, helpHeader } from '~components/help'
   export default {
     name: 'help',
-    data () {
-      return {
-        showAlone: false
-      }
-    },
     components: {
       left,
       helpHeader
@@ -64,13 +59,6 @@
         store.dispatch('loadHelpTitle', route.params)
       ])
     },
-    created () {
-      if(this.helpList && this.helpList.length === 1) {
-        this.$router.push(`/help/helpDetail/${this.helpList[0].num}`)
-      } else {
-        this.showAlone = true
-      }
-    },
     computed: {
       helpTitle () {
         return this.$store.state.help.title.data

+ 21 - 9
pages/help/home.vue

@@ -20,7 +20,7 @@
                 <h4 v-text="nav01.item"></h4>
                 <div class="row">
                   <div v-for="nav02 in nav01.children">
-                    <em></em><nuxt-link :to="`/help/helpList/${nav02.id}`" v-text="nav02.item"></nuxt-link>
+                    <em></em><a @click="goToUrl(nav02.id)" v-text="nav02.item"></a>
                   </div>
                 </div>
               </div>
@@ -33,14 +33,14 @@
   </div>
 </template>
 <script>
-//   升序
-//  function compare (property) {
-//    return function (a, b) {
-//      var value1 = a[property]
-//      var value2 = b[property]
-//      return value1 - value2
-//    }
-//  }
+  // 升序
+ function compare (property) {
+   return function (a, b) {
+     var value1 = a[property]
+     var value2 = b[property]
+     return value1 - value2
+   }
+ }
   function sortBy (arr, property) {
     for (let i = 0; i < arr.length; i++) {
       for (let j = i; j < arr.length; j++) {
@@ -77,6 +77,18 @@
         }
         return list
       }
+    },
+    methods: {
+      goToUrl (id) {
+        this.$http.get('/api/help-service/issues', {params: {navId: id}}).then(res => {
+          let helpList = res.data || res.data.sort(compare('detno'))
+          if(helpList && helpList.length === 1) {
+            this.$router.push(`/help/helpDetail/${helpList[0].num}`)
+          } else {
+            this.$router.push(`/help/helpList/${id}`)
+          }
+        })
+      }
     }
   }
 </script>