<template>
  <div class="mobile-center">
    <div class="com-mobile-header mobile-center-header">
      <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
      <p>卖家中心</p>
      <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
    </div>
    <div class="mobile-fix-content mobile-centerfix-content">
      <div class="seek-banner block-wrap">
        <img src="/images/mobile/center/vendor/adv.jpg" alt="">
      </div>
      <div class="block-wrap seek-operation">
        <p><i></i>库存管理</p>
        <ul>
          <nuxt-link tag="li" to="/mobile/center/vendor/product?providerType=enterprise">
            <img src="/images/mobile/center/vendor/material.png" alt="">
            <p>公司产品库</p>
          </nuxt-link>
          <nuxt-link tag="li" to="/mobile/center/vendor/product?providerType=person">
            <img src="/images/mobile/center/vendor/material-person.png" alt="">
            <p>个人产品库</p>
          </nuxt-link>
          <nuxt-link tag="li" to="/mobile/center/vendor/product?providerType=onLine">
            <img src="/images/mobile/center/vendor/onsale.png" alt="">
            <p>在售产品</p>
          </nuxt-link>
        </ul>
      </div>
      <div class="block-wrap seek-operation">
        <p><i></i>商机管理</p>
        <ul>
          <nuxt-link to="/mobile/center/vendor/seek?seekType=wait" tag="li">
            <img src="/images/mobile/center/vendor/all.png" alt="">
            <p>公司商机</p>
          </nuxt-link>
          <nuxt-link to="/mobile/center/vendor/seek?seekType=done" tag="li">
            <img src="/images/mobile/center/vendor/seek-done.png" alt="">
            <p>已报价</p>
          </nuxt-link>
          <nuxt-link to="/mobile/center/vendor/attentionBus" tag="li">
            <img src="/images/mobile/center/vendor/attention-bu.png" alt="">
            <p>商机关注</p>
          </nuxt-link>
        </ul>
      </div>
      <div class="block-wrap seek-operation">
        <p><i></i>更多服务</p>
        <ul>
          <nuxt-link tag="li" to="/mobile/order?type=saler">
            <img src="/images/mobile/center/user/order.jpg" alt="">
            <p>销售订单</p>
          </nuxt-link>
          <nuxt-link tag="li" to="/mobile/center/vendor/message"  v-if="user.data.enterprise.uu">
            <img src="/images/mobile/center/user/message.png" alt="">
            <p>消息中心<span class="text">({{messageCount.count || 0}})</span></p>
          </nuxt-link>
        </ul>
      </div>

    </div>
    <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  </div>
</template>
<script>
  import { RemindBox } from '~components/mobile/common'
  export default {
    middleware: 'authenticated',
    layout: 'mobileNoHeader',
    data () {
      return {
        remindText: '',
        timeoutCount: 0
      }
    },
    fetch ({ store }) {
     let user = store.state.option.user.data
      return Promise.all([
        store.dispatch('loadStoreStatus', { op: 'check' }),
        store.dispatch('messageShow/loadMessageCount', {receiverUu: user.userUU, receiverEnuu: user.enterprise.uu, consumerApp: 'MALL', isRead: 0})
      ])
    },
    components: {
      RemindBox
    },
    computed: {
      storeInfo () {
        return this.$store.state.option.storeStatus.data
      },
     messageCount () {
       return this.$store.state.messageShow.messageCount.count.data
     }
    },
    methods: {
      goStore: function () {
        if (this.storeInfo.uuid) {
          this.$router.push(`/mobile/shop/${this.storeInfo.uuid}`)
        } else {
          this.onRemind('请前往账户中心【我】进行开店申请')
        }
      },
      onRemind: function (str) {
        this.remindText = str
        this.timeoutCount++
      }
    }
  }
</script>
<style lang="scss" scoped>
  @import '~assets/scss/mobileCenter';
  .mobile-center{
    .collect-block {
      height: auto;
    }
  }
</style>
