<template>
  <div class="main_box">
    <navbar title="商户客户详情"></navbar>
    <div class="wrapper">
      <div class="title">法人信息</div>
      <van-cell title="经营者姓名" :value="baseInfo.operatorName" />
      <van-cell title="身份证号" :value="baseInfo.operatorCustIdc" />
      <van-cell title="性别" :value="baseInfo.operatorGender" />
      <van-cell title="出生日期" :value="baseInfo.operatorBirth" />
      <van-cell title="年龄" :value="baseInfo.operatorAge" />
      <van-cell title="经营者手机号" :value="baseInfo.operatorPhone" />
      <div class="title">商户信息</div>
      <van-cell title="建档状态">
        <template>
          <div class="sp_d">
            {{baseInfo.regStatus?'是':'否'}}
            <div class="sp_d_bt" @click="custLeadUpdateRegStatusFn">修改</div>
          </div>
        </template>
      </van-cell>
      <van-cell title="商户名称" :value="baseInfo.custName" />
      <van-cell title="统信码" :value="baseInfo.usci" />
      <van-cell title="经营状态" :value="baseInfo.operaStatus" />
      <van-cell title="经营范围" :value="baseInfo.operaScope" />
      <van-cell title="经营地址" :value="baseInfo.operaAddress" />
      <van-cell title="门牌号" :value="baseInfo.operaAddressDetail" />
      <van-cell title="经度" :value="baseInfo.lng" />
      <van-cell title="维度" :value="baseInfo.lat" />
      <van-cell title="注册地址" :value="baseInfo.regAddress" />
      <van-cell title="门牌号" :value="baseInfo.regAddressDetail" />
      <van-cell title="行业名称" :value="baseInfo.industry" />
      <van-cell title="企业电话" :value="baseInfo.custPhone" />
      <div class="title">关联人信息</div>
      <div class="glrBox" v-for="(item, index) in relatePersonsList" :key="index">
        <div class="glrBox_left">
          <div class="left_img_box">
            <img src="../../images/home/xkdjrw.png" alt style="width: 30px;height: 30px;" />
          </div>
          <div class="left_main_box">
            <div class="left_main_box_top">{{ item.relatePerson }}</div>
            <div class="left_main_box_card">身份号:{{ item.relateCustIdc }}</div>
          </div>
        </div>
      </div>
      <div class="title">其他信息</div>
      <van-cell title="客户经理归属机构" :value="baseInfo.relateDeptName" />
      <van-cell title="客户经理" :value="baseInfo.relateUserName" />
      <div class="title">照片信息</div>
      <div class="top_item">
        <div style="display:flex;flex-wrap:wrap;flex:1" v-if="baseInfo.imageList && baseInfo.imageList.length != 0">
          <div v-for="(item, index) in baseInfo.imageList" :key="index">
            <img
              :src="`data:image/png;base64,${item}`"
              alt
              style="width: 50px; height: 50px; margin: 10px"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import navbar from "../../components/navbar/navbar.vue";
import { custLeadSelect, custLeadUpdateRegStatus } from "@/service/api/filing";
import {
  Tab,
  Tabs,
  Icon,
  Button,
  Search,
  Field,
  Popup,
  Picker,
  Toast
} from "vant";
export default {
  data() {
    return {
      baseInfo: {},
      relatePersonsList: []
    };
  },
  components: {
    navbar: navbar,
    VanTab: Tab,
    VanTabs: Tabs,
    VanIcon: Icon,
    VanButton: Button,
    VanSearch: Search,
    VanField: Field,
    VanPopup: Popup,
    VanPicker: Picker,
    Toast: Toast
  },
  created() {
    this.init();
  },
  methods: {
    async init() {
      custLeadSelect({ custId: sessionStorage.getItem("custId") }).then(res => {
        if (res.code == 200) {
          this.baseInfo = res.data;
          if (this.baseInfo.relatePersons) {
            this.relatePersonsList = JSON.parse(this.baseInfo.relatePersons);
          }
        }
      });
    },
    custLeadUpdateRegStatusFn() {
      custLeadUpdateRegStatus({
        custId: sessionStorage.getItem("custId")
      }).then(res => {
        if (res.code == 200) {
          Toast.success("修改成功！");
          this.init();
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.wrapper {
  padding-top: 46px;
  min-height: 100vh;
  font-size: 16px;
  padding-bottom: 60px;
}
.title {
  padding: 5px 10px;
  font-weight: bold;
}
.top_item {
  background-color: #ffffff;
  padding: 10px 20px;
  display: flex;
}
.glrBox {
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  padding: 15px;
}
.glrBox_left {
  display: flex;
  align-items: center;
}
.left_img_box {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background-color: rgb(246, 249, 255);
}
.left_main_box {
  margin-left: 20px;
}
.left_main_box_top {
  font-size: 16px;
  font-weight: 600;
  line-height: 30px;
}
.left_main_box_card {
  font-size: 12px;
  line-height: 25px;
  color: rgb(140, 140, 140);
}
.glr_right {
  display: flex;
}
.glr_right_edit {
  background-color: rgb(233, 241, 253);
  color: rgb(35, 114, 235);
  height: 33px;
  line-height: 33px;
  width: 60px;
  text-align: center;
  border-radius: 5px;
}
.glr_right_delete {
  background-color: rgb(253, 243, 234);
  color: rgb(238, 140, 21);
  height: 33px;
  line-height: 33px;
  width: 60px;
  text-align: center;
  border-radius: 5px;
  margin-left: 5px;
}
.sp_d{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  &_bt{
    color: #1989fa;
    margin-left: 20px;
  }
}
</style>