<!--
 * @Author: liuzhenlin 461480418@qq.ocm
 * @Date: 2023-01-12 11:57:48
 * @LastEditors: liuzhenlin
 * @LastEditTime: 2023-02-28 10:21:59
 * @Description: file content
 * @FilePath: \oms\pages\distributor\details.vue
-->
<template>
  <view class="home">
    <view class="nav">
      <view :style="{ paddingTop }">
        <view class="title" :style="[{ height }, { lineHeight: height }]">
          <view class="back" @click="goBack()">
            <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
          </view>
          <text>经销商详情</text>
        </view>
      </view>
    </view>
    <view class="main">
      <view class="main-top">
        <view class="customer-box">
          <view class="header flex1">
            <view class="name flex_l">
              <image class="img" src="../../static/images/menu1.png" mode="scaleToFill" />
              <text>{{ distrInfo.distName }}</text>
            </view>
            <view class="date">{{ parseTime(distrInfo.createdTime, '{y}-{m}-{d}') }}</view>
          </view>
          <view class="info">
            <view class="info-item">
              <u-row>
                <u-col span="7">
                  <view class="flex_l">
                    <view class="info-label">客户编码：</view>
                    <text class="info-txt">{{ distrInfo.distCode }}</text>
                  </view>
                </u-col>
                <u-col span="5">
                  <view class="flex_l">
                    <view class="info-label">负责人：</view>
                    <text class="info-txt">{{ distrInfo.distBoss }}</text>
                  </view>
                </u-col>
              </u-row>
            </view>
            <view class="info-item">
              <u-row justify="space-between">
                <u-col span="7">
                  <view class="flex_l">
                    <view class="info-label">销售人：</view>
                    <text class="info-txt">{{ distrInfo.belongSale }}</text>
                  </view>
                </u-col>
                <u-col span="5">
                  <view class="flex_l">
                    <view class="info-label">归属省份：</view>
                    <text class="info-txt">{{ distrInfo.provinceDesc }}</text>
                  </view>
                </u-col>
              </u-row>
            </view>
          </view>
        </view>
        <view class="tabs">
          <u-tabs
            @change="changeTabs"
            :current="curTabIndex"
            :scrollable="false"
            :list="list"
            :activeStyle="{
              color: '#3E7EF8',
              fontWeight: 'bold',
            }"
            :inactiveStyle="{
              color: '#969696',
            }"></u-tabs>
        </view>
      </view>
      <view class="data-list">
        <!-- 跟进记录 -->
        <follow-records v-if="curTabIndex == 0" ref="follow" :customerId="customerId"></follow-records>
        <!-- 详情 -->
        <distr-detail v-if="curTabIndex == 1" :detail="distrInfo"></distr-detail>
      </view>
    </view>
  </view>
</template>
<script>
  import distrApi from '../../api/base/distr'
  import to from 'await-to-js'
  import distrDetail from './components/distrDetail'
  import followRecords from './components/followRecords'
  export default {
    name: 'omsIndex',
    components: { distrDetail, followRecords },
    data() {
      return {
        openBtnWidth: false,
        curTabIndex: 0,
        fllowList: [], //跟进数据
        list: [
          {
            name: '跟进记录',
            index: 0,
          },
          {
            name: '详细信息',
            index: 1,
          },
        ],
        height: '',
        paddingTop: '',
        distrInfo: {},
        distrId: 0, //客户id
      }
    },
    onLoad(option) {
      this.distrId = parseInt(option.id)
    },
    created() {
      const navData = uni.getMenuButtonBoundingClientRect()
      this.height = navData.height + 'px'
      this.paddingTop = navData.top + 'px'
    },
    onShow() {
      this.getDistrDetail()
    },
    methods: {
      async getDistrDetail() {
        const [err, res] = await to(distrApi.getEntity({ id: this.distrId }))
        if (err) return
        if (res && res.code == 200) {
          // console.log(res)
          this.distrInfo = res.data.list
        }
      },
      // 改变tab
      changeTabs(data) {
        // console.log(data)
        this.curTabIndex = data.index
      },
      goBack() {
        uni.navigateBack({
          //关闭当前页面，返回上一页面或多级页面。
          delta: 1,
        })
      },
    },
  }
</script>
<style>
  page {
    background: #f2f3f5;
  }
</style>
<style lang="scss" scoped>
  .home {
    padding-top: 200rpx;

    .nav {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 356rpx;
      background: #3e7ef8;
      border-radius: 0 0 31rpx 31rpx;
      .title {
        position: relative;
        text-align: center;
        font-size: 32rpx;
        font-weight: bold;
        color: #ffffff;
        .back {
          position: absolute;
          top: 0;
          bottom: 0;
          margin: auto;
          left: 70rpx;
          display: flex;
        }
      }
    }

    .main {
      position: absolute;
      width: 100%;
      height: calc(100vh - 200rpx);
      overflow: hidden;
      padding-bottom: 64rpx;
      .main-top {
        padding: 0 32rpx;
      }
      .customer-box {
        width: 100%;
        background: #ffffff;
        box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
        border-radius: 32rpx;
        padding: 22rpx 38rpx 68rpx 40rpx;
        .header {
          .name {
            .img {
              width: 46rpx;
              height: 46rpx;
              border-radius: 50%;
              margin-right: 8rpx;
            }
            text {
              font-size: 28rpx;
              font-weight: bold;
              color: #323232;
            }
          }
          .date {
            font-size: 24rpx;
            color: #3e7ef8;
          }
        }
        .info {
          .info-item {
            margin-top: 18rpx;
            .info-label {
              width: 116rpx;
              text-align: left;
              font-size: 24rpx;
              color: #646464;
            }
            .info-txt {
              flex: 1;
              font-size: 24rpx;
              color: #323232;
            }
          }
        }
      }
      .data-list {
        margin-top: 16rpx;
        width: 100%;
        height: calc(100vh - 532rpx);
        background: #ffffff;
        padding: 32rpx;
        overflow: auto;
        padding-bottom: 145rpx;
        .status1 {
          color: #4096fb;
          background: rgba(64, 150, 251, 0.2);
        }
        .status2 {
          background: rgba(255, 184, 60, 0.2);
          color: #ffb83c;
        }
        .status3 {
          color: #fe6936;
          background: rgba(254, 105, 54, 0.2);
        }
      }
    }
    .fixed-btn-group {
      position: fixed;
      display: flex;
      justify-content: space-around;
      align-items: center;
      width: 90rpx;
      height: 90rpx;
      bottom: 50rpx;
      right: 50rpx;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      border-radius: 20px;
      transition: all 0.2s;
      background: #fff;
      .btn {
        width: 60rpx;
        height: 60rpx;
        background: #3e7ef8;
        border-radius: 50%;
        margin: 10rpx;
        font-size: 26rpx;
        font-weight: bold;
        color: #ffffff;
      }
    }
  }
</style>
