<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="expand" v-if="current == 0" :style="{height:expand?'auto':'300px'}">
					<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 omit">{{ item.settleBillNo }}</text>
					</view>
					<view class="item">
						<text class="label">预申报编号</text>
						<text class="desc omit">{{ item.platSeqNo }}</text>
					</view>
					<view class="item">
						<text class="label">买家</text>
						<text class="desc omit">{{ item.buyUserName }}</text>
					</view>
					<view class="item">
						<text class="label">车牌号</text>
						<text class="desc">{{ item.veNo }}</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.netWt }}</text>
					</view>
					<view class="item">
						<text class="label">毛重</text>
						<text class="desc">{{ item.grossWt }}</text>
					</view>
					<view class="item">
						<text class="label">申报数量</text>
						<text class="desc">{{ item.buyQty }}</text>
					</view>
					<view class="item">
						<text class="label">商户名称</text>
						<text class="desc">{{ item.enterpriseName }}</text>
					</view>
					<view class="item">
						<text class="label">边民额度序号</text>
						<text class="desc">{{ item.limitNo }}</text>
					</view>
					<view class="item">
						<text class="label">商品额度</text>
						<text class="desc">{{ item.glimit }}</text>
					</view>
					<view class="item">
						<text class="label">商品序号</text>
						<text class="desc">{{ item.gno }}</text>
					</view>
					<view class="item">
						<text class="label">交易地区名称</text>
						<text class="desc">{{ item.tradeAreaName }}</text>
					</view>
					<view class="item">
						<text class="label">进口预申报号</text>
						<text class="desc">{{ item.preIeportNo }}</text>
					</view>
					<view class="item">
						<text class="label">批次预录入号</text>
						<text class="desc">{{ item.preNo }}</text>
					</view>
				</view>
				<view class="expand" v-else :style="{height:expand?'auto':'300px'}">
					<view class="item">
						<text class="label">业务编号</text>
						<text class="desc omit">{{ item2.platSeqNo }}</text>
					</view>
					<view class="item">
						<text class="label">预录入编号</text>
						<text class="desc">{{ item2.preNo }}</text>
					</view>
					<view class="item">
						<text class="label">关联进境申报单编号</text>
						<text class="desc">{{ item2.itrdclDeclareId }}</text>
					</view>
					<view class="item">
						<text class="label">申报人类型</text>
						<text class="desc">{{ item2.declareType }}</text>
					</view>
					<view class="item">
						<text class="label">申报人姓名</text>
						<text class="desc">{{ item2.declareName }}</text>
					</view>
					<view class="item">
						<text class="label">申报人身份证号</text>
						<text class="desc">{{ item2.ciphertextIdno }}</text>
					</view>
					<view class="item" v-if="item2.declareType == '2'">
						<text class="label">商铺编码</text>
						<text class="desc">{{ item2.shopNo }}</text>
					</view>
					<view class="item" v-if="item2.declareType == '2'">
						<text class="label">商铺名称</text>
						<text class="desc">{{ item2.shopName }}</text>
					</view>

					<view class="item">
						<text class="label">商品名称</text>
						<text class="desc">{{ item2.goodsNames }}</text>
					</view>
					<view class="item">
						<text class="label">商品额度</text>
						<text class="desc">{{ item2.gLimit }}</text>
					</view>

					<view class="item">
						<text class="label">总金额</text>
						<text class="desc">{{ item2.sumAmt }}</text>
					</view>
					<view class="item">
						<text class="label">总毛重</text>
						<text class="desc">{{ item2.sumGrossWt }}</text>
					</view>
					<view class="item">
						<text class="label">总净重</text>
						<text class="desc">{{ item2.sumNetWt }}</text>
					</view>
					<view class="item">
						<text class="label">币制</text>
						<text class="desc">{{ item2.currCode }}</text>
					</view>
					<view class="item">
						<text class="label">件数</text>
						<text class="desc">{{ item2.packNo }}</text>
					</view>
					<view class="item">
						<text class="label">车牌号</text>
						<text class="desc">{{ item2.veNo }}</text>
					</view>
					<view class="item">
						<text class="label">运输方式</text>
						<text class="desc">{{ item2.trafMode }}</text>
					</view>
					<view class="item" v-if="item2.declareType == '3' || item2.declareType == '4'">
						<text class="label" v-if="item2.declareType == '3'">互助组备案编号</text>
						<text class="label" v-if="item2.declareType == '4'">合作社备案编号</text>
						<text class="desc">¥ {{ item2.orgPutrecNo }}</text>
					</view>
					<view class="item" v-if="item2.declareType == '3' || item2.declareType == '4'">
						<text class="label" v-if="item2.declareType == '3'">互助组名称</text>
						<text class="label" v-if="item2.declareType == '4'">合作社名称</text>
						<text class="desc">¥ {{ item2.orgName }}</text>
					</view>
					<view class="item" v-if="item2.declareType == '4'">
						<text class="label">合作社信用代码</text>
						<text class="desc">¥ {{ item2.orgScc }}</text>
					</view>
					<view class="item">
						<text class="label">监管场所</text>
						<text class="desc">{{ item2.fieldName }}</text>
					</view>
					<view class="item">
						<text class="label">贸易国别</text>
						<text class="desc">{{ item2.tradeCountry }}</text>
					</view>
					<view class="item">
						<text class="label">企业编码</text>
						<text class="desc">{{ item2.entCode }}</text>
					</view>
					<view class="item">
						<text class="label">企业名称</text>
						<text class="desc">{{ item2.entName }}</text>
					</view>
				</view>
				<view class="more" @click="expand = !expand">
					<text class="icon">&#xe649;</text>
					<text>{{expand?'收起':'更多信息'}}</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 {
			expand: false, //展开
			current: 0,
			item: {},
			item2: {},
			orderId: '',
			peopleConfirmStatus: '',
			cooperEntrustStatus: '',
			applyConfirmStatus: ''
		};
	},
	onLoad(e) {
		if (e.orderId && e.peopleConfirmStatus && e.cooperEntrustStatus && e.applyConfirmStatus) {
			this.orderId = e.orderId;
			this.peopleConfirmStatus = e.peopleConfirmStatus;
			this.cooperEntrustStatus = e.cooperEntrustStatus;
			this.applyConfirmStatus = e.applyConfirmStatus;

			if(this.peopleConfirmStatus == 0) {
				this.current = 0;
				this.getData1();
			} else if(this.peopleConfirmStatus == 1 && this.cooperEntrustStatus == 0) {
				this.current = 1;
				this.getData2();
			} else if(this.peopleConfirmStatus == 1 && this.cooperEntrustStatus == 1 && this.applyConfirmStatus == 0) {
				this.current = 2;
				this.getData2();
			}
		}
	},
	methods: {
		getData1() {
			this.http.request({
				url: '/level-one-server/app/TbOrder/orderDetail',
				data: { orderId: this.orderId },
				success: res => {
					this.item = res.data.data;
				}
			});
		},
		getData2() {
			this.http.request({
				url: '/level-one-server/app/TbImportOrder/importOrderDetail',
				data: { orderId: this.orderId },
				success: res => {
					this.item2 = 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;
}
.cmain{
	padding-bottom: 100px;
}
.expand {
	overflow: hidden;
}
.more {
	text-align: center;
	padding: 10px 10px 15px 10px;
	.icon {
		padding-right: 3px;
	}
}
.ctt {
	text-align: center;
	font-weight: bold;
}
</style>
