<template>
  <div class="detail" v-if="pageShow">
    <div class="header">
      <img :src="$cdn + 'xincheng/icon.png'" alt="" class="logo-img">
      <div class="text-info">
        <p>{{ info.bossName }}</p>
        <div>
          <img :src="$cdn + 'xincheng/dw.png'" alt="" class="local-icon">
          <span>{{ info.businessAddress }}</span>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="title">基础信息</div>
      <div class="info">
        <span>店主</span>
        <span class="color-333">{{ info.businessName }}</span>
      </div>
      <div class="info">
        <span>电话</span>
        <span class="color-3D94FB">{{ info.telephone }}</span>
      </div>
      <div class="info">
        <span>身份证</span>
        <span class="color-333">{{ info.cardId }}</span>
      </div>
      <div class="img-list">
        <div class="info">
          <span>门店照片</span>
        </div>
        <image v-if="info.storePicUrl" :src="info.storePicUrl" mode="widthFix" />
      </div>
      <div class="info">
        <span>地图</span>
        <span class="color-3D94FB">定位</span>
      </div>
    </div>
    <div class="content" v-if="info.detailList.length">
      <div class="title">店员信息</div>
      <div class="info" v-for="(item, index) in info.detailList" :key="index">
        <span>{{ item.userName }}</span>
        <span class="color-3D94FB">{{ item.userPhone }}</span>
      </div>
    </div>
    <AiGap h="112"/>
    <div class="btn" @click="linkTo('./addClerk?id=' + id)">新增店员</div>
  </div>
</template>

<script>
  import {mapState} from 'vuex'

  export default {
    name: 'detail',

    appName: '商户详情',

    data () {
      return {
        info: {},
        pageShow: false
      }
    },

    computed: {...mapState(['user'])},

    onLoad (query) {
      this.id = query.id

      this.getInfo()

      uni.$on('updateUser', () => {
        this.getInfo()
      })
    },

    methods: {
      getInfo () {
        this.$loading()
        this.$http.post(`/app/appcompany/getDetailById?id=${this.id}`).then(res => {
          if (res.code === 0) {
            this.info = res.data

            this.pageShow = true
          }
        })
      },

      linkTo (url) {
        uni.navigateTo({
          url
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.detail {
  .header{
    width: 100%;
    background-color: #fff;
    padding: 48px 32px;
    box-sizing: border-box;
    margin-bottom: 8px;
    .logo-img{
      width: 96px;
      height: 96px;
      margin-right: 24px;
      vertical-align: top;
    }
    .text-info{
      display: inline-block;
      width: calc(100% - 120px);
      p{
        font-size: 32px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333;
        line-height: 44px;
        margin-bottom: 6px;
        word-break: break-all;
      }
      .local-icon{
        width: 20px;
        height: 26px;
        margin-right: 6px;
      }
      span{
        display: inline-block;
        width: calc(100% - 32px);
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #90969E;
        line-height: 40px;
        vertical-align: text-top;
      }
    }
  }
  .content{
    background-color: #fff;
    padding: 0 32px 20px;
    margin-bottom: 8px;
    .title{
      font-size: 32px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333;
      line-height: 44px;
      padding: 32px 0;
    }
    .info{
      display: flex;
      justify-content: space-between;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999;
      line-height: 44px;
      padding: 14px 0;
      .color-333{
        color: #333;
      }
      .color-3D94FB{
        color: #3D94FB;
      }
    }
    .img-list{
      image {
        width: 100%;
      }
    }
  }
  .btn{
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    height: 112px;
    line-height: 112px;
    background: #3975C6;
    box-shadow: inset 0px 2px 0px 0px #EEEEEE;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFF;
  }
}
</style>
