<template>
	<view>
		<view class="cmain" v-for="(item,index) in list">
			<view class="box order_detail">
				<view class="item">
					<text class="label">收购商品</text>
					<text class="desc omit">{{ item.goodsName }}</text>
				</view>
				<view class="item">
					<text class="label">商品编号</text>
					<text class="desc">{{ item.goodsNo }}</text>
				</view>
				<view class="item">
					<text class="label">计价单位</text>
					<text class="desc">{{ item.goodsUnit }}</text>
				</view>
				<view class="item">
					<text class="label">发布商</text>
					<text class="desc">{{ item.createName }}</text>
				</view>
				<view class="item">
					<text class="label">发布时间</text>
					<text class="desc">{{ item.createTime }}</text>
				</view>
				<view class="item">
					<text class="label">接单人</text>
					<text class="desc">{{ user.name }}</text>
				</view>
			</view>
		</view>
		<view class="mfooter">
			<view class="flex">
				<view class="f">
					<button class="btn" @click="pay()">立即购买</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			user: this.getUser(),
			list: [],
			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 => {
					this.list = res.data.data;
				}
			});

		}
	},
	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.redirectTo({url:'/pages/market/two/leader/success'});
							}
						});
					}
				}
			});
		}
	}
};
</script>

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