<template>
	<view class="wrap">
		<view class="block">
			<view class="title">编号{{ id }}</view>
			<view class="shop">
				<image v-if="item.shopLogo" class="icon logo" :src="item.shopLogo"></image>
				<image v-else class="icon" :src="Common.shopIcon"></image>
				
				{{ info.shopName }}
				<view class="status">{{ info.authentication }}</view>
			</view>
		</view>
		
		<view v-if="info.orderItemDtos.length" class="block">
			<view class="title">采购内容</view>
			<view class="content">
				<view v-for="(item, i) in info.orderItemDtos" :key="i" class="item">
					<view class="prod">
						<view class="name">{{ item.prodName}}</view>
						<view class="price">{{ item.price ? '￥' + item.price : '面议' }}</view>
					</view>
					<text class="count">{{ item.prodCount }}件</text>
				</view>
			</view>
		</view>
		
		<view v-if="info.remarks" class="block">
			<view class="title">客户留言</view>
			<view class="remarks">{{ info.remarks }}</view>
		</view>
		
		<view class="block">
			<view class="title">采购方信息</view>
			<view class="info">
				<view class="line">
					<text class="field">采购人</text>
					<text>{{ info.purchasingPerson }}</text>
				</view>
				<view class="line">
					<text class="field">联系方式</text>
					<text>{{ info.phone }}</text>
				</view>
				<view class="line">
					<text class="field">采购类型</text>
					<text>{{ info.orderType === 1 ? '个人' : '组织' }}</text>
				</view>
				<view v-if="info.orderType === 2" class="line">
					<text class="field">所属组织</text>
					<text>{{ info.shopName }}</text>
				</view>
				<view class="line">
					<text class="field">提交时间</text>
					<text>{{ info.createTime }}</text>
				</view>
				<view class="line">
					<text class="field">{{ info.orderType === 1 ? '个人是否已实名' : '是否已认证' }}</text>
					<text>{{ info.authentication }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { orderDetail } from '@/apis/modules/order.js'
	import Common from '@/config/common'
	export default {
		data() {
			return {
				Common,
				id: '',
				info: {
					orderItemDtos: [],
					authentication: '',
					shopLogo: '',
					shopName: '',
					purchasingPerson: '',
					phone: '',
					shopName: '',
					createTime: '',
					createTime: '',
				},
				mpStyle: {
					p: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;',
					span: 'font-size: 25rpx !important;font-family: Microsoft Yahei !important;font-weight: 400 !important;color: #333 !important;'
				}
			}
		},
		onShow() {
			const pages = getCurrentPages()
			const { options } = pages[pages.length - 1]
			this.id = options.id
			this.getInfo()
		},
		methods: {
			// 获取详情
			async getInfo() {
				uni.showLoading({
					title: '加载中'
				})
				const { data } = await orderDetail({
					orderNumber: this.id
				})
				this.info = data
				uni.hideLoading()
			},
		}
	}
</script>

<style scoped lang="scss">
.block {
	padding: 24rpx;
}
.title {
	margin-bottom: 20rpx;
	font-size: 30rpx;
	font-weight: 600;
	color: #333;
}
.shop {
	position: relative;
	display: flex;
	align-items: center;
	font-size: 28rpx;
	color: #333;
	.icon {
		width: 80rpx;
		min-width: 80rpx;
		height: 80rpx;
		margin-right: 20rpx;
		border-radius: 4px;
	}
	.logo {
		border-radius: 50%;
	}
	.status {
		position: absolute;
		bottom: 0;
		right: 0;
		padding: 8rpx 28rpx;
		font-size: 28rpx;
		color: #fff;
		background-color: $uni-primary;
		border-radius: 20px;
	}
}
.content {
	font-size: 28rpx;
	color: #333;
	.item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 10rpx;
		margin-bottom: 20rpx;
		&:last-child {
			margin-bottom: 0;
		}
	}
	.prod {
		max-width: 70%;
	}
	.name {
		margin-bottom: 10rpx;
		font-size: 26rpx;
		color: #333;
	}
	.price {
		font-size: 24rpx;
		color: #8c8c8c;
	}
	.count {
		font-size: 26rpx;
		color: #333;
	}
}
.remarks {
	font-size: 26rpx;
	color: #6d6d6d;
}
.info {
	font-size: 28rpx;
	color: #333;
	.line {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}
	.field {
		color: #717171;
	}
}
</style>
