// 评价页面
<template>
  <div class="page">
    <div class="stepList item_content" :key="stepShow+'123'">
      <div class="item_content_top">
        <div class="stepList_title">维修单号 {{id}}</div>
        <!-- <van-button class="top_but" type="primary" size="small">去支付</van-button> -->
        <van-button v-if="detailData.repairerVo?.status == 3" size="small" @click="goRoute(`/repair/${id}`)" color="#00B3EC" type="primary" >待确认</van-button>
        <van-button v-if="detailData.repairerVo?.status == 9" size="small" @click="goRoute(`/payment/${id}`)" color="#00B3EC" type="primary" >支付</van-button>
        <van-button v-if="detailData.repairerVo?.status == 13" size="small" @click="goRoute(`/evaluate/${id}`)" color="#00B3EC" type="primary" >评价</van-button>
        <van-button v-if="detailData.repairerVo?.status == 10" size="small" @click="goRoute(`/invoice/${id}`)" color="#00B3EC" type="primary" >申请开票</van-button>
      </div>
      <transition-group name="van-fade">
        <!-- <div v-show="stepShow">Slide Right</div> -->
        <div class="border stepItem" v-for="(item, index) in processList" :key="index" v-show="stepShow ? true : index < 1">
          <div class="step">
            <div class="step_title">{{item.remark}}</div>
            <div v-if="item.customerAddress">{{item.customerAddress.sendType == 0?' 前台送修':`快递寄送 ${item.customerAddress?.sendTrackingNum}`}}</div>
            <div v-if="item.customerAddress">{{item.customerAddress.getType == 0?' 前台取回':`快递寄回 ${item.customerAddress?.getTrackingNum}`}}</div>
            <div v-if="item.customerAddress">前台取回 </div>
            <div v-if="item.repairRegisterVo?.checkResult">检测结果： {{item.repairRegisterVo?.checkResult}}</div>
            <div v-if="item.repairRegisterVo?.partNamesStr">所需备件： {{item.repairRegisterVo?.partNamesStr}}</div>
            <div v-if="item.repairRegisterVo?.orderFaultMsg">机器外观： {{item.orderReceiving?.orderFaultMsg}}</div>
            <div class="imgList">
              <img :src="imgItem" v-for="imgItem in item.imagesInfo" :key="imgItem + index" alt="" />
            </div>
            <div class="step_time">{{dayjs(item.createTime).format('MM-DD hh:mm')}}</div>
            <div class="doct" :class="index == 0 ? 'oneSpot' : 'Spot'"></div>
          </div>
        </div>
      </transition-group>
      <van-divider v-if="processList?.length >1">
        <div @click="handleShow">
          <van-icon :name="!stepShow ? 'arrow-down' : 'arrow-up'" />
          {{ !stepShow ? '展开' : '收起' }}
        </div>
      </van-divider>
    </div>
    <div class="page_top item_content" v-if="detailData.customer">
      <div class="title">客户信息</div>
      <div class="content">
        <div class="cost_list" style="border-bottom: none">
          <div class="item">
            <span>公司名称</span>
            <span>{{detailData.customer?.companyName}}</span>
          </div>
          <div class="item">
            <span>联系人</span>
            <span>{{detailData.customer?.customerName}}</span>
          </div>
          <div class="item">
            <span>联系电话</span>
            <span>{{detailData.customer?.phone}}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="page_top item_content" v-if="detailData.orderReceivingVo">
      <div class="title">故障信息</div>
      <div class="content">
        <div class="text">{{cameraType[detailData.repairerVo?.cameraType]}} {{detailData.repairerVo?.cameraSnCode}}</div>
        <div class="text" v-html="detailData.repairerVo?.faultMsg"></div>
        
        <div class="imgList" v-if="detailData.repairerVo">
          <img :src="imgItem" v-for="imgItem in detailData.repairerVo.faultImg" :key="imgItem" alt="" />
        </div>
      </div>
    </div>
    <div class="page_custinfo item_content" v-if="detailData.priceList.length">
      <div class="title">费用明细</div>
      <div class="content">
        <div class="cost_list">
          <div class="item" v-for="item in detailData.priceList" :key="item.name">
            <span>{{ item.name }}</span>
            <span>¥{{ item.price }} x{{ item.count }}</span>
          </div>
        </div>
        <div class="cell" style="border: none">
          <span>维修费用</span>
          <span>¥{{ priceCount(detailData?.priceList || []) }}</span>
        </div>
      </div>
    </div>
    <div class="page_top item_content" v-if="detailData.customerAddress">
      <div class="title">运输信息</div>
      <div class="content">
        <div class="cost_list">
          <div class="item">
            <span>送修方式</span>
            <span>{{detailData.customerAddress.sendType == 0 ?'前台送修':'快递寄送'}}</span>
          </div>
          <div class="item" v-if="detailData.customerAddress.sendType != 0">
            <span>快递单号</span>
            <span>{{detailData.customerAddress.sendTrackingNum}}</span>
          </div>
          <div class="item">
            <span>取回方式</span>
            <span>{{detailData.customerAddress.getType == 0 ?'前台取回':'快递寄回'}}</span>
          </div>
          <div class="item" v-if="detailData.customerAddress.getType != 0">
            <span>快递单号</span>
            <span>{{detailData.customerAddress.getTrackingNum}}</span>
          </div>
          <div class="item" v-if="detailData.customerAddress.getType != 0">
            <span>收件人</span>
            <span>{{detailData.customerAddress.getAddrName}}</span>
          </div>
          <div class="item" v-if="detailData.customerAddress.getType != 0">
            <span>收件人电话</span>
            <span>{{detailData.customerAddress.getAddrPhone}}</span>
          </div>
          <div class="item" v-if="detailData.customerAddress.getType != 0">
            <span>收件地址</span>
            <span>{{detailData.customerAddress.getAddress}}</span>
          </div>
        </div>
      </div>
    </div>

    <div class="page_top item_content" v-if="detailData.RepairComment">
      <div class="title">评价信息</div>
      <div class="content">
        <div class="cost_list" style="border-bottom: none">
          <div class="item">
            <span>内容</span>
            <span>{{detailData.RepairComment?.comment}}</span>
          </div>
          <div class="item">
            <span>评分</span>
            <span>{{detailData.RepairComment?.starRank}}分</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
  
