<template>
	<view class="inspage-content" :style="{'--status-bar-': statusBarHeight}">
		<u-navbar title="提现详情" :placeholder="true" @leftClick="leftClick" :autoBack="false" :safeAreaInsetTop="true" />
		<view class="inspage-content-info">
			<!-- 头部主要内容 开始 -->
		<!-- 	<view class="inspage-content-header">	
				<customNavbar 
				title="提示" 
				bgColor="var(--gd-bgm-color)"
				:contentStyle="{ color: '#fff' }"
				:left-style="{ color: '#fff' }"
				></customNavbar>
			</view> -->
			<!-- 头部主要内容 结束 -->
			
			<!-- userInfo内容 开始 -->
			
			<view class="inspage-content-userinfo">
				<text>{{ withdrawStatus(retailStatistics.status) }}</text>
				<text>￥{{retailStatistics.withdrawPrice}}</text>
				<view>
					<view>
						<text>服务费</text>
						<text>￥{{ serviceMoney }}</text>
					</view>
					<view>
						<text>到账账户</text>
						<text>{{ withdrawType(retailStatistics.withdrawType) }}</text>
					</view>
				</view>
			</view>
			<!-- userInfo内容 结束 -->
		</view>
	</view>
</template>

<script>
	import { navigateTo } from "@/utils/util.js"
	export default {
		data() {
			return {
				title: '提示',
				statusBarHeight: 0, // 状态栏安全距离
				tool: [ // 我的工具
					{ title: "邀请总人数",num: 0,decimals:0 },
					{ title: "待核销",num: 0,decimals:2 },
					{ title: "已核销",num: 0,decimals:2 },
				],
				retailStatistics: {}, // 统计信息
				params: {},
				serviceMoney: null,
			}
		},
		onLoad(e) {
			this.params = e
		},
		onShow() {
			this.statusBarHeight = getApp().globalData.statusBarHeight
			this.orderWithdrawSelectById()
		},
		methods: {
			leftClick(e) {
				uni.reLaunch({
					url: '/pages/distributor/index'
				});
				console.log('leftClick', e);
			},
			/**
			 * @author ygh
			 * @data 2023-12-20
			 */
			navigateToFun(item){
				navigateTo(item.url)
			},
			/**
			 * 数字显示格式化
			 *
			 */
			numFormat(num=0) {
				if(num<100000) {
					return num
				}else if(num>100000){
					return (num/10000).toFixed(2)
				}
			},
			/** 获取数据 */
			async orderWithdrawSelectById(){
				try{
					this.serviceMoney = this.params.serviceMoney
					let res = await this.$u.api.orderWithdrawSelectById({
						noSign: 1,
						userid: this.distribution_user_info.userId,
						id: this.params.id
					})
					
					if(res && res.code ===200) {
						this.retailStatistics = res.data
					} 
				}catch(e){
					//TODO handle the exception
					console.error("e===",e)
				}
			},
			withdrawType(type){
				let src = ''
				switch(type) {
					case 'wechat': src="微信零钱"; break;
					case 'bank': src="银行卡"; break;
				}
				return src
			},
			/**
			 * 申请状态
			 */
			withdrawStatus(type){
				let src = ''
				switch(type) {
					case 0: src="正在提现,请耐心等待!"; break;
					case 1: src="提现成功!"; break;
					case 2: src="提现失败!"; break;
				}
				return src
			},
			/**
			 * 设置服务费显示
			 */
			setServiceType(data) {
				if (data && data.serviceType) {
					if(data.serviceType == 1){
						return ('￥' + data.serviceCharge)
					}else {
						let num1 = this.withdrawInfo.serviceCharge;
						let num = isNaN(num1) ? 0 : (Number(num1) / 100)
						let money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
						return '￥' + money
						
					}
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.inspage-content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		--header-h: 90rpx;
		.inspage-content-info {
			width: 100%;
			box-sizing: border-box;
		}
	}
	/** 头部主要内容 开始 */
	.inspage-content-header {
		width: 100%;
		height: var(--header-h);
		box-sizing: border-box;
		::v-deep .u-search {
			padding: 0 30rpx !important;
		}
		::v-deep .u-search__action {
			color: #fff !important;
		}
	}
	/** 头部主要内容 结束  **/
	
	/** userInfo内容 开始 */
	.inspage-content-userinfo {
		width: 100%;
		padding: 24rpx 40rpx 0;
		box-sizing: border-box;
		>text {
			width: 100%;
			display: flex;
			justify-content: center;
		}
		>text:nth-child(1) {
			padding: 50rpx 0 100rpx;
			font-size: 32rpx;
		}
		>text:nth-child(2) {
			padding: 50rpx 0 100rpx;
			color: var(--gd-bgm-color);
			font-size: 52rpx;
		}
		>view {
			padding-top: 50rpx;
			color: #606060;
			font-size: 24rpx;
			>view {
				padding-bottom: 20rpx;
				width: 100%;
				display: flex;
				justify-content: space-between;
			}
		}
	}
	/** userInfo内容 结束  **/
</style>
