<template>
	<view>
		<view class="cmain">
			<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 omit">{{ item.orderNo }}</text>
				</view>
				<view class="item">
					<text class="label">转售金额（必填）</text>
					<text class="desc">
						<input type="number" v-model="item.resalePrice" placeholder="请输入(元)" />
					</text>
				</view>
			</view>
			<u-divider text="费项明细"></u-divider>
			<view class="box">
				<u-collapse v-for="(item,index) in feeItemLIst" :key="index">
					<u-collapse-item :title="item.name" class="cell_title" >
						<view class="itm">1、收费企业：{{ item.companyName }}</view>
						<view class="itm" v-if="item.feeType ==1">2、收费类型：按交易额收取</view>
						<view class="itm" v-if="item.feeType ==2">2、收费类型：按次收取</view>
						<view class="itm" v-if="item.feeType ==3">2、收费类型：按吨收取</view>
						<view class="itm" v-if="item.feeType ==1">3、收费%(按交易额)：<span style="color: coral;">{{ item.percent }} %</span></view>
						<view class="itm" v-if="item.feeType ==1">4、当前订单收取金额：<span style="color: coral;">{{ (item.percent * resalePrice)/100}} 元</span></view>
						<view class="itm" v-if="item.feeType ==2">3、收费金额(按次收)：<span style="color: coral;">{{ item.feeMoney }} 元</span></view>
						<view class="itm" v-if="item.feeType ==2">4、当前订单收取金额：<span style="color: coral;">{{ item.feeMoney }} 元</span></view>
						<view class="itm" v-if="item.feeType ==3">3、收费%(按吨)：<span style="color: coral;">{{ item.percent }} %</span></view>
						<view class="itm" v-if="item.feeType ==3">4、当前订单收取金额：<span style="color: coral;">{{ (item.percent * resalePrice)/100}} 元</span></view>
						</br>
						<view class="itm">当前费项收取金额以最后结算时为准</view>
					</u-collapse-item>
				</u-collapse>
			</view>
		</view>
		<view class="mfooter" v-if="resaleStatus == 0">
			<view class="flex">
				<view class="f">
					<button class="btn" @click="ok()">确定</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {resalePrice: ''},
			feeItemLIst: [],
			resaleStatus: 0,
			price: ''
		};
	},
	watch:{
		'item.resalePrice':{
			 handler(newVal, oldVal) {
				 this.price = newVal;
			}
		}
	},
	onLoad(e) {
		if (e.id) {
			this.http.request({
				url: '/level-two-server/app/TbOrders/getByLevelOneOrderId',
				data: {levelOneOrderId: e.id},
				success: res => {
					this.item = res.data.data;
					this.price = this.item.resalePrice;
				}
			});
		}
		this.getFeeItem();
	},
	methods: {
		//费项明细
		getFeeItem(){
			this.http.request({
				url: '/level-two-server/app/TbItemRules/getAllList',
				success: res => {
					this.feeItemLIst = res.data.data
				}
			});
		},
		changePrice() {
			
		},
		ok() {
			let rule = [{ name: 'resalePrice', checkType: 'notnull', errorMsg: '请输入转售金额' }];
			if (!this.verify.check(this.item, 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/TbOrders/updateResalePrice',
							data: {id: this.item.id, resalePrice: this.price},
							success: res => {
								uni.showToast({title: '修改成功成功'});
								this.resaleStatus = 1;
							}
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
.item {
	input{
		margin-top: 0px!important;
	}
	}

</style>
