<template>
	<view>
		<view v-if="notesList == ''" class="mart60 fotct font14 fcor666">
			<image mode="widthFix" style="width: 70vw;" src="../../../static/img/noorder.png"></image>
		</view>
		<view class="height90 width94 backcorfff mart20" v-for="(item,index) in notesList" :key="index">
			<view class="font24 fcor333 paddtop10 padleft15">¥ <text
					class="font306adb fontwig6 margle font28">{{item.tradeAmount}}</text>
				<text class="stus font15 fcoreb5"
					v-if="item.status == 1 || item.status == 5 || item.status == 4 || item.status == 6">{{statusList[item.status]}}</text>
				<text class="stus font15 fcor41c"
					v-if="item.status == 2 || item.status == 3">{{statusList[item.status]}}</text>
			</view>
			<view class="mart10 fcor666  padleft15 font15">{{item.createTime | timeFormat('yyyy-mm-dd')}}
				{{item.createTime | timeFormat('hh:mm')}}
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getTradeOrderList
	} from '../../../Utils/Api.js';
	export default {
		data() {
			return {
				notesList: [],
				statusList: {
					1: "待支付",
					2: "支付中",
					3: "支付成功",
					4: "支付失败",
					5: "已取消",
					6: "已退款"
				},
				pageNum: 1,
				pageSize: 10,
				isNoMoreData: false, //是否加载中
			}
		},
		onLoad() {
			this.getTradeOrderList();
		},
		onReachBottom() {
			this.getTradeOrderList();
		},
		methods: {
			getTradeOrderList() {
				uni.showLoading({
					title: '加载中...'
				})
				if (this.isNoMoreData) {
					uni.hideLoading()
					return false;
				}
				let pagenum = this.pageNum;
				let datas = {
					pageNum: pagenum,
					pageSize: this.pageSize
				}

				getTradeOrderList(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data.pageInfo.list) {
						this.isNoMoreData = res.return_data.pageInfo.list.length == this.pageSize ? false : true;
						this.notesList = this.notesList.concat(res.return_data.pageInfo.list);
						if (res.return_data.pageInfo.total == (this.pageNum * this.pageSize)) {
							this.isNoMoreData = true;
						}
						this.pageNum = res.return_data.pageInfo.list.length == this.pageSize ? ++pagenum : pagenum;
					} else {
						this.notesList = [];
						uni.showToast({
							title: res.return_msg,
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f9f9;
	}

	.font306adb {
		color: #306adb;
	}

	.stus {
		float: right;
		margin-right: 20px;
	}
</style>
