<template>
	<div>
		<block v-if="!$util.isEmpty(list.data)">
			<t-table :headerBackgroundColor="'#F0F2F6'">
				<t-tr header>
					<t-th v-for="(item, index) in columns" :key="index" :align="item.align">
						{{ item.name }}
					</t-th>
				</t-tr>
				<t-tr v-for="(item, index) in list.data" :key="index">
					<t-td
						v-for="(column, colIndex) in columns"
						:key="colIndex"
						:align="column.align"
						:color="column.color"
					>
						<view>
							{{ item[column.dataIndex] || "" }}
						</view>
					</t-td>
				</t-tr>
			</t-table>
		</block>
		<block v-else>
			<AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
		</block>
    <kd-entrance></kd-entrance>
	</div>
</template>

<script>
import AppWrapperEmpty from "@/components/app-wrapper-empty";
import { withdrawCashList } from '@/api/store'
import list from '@/mixins/list'
export default {
	name: "withDraw", //提现记录
	components: {
		AppWrapperEmpty
	},
	mixins:[list],
	data() {
		return {
			columns: [
				{
					name: "提现时间",
					dataIndex: "updateTime",
					color: "info",
					align: "center"
				},
				{
					name: "提现金额",
					dataIndex: "amount",
					color: "info",
					align: "center"
				},
				{
					name: "状态",
					dataIndex: "statusText",
					color: "info",
					align: "center"
				}
			],
		};
	},
	methods: {
		async init(){
			 uni.showLoading({
                    title: '加载中'
                });
				try {
				const res = await withdrawCashList({
					page:this.list.page
				})
				res.data.list  = res.data.list.map(i=>({
					...i,
					statusText: i.status ==1?'待处理':i.status ==2?'已完成':'未知'				  
				}))
			   this.completes(res)
              } finally {
                 uni.hideLoading(); 
              }
		}
	},
	async onPullDownRefresh() {
		this.resetList();
		await this.init()
		uni.stopPullDownRefresh();
	},
	async onReachBottom() {
		if (!this.list.finished) {
			await this.init()
			uni.stopPullDownRefresh();;
		} else {
			uni.stopPullDownRefresh();
		}
	},
	
};
</script>

<style lang="scss" scoped></style>
