<template>
	<view>
		<view class="cmain">
			<view class="box order_detail" style="padding: 13px">
				<u-steps :current="current">
					<u-steps-item title="订单确认"></u-steps-item>
					<u-steps-item title="互助委托确认"></u-steps-item>
					<u-steps-item title="进口申报确认"></u-steps-item>
				</u-steps>
			</view>
			<view class="box order_detail">
				<view v-if="current == 0">
					<view class="item ctt">订单确认</view>
				</view>
				<view v-if="current == 1">
					<view class="item ctt">互助委托书</view>
					<view class="item desc">边民 {{ item.buyUserName }}(身份证号:4509231***12)委托代理边民互市(进口/入境)商品交易(进口/入境)商品交易信息如下:</view>
				</view>
				<view v-if="current == 2">
					<view class="item ctt">进口申报确认</view>
				</view>
				<view class="item">
					<text class="label">订单编号</text>
					<text class="desc omit">{{ item.tradeNo }}</text>
				</view>
				<view class="item">
					<text class="label">商品名称</text>
					<text class="desc">{{ item.goodsNames }}</text>
				</view>
				<view class="item">
					<text class="label">商品金额</text>
					<text class="desc">¥ {{ item.totalPrice }}</text>
				</view>
				<view class="item">
					<text class="label">车牌号</text>
					<text class="desc">{{ item.veNo }}</text>
				</view>
			</view>
		</view>
		<view class="mfooter">
			<view class="flex">
				<view class="f">
					<button class="btn" @click="ok()">确定</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			current: 0,
			item: {},
			orderId: '',
		};
	},
	onLoad(e) {
		if (e.orderId) {
			this.orderId = e.orderId;
			this.getData();
		}
	},
	methods: {
		getData() {
			this.http.request({
				url: '/level-one-server/app/TbOrder/orderDetail',
				data: { orderId: this.orderId },
				success: res => {
					this.item = res.data.data;
				}
			});
		},
		ok() {
			//根据不同的步骤提交不同的url或者状态参数
			if (this.current == 0) {
				uni.showModal({
					title: '提示',
					content: '我已核对信息无误',
					success: res => {
						if (res.confirm) {
							this.http.request({
								url: '/level-one-server/app/TbOrder/confirmOrder',
								method: 'POST',
								data: { orderId: this.item.id },
								success: res => {
									uni.showToast({ title: '订单确认成功' });
									this.current = 1;
									uni.setNavigationBarTitle({ title: '互助委托确认' });
								}
							});
						}
					}
				});
			}
			if (this.current == 1) {
				uni.showModal({
					title: '提示',
					content: '我已核对信息无误',
					success: res => {
						if (res.confirm) {
							this.http.request({
								url: '/level-one-server/app/TbOrder/cooperOrder',
								method: 'POST',
								data: { orderId: this.item.id },
								success: res => {
									uni.showToast({ title: '互助委托确认成功' });
									this.current = 2;
									uni.setNavigationBarTitle({ title: '进口申报确认' });
								}
							});
						}
					}
				});
			}
			if (this.current == 2) {
				uni.showModal({
					title: '提示',
					content: '我已核对信息无误',
					success: res => {
						if (res.confirm) {
							this.http.request({
								url: '/level-one-server/app/TbOrder/applyOrder',
								method: 'POST',
								data: { orderId: this.item.id },
								success: res => {
									uni.showToast({ title: '进口申报确认成功' });
									setTimeout(() => {
										uni.switchTab({ url: '/pages/index/index' });
									}, 1000);
								}
							});
						}
					}
				});
			}
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
.ctt {
	text-align: center;
	font-weight: bold;
}
</style>