<template>
	<div class="app-content">
		<block v-if="!$util.isEmpty(list.data)">
			<div class="list-wrap" v-for="(item, index) in list.data" :key="index" @click="pageTo({
			url: '/pages/order/detail',
			query: {
				id: item.id
			}
		})">
				<div class="list-top flex-center-between">
					<div class="app-color-3">订单编号：{{ item.sendNum }}</div>
					<div class="app-price">{{ item.status | constantfilter('ORDER_STATUS') }}</div>
				</div>
				<div class="list-blo">
					<block v-if="!$util.isEmpty(item.goodsInfoList)">
						<list-module v-for="(items, subIndex) in item.goodsInfoList" :key="subIndex" :info="items" />
					</block>
				</div>
				<div class="list-bottom flex-center-between">
					<div>
						<span>应付金额：</span>
						<span class="app-size-30 app-bold">¥{{ item.actPrice }}</span>
					</div>
					<block v-if="item.status == 0">
						<button class="button-com red" @click.stop="pageTo({
						url: '/pages/callback/index',
						query: {
							pagestatus: 1,
							orderSn: item.orderSn,
							totalPrice: item.prePrice,
							couponId: item.couponId
						}
					})">立即付款</button>
					</block>
					<block v-if="item.status == 1">
						<button class="button-com red defalut" @click.stop="pageTo({
						url: '/pages/order/buy',
						query: {
							id: item.id
						}
					})">填写收花地址</button>
					</block>
					<block v-if="item.status == 5">
						<button class="button-com red defalut" @click.stop="pageTo({
						url: '/pages/order/comment',
						query: {
							id: item.id
						}
					})">评价</button>
					</block>
				</div>
			</div>
		</block>
		<block v-else>
			<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
		</block>
	</div>
</template>

<script>
import ListModule from '@/components/module/app-order-list'
import AppWrapperEmpty from '@/components/app-wrapper-empty'
import { list } from '@/mixins'
// api
import { getList } from '@/api/order'
export default {
	name: 'order-list',
	components: {
		ListModule,
		AppWrapperEmpty
	},
	mixins: [list],
	data() {
		return {}
	},
	onPullDownRefresh() {
		this.resetList()
		this._list().then(res => {
			uni.stopPullDownRefresh()
		})
	},
	// 加载更多
	onReachBottom() {
		if (this.list.moreData == 1) {
			this._list().then(res => {
				uni.stopPullDownRefresh()
			})
		} else {
			uni.stopPullDownRefresh()
		}
	},
	onLoad: function() {
		// this.init()
	},
	methods: {
		async init() {
			this._list()
		},
		_list() {
			return getList({ status: this.tabIndex }).then(res => {
				this.completes(res)
			})
		}
	}
}
</script>

<style lang="scss" scoped>
	.app-content {
		padding-top: 20px;
		padding-bottom: 1px;
		.list-wrap {
			padding: 0 30px;
			background-color: #fff;
			margin-bottom: 20px;
			.list-top,
			.list-bottom {
				padding: 20px 0;
				border-bottom: 1px solid $borderColor;
				.button-com {
					padding-top: 15px;
					padding-bottom: 15px;
				}
			}
		}
	}
</style>
