<template>
  <div class="memebr-count">
    <span v-if="memberType == 1">会员共{{wxMember}}人</span>
    <span v-if="memberType == 2">会员共{{posMember}}人</span>
    <span v-if="memberType == 3">会员共{{ecommerceMember}}人</span>
    <span v-if="memberType == 4">会员共{{ecommerceBuyer}}人</span>
    <!-- <div class="maintop">
      <h3> {{ $route.meta.title }} <span class="pointer"><i class="el-icon-setting fr"></i></span></h3>
    </div> -->
    <!-- <div class="type-member">
      <router-link :to="{path: '/wechatmembers'}" class="type-item">
        <div class="type-icon bgcolor-green"><i class="iconfont icon-weixin iconfontsize"></i></div>
        <div class="member-detail">
          <p class="member-num">{{ wxMember }}</p>
          <p class="member-unit">微信会员（人）</p>
        </div>
      </router-link>
      <router-link :to="{path: '/posmembers'}" class="type-item ">
        <div class="type-icon bgcolor-red"><i class="iconfont icon-yinxingqia iconfontsize"></i></div>
        <div class="member-detail">
          <p class="member-num">{{ posMember }}</p>
          <p class="member-unit">POS会员（人）</p>
        </div>
      </router-link> -->
      <!-- <router-link :to="{path: '/onlinemembers'}" class="type-item">
        <div class="type-icon bgcolor-purple"><i class="iconfont icon-touxiang iconfontsize"></i></div>
        <div class="member-detail">
          <p class="member-num">{{ ecommerceMember }}</p>
          <p class="member-unit">电商会员（人）</p>
        </div>
      </router-link>
      <router-link :to="{path: '/buyermembers'}" class="type-item ">
        <div class="type-icon bgcolor-blue"><i class="iconfont icon-gouwu iconfontsize"></i></div>
        <div class="member-detail">
          <p class="member-num">{{ ecommerceBuyer }}</p>
          <p class="member-unit">电商买家（人）</p>
        </div>
      </router-link> -->
    </div>
  </div>
</template>

<script>
  import { doFetch } from "../../../components/axios/api";
  import url from '../../../components/axios/url'
  import {checkFalse, checkStatus, checkSuccess} from "../../../../static/js/checkStatus";
  export default {
    props: {
      memberType: {
        type: Number,
        required: true
      }
    },
    data() {
      return {
        wxMember: 0,
        posMember: 0,
        ecommerceMember: 0,
        ecommerceBuyer: 0
      }
    },
    methods: {
      getMemberCount() {
        doFetch(url.memberCount).then(res => {
          if(res.data.errorCode === 0) {
            let temp = res.data.result;
            this.wxMember = temp.wxMember; // 微信会员
            this.posMember = temp.posMember; // pos会员
            this.ecommerceMember = temp.ecommerceMember; // 电商会员
            this.ecommerceBuyer = temp.ecommerceBuyer; // 电商买家
          }else {
            checkFalse(res.data.message);
          }
        }).catch(err => {
          checkStatus(err);
        })
      }
    },
    created() {
      this.getMemberCount();
    }
  }
</script>

<style lang="stylus">
.memebr-count
  display inline-block
  height 40px
  line-height 40px
  span 
    margin-right 10px
</style>
