<template>
	<view class="orderDetail">
		<!-- 标题栏 -->
		<view class="nav">
			<view class="orderStatus" v-if="status == 2 && is_virtual == 0">待发货</view>
			<view class="orderStatus" v-if="status == 3 && is_virtual == 0">待收货</view>
			<view class="orderStatus" v-if="status == 3 && is_virtual == 1">待核销</view>
			<view class="orderStatus" v-if="status == 4 && is_virtual == 0">已完成</view>
			<view class="orderStatus" v-if="status == 4 && is_virtual == 1">已核销</view>
		</view>

		<view class="midBox">
			<!-- 物流信息 -->
			<view class="logistics" v-if="goodsDet.express_type == 1">
				<view class="logisticsTitle">物流信息</view>
				<view class="logisticsMsg"><text>快递公司</text><text
						style="margin-left: 26rpx;">{{goodsDet.express_company}}</text></view>
				<view class="logisticsMsg"><text>快递单号</text><text
						style="margin-left: 26rpx;">{{goodsDet.express_no}}</text>
				</view>
				<view class="copy" @click="copyOrder(goodsDet.express_no)">复制</view>
			</view>
			<!-- 配送信息 -->
			<view class="delivery">
				<view class="deliveryTitle">
					<text>配送信息</text>
				</view>
				<view class="deliveryMsg">
					<image class="bgimg" src="http://t9.9026.com/imgs/ordermap.png"></image>
					<!-- 联系信息 -->
					<view class="deliveryicon">
						<image src="/static/icon/phone.png"></image>
						<text>联系信息</text>
					</view>
					<view class="deliverytext">
						<text>{{goodsDet.receiver}}</text>
						<text style="margin-left: 24rpx;">{{goodsDet.phone}}</text>
					</view>

					<!-- 发货方式 -->
					<view class="deliveryicon">
						<image src="/static/icon/delivery.png"></image>
						<text>发货方式</text>
					</view>
					<view class="deliverytext">
						<text v-if="goodsDet.express_type ==1">快递发货</text>
						<text v-if="goodsDet.express_type ==2">到店自提/线下核销</text>
					</view>

					<!-- 收货地址 -->
					<view class="deliveryicon" v-if="goodsDet.express_type ==1">
						<image src="/static/icon/position.png"></image>
						<text>收货地址</text>
					</view>
					<view class="deliverytext" v-if="goodsDet.express_type ==1">
						<text>四川省 成都市 高新区 XXX小区 XXX号</text>
					</view>

					<!-- 门店地址 -->
					<view class="deliveryicon" v-if="goodsDet.express_type ==2">
						<image src="/static/icon/position.png"></image>
						<text>{{hotelDet.name}}</text>
					</view>
					<view class="deliverytext" v-if="goodsDet.express_type ==2" style="position:relative;">
						<text>{{hotelDet.address}}</text>
						<image src="/static/icon/navigation.png" @click="goLocaltion(hotelDet.name,hotelDet.address)"
							style="width: 50rpx;height: 48rpx; position: absolute; top: 0rpx;right: 30rpx;"></image>
					</view>

					<!-- 门店联系方式 -->
					<view class="deliveryicon" v-if="goodsDet.express_type ==2">
						<image src="/static/icon/phone.png"></image>
						<text>门店联系方式</text>
					</view>
					<view class="deliverytext" v-if="goodsDet.express_type ==2">
						<text>{{hotelDet.phone}}</text>
					</view>
				</view>
			</view>
			<!-- 订单信息 -->
			<view class="myorder">
				<view class="orderTitle">订单信息</view>
				<view class="orderMsg"><text>订单编号</text><text style="margin-left: 26rpx;">{{goodsDet.order_no}}</text>
				</view>
				<view class="orderMsg"><text>下单时间</text><text style="margin-left: 26rpx;">{{goodsDet.created_at}}</text>
				</view>
				<view class="copyorder" @click="copyOrder(goodsDet.order_no)">复制</view>
			</view>
		</view>

		<!-- 产品信息 -->
		<view class="shopMsg">
			<view class="title">
				<text>产品信息</text>
			</view>
			<view class="shopCard">
				<image :src="goodsDet.img_urls"></image>
				<view style="margin-left: 24rpx;">
					<text class="name">{{goodsDet.product_name}}</text>
					<!-- <text class="tag">礼盒装 2000积分</text> -->
				</view>
			</view>
			<view class="shopNumber">
				<text>件数</text>
				<text>1件</text>
			</view>
			<view class="shopNumber" v-if="false">
				<text>积分</text>
				<text>2000积分</text>
			</view>
			<view style="width: 694rpx;height: 4rpx;border: 2rpx solid #F2F2F2;margin-top: 38rpx;"></view>
			<view class="shopNumber" v-if="false">
				<text>合计</text>
				<text>2000积分</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//门店详情
				hotelDet: '',
				//订单详情
				goodsDet: '',
				//订单id
				order_id: '',
				//订单状态
				status: '',
				//实物:0虚拟奖品:1
				is_virtual: '',
			}
		},
		onLoad(o) {
			if (o.id) {
				//订单id
				this.order_id = o.id
				this.orderDeatil()
			}

		},

		methods: {
			//导航
			goLocaltion(name, address) {
				uni.openLocation({
					type: "gcj02",
					latitude: parseFloat(this.hotelDet.latitude), // 纬度，浮点数，范围为90 ~ -90
					longitude: parseFloat(this.hotelDet.longitude), // 经度，浮点数，范围为180 ~ -180。
					scale: 6, // 地图缩放级别,整形值,范围从1~28。默认为最大
					name: name, // 位置名
					address: address, // 地址详情说明
				})
			},

			//门店详情
			hotelDetail(id) {
				this.$api.hotel.getHotelDetail({
					hotel_id: id
				}).then(res => {
					this.hotelDet = res.data
				})
			},

			//订单详情
			orderDeatil() {
				this.$api.orders.getOrderDetail({
					order_id: this.order_id
				}).then(res => {
					this.is_virtual = res.data.is_virtual
					this.status = res.data.status
					this.goodsDet = res.data
					if (this.goodsDet.express_type == 2 && this.goodsDet.hotel_id) {
						this.hotelDetail(this.goodsDet.hotel_id)
					}

				})
			},
			// 复制订单号
			copyOrder(num) {
				uni.setClipboardData({
					data: `${num}`,
					success: function() {
						uni.showToast({
							icon: 'none',
							title: '复制成功'
						})
					}
				});
			}
		},
		computed: {

		}
	}
