<template>
	<view>
		<view class="cmain">
			<view class="box" style="padding: 12px; margin-top: 0px">
				<u-steps :current="0">
					<u-steps-item title="接单确认"></u-steps-item>
					<u-steps-item title="收购商确认"></u-steps-item>
					<u-steps-item title="完成交易"></u-steps-item>
				</u-steps>
			</view>
			<u-divider text="需求信息"></u-divider>
			<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.goodsQuantity }}</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">待接单</text>
				</view>
				<view class="item">
					<text class="label">接单人</text>
					<text class="desc">{{ user.name }}</text>
				</view>
				<view class="item">
					<text class="label">出价金额（必填）</text>
					<text class="desc">
						<input type="number" v-model="order.price" placeholder="请输入(元)" />
					</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(),
			item: {},
			order: {}
		};
	},
	onLoad(e) {
		if (e.item) {
			this.item = JSON.parse(e.item);
			this.order.purchaserId = this.item.purchaserId;
			this.order.goodsDemandId = this.item.id;
		}
	},
	methods: {
		pay() {
			let rule = [{ name: 'price', checkType: 'notnull', errorMsg: '请输入报价' }];
			if (!this.verify.check(this.order, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			uni.showModal({
				title: '提示',
				content: '我已核对接单信息无误',
				success: res => {
					if (res.confirm) {
						this.http.request({
							url: '/level-two-server/app/TbDemandQuotation/quotation',
							method: 'POST',
							data: this.order,
							success: res => {
								uni.navigateTo({ url: '/pages/market/two/leader/success' });
							}
						});
					}
				}
			});
		}
	}
};
</script>

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