<template>
	<view class="wallet">
<!-- 		<view class="select-date" @click="openCalendar">
			<u-icon class="icon" size="22" name="calendar"></u-icon>
			<text v-if="createTimeStart && createTimeEnd">{{ createTimeStart }} ~ {{ createTimeEnd }}</text>
		</view> -->
		<mescroll-uni @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
			<view class="order" v-for="(item,index) in datas" :key="index">
				<view class="fenqi">
					<block>
						<view class="item">
							<view class="goods-info">
								<view class="goods-name">
									<text class="name">{{item.applyStatusDis}}</text>
									<text v-if="item.rejectReason" class="selling-point">拒绝理由：{{ item.rejectReason }}</text>
									<image v-if="item.image" :src="item.image" mode="widthFix" style="width: 100px;" @click="proView(item.image)"></image>
									<text class="selling-point">申请时间：{{ item.createTime }}</text>
								</view>
								<view class="goods-price">
									<!-- <text class="add-price"
										v-if="item.scene == 10 || item.scene == 40">+￥{{ item.money }}</text>
									<text class="sub-price" v-if="item.scene == 20">-￥{{ item.money }}</text>
									<block v-if="item.scene == 30">
										<text class="add-price" v-if="item.money > 0">+￥{{ item.money }}</text>
										<text class="sub-price" v-else>-￥{{ Math.abs(item.money) }}</text>
									</block> -->
									<text class="num">￥{{ item.money }}</text>
								</view>
							</view>
						</view>
					</block>
				</view>
			</view>
		</mescroll-uni>
		
		<!-- <u-empty mode="order" icon="http://cdn.uviewui.com/uview/empty/car.png" text="暂无提现记录" v-if="list.length == 0">
		</u-empty> -->
		<!-- <mescroll-empty v-if="dataList.length==0"></mescroll-empty> -->
	</view>
</template>

