<template>
	<mobile-frame>
		<view class="main">
			<view class="zero">
				<scroll-view scroll-y="true" class="scroll-view">
					<view class="list-scroll-view">
						<view class="one">
							<view class="one_1">
								<text class="iconfont icon-dingweixiao"></text>
							</view>
							<view class="one_2">
								<view class="name">
									<text>{{info.address.name}}</text>
									<text>{{info.address.phone}}</text>
								</view>
								<view class="address">
									<text>{{info.address.province}}</text>
									<text>{{info.address.city}}</text>
									<text>{{info.address.area}}</text>
									<text>{{info.address.address}}</text>
								</view>
							</view>
						</view>
						<view class="two">
							<view class="two_0">
								<text>{{info.zhStatus||'未识别'}}</text>
							</view>
							<view class="two_1" v-if="info.status=='0'||is_order=='true'">
								<view class="list" v-for="(item,index) in info.goods" :key="index">
									<view class="list_1" v-if="item.is_set=='0'">
										<view class="r">
											<text class="set">套装</text> {{item.name}}
										</view>
									</view>
									<view class="list_1" v-else>
										<text class="iconfont icon-shangdian"></text>
										<text>{{item.shop_name}}</text>
									</view>
									<view class="list_2">
										<view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
											<view class="goods_1">
												<view class="url">
													<image class="image"
														:src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:tag.goods.goods.file[0].url"
														mode=""></image>
												</view>
												<view class="goodsname">
													{{tag.goods.name}}
													<view class="specs" v-if="item.is_set=='0'">
														{{tag.spec_name}}
													</view>
													<view class="specs" v-else>
														{{tag.name}}
													</view>
													<view class="other">
														<text v-if="tag.gift&&tag.gift.length>0" class="gift">赠品</text>
														<text v-if="tag.sp_price" class="act">特价</text>
													</view>
												</view>
												<view class="goodsother" v-if="item.is_set=='0'">
													<view class="price">{{tag.set_num}}件/套x{{tag.set_num}}</view>
												</view>
												<view class="goodsother" v-else>
													<view v-if="info.type=='0'" class="price">
														¥{{tag.price||tag.sell_money}}
													</view>
													<view v-else class="price">
														¥{{tag.group_config.money}}
													</view>
													<view class="num">
														×{{tag.buy_num}}
													</view>
												</view>
											</view>
											<view class="goods_2" v-if="tag.gift&&tag.gift.length>0">赠品</view>
											<view class="goods_3" v-if="tag.gift&&tag.gift.length>0"	v-for="(tags,indexx) in tag.gift" :key="indexx">
												<view class="left">
													<view class="name">
														{{tags.goods_name}}
													</view>
													<view class="Spec">
														规格:{{tags.spec_name}}
													</view>
													<view class="Spec">
														说明:{{tags.desc}}
													</view>
												</view>
												<view class="right" v-if="item.is_set=='0'">
													<view class="price">{{tags.set_num}}件/套x{{tags.set_num}}</view>
												</view>
												<view class="right" v-else>
													<view class="price">
														¥{{tags.money||0}}
													</view>
													<view class="num">
														×{{tags.num}}
													</view>
												</view>
											</view>
										</view>
									</view>
									<view class="list_3" v-if="item.is_set=='0'">
										<view class="list_3_1">单价：￥{{item.sell_money}}</view>
										<view class="list_3_2">数量：×{{item.buy_num}}</view>
									</view>
								</view>
							</view>
							<view class="two_2" v-else>
								<view class="list_1">
									<text class="iconfont icon-shangdian"></text>
									<text>{{info.shop.name}}</text>
								</view>
								<view class="list_2">
									<view class="goods" v-for="(item,index) in info.goods" :key="index">
										<view class="set_name" v-if="item.is_set=='0'">
											<view class="r">
												<text class="set">套装</text> {{item.name||'暂无'}}
											</view>
										</view>
										<view v-if="item.is_set=='0'">
											<view class="goods_1" v-for="(tag,indexc) in item.goods" :key="indexc">
												<view class="url">
													<image class="image"
														:src="tag.file&&tag.file.length>0?tag.file[0].url:tag.goods.file[0].url"
														mode="">
													</image>
												</view>
												<view class="goodsname">
													{{tag.goods.name}}
													<view class="specs">
														{{tag.spec_name}}
													</view>
												</view>
												<view class="goodsother">
													<view class="price">{{tag.set_num}}件/套x{{tag.set_num}}
													</view>
												</view>
											</view>
										</view>
										<view class="goods_1" v-else>
											<view class="url">
												<image class="image"
													:src="item.file&&item.file.length>0?item.file[0].url:item.goods.file[0].url"
													mode="">
												</image>
											</view>
											<view class="goodsname">
												{{item.goods.name}}
												<view class="specs">
													{{item.name}}
												</view>
												<view class="other">
													<text v-if="item.gift&&item.gift.length>0" class="gift">赠品</text>
													<text v-if="item.sp_price" class="act">特价</text>
												</view>
											</view>
											<view class="goodsother">
												<view v-if="info.type=='0'" class="price">
													¥{{item.price||item.sell_money}}
												</view>
												<view v-else class="price">
													¥{{item.group_config.money}}
												</view>
												<view class="num">
													×{{item.buy_num}}
												</view>
											</view>
										</view>
										<view class="goods_2" v-if="item.gift&&item.gift.length>0">赠品</view>
										<view class="goods_3" v-if="item.gift&&item.gift.length>0"
											v-for="(tag,indexx) in item.gift" :key="indexx">
											<view class="left">
												<view class="name">
													{{tag.goods_name}}
												</view>
												<view class="Spec">
													规格:{{tag.spec_name}}
												</view>
												<view class="Spec">
													说明:{{tag.desc}}
												</view>
											</view>
											<view class="right">
												<view class="price">
													¥{{tag.money||0}}
												</view>
												<view class="num">
													×{{tag.num}}
												</view>
											</view>
										</view>
										<view class="goods_4" v-if="item.is_set=='0'">
											<view class="goods_4_1">单价：￥{{item.sell_money}}</view>
											<view class="goods_4_2">数量：×{{item.buy_num}}</view>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="thr">
							<view class="thr_1" v-for="(item,index) in info.total_detail" :key="index">
								<text>{{item.zh}}</text>
								<text>¥{{item.money}}</text>
							</view>
							<view class="thr_1">
								<text>实付金额</text>
								<text>¥{{info.goods_total}}</text>
							</view>
						</view>
						<view class="four">
							<view class="four_1">
								<text>订单号</text>
								<text>{{info.no}}</text>
							</view>
							<view class="four_1">
								<text>订单状态</text>
								<text>{{info.zhStatus||'未识别'}}</text>
							</view>
							<view class="four_1">
								<text>下单时间</text>
								<text>{{info.buy_time}}</text>
							</view>
							<view class="four_1">
								<text>订单备注</text>
								<text>{{info.remarks}}</text>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<view class="zero_1">
				<text>合计:</text>
				<text>¥{{info.goods_total}}</text>
			</view>
		</view>
	</mobile-frame>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				status: '',
				is_order: false,
				info: {},
				// 售后状态
				statusList: [],
			};
		},
		onLoad: async function(e) {
			const that = this;
			that.$set(that, `id`, e.id);
			that.$set(that, `status`, e.status);
			that.$set(that, `is_order`, e.is_order);
			await that.searchOther();
			await that.search()
		},
		onShow: function() {},
		methods: {
			// 查询详情
			async search() {
				uni.showLoading({
					title: '加载中'
				});
				const that = this;
				let res;
				// 待付款
				if (that.id) {
					if (that.is_order) {
						if (JSON.parse(that.is_order)) {
							res = await that.$api(`/order/${that.id}`);
						} else {
							res = await that.$api(`/orderDetail/${that.id}`);
						}
					} else {
						if (that.status == '0') {
							res = await that.$api(`/order/${that.id}`);
						} else {
							res = await that.$api(`/orderDetail/${that.id}`);
						}
					}
					if (res.errcode == '0') {
						let status = that.statusList.find(i => i.value == res.data.status)
						if (status) res.data.zhStatus = status.label;
						// 运费总数和商品总数相加
						let total = 0;
						for (let val of res.data?.total_detail) total = this.$plus(total, val.money)
						res.data.goods_total = total
						that.$set(that, `info`, res.data);
						uni.hideLoading();
					}
				}
			},
			// 查询其他信息
			async searchOther() {
				const that = this;
				let res;
				// 查询状态
				res = await that.$api(`/dictData`, 'GET', {
					code: 'order_process'
				})
				if (res.errcode == '0') that.$set(that, `statusList`, res.data);
			},
		}
	}
