<template>
	<view class="mine-stored-record">
		<fixed>
			<view class="record-header flex-center flex-column c-base" :style="{background:primaryColor}">
				<view class="f-caption">已累积提现金额(元)</view>
				<view class="wallet-price">{{wallet_price}}</view>
			</view>
			<tab @change="handerTabChange" :list="tabList" :activeIndex="activeIndex" :activeColor="primaryColor"
				:width="100/tabList.length + '%'" height="100rpx"></tab>
		</fixed>

		<view class="pd-lg fill-base b-1px-b flex-center" :class="[{'mt-md':index==0}]"
			v-for="(item,index) in list.data" :key="index">
			<view class="record radius"
				:style="{backgroundColor:item.status==1?primaryColor:item.status==2?subColor:'#f86c53'}"></view>
			<view class="f-title c-title flex-1 ml-md">
				<view class="flex-y-center">
					<view>{{statusType[item.status]}}</view>
					<view class="record-tag ml-sm" v-if="item.status==1"
						@tap="$util.goUrl({url:item.order_code,openType:'copy'})">复制提现编号</view>
				</view>

				<view class="f-caption c-caption">{{item.create_time_text}}</view>
			</view>
			<view class="text-bold f-title c-title">-{{item.pay_price}}</view>
		</view>

		<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
		</load-more>
		<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>

		<view class="space-footer"></view>
	</view>
</template>

<script>
	import {
		mapState,
	} from "vuex"
	export default {
		components: {},
		data() {
			return {
				options: {},
				activeIndex: 0,
				tabList: [{
					id: 0,
					title: '全部'
				}, {
					id: 1,
					title: '未到账'
				}, {
					id: 2,
					title: '已到账'
				}, {
					id: 3,
					title: '已拒绝'
				}],
				statusType: {
					1: '未到账',
					2: '已到账',
					3: '已拒绝'
				},
				param: {
					page: 1,
				},
				list: {
					data: []
				},
				wallet_price: '',
				loading: true,
				lockTap: false
			}
		},
		computed: mapState({
			primaryColor: state => state.config.configInfo.primaryColor,
			subColor: state => state.config.configInfo.subColor,
		}),
		onLoad() {
			this.$util.showLoading()
			let {
				wallet_price
			} = this.$util.getPage(-1).detail
			this.wallet_price = wallet_price
			this.initIndex()
		},
		onPullDownRefresh() {
			// #ifndef APP-PLUS
			uni.showNavigationBarLoading()
			// #endif
			this.initRefresh()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.list.current_page >= this.list.last_page || this.loading) return
			this.param.page = this.param.page + 1
			this.loading = true
			this.getList()
		},
		methods: {
			initIndex() {
				this.getList()
			},
			initRefresh() {
				this.param.page = 1
				this.initIndex()
			},
			handerTabChange(index) {
				this.activeIndex = index
				this.$util.showLoading()
				this.param.page = 1
				this.list.data = []
				this.getList()
			},
			async getList() {
				let {
					list: oldList,
					activeIndex,
					tabList,
					param
				} = this
				let {
					id
				} = tabList[activeIndex]
				param.status = id

				let newList = await this.$api.mine.walletList(param);
				if (this.param.page == 1) {
					this.list = newList
				} else {
					newList.data = oldList.data.concat(newList.data)
					this.list = newList
				}
				this.loading = false
				this.$util.hideAll()
			}
		}
	}
</script>


<style lang="scss">
	.record-header {
		width: 100%;
		height: 250rpx;

		.wallet-price {
			font-size: 70rpx;
		}
	}


	.record {
		width: 24rpx;
		height: 24rpx;
		display: block;
	}

	.record-tag {
		width: 152rpx;
		height: 32rpx;
		background: #eeeeee;
		font-size: 22rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #999999;
	}
</style>
