<template>
	<view>
		<view class="bg-white p-3 rounded-lg mt-2 mx-2" v-for="(item,index) in resdata" :key="index">
			<view class="flex align-center justify-between pb-3 border-bottom">
				<view class="text-muted font28">{{item.create_time}}</view>
				<view class="text-danger font28" v-if="item.status == 0">已取消</view>
				<view class="text-danger font28" v-else-if="item.status <= 2">待支付</view>
				<view class="text-danger font28" v-else-if="item.status == 3">待验证</view>
				<view class="text-danger font28" v-else-if="item.status == 4">待发货</view>
				<view class="text-danger font28" v-else-if="item.status == 5">待收货</view>
				<view class="text-danger font28" v-else-if="item.status == 6">已收货</view>
			</view>
			<!-- 单个产品 -->
			<view class="py-3 flex align-start" @click="toShow(gitem)" v-for="(gitem, gindex) in item.items" :key="gindex">
				<image :src="gitem.gcover" style="width: 150rpx;height: 150rpx;" class="flex-shrink mr-2 rounded"></image>
				<view class="flex-1">
					<view class="text-ellipsis-1 font32">{{gitem.gname}}</view>
					<view class="flex align-center justify-between mt-2 ">
						<view class="text-danger">
							<text class="cny_jf">{{gitem.total_price_cost}}</text>
						</view>
						<view class="flex align-center justify-end font28">
							<text class="text-muted">数量：</text>
							<text>{{gitem.stock_sales}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 多个产品 -->
			<!-- <view class="flex align-center py-3" v-else @click="toShow(item)">
				<image src="/static/pro1.jpg" style="width: 150rpx;height: 150rpx;" class="flex-shrink mr-2 rounded"></image>
				<image src="/static/pro1.jpg" style="width: 150rpx;height: 150rpx;" class="flex-shrink mr-2 rounded"></image>
				<image src="/static/pro1.jpg" style="width: 150rpx;height: 150rpx;" class="flex-shrink mr-2 rounded"></image>
			</view> -->
			
			<view class="flex align-center justify-end pb-3 border-bottom">
				<view class="flex align-center font30 mr-2">
					<text class="text-muted">共</text>
					<text class="mx-1">{{item.number_goods}}</text>
					<text class="text-muted">件商品</text>
				</view>
				<view class="flex align-center font28">
					<text class="text-muted">总消耗</text>
					<text class="ml-1 cny_jf text-danger">{{item.amount_total}}</text>
				</view>
			</view>
			<view class="flex align-center justify-end pt-3">
				<view class="bg-light text-muted font28 px-3 py-2 rounded-circle ml-2" v-if="item.status > 0 && item.status <= 2" @click="doCancel(item)">取消</view>
				<view class="bg-danger text-white font28 px-4 py-2 rounded-circle ml-2" v-if="item.status == 5" @click="doConfirm(item)">确认收货</view>
				<view class="bg-success text-white font28 px-4 py-2 rounded-circle ml-2" v-if="item.status > 0 && item.status <= 2" @click="toPay(item)">支付</view>
			</view>
		</view>
	</view>
</template>

<script>
import { TaAjax } from '../../common/ajax';

	export default {
		name:"i-order-list",
		props:{
			resdata:{
				type:Array,
				default() {
				  return [];
				},
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			toShow(item){
				uni.navigateTo({
					url:'/pages/order/orderDetail'
				})
			},
			toPay(item){
				uni.navigateTo({
					url:'/pages/points-mall/buy?order_no='+item.order_no
				})
			},
			doConfirm(item) {
				uni.showModal({
					title: '提示',
					content: '确定收货吗？',
					success: (res) => {
						if (res.confirm) {
							this.$emit("confirm", item.order_no)
						}
					},
				})
			},
			doCancel(item) {
				uni.showModal({
					title: '提示',
					content: '确定取消订单吗？',
					success: (res) => {
						if (res.confirm) {
							this.$emit("cancel", item.order_no)
						}
					},
				})
			}
		}
	}
</script>

<style>

</style>