</script>

<style lang="scss">
	.main {
		display: flex;
		flex-direction: column;
		width: 100vw;
		height: 100vh;
		background-color: #f5f5f5;

		.zero {
			position: relative;
			flex-grow: 1;

			.one {
				background-color: #fff;
				margin: 0 0 2vw 0;
				display: flex;
				justify-content: space-between;
				padding: 2vw;
				border-bottom: 2px dashed var(--fFB1Color);

				.one_1 {
					width: 8vw;
					text-align: center;
					padding: 3vw 0 0;
				}

				.one_2 {
					width: 86vw;

					.name {
						font-size: 16px;
						margin: 0 0 1vw 0;

						text {
							padding: 0 0 0 2vw;
						}
					}

					.address {
						font-size: 14px;
						color: #858585;

						text {
							padding: 0 0 0 2vw;
						}
					}
				}
			}

			.two {
				background-color: #fff;
				margin: 0 0 2vw 0;
				padding: 2vw;

				.two_0 {
					text-align: right;
					color: var(--fFB1Color);
				}

				.two_1 {
					display: flex;
					flex-direction: column;

					.list {
						margin: 0 0 1vw 0;

						.list_1 {
							font-size: 16px;
							margin: 0 0 1vw 0;

							text:last-child {
								padding: 0 0 0 2vw;
							}

							.r {
								.set {
									margin: 0 1vw 0 0;
									font-size: 12px;
									border-radius: 5px;
									padding: 0 1vw;
									color: #ffffff;
									background-color: #FF6347;
									border: 1px solid #FFA500;
								}
							}
						}

						.list_2 {
							display: flex;
							flex-direction: column;

							.goods {
								border-bottom: 1px dashed #f1f1f1;
								padding: 2vw 0;

								.goods_1 {
									display: flex;

									.url {
										width: 20vw;

										.image {
											width: 100%;
											height: 20vw;
											border-radius: 5px;

										}
									}

									.goodsname {
										display: flex;
										flex-direction: column;
										width: 60vw;
										padding: 0 2vw;
										font-size: 16px;

										.specs {
											color: var(--f85Color);
											font-size: var(--font12Size);
										}

										.other {
											display: flex;
											padding: 1vw 0 0 0;

											.gift {
												margin: 0 1vw 0 0;
												font-size: 12px;
												color: #FFA500;
												border: 1px solid #FFA500;
												border-radius: 5px;
												padding: 0 1vw;
											}

											.act {
												font-size: 12px;
												border: 1px solid var(--fFB1Color);
												color: var(--fFB1Color);
												border-radius: 5px;
												padding: 0 1vw;
											}
										}
									}

									.goodsother {
										width: 15vw;
										text-align: right;
									}
								}

								.goods_2 {
									padding: 0 1vw 1vw 0;
									font-size: var(--font14Size);
								}

								.goods_3 {
									display: flex;
									justify-content: space-between;
									border: 1px solid var(--fcColor);
									border-radius: 5px;
									margin: 0 0 1vw 0;
									padding: 1vw;

									.left {
										.name {
											font-size: 14px;
										}

										.Spec {
											font-size: var(--font12Size);
											color: var(--f85Color);
										}
									}
								}
							}
						}

						.list_3 {
							display: flex;
							justify-content: space-between;
							margin: 0 0 2vw 0;
							padding: 2vw 0;

							.list_3_1 {
								font-size: var(--font16Size);
								color: var(--f85Color);
							}

							text {
								padding: 0 1vw 0 0;
								font-size: var(--font20Szie);
							}
						}
					}
				}

				.two_2 {
					.list_1 {
						font-size: 16px;
						margin: 0 0 1vw 0;

						text:last-child {
							padding: 0 0 0 2vw;
						}
					}

					.list_2 {
						display: flex;
						flex-direction: column;

						.goods {
							border-bottom: 1px dashed #f1f1f1;
							padding: 2vw 0;

							.set_name {
								padding: 2vw;

								.r {
									.set {
										margin: 0 1vw 0 0;
										font-size: 12px;
										border-radius: 5px;
										padding: 0 1vw;
										color: #ffffff;
										background-color: #FF6347;
										border: 1px solid #FFA500;
									}
								}
							}

							.goods_1 {
								display: flex;

								.url {
									width: 20vw;

									.image {
										width: 100%;
										height: 20vw;
										border-radius: 5px;

									}
								}

								.goodsname {
									display: flex;
									flex-direction: column;
									width: 60vw;
									padding: 0 2vw;
									font-size: 16px;

									.specs {
										color: var(--f85Color);
										font-size: var(--font12Size);
									}

									.other {
										display: flex;
										padding: 1vw 0 0 0;

										.gift {
											margin: 0 1vw 0 0;
											font-size: 12px;
											color: #FFA500;
											border: 1px solid #FFA500;
											border-radius: 5px;
											padding: 0 1vw;
										}

										.act {
											font-size: 12px;
											border: 1px solid var(--fFB1Color);
											color: var(--fFB1Color);
											border-radius: 5px;
											padding: 0 1vw;
										}
									}
								}

								.goodsother {
									width: 15vw;
									text-align: right;
								}
							}

							.goods_2 {
								padding: 0 1vw 1vw 0;
								font-size: var(--font14Size);
							}

							.goods_3 {
								display: flex;
								justify-content: space-between;
								border: 1px solid var(--fcColor);
								border-radius: 5px;
								margin: 0 0 1vw 0;
								padding: 1vw;

								.left {
									.name {
										font-size: 14px;
									}

									.Spec {
										font-size: var(--font12Size);
										color: var(--f85Color);
									}
								}
							}

							.goods_4 {
								display: flex;
								justify-content: space-between;
								margin: 0 0 2vw 0;
								padding: 2vw 0;

								.goods_4_1 {
									font-size: var(--font16Size);
									color: var(--f85Color);
								}

								text {
									padding: 0 1vw 0 0;
									font-size: var(--font20Szie);
								}
							}
						}
					}
				}
			}

			.thr {
				background-color: #fff;
				margin: 0 0 2vw 0;
				padding: 0 2vw;

				.thr_1 {
					margin: 2vw 0;
					font-size: 15px;
					display: flex;
					justify-content: space-between;
				}

				.thr_1:last-child {
					text:last-child {
						color: var(--fFB1Color);
					}
				}
			}

			.four {
				background-color: #fff;
				margin: 0 0 2vw 0;
				padding: 0 2vw;

				.four_1 {
					margin: 2vw 0;
					font-size: 15px;
					display: flex;
					justify-content: space-between;
				}
			}
		}

		.zero_1 {
			background-color: white;
			width: 96vw;
			padding: 4vw 2vw;
			font-size: 16px;

			text:last-child {
				color: var(--fFB1Color);
				padding: 0 0 0 2vw;
			}
		}
	}

	.scroll-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;

		.list-scroll-view {
			display: flex;
			flex-direction: column;
		}
	}
</style>
