<template>
	<view>
		<view class="back-top"></view>
		
		<uni-group mode="card" class="card">
		  <view class="box">
		    <text class="title">订单号:</text>
		    <text>{{ withdrawDetailInfo.orderId }}</text>
		  </view>
		  
		  <view class="box" v-if="withdrawDetailInfo.channel == '2'">
		    <text class="title">手机号:</text>
		    <text>{{withdrawDetailInfo.phone }}</text>
		  </view>
		  <view class="box" v-if="withdrawDetailInfo.channel == '1'">
		    <text class="title">银行卡:</text>
		    <text>{{withdrawDetailInfo.bankNo }}</text>
		  </view>
		  <view class="box">
		    <text class="title">提现金额:</text>
		    <text style="color: red">{{ withdrawDetailInfo.amt }}</text>
		  </view>
		  <view class="box">
		    <text class="title">渠道:</text>
		    <text>{{ setChannel(withdrawDetailInfo.channel) }}</text>
		  </view>
		  <view class="box">
		    <text class="title">状态:</text>
		    <text>{{ setStatus(withdrawDetailInfo.status) }}</text>
		  </view>
		  <view class="border"></view>
		  <view class="box">
		    <text class="title">提现时间:</text>
		    <text>{{withdrawDetailInfo.createTime}}</text>
		  </view>
		  <view class="box">
		    <text class="title">审核理由:</text>
		    <text>{{withdrawDetailInfo.reason}}</text>
		  </view>
		  <view class="box">
		    <text class="title">到账时间:</text>
		    <text>{{withdrawDetailInfo.achieveTime || "待确认"}}</text>
		  </view>
		  </uni-group>
	</view>
</template>

<script>
	import {
		getWithdrawDetails
	} from '@/api/userInfo.js'
	export default {
		data() {
			return {
				withdrawDetailInfo: {
					orderId: '',
					amt: 0,
					phone: '',
					bankNo: '',
					channel: '',
					status: '',
					createTime: '',
					reason: '',
					achieveTime: '',
					userInfo:{}
				}
			}
		},
		created() {
			const userInfo = uni.getStorageSync('userInfo')
			if (!userInfo) {
				console.log('havent userInfo')
				uni.showModal({
					content: '艺术家账户过期,请重新登录！',
					showCancel: false,
					success() {
						//没有缓存则跳转登录页面
						uni.reLaunch({
							url: '/pages/login/login'
						});
					}
				});
			} else {
				this.userInfo = userInfo;
				console.log('have userInfo')
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option)
			this.withdrawDetailInfo.orderId = option.orderId
			this.getWithdrawDetails();
		},
		methods: {
			// 查询提现记录明细
			async getWithdrawDetails() {
				let that = this;
				const res = await getWithdrawDetails({
					orderId: that.withdrawDetailInfo.orderId
				})
				console.log('res', res)
				if (res.data.code === 200) {
					that.withdrawDetailInfo = res.data.data
				} else {
					uni.showModal({
						content: '提现记录详情数据加载失败！',
						showCancel: false
					});
				}
			},
			setChannel(data){
				if (data == "0") {
				  return "微信";
				} else if (data == "1") {
				  return "银行卡";
				} else if (data == "2") {
				  return "支付宝";
				}
			},
			setStatus(data){
				if (data == "0") {
				  return "待审核";
				} else if (data == "1") {
				  return "提现中";
				} else if (data == "2") {
				  return "提现成功";
				} else if(data == "3"){
				  return "提现失败";
				}else if(data == "4"){
				  return "审核拒绝";
				}
			},
		}
	}
</script>

<style>
.back-top {
  width: 100%;
  position: absolute;
  height: 240rpx;
  background: #416bdc;
}
.card {
  width: 100%;
  position: absolute;
}
.uni-group--card {
  margin-top: 40rpx !important;
}
.title {
  display: block;
  width: 140rpx;
  margin-right: 20rpx;
  font-weight: bold;
}
.box {
  display: flex;
  margin-bottom: 40rpx;
}
.card view:first-child {
  margin-top: 20rpx;
}
.border {
  width: 100%;
  height: 2rpx;
  background: rgb(229, 229, 229);
  margin-bottom: 40rpx;
}
</style>
