<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
    <home-base :show="false"><view class="div container">
        <view class="div common-header-wrap">
            <view :style="'height:'+navHeight+'px'"></view>
            <view class="common-header-holder"></view>
            <view class="common-header-fixed">
            <title-header />
            <uni-nav-bar title="店铺分类" class="common-header" left-icon="back" @clickLeft="goBack()">
            </uni-nav-bar>
        </view>
        </view>
        <view class="div class-list">
                <flex-line v-for="item in storeclass_list" :is-link="true" :show-border="true" v-bind:key="item.storeclass_id" @click.native="goHomeStorelist(item.storeclass_id)">
                    {{item.storeclass_name}}
                </flex-line>
        </view>
        <empty-record v-if="storeclass_list && !storeclass_list.length"></empty-record>
    </view></home-base>
</template>

<script>
import {getFontSize} from '@/util/common'
import TitleHeader from '../../TitleHeader'
import { urlencode } from '@/util/common'
import HomeBase from '../HomeBase'
import { getStoreClass } from '../../../api/seller'
import EmptyRecord from '../../EmptyRecord'
import flexLine from '../../flexLine'
export default {
  components:{
      TitleHeader,
      HomeBase,
      flexLine,
    EmptyRecord
  },
  name: 'Storeclass',
  mounted(){
  // #ifdef  MP-WEIXIN
  this.navHeight = uni.getMenuButtonBoundingClientRect().top
  // #endif
  },
  computed:{
  fontSize(){
    return getFontSize()
  },
  },
  data(){
    return {
      navHeight: 0,
      storeclass_list: false
    }
  },
  created: function () {
    this.getStoreclassList()
  },
  methods:{
    goBack(){uni.navigateBack({delta:1})},
    getStoreclassList () {
      uni.showLoading({ title: '加载中' })
        getStoreClass().then(res => {
        uni.hideLoading()
        this.storeclass_list = res.result.store_class
      }).catch(function (error) {
        uni.hideLoading()
        uni.showToast({icon:'none',title: error.message})
      })
    },
    goHomeStorelist (storeclassId) {
      uni.navigateTo({ url: '/pages/home/storelist/Storelist'+'?'+urlencode( { storeclass_id: storeclassId } )})
    }
  }
}
</script>

<style scoped lang="scss">
.class-list{padding:0 $pageSpace;background: #fff}
</style>