<script>
	import {
		dateFormat
	} from '@/utils/util.js'
	import store from '@/store';
	import { ref } from 'vue';
	import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins';
	import { withdrawPage } from '@/websoft/api/merchant.js'

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				upOption:{
					// page: {
					// 	size: 5 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: '~ 搜索无数据 ~', // 提示
						btnText: '去看看'
					}
				},
				datas: [], //列表数据
				// tabs: [{name:'全部',type:'xx'}, {name:'奶粉',type:'xx'}, {name:'面膜',type:'xx'}, {name:'图书',type:'xx'}],
				// tabIndex: 0 // tab下标
			}
		},
		// onLoad(option) {
		// 	const app = this
		// 	app.minDate = uni.$u.timeFormat(new Date().getTime() - 2592000000 * 2, 'yyyy-mm-dd');
		// },
		// onShow() {
		// },
		methods: {	
			upCallback(page) {
				console.log(page)
				const app = this
				page.size = 5
				withdrawPage({page:page.num,limit:page.size}).then(res=>{
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					// this.mescroll.endSuccess(res.data.count);
					// app.mescroll.endBySize(page.size, res.data.count); 
					
					//设置列表数据
					if(page.num == 1) app.datas = []; //如果是第一页需手动制空列表
					app.datas=app.datas.concat(res.data.list); //追加新数据
					// app.mescroll.endBySize(res.data.list.length, res.data.count);
					
					let totalPage = res.data.count / page.size + (res.data.count % page.size == 0 ? 0 : 1);
					let hasNext = (totalPage - page.num > 0);
					app.mescroll.endSuccess(res.data.count, true);
				}).catch(()=>{
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			openCalendar() {
				this.show = true
			},
			closeShow(){
				this.show = false
			},
			proView(url){
				uni.previewImage({
					urls: [url]
				})
			},
			//点击空布局按钮的回调
			emptyClick(){
				uni.showToast({
					title:'点击了按钮,具体逻辑自行实现'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wallet {
		background-color: #f3f3f3;
		padding-top: 42rpx;
	}

	.order {
		background-color: #ffffff;
		border-radius: 12rpx;
		width: 700rpx;
		margin: 20rpx auto;
		padding: 10rpx 0;

		.title {
			font-weight: bold;
			font-size: 30rpx;
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
		}

		.xieyi {
			padding: 20rpx;
			font-size: 26rpx;
		}
	}

	.fenqi {
		padding: 10rpx 30rpx;
		font-size: 26rpx;

		.item {
			display: flex;
			padding: 10rpx 0;

			.image {
				width: 160rpx;
				height: 120rpx;
			}

			.goods-info {
				width: 700rpx;
				margin-left: 10rpx;
				display: flex;
				justify-content: space-between;
				
				.name {
					font-weight: 500;
					max-width: 300rpx;
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden; //溢出内容隐藏
					text-overflow: ellipsis; //文本溢出部分用省略号表示
					display: -webkit-box; //特别显示模式
					-webkit-line-clamp: 2; //行数
					line-clamp: 2;
					-webkit-box-orient: vertical; //盒子中内容竖直排列
				}

				.goods-name {
					text-align: left;
					display: flex;
					flex-direction: column;
					
					.comments{
						
					}
				}

				
			}

		}
	}

	.select-date {
		text-align: center;
		font-size: 28rpx;
		padding: 12rpx 0;
		margin: auto;
		display: flex;
		justify-content: center;
		align-items: center;

		.icon {
			margin-right: 10rpx;
		}
	}
	
	.selling-point {
		margin-top: 0.2rem;
		max-width: 400rpx;
		color: #999999;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden; //溢出内容隐藏
		text-overflow: ellipsis; //文本溢出部分用省略号表示
		display: -webkit-box; //特别显示模式
		-webkit-line-clamp: 1; //行数
		line-clamp: 1;
		-webkit-box-orient: vertical; //盒子中内容竖直排列
	}
	
	.goods-price {
		display: flex;
		flex-direction: column;
	
		.add-price {
			color: #27b900;
		}
	
		.sub-price {
			color: #ff0000;
		}
	
		.num {
			text-align: right;
			color: #ff0000;
		}
	}

	.on-buy {
		background-color: #804002;
	}

	.user-card {
		width: 700rpx;
		height: 260rpx;
		margin: 30rpx auto;
		border-radius: 24rpx;
		background: linear-gradient(to bottom, #9E1A91, #4D0868);
		
		.user-info {
			padding: 40rpx;
			position: relative;

			.avatar {
				display: flex;
				align-items: center;
				color: #ffffff;

				.avatar-img {
					border: 4rpx solid #ffffff;
				}

				.user {
					margin-left: 15rpx;

					.nickname {
						font-size: 34rpx;
					}

					.desc {
						font-size: 26rpx;
						color: #b2b2b2;
					}
				}

				image {
					border: 4rpx solid #ffffff;
				}
			}

			.buy-log {
				position: absolute;
				z-index: 999;
				text-align: center;
				top: 50rpx;
				right: 40rpx;
				font-size: 24rpx;
				padding: 5rpx 20rpx;
				border-radius: 12rpx 0 12rpx 0;
				background-color: #f3f3f3;
			}
		}
	}

	// 我的收益
	.my-profit {
		background: linear-gradient(to bottom, #9E1A91, #4D0868);
		display: flex;
		align-items: center;
		justify-content: space-around;
		color: #ffffff;
		margin: 0 auto;
		padding: 22rpx 0;
		width: 700rpx;
		height: 140rpx;
		box-shadow: 0 1rpx 5rpx 0px #eaebec;
		border-radius: 24rpx;

		.item {
			text-align: center;

			.profit {
				font-size: 38rpx;
				font-weight: 500;
				color: #ffffff;
			}

			.desc {
				font-size: 24rpx;
				color: #d8d9dc;
			}
		}

	}
</style>
