<template>
  <div>
    <UserInfoHeader />
    <van-cell-group>
      <NavItem v-for="(item, index) of navList" :key="index" :config="item" />
    </van-cell-group>
  </div>
</template>

<script>
import UserInfoHeader from '@/components/ebiz/manpower/UserInfoHeader'
import NavItem from '@/components/ebiz/manpower/NavItem'

import { CellGroup } from 'vant'

import { getTokenForUserModel } from '@/api/ebiz/manpower/manpower'

export default {
  name: 'Navigation',
  components: {
    [UserInfoHeader.name]: UserInfoHeader,
    [NavItem.name]: NavItem,
    [CellGroup.name]: CellGroup
  },
  data() {
    return {
      active: 0,
      navList: [
        {
          title: '增员分享',
          icon: 'cluster-o',
          path: '/',
          share: true,
          shareConfig: null
        },
        {
          title: '增员审批',
          icon: 'comment-o',
          path: '/agentEenter/approve/ApproveList'
        }
      ]
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    async getInfo() {
      const res = await getTokenForUserModel()
      if (res.result == 0) {
        this.navList[0].shareConfig = {
          title: res.title,
          imgUrl: res.link,
          desc: res.content,
          link: res.icon
        }
      } else {
        this.$toast(res.resultMessage)
      }
    }
  }
}
</script>
<style lang="scss" scoped></style>
