<template>
	<view class="running-water">
		<navbar :title="title[status]" leftClick @leftClick="leftClick" />
		
		<userShopCommission/>
		
		<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">
				
					<template #value>
						<view class="info">
							<view class="price">
								{{ x[item.type] + item.price }}
							</view>
							<view class="uni-color-btn"
							@click="requestMerchantTransfer(item)"
							v-if="item.type == 0 && item.state == 1"
							>
								领取
							</view>
							<view class="status"
							v-else>
								{{ item.state_dictText }}
							</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()
					},
					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;
	.tab-box{
		margin: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		overflow: hidden;
	}
}
</style>