<script lang="ts" setup name="detailPage">
import { useRouter } from 'vue-router';
import { ref, onMounted, unref, onActivated } from 'vue';
import { repairProcess, repairDetails } from '/@/api';
import dayjs from 'dayjs'
const { currentRoute } = useRouter();
const router = useRouter();
const { id } = unref(currentRoute)?.params
const stepShow = ref<boolean>(false);
const cameraType = {
    0:'四维看看',
    1:'四维看见',
    2:'四维深时',
  }
let detailData = ref({
  customer:<any>{},
  customerAddress:<any>{},
  repairerVo:<any>{},
  RepairTestVo:<any>{},
  repairRegisterVo:<any>{},
  orderReceivingVo:<any>{},
  repairPay:<any>{},
  RepairComment:<any>{},
  priceList:<any>[],
});
let processList = ref<any>([])
onMounted(() => {
  console.log('onMounted',id)
  getDetaile();
});
onActivated(()=>{
  console.log('onActivated')
  getDetaile();

})
function priceCount(list){
  let price = 0
  list.map(ele => {
    price = (ele.price * ele.count) + price
  })
  return price.toFixed(2)
}
const getDetaile = async () => {
  const { response } = await repairDetails(id);
  let detaile = unref(response)?.data;
  detailData.value = detaile
  const resProcess = await repairProcess(id);
  console.log('resProcess',resProcess)
  let process = unref(resProcess?.response)?.data;
  processList.value = process
  console.log('getDetaile',detaile,process)
};
const handleShow = () => {
  stepShow.value = !stepShow.value;
};
const goRoute = (path) => {
  console.log('goRoute',path)
  if (!path) return;
  router.push(path);
};
</script>
 <style lang="scss" >
.page {
  min-height: 100vh;
  background-color: #f5f5f5;
  overflow: hidden;
  .item_content {
    background-color: #fff;
    border-radius: 4px 4px 4px 4px;
    margin: 12px;
    .title {
      font-size: 14px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 600;
      color: #000000;
      padding: 15px 0;
      margin: 0 15px;
      border-bottom: 1px solid #e7e7e7;
    }
    .content {
      padding: 24px 15px;
    }
    .item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      line-height: 30px;
      font-size: 14px;
      // margin-bottom: 8px;
    }

    .imgList {
      margin-top: 8px;
      img {
        height: 64px;
        width: 64px;
        padding: 0 8px 0 0;
      }
    }
  }
  .stepList {
    padding: 24px 16px;
    .item_content_top{
      padding-bottom: 15px;
      margin-bottom: 24px;
      border-bottom: 1px solid #f5f5f5;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    &_title {
      font-size: 14px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #000000;
    }
    .stepItem {
      transition: all 3s 2s linear;
    }
    .step {
      &:last-child {
        // border: none;
      }
      padding: 0 15px;
      border-left: 1px solid #f5f5f5;
      &_title {
        font-size: 14px;
        line-height: 22px;
      }
      &_time {
        font-size: 10px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
        line-height: 14px;
        padding-bottom: 24px;
      }
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 30px;
      position: relative;
      .doct {
        display: inline-block;
        position: absolute;
        left: 0;
        top: 0;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        transform: translat(-50%, -50%);
      }
      .oneSpot {
        border: 4px solid #00b3ec;
        left: -8px;
        top: 4px;
        background: #fff;
      }
      .Spot {
        background: #cccccc;
        left: -4px;
        top: 8px;
      }
    }
  }
  .colortext {
    color: #e34d59;
  }
  .cell {
    border-top: 1px solid #e7e7e7;
    &:first-child {
      border-top: none;
    }
    // height: 48px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 22px;
  }
  .page_custinfo {
    .cost_list {
      padding-bottom: 8px;
      // margin: 0 15px;
      // padding-top: 24px;
      border: {
        // top: 1px solid #e7e7e7;
        bottom: 1px solid #e7e7e7;
      }
    }
  }
  .page_top {
    .cost_list {
      border: {
        // bottom: 1px solid #e7e7e7;
      }
    }
    .text {
      line-height: 30px;
    }
  }
  .repairInfo {
    background-color: #fff;
    margin-bottom: 12px;
    border-radius: 4px 4px 4px 4px;
  }
  .but {
    padding: 25px 15px;
    .tips {
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      margin-bottom: 10px;
    }
    button {
      margin-top: 16px;
    }
  }
}
</style>
  