<template>
	<view class="card_order_management">
		<view class="card_order frame" v-for="(item,index) in datalist" :key="index" v-if="datalist.length > 0">
			<view @click="goDetails(item)">
				<view class="space_between">
					<view class="item_headline" v-if="item.goods && item.spec">{{item.goods.name}}{{item.spec.name}}
					</view>
					<view v-if="item.state == 3 || item.state == 4">
						<view class="details_title" style="color: #5ac725;" v-if="item.state == 3">已送达</view>
						<view class="details_title" style="color: #f56c6c;" v-else-if="item.state == 4">已取消</view>
					</view>
				</view>
				<view class="item_num">×{{item.quantity}}</view>
				<view class="item_address">配送地址:{{item.address}}</view>
				<view class="item_address" v-if="item.state == 5">送气员电话:{{item.user.phone}}
					<u-icon color="#70B603" size="26" name="phone-fill"
						@click.native.stop="phone(item.user.phone)"></u-icon>
				</view>
				<view class="item_address">下单时间:{{item.orderTime}}</view>
				<view class="item_address" v-if="item.state == 3">送达时间:{{item.arriveTime}}</view>
			</view>
			<view class="card_delivery" v-if="item.state == 1 || item.state == 2">
				<view style="margin-right: 10rpx;flex: 1;">
					<u-button type="primary" @click="goSecurityCheck(item)">修改订单</u-button>
				</view>
				<view style="margin-left: 10rpx;flex: 1;">
					<u-button type="warning" @click="confirmedDelivery(item)">取消订单</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			datalist: {
				type: Array,
				default: []
			}
		},
		data() {
			return {
				orderId: null,
			}
		},
		methods: {
			goDetails(value) {
				uni.setStorageSync('detailsData', value);
				uni.navigateTo({
					url: '/pages/order/orderDetails'
				});
			},
			//修改订单
			goSecurityCheck(row) {
				this.$cache.setCache('orderList', row)
				uni.navigateTo({
					url: '/pages/order/booking?companyId=' + row.storeId + '&revamp=' + true
				});
			},
			// 取消订单
			confirmedDelivery(row) {
				this.orderId = row.id
				this.$emit('confirmedDelivery', this.orderId)
			},
			// 补全用户信息
			goCompletionTasks(row) {
				uni.navigateTo({
					url: '/pages/order/completionTasks?customerId=' + row.customerId
				});
			},
			phone(phone) {
				console.log(phone, 66)
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-modal__content__text {
		text-align: center;
	}

	.card_order_management {
		margin: 0rpx 20rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.card_order {
		width: calc(100% - 40rpx);
		margin-top: 20rpx;
		// border: 1rpx solid rgba(215, 215, 215, 1);
		border-radius: 8rpx;
		padding: 30rpx 20rpx 10rpx 20rpx;
	}

	// 伪元素1rpx边框
	.frame {
		position: relative; //重要
	}

	.frame::after {
		position: absolute;
		content: '';
		border: 2rpx solid #e7e6e4;
		border-radius: 16rpx;
		width: 200%;
		height: 200%;
		top: 0;
		left: 0;
		transform: scale(0.5);
		transform-origin: 0 0;
		pointer-events: none; /* 使伪元素不会阻止鼠标事件 */
	}

	.item_headline {
		font-size: 36rpx;
		font-weight: 800;
	}

	.item_num {
		margin: 20rpx 0rpx;
		font-size: 26rpx;
	}

	.details_title {
		font-size: 26rpx;
		font-weight: 500;
	}

	.item_address {
		display: flex;
		align-items: center;
		font-size: 26rpx;
		color: #7f7f7f;
		margin-bottom: 20rpx;
	}

	.card_delivery {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
	}
</style>