<template>
	<view>
		<view class="product_detail">
			<image src="../../../static/news.jpg" mode="widthFix" class="pic"></image>
			<view class="box">
				<view class="title">{{ item.goodsName }}</view>
				<view class="clear"></view>
				<u-divider text="规格参数"></u-divider>
				<view class="item">
					<text class="desc">商品编号：</text>
					<text>{{ item.goodsNo }}</text>
					<view class="clear"></view>
				</view>
				<view class="item">
					<text class="desc">计量单位：</text>
					<text>{{ item.goodsUnit }}</text>
					<view class="clear"></view>
				</view>
				<view class="item">
					<text class="desc">发布商：</text>
					<text>{{ item.createName }}</text>
				</view>
				<view class="item">
					<text class="desc">互市区：</text>
					<text>{{ item.tradeAreaName }}</text>
					<view class="clear"></view>
				</view>
				<view class="item">
					<text class="desc">发布时间：</text>
					<text>{{ item.createTime }}</text>
					<view class="clear"></view>
				</view>
			</view>
		</view>
		<view class="mfooter">
			<view class="flex">
				<view class="f">
					<button class="btn" v-if="user.userType == 3" @click="pay()">立即购买</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			user: this.getUser(),
			item: {},
			orderIds: ''
		};
	},
	onLoad(e) {
		if (e.orderId) {
			this.orderIds = e.orderId;
			this.http.request({
				url: '/level-two-server/app/TbOrders/getDetailById',
				method: 'POST',
				data: { ids: this.orderIds},
				success: res => {
					let data = res.data.data;
					this.item = data[0];
				}
			});
		}
	},
	methods: {
		pay() {
			uni.showModal({
				title: '提示',
				content: '我已核对订单信息无误',
				success: res => {
					if (res.confirm) {
						this.http.request({
							url: '/level-two-server/app/TbOrders/purchaserBuy',
							method: 'POST',
							data: { ids: this.orderIds},
							success: res => {
								uni.navigateTo({ url: '/pages/market/two/leader/success' });
							}
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
</style>
