<template>
  <div>
    <help-header></help-header>
  <div id="main">
    <div class="container" style="padding: 0; width: 1190px;">
      <div style="display: inline-block; width: 100%; margin: 0 auto">
        <div class="left">
          <left></left>
        </div>
        <div class="right">
          <div class="help-center">
            <div class="help-head"><img src="/images/help/help-title.png"></div>
            <div class="help-center-title">
              <a style="font-size: 14px" v-bind:href="'/help/home'">帮助中心首页</a>
            </div>
            <div class="help-center-home">
              <div v-for="nav01 in helpNav">
                <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>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>
<script>
  // 升序
  function compare (property) {
    return function (a, b) {
      var value1 = a[property]
      var value2 = b[property]
      return value1 - value2
    }
  }
  import { left, helpHeader } from '~components/help'
  export default {
    name: 'help',
    components: {
      left,
      helpHeader
    },
    fetch ({ store }) {
      return Promise.all([
        store.dispatch('loadHelpSnapsho', { parentId: 0 })
      ])
    },
    computed: {
      helpNav () {
        let list = this.$store.state.help.snapsho.data.sort(compare('detno'))
        if (list) {
          for (let i = 0; i < list.length; i++) {
            list[i].children = list[i].children.sort(compare('detno'))
          }
        }
        return list
      }
    }
  }
</script>
<style scoped>
  @import '~assets/scss/help.css';
</style>