</script>

<style lang="scss" scoped>
	$pageColor:#F9F9F9;
	$bgColor:#FFFFFF;

	// flex布局居中对齐
	@mixin flexlayout {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.orderDetail {
		height: 100%;
		background: $pageColor;
	}

	.nav {
		width: 750rpx;
		height: 108rpx;
		background: $bgColor;
		border-radius: 0px 0px 16rpx 16rpx;
		padding: 32rpx 0 0 28rpx;
		box-sizing: border-box;

		.orderStatus {
			font-size: 40rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			color: #FF6200;
		}
	}

	.midBox {
		margin-top: 24rpx;
		width: 750rpx;
		background: $bgColor;
		border-radius: 16rpx;
		position: relative;
		padding: 40rpx 28rpx;
		box-sizing: border-box;


		.logistics {
			position: relative;

			.logisticsTitle {
				margin-bottom: 25rpx;
				font-size: 30rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #080F18;
			}

			.logisticsMsg {
				margin-bottom: 25rpx;

				text {
					font-size: 28rpx;
					font-family: PingFang-SC-Medium, PingFang-SC;
					font-weight: 500;
					color: #666666;
				}
			}

			.copy {
				position: absolute;
				right: 30rpx;
				top: 68rpx;
				font-size: 28rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #FF6200;
			}
		}

		.myorder {
			position: relative;

			.orderTitle {
				margin-bottom: 25rpx;
				font-size: 30rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #080F18;
			}

			.orderMsg {
				margin-bottom: 25rpx;

				text {
					font-size: 28rpx;
					font-family: PingFang-SC-Medium, PingFang-SC;
					font-weight: 500;
					color: #666666;
				}
			}

			.copyorder {
				position: absolute;
				right: 30rpx;
				bottom: 72rpx;
				font-size: 28rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #FF6200;
			}
		}

		.delivery {
			margin-bottom: 20rpx;

			.deliveryTitle {
				margin-bottom: 24rpx;

				text {
					font-size: 32rpx;
					font-family: PingFang-SC-Bold, PingFang-SC;
					font-weight: bold;
					color: #080F18;
				}
			}

			.deliveryMsg {
				width: 694rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				padding-top: 24rpx;
				position: relative;

				.bgimg {
					width: 100%;
					height: 100%;
					position: absolute;
					top: 0rpx;
				}

				.deliveryicon {
					margin-bottom: 15rpx;
					display: flex;
					align-items: center;
					z-index: 999;

					image {
						width: 26rpx;
						height: 26rpx;
						margin-right: 5rpx;
					}

					text {
						font-size: 28rpx;
						font-family: PingFang-SC-Medium, PingFang-SC;
						font-weight: 500;
						color: #333333;
					}
				}

				.deliverytext {
					margin-bottom: 20rpx;
					z-index: 999;

					text {
						font-size: 28rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #080F18;
					}
				}
			}
		}
	}

	.shopMsg {
		margin-top: 24rpx;
		width: 750rpx;
		height: 534rpx;
		background: $bgColor;
		border-radius: 12rpx 12rpx 0px 0px;
		padding: 32rpx 30rpx;
		box-sizing: border-box;

		.title {
			margin-bottom: 24rpx;

			text {
				font-size: 32rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #080F18;
			}
		}

		.shopCard {
			margin-top: 28rpx;
			width: 694rpx;
			height: 164rpx;
			background: #F4F5F6;
			border-radius: 10rpx;
			display: flex;
			align-items: center;

			image {
				width: 132rpx;
				height: 132rpx;
				margin-left: 16rpx;
				display: inline-block;
				border-radius: 10rpx;
			}

			.name {
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #080F18;
				display: block;
			}

			.tag {
				font-size: 24rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #666666;
			}
		}

		.shopNumber {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 25rpx;

			text {
				font-size: 26rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #000000;
			}
		}
	}
</style>
