<template>
	<view class="running-water">
		<navbar :title="title[status]" leftClick @leftClick="leftClick" />
		
		<userShopCommission :type="status" />
		
		<view class="tab-box">
			<view class="tab-box1">
				<!-- <uv-cell 
				center 
				border 
				:title="item.title"
				v-for="(item, index) in list"
				:value="x[item.type] + item.intger" 
				:label="item.createTime" /> -->
				
				<uv-cell center border
				:key="item.id"
				:title="item.title" v-for="(item, index) in list"
				:label="item.createTime">
				
				<!-- <text 
								style="font-size: 22rpx;"
								v-if="item.getPrice">到账{{ item.getPrice }}</text> -->
				
					<template #value>
						<view class="info">
							<view class="price">
								{{ x[item.type] + (item.price || item.intger) }}
							</view>
							<view class="uni-color-btn"
							@click="requestMerchantTransfer(item)"
							v-if="item.type == 0 && item.state == 1"
							>
								领取 <text v-if="item.getPrice">￥{{ item.getPrice }}</text>
							</view>
							<view class="status"
							v-else-if="item.state_dictText">
								{{ item.state_dictText }}<text v-if="item.getPrice">，到账 ￥{{ item.getPrice }}</text>
							</view>
						</view>
					</template>
				
				</uv-cell>
			</view>
			
			<view 
			style="padding: 100rpx 0;"
			v-if="list.length == 0">
				<uv-empty 
				mode="history"
				textSize="28rpx"
				iconSize="100rpx"/>
			</view>
		</view>
		
	</view>
</template>

<script>
	import userShopCommission from '@/components/userShop/userShopCommission.vue'
	import mixinsList from '@/mixins/list.js'
	export default {
		components : {
			userShopCommission,
		},
		mixins: [mixinsList],
		data() {
			return {
				mixinsListApi : 'getWalletFlow',
				title : ['余额记录','积分记录'],
				agentFlow : {
					total : 0,
					records : [
						{
							type : 0,
							money : 100,
							createTime : '2024-04-02 20:00',
							title : "佣金提现",
						},
						{
							type : 0,
							money : 100,
							createTime : '2024-04-02 20:00',
							title : "佣金提现",
						},
						{
							type : 0,
							money : 100,
							createTime : '2024-04-02 20:00',
							title : "佣金提现",
						},
					]
				},
				x : ['-' , '+'],
				status : 0,
			}
		},
		onLoad(e) {
			this.status = e.status
			this.mixinsListApi = ['getWalletFlow', 'getPointsFlow'][e.status]
		},
		methods: {
			leftClick() {		//返回钱包
				uni.navigateBack(-1)
			},
			requestMerchantTransfer(item) {
				if (!wx.canIUse('requestMerchantTransfer')) {
					wx.showModal({
						content: '你的微信版本过低，请更新至最新版本。',
						showCancel: false,
					});
					return
				}
				wx.requestMerchantTransfer({
					mchId: '1673516176',//万能墙商户号
					appId: wx.getAccountInfoSync().miniProgram.appId,
					package: item.packageInfo,
					success: (res) => {
						// res.err_msg将在页面展示成功后返回应用时返回ok，并不代表提款成功
						console.log('success:', res);
						this.getData()
						
						this.$api('requestMerchantTransfer', {
							id : item.id,
						})
					},
					fail: (res) => {
						console.log('fail:', res);
						this.getData()
					},
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
.running-water{
	width: 750rpx;
	background: #F5F5F5;
	margin: 0 auto;
	min-height: 100vh;
	.info{
		text-align: right;
		.status{
			font-size: 22rpx;
		}
	}
	.tab-box{
		margin: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		overflow: hidden;
	}
	.uni-color-btn{
		margin: 0;
		border-radius: 10rpx;
		padding: 6px;
		font-size: 22rpx;
	}
}
</style>
