<template>
	<view class="order-ul">
		<view class="order-li" v-for="(item, index) in order_list" :key="index" @click="changeData(item)">
			<view class="customer ellipsis">{{ item.customerName }}</view>
			<view class="list-other">
				<view class="other-li clearfix">
					<text class="float_left">{{ item.no }}</text>
					<text class="float_right price">{{ $utils.formattedNumber(item.payAmount) }}</text>
				</view>
				<view class="other-li">{{ $u.timeFormat(item.createTime) }}</view>
				<view class="other-li clearfix">
					<text class="float_left">{{ item.receiveData.realName }}</text>
					<view class="float_right mobile" @click="callPhone(item.receiveData.mobile || '')"><u-icon size="38" name="dianhua" custom-prefix="custom-icon"></u-icon></view>
				</view>
			</view>
		</view>
		<u-loadmore v-if="order_list.length" :status="load_status" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			load_status: 'nomore',
			page: 1,
			pageSize: 10,
			total: 0,
			order_list: []
		};
	},
	onLoad() {
		this.getAllOrder();
	},
	onPullDownRefresh() {
		this.page = 1;
		this.getAllOrder();
	},
	// 上拉加载
	onReachBottom() {
		if (this.total / this.pageSize > this.page) {
			this.page += 1;
			this.getAllOrder();
		}
	},
	methods: {
		changeData(item) {
			// 选择返回上一页
			this._prePage().orderData = item;
			uni.navigateBack();
		},
		getAllOrder() {
			this.load_status = 'loading';
			//  获取订单
			this.$u.api
				.getAllOrder({
					page: this.page,
					pageSize: this.pageSize,
					orderStatus: 5,
					returnStatus: [0, 1],
					outStatus: 5,
					search: { orderType: [1, 23, 24] }
				})
				.then(res => {
					uni.stopPullDownRefresh();
					if (this.page === 1) {
						this.order_list = res.data;
					} else {
						this.order_list = this.order_list.concat(res.data);
					}
					this.total = res.pageTotal;
					this.load_status = this.$utils.loadStatus(this.page,this.pageSize,this.total);
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.order-ul {
	.order-li {
		width: 710rpx;
		background: #ffffff;
		margin: 20rpx auto;
		border-radius: 16rpx;
		padding: 0 24rpx;
		.customer {
			font-weight: bold;
			line-height: 80rpx;
			border-bottom: 1px solid #eeeeee;
		}
		.list-other {
			padding: 24rpx 0 14rpx;
			.other-li {
				font-size: 26rpx;
				padding-bottom: 10rpx;
				.mobile {
					color: $uni-color-primary;
				}
				.price {
					color: $uni-color-error;
					font-weight: bold;
					font-size: 28rpx;
				}
			}
		}
	}
}
</style>
