<template>
  <view class="page-wrapper">
    <JHeaderTitle title="提现记录详情" :bgColor="headerBgColor" color="#fff" imgUrl="/static/iconImg/left-white.svg" />
    <image src="/static/iconImg/wh-bg-img.svg" class="bg-image" mode="scaleToFill" />
    <view class="expand-header">
      <image src="/static/iconImg/icon-wh.svg" mode="scaleToFill" />
      <view class="expand-title">￥{{ (withInfo.applyAmount / 100).toFixed(2) }}</view>
      <view class="expand-phone">{{ withInfo.createdAt?.split("-").join("/") }}</view>
      <view class="expand-edit bgF bdR10" v-if="withInfo.state == 2 || withInfo.state == 5" @tap="toTake">
        <image src="/static/iconImg/icon-wh-file.svg" mode="scaleToFill" />
        重新提交
      </view>
    </view>
    <JMainCard pd="0" bgColor="rgba(0,0,0,0.1)">
      <view class="with-error" v-if="withInfo.state == 2 || withInfo.state == 5"
        >失败原因：{{ withInfo.auditRemark }}</view
      >
      <JInput name="提现状态" textColor="rgba(255,255,255,0.6)" pd="40rpx" :isBorder="true">
        <view
          class="with-state"
          :class="{
            'with-state-error': withInfo.state == 2 || withInfo.state == 5,
            'with-state-success': withInfo.state == 4,
            'with-state-wait': withInfo.state == 1 || withInfo.state == 3,
          }"
          ><image :src="stateList[withInfo.state]?.img" mode="scaleToFill" />
          {{ stateList[withInfo.state]?.text }}</view
        ></JInput
      >
      <JInput name="提现单号" pd="0 40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.rid }}</text></JInput
      >
      <JInput name="联系人姓名" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.settAccountName }}</text></JInput
      >
      <JInput name="联系人手机号" pd="0 40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.settAccountTelphone }}</text></JInput
      >
      <JInput name="提现账户" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.settAccountNo }}</text></JInput
      >
      <JInput name="提现账户类型" pd="0 40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ settAccountType[withInfo.settAccountType] }}</text></JInput
      >
      <JInput name="提现时间" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.createdAt?.split("-").join("/") }}</text></JInput
      >
    </JMainCard>
    <JMainCard pd="0" bgColor="rgba(0,0,0,0.1)" wrapPd="0 50rpx">
      <JInput name="提现金额" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ (withInfo.applyAmount / 100).toFixed(2) }}</text></JInput
      >
      <JInput name="到账金额" pd="0 40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ (withInfo.settAmount / 100).toFixed(2) }}</text></JInput
      >
      <JInput name="手续费" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ (withInfo.settFeeAmount / 100).toFixed(2) }}</text></JInput
      >
    </JMainCard>
    <JMainCard pd="0" bgColor="rgba(0,0,0,0.1)">
      <JInput name="备注" pd="40rpx" textColor="rgba(255,255,255,0.6)" :isBorder="true">
        <text class="right-color">{{ withInfo.applyRemark }}</text></JInput
      >
      <JUpLoad
        name="申请资料"
        pd="0 40rpx 40rpx"
        pdLeft="0"
        :imgUrl="withInfo.settCertImg || imgUrl"
        borderNone
        textColor="rgba(255,255,255,0.6)"
      />
      <JUpLoad v-if="withInfo.state == 4"
        name="打款凭证"
        pd="0 40rpx 40rpx"
        pdLeft="0"
        :imgUrl="withInfo.transferCertImg || imgUrl"
        borderNone
        textColor="rgba(255,255,255,0.6)"
      />
    </JMainCard>   
  </view>
</template>

