<template>
	<view class="content">
		<view class="header">
			<view class="qiehuan">
				<view @click="getlist(i+1)" v-for="(v,i) in arr" :key="i">
					<view :class="show==i+1?'xzs':'wzs'">{{v}}</view>
					<view class="qiehuan_line" v-if="show==i+1"></view>
				</view>
			</view>
		</view>
		<!-- 内容 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<view class="xuyuan" v-for="(v,i) in listData" :key='i' v-if="listData.length>0">
				<view class="xuyuan_head">
					<view>订单号：<text style="font-size: 28rpx;">{{v.order_no}}</text></view>
					<view style="color: #1FF7F0;" v-if="v.status==1">待发货</view>
					<view style="color: #1FF7F0;" v-if="v.status==2">待收货</view>
					<view v-if="v.status==3">已完成</view>
				</view>
				<view class="xuyuan_item">
					<view class="shop_item_img">
						<image :src="v.goods_info.goods_image"></image>
					</view>
					<view class="xuyuan_item_2">
						<view class="hang2">{{v.goods_info.goods_name}}</view>
						<view> 规格：{{v.goods_info.goods_spec}} </view>
						<view>
							<text>￥{{v.goods_info.goods_seckill_price}}</text>
							<view>×{{v.goods_info.goods_num}}</view>
						</view>
					</view>
				</view>
				<view class="shifu">
					<view>共 <text style="font-size: 28rpx;margin: 0 6rpx;"> {{v.goods_info.goods_num}}</text> 件</view>
					<view>实付款：￥<text style="font-size: 36rpx;">{{v.pay_price}}</text></view>
				</view>

				<view class="xuyuan_foot">
					<view class="qrsh" style="margin-right: 0;" v-if="v.status==1"
						@click="gotoPage('/pages/shop/order_detail?order_id=' + v.id)">查看详情
					</view>
					<template v-if="v.status==2">
						<view class="qrsh" @click="gotoPage('/pages/shop/order_detail?order_id=' + v.id)">查看详情</view>
						<view class="qrsh" @click="gotoPage('/pages/shop/wuliu_detail?order_id=' + v.id)">查看物流</view>
						<view class="ckwl" @click="quren(v.id)">确认收货</view>
					</template>

					<view class="detail_gray" v-if="v.status==3"
						@click="gotoPage('/pages/shop/order_detail?order_id=' + v.id)">查看详情</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr: ['待发货', '已发货', '已完成'],
				show: 1,

				downOption: {
					auto: false
				},

				listData: []
			}
		},
		onLoad(e) {

		},
		methods: {
			quren(e) {
				let that = this;
				that.req({
					url: 'seckill_order_confirm',
					data: {
						id: e
					},
					success(res) {
						if (res.status == 1) {
							uni.showToast({
								title: res.msg,
								icon: 'success',
								duration: 1500,
								success() {
									setTimeout(() => {
										that.loadData(1)
									}, 1000)
								}
							})
						}
					}
				})
			},


			getlist(v) {
				this.show = v;
				this.listData = []
				this.mescroll.resetUpScroll()
			},

			/*下拉刷新的回调 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'seckill_order_list',
					Loading: true,
					data: {
						page: pageNo,
						status: that.show
					},
					success(res) {
						if (res.status == 1) {
							that.mescroll.endByPage(res.data.data.length, res.data.last_page);
							if (pageNo == 1) {
								that.listData = res.data.data;
							} else {
								that.listData = that.listData.concat(res.data.data);
							}
						}


					}
				})
			},


		}
	}
</script>

<style>
	.detail_gray {
		background: #FFFFFF;
		border: 2rpx solid #E5E5E5;
	}

	.ckwl {
		background: #FFFFFF;
		border: 2rpx solid #E5E5E5;
	}

	.qrsh {
		background: #1FF7F0;
		color: #FFFFFF;
		margin-right: 20rpx;
	}

	.xuyuan_foot>view {
		width: 199rpx;
		height: 64rpx;
		border-radius: 32rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
	}

	.xuyuan_foot {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		padding: 30rpx;
		font-size: 24rpx;
	}

	.shifu>view:nth-of-type(1) {
		font-size: 24rpx;
	}

	.shifu {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 30rpx 0;
		font-size: 28rpx;
	}

	.xuyuan_item_2 text {
		font-size: 28rpx;
	}

	.xuyuan_item_2>view:nth-of-type(3) {
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
		font-size: 20rpx;
	}

	.xuyuan_item_2>view:nth-of-type(2) {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.6);
	}

	.xuyuan_item_2 {
		color: #FFFFFF;
		font-size: 28rpx;
		width: 440rpx;
		/* border: 1rpx solid red; */
		margin-top: 10rpx;
		margin-left: 20rpx;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
	}


	.shop_item_img>image {
		width: 170rpx;
		height: 170rpx;
		border-radius: 10rpx;
	}

	.shop_item_img {
		width: 170rpx;
		height: 170rpx;
		border-radius: 10rpx;
		position: relative;
		text-align: left;
		box-sizing: border-box;

	}

	.xuyuan_item {
		display: flex;
		margin: 14rpx auto 0;
		width: 630rpx;
		box-sizing: border-box;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #cccccc;
	}


	.xuyuan_head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
		color: #FFFFFF;
		font-weight: 500;
	}

	.xuyuan {
		width: 690rpx;
		box-shadow: 0px 0rpx 10rpx 0px #1FF7F0;
		border-radius: 24rpx;
		margin: 24rpx auto 0;
		padding-top: 24rpx;
		box-sizing: border-box;
	}

	.qiehuan {
		display: flex;
		justify-content: space-between;
		/* align-items: center; */
		color: #FFFFFF;
		width: 440rpx;
	}

	.qiehuan_line {
		margin: 10rpx auto;
		width: 60rpx;
		height: 4rpx;
		background: #1FF7F0;
	}

	.qiehuan>view {
		flex: 1;
		text-align: center;
	}

	.wzs {
		font-size: 32rpx;
		color: #FFFFFF;
		/* margin-bottom: 10rpx; */
	}

	.xzs {
		font-size: 32rpx;
		color: #1FF7F0;
		font-weight: bold;
		/* margin-bottom: 10rpx; */
	}


	.header {
		width: 750rpx;
		height: 88rpx;
		background: #000000;
		font-size: 28rpx;
		color: #333333;
		padding: 10rpx 30rpx 0;
		box-sizing: border-box;
		position: fixed;
		/* #ifdef MP */
		top: 0;
		/* #endif */
		/* #ifndef MP */
		top: 88rpx;
		/* #endif */
		z-index: 15;
	}

	.content {
		width: 100vw;
		min-height: 100vh;
		padding-top: 88rpx;
		background: #000000;
		box-sizing: border-box;
	}
</style>
