<template>
	<view class="site">
		<view class="site-bd">
			<view class="item" v-for="(a,i) in list" :key="i">
				<view class="a">提现{{a.money}}元<text>{{a.createtime}}</text><view class="err" v-if="a.status == 2">拒绝原因：{{a.reason}}</view></view>
				<view class="b b-on" v-if="a.status == 2">{{a.status_text}}</view>
				<view class="b" v-if="a.status == 1 || a.status == 0">{{a.status_text}}</view>
			</view>
		</view>
		<view class="empty" v-if="total == 0">
			<image src="https://zhengxin.njrenzhou.cn/static/empty.png"></image>
			<view class="txt">暂无数据 ~</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				offset: 1,
				total: 1,
			};
		},
		mounted() {
			this.getList();
		},
		onReachBottom() {
			const that = this;
			uni.showLoading({
				title: "加载中"
			})
			if(that.list.length <= that.total){
				that.offset ++
				setTimeout(()=>{
					that.getList(1)
				},1000)
			}
		},
		methods: {
			//数组对象去重
			arrayUnique (arr, name) {
				var hash = {};
				return arr.reduce(function (item, next) {
					hash[next[name]]
						? ""
						: (hash[next[name]] = true && item.push(next));
					return item;
				}, []);
			},
			async getList(type) {
				const { code, data, msg } = await this.$api.gettixianlist({
					offset: this.offset,
					limit: 20,
					token: uni.getStorageSync("token")
				})
				if(type==1){
					uni.hideLoading();
				}
				if(code == 1){
					this.list = this.arrayUnique([...this.list,...data.rows],'id');
					this.total = data.total;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.site{
	padding: 0 25rpx 25rpx;
	overflow: hidden;
	.empty{
		padding: 150rpx 0;
		text-align: center;
		font-size: 26rpx;
		color: #666;
		image{
			width: 460rpx;
			height: 400rpx;
			margin-bottom: 30rpx;
		}
	}
	&-bd{
		width: 100%;
		margin: 0 auto;
		position: relative;
		.item{
			background: #FFFFFF;
			box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
			border-radius: 20rpx;
			padding: 20rpx 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			overflow: hidden;
			margin-top: 20rpx;
			.a{
				flex: 1;
				font-weight: 500;
				font-size: 34rpx;
				color: #333333;
				max-width: 500rpx;
				text{
					display: block;
					font-size: 24rpx;
					color: #999999;
					margin-top: 20rpx;
				}
				.err{
					margin-top: 15rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #D80C0C;
				}
			}
			.b{
				font-weight: 400;
				font-size: 30rpx;
				color: #00C6A9;
				&-on{
					color: #D80C0C;
				}
			}
		}
	}
}
</style>

