home.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div>
  3. <help-header></help-header>
  4. <div id="main">
  5. <div class="container" style="padding: 0; width: 1190px;">
  6. <div style="display: inline-block; width: 100%; margin: 0 auto">
  7. <div class="left">
  8. <left></left>
  9. </div>
  10. <div class="right">
  11. <div class="help-center">
  12. <div class="help-head">
  13. <nuxt-link to="/help/home"><img src="/images/help/help-title.png"></nuxt-link>
  14. </div>
  15. <div class="help-center-title">
  16. <nuxt-link style="font-size: 14px" :to="'/help/home'">帮助中心首页</nuxt-link>
  17. </div>
  18. <div class="help-center-home">
  19. <div v-for="nav01 in helpNav">
  20. <h4 v-text="nav01.item"></h4>
  21. <div class="row">
  22. <div v-for="nav02 in nav01.children">
  23. <em></em><a @click="goToUrl(nav02.id)" v-text="nav02.item"></a>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. // 升序
  37. function compare (property) {
  38. return function (a, b) {
  39. var value1 = a[property]
  40. var value2 = b[property]
  41. return value1 - value2
  42. }
  43. }
  44. function sortBy (arr, property) {
  45. for (let i = 0; i < arr.length; i++) {
  46. for (let j = i; j < arr.length; j++) {
  47. if (arr[i][property] > arr[j][property]) {
  48. let tmp = arr[i]
  49. arr[i] = arr[j]
  50. arr[j] = tmp
  51. }
  52. }
  53. }
  54. return arr
  55. }
  56. import { left, helpHeader } from '~components/help'
  57. export default {
  58. name: 'help',
  59. components: {
  60. left,
  61. helpHeader
  62. },
  63. fetch ({ store }) {
  64. return Promise.all([
  65. store.dispatch('loadHelpSnapsho', { parentId: 0 })
  66. ])
  67. },
  68. computed: {
  69. helpNav () {
  70. let list = [...this.$store.state.help.snapsho.data]
  71. if (list.length > 0) {
  72. list = sortBy(list, 'detno')
  73. for (let i = 0; i < list.length; i++) {
  74. let tem = sortBy(list[i].children, 'detno')
  75. list[i].children = tem
  76. }
  77. }
  78. return list
  79. }
  80. },
  81. methods: {
  82. goToUrl (id) {
  83. this.$http.get('/api/help-service/issues', {params: {navId: id}}).then(res => {
  84. let helpList = res.data || res.data.sort(compare('detno'))
  85. if(helpList && helpList.length === 1) {
  86. this.$router.push(`/help/helpDetail/${helpList[0].num}`)
  87. } else {
  88. this.$router.push(`/help/helpList/${id}`)
  89. }
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style scoped>
  96. @import '~assets/scss/help.css';
  97. </style>