<script setup>
import { ref, reactive } from "vue"
import { onLoad, onShow, onPageScroll } from "@dcloudio/uni-app"
import { $getCashoutDetail } from "@/http/apiManager.js"
import JHeaderTitle from "@/components/newComponents/JHeaderTitle/JHeaderTitle"
import JMainCard from "@/components/newComponents/JMainCard/JMainCard"
import JInput from "@/components/newComponents/JInput/JInput"
import JButton from "@/components/newComponents/JButton/JButton"
import JUpLoad from "@/components/newComponents/JUpLoad/JUpLoad"
onLoad((option) => {
  params.value.rid = option.rid
  getWithInfo()
})
const stateList = reactive([
  {}, //站位 状态码 1 - 5
  { text: "审核中", img: "/static/iconImg/icon-apply-examine.svg" },
  { text: "审核失败", img: "/static/iconImg/icon-apply-error.svg" },
  { text: "结算中", img: "/static/iconImg/icon-apply-examine.svg" },
  { text: "提现成功", img: "/static/iconImg/icon-success-wh.svg" },
  { text: "结算失败", img: "/static/iconImg/icon-apply-error.svg" },
])
const settAccountType = reactive({
  BANK_PRIVATE: "对私账户",
  BANK_PUBLIC: "对公账户",
  WX_CASH: "个人微信",
  ALIPAY_CASH: "个人支付宝",
})
const imgUrl = ref("/static/iconImg/defaultImg.svg")
const withInfo = ref({})
const params = ref({
  rid: "",
})
const getWithInfo = () => {
  $getCashoutDetail(params.value.rid).then(({ bizData }) => {
    withInfo.value = bizData
  })
}
const headerBgColor = ref("transparent")
const toTake = () => {
  uni.navigateTo({
    url: "/pageAccount/takeMoney/takeMoney?rid=" + params.value.rid,
  })
}
onPageScroll((data) => {
  if (data.scrollTop > 20) {
    headerBgColor.value = "$primaryColor"
  } else {
    headerBgColor.value = "transparent"
  }
})
</script>

<style lang="scss" scoped>
.page-wrapper {
  position: relative;
  width: 100%;
  min-height: 100%;
  background-color: $primaryColor;
  text {
    color: #fff;
  }
  .bg-image {
    position: absolute;
    top: -40rpx;
    left: 73rpx;
    width: 650rpx;
    height: 650rpx;
  }
  .expand-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50rpx;
    image {
      width: 93rpx;
      height: 93rpx;
    }
    .expand-title {
      margin-top: 20rpx;
      font-size: 33rpx;
      font-weight: 700;
      color: #fff;
    }
    .expand-phone {
      margin: 30rpx 0;
      color: rgba(255, 255, 255, 0.6);
      font-size: 25rpx;
    }
    .expand-edit {
      position: relative;
      z-index: 30;
      padding: 20rpx 41rpx;
      font-size: 28rpx;
      color: $primaryColor;
      image {
        width: 26.25rpx;
        height: 26.25rpx;
        vertical-align: middle;
      }
    }
  }
  .right-color {
    color: #fff;
    font-size: 30rpx;
  }
  .page-title {
    margin: 50rpx 0 30rpx 0;
    text-align: center;
    font-size: 33rpx;
    color: #fff;
  }
  .mch-info {
    border-top: 1rpx solid rgba(0, 0, 0, 0.1);
    padding: 60rpx;
    view {
      display: flex;
      flex-direction: column;
    }
    text {
      margin-bottom: 20rpx;
      color: rgba(255, 255, 255, 0.6);
      font-size: 25rpx;
      font-weight: 500;
    }
    .mch-many {
      color: #fff;
      font-size: 56rpx;
      font-weight: 700;
    }
    .mch-footer {
      display: flex;
      flex-direction: row;
      margin-top: 50rpx;
      view {
        flex: 1;
        font-size: 33rpx;
        font-weight: 700;
        color: #fff;
      }
    }
  }
}
.with-error {
  padding: 30rpx 40rpx;
  background-color: #ff6680;
  font-size: 30rpx;
  color: #fff;
}
.with-state {
  font-size: 30rpx;
  image {
    width: 40rpx;
    height: 40rpx;
    vertical-align: middle;
  }
}
.with-state-error {
  color: #ff6680;
}
.with-state-success {
  color: #78ffa0;
}
.with-state-wait {
  color: #ffbb78;
}
</style>
