<template>
  <scroll-view
    refresher-enabled
    :refresher-triggered="isRefreshing"
    @refresherrefresh="onCustomRefresh"
    class="details-main"
    @scrolltolower="scrolltolower"
    scroll-y
  >
    <view class="header-box flex_c_c_f hr-solid">
      <view class="price-img"></view>
      <view class="header-title">余额提现-到支付宝</view>
      <view class="header-price">¥{{ data?.takeAmount || 0.0 }}</view>
    </view>
    <view class="stauts-box hr-solid">
      <view class="font-30-333 stauts-text">当前状态</view>
      <view>
        <up-steps :current="current" direction="column" dot>
          <up-steps-item title="发起提现" :desc="data?.createTime">
          </up-steps-item>
          <up-steps-item
            title="已驳回"
            :desc="data?.rejectReason"
            v-if="data?.appStatus === '3'"
            error
          ></up-steps-item>
          <up-steps-item
            title="后台处理中"
            :desc="data?.updateTime"
            v-else
          ></up-steps-item>
          <up-steps-item
            title="打款失败"
            v-if="data?.isPay === '2'"
            error
          ></up-steps-item>
          <up-steps-item
            title="到账"
            :desc="data?.lastTime"
            v-if="['1', '0'].includes(data?.isPay)"
          ></up-steps-item>
        </up-steps>
      </view>
    </view>
    <view class="list-box">
      <view v-for="item in list" :key="item.key" class="list-item">
        <view class="font-30-333 list-name">{{ item.name }}</view>
        <view class="font-30-333" v-if="item.type === 'value'"> 支付宝 </view>
        <view class="font-30-333" v-else>{{ data?.[item.key] || '-' }}</view>
      </view>
    </view>
    <button @click="handlClick" class="btn-cancel">撤销提现</button>
  </scroll-view>
</template>

<script setup>
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getIncomeDetails, volEetCancelTake } from '@/api/mine'

const isRefreshing = ref(false)
const list = [
  {
    name: '提现金额',
    key: 'shoudAmount',
  },
  {
    name: '提现账户',
    key: 'alipayName',
  },
  {
    name: '提现账号',
    key: 'alipayAccountNo',
  },
  {
    name: '申请时间',
    key: 'createTime',
  },
  {
    name: '到账时间',
    key: 'lastTime',
  },
  {
    name: '打款方式',
    key: 'payType',
    type: 'value',
  },
  // {
  //     name: '提现单号',
  //     key: 'volunteerTakeRecordId'
  // },
]

const id = ref(null)
const data = ref({
  alipayName: '**',
  createTime: '',
  takeAmount: 0.0,
  appStatus: '',
  isPay: '',
  updateTime: '',
  lastTime: '',
  shoudAmount: '',
  alipayAccountNo: '',
})

const current = computed(() => {
  if (
    ['3', '1'].includes(data.value?.appStatus) ||
    ['0'].includes(data.value?.isPay)
  ) {
    return 1
  }
  return 2
})

const onCustomRefresh = () => {
  getDetails()
}

const scrolltolower = () => {
  console.log('scrolltolower')
}

// const getDetails = async () => {
//   try {
//     isRefreshing.value = true
//     const res = await getIncomeDetails(id.value)
//     if (res.code !== 200) {
//       throw res.msg || '账单详情获取失败！'
//     }
//     data.value = res.data || {}
//   } catch (error) {
//     console.log('TCL: getDetails -> error', error)
//     uni.showToast({
//       title: error.message || error,
//       icon: 'none',
//     })
//   } finally {
//     isRefreshing.value = false
//   }
// }

// 撤销提现
const handlClick = async () => {
  uni.showModal({
    title: '提示',
    content: '确认要撤销此次提现吗？',
    success: async function (res) {
      if (res.confirm) {
        const params = {
          volunteerTakeRecordId: data.value?.volunteerTakeRecordId
        }
        const res = await volEetCancelTake(params)
        if (res.code === 200) {
          uni.showToast({
            title: '撤销提现成功',
          })
          uni.navigateBack({
            delta: 1,
          })
        } else {
          uni.showToast({
            title: res.msg || '撤销提现失败',
            icon: 'none'
          })
        }
      }
    },
  })
}

onLoad((options) => {
  console.log('TCL: options', options)
  if (options.data) {
    try {
      data.value = JSON.parse(decodeURIComponent(options.data))
    } catch (error) {
      console.error('解析数据失败:', error)
      uni.showToast({
        title: '数据解析失败',
        icon: 'none'
      })
    }
  }
})
</script>

<style scoped lang="scss">
.details-main {
  padding: 20rpx;

  position: fixed;
  left: 0px;
  top: 0px;
  right: 0px;
  bottom: 0;
  background: #fff;

  overflow: hidden;
  overflow-y: auto;
}

.header-box {
  margin-top: 48rpx;
  padding: 24rpx 0;

  .price-img {
    width: 140rpx;
    height: 140rpx;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMw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gAnNX1ftIpE7PPhzreqLbAANhrPmI5rfM9peUKbjUu/nY103kAUhrDhdmrd45ce2BAoZESeAhL/LaeKDRSmKewxG/tkUIjuXkMC9RQVk5j9jjBcO6zDdIg8QTf63M9r4EBSCocek4ju0zqrIZt43VItk7PaSRFbc9ZdgkmMAD2kmMMH9HaM4lFWE6S1SJBCCowAPY7YyxftNW54wwL+hyWvQHMlfc5zHPmZ+bJVueZ77aIN/MQwwIB9jDrtJSmk4KZr2wSdGBA85oOiTBMki3uwQo+MLDaiPYFbXlup0DnK5s0IjBLGqK1UtBDsOcaFRgAe8UBhs+qojWcYYHhXdU7JMsWXJVsF7PPjFtea0lNo0245XXTwgIN7GHW2SsOiFcHHPhtiWTSoLnKNo0OzJK95hTLGaqkhSk+butT6BWwLFoRGAA7ZcgrzlQUCIzhgj6TJvcq61oTmCX7nTEPfETDNL9aFpSl1gVmSfMbb2bEpeKZ53ZUorWBWVJwajOjxUFZan1glhScihgusPzR9qAsdSYwS/aGEff8npwloKpaUS2do+zSucAs2SlD+hxj+BX1OtkYFjww4RWzrgVlqbOBWZcst/lVvc5GEYavXRp2pVFg1tgpQwaMMfyG5YjuhicOyQPfQtoeHAIFZovOhSd+Gj9TSNIpMBnZ74y5T4Zu8b6cNgRohuUbfWZNXAjpgwJTwKr3sYwx/EJcNAg7QIYFljmWPzHMNR8pRoEpib1hxC1jYESP/2KTP9cfpAhYAItlOLhjbg6Jam5HKykwFbNThvyLEffJMK7HT8AQyzD539Hqm03yd09F2OTDbohg9ecFln+Sry0wRApG9f4fLUkfWHpLd5QAAAAASUVORK5CYII=);
    background-position: center;
    background-size: 140rpx auto;
    background-repeat: no-repeat;
  }

  .header-title {
    font-family: PingFang SC;
    font-size: 32rpx;
    font-weight: normal;
    line-height: 32rpx;
    letter-spacing: normal;
    color: #000000;
    padding: 20rpx 0 30rpx;
  }

  .header-price {
    font-family: PingFang SC;
    font-size: 34rpx;
    font-weight: bold;
    line-height: 48rpx;
    letter-spacing: normal;
    color: #3d3d3d;
  }
}

.stauts-box {
  padding: 23rpx 0;
  display: flex;

  .stauts-text {
    margin-right: 44rpx;
  }
}

.list-box {
  padding: 23rpx 0;

  .list-item {
    display: flex;
    padding: 16rpx 0;
    .list-name {
      width: 150rpx;
    }
  }
}

.btn-cancel {
  background: red;
  color: #fff;
  border-radius: 50rpx;
  padding: 10rpx 20rpx;
  margin-top: 20rpx;
}
</style>
