<template>
	<view>
		<view class="cmain" v-for="(item,index) in feeItemList">
			<view class="box order_detail">
				<view class="item">
					<text class="label">收费企业：</text>
					<text class="desc">{{ item.companyName }}</text>
				</view>
				<view class="item">
					<text class="label">收费类型：</text>
					<text class="desc" v-if="item.feeType ==1">按交易额收取</text>
					<text class="desc" v-if="item.feeType ==2">按次收取</text>
				</view>
				<view class="item" v-if="item.feeType ==1">
					<text class="label">收费%(按交易额)：</text>
					<text class="desc"><span style="color: coral;">{{ item.percent }} %</span></text>
				</view>
				<view class="item" v-if="item.feeType ==2">
					<text class="label">收费金额(按次收)：</text>
					<text class="desc"><span style="color: coral;">{{ item.feeMoney }} 元</span></text>
				</view>
				<view class="item">
					<text class="label">当前订单收取金额：</text>
					<text class="desc" v-if="item.feeType ==1"><span style="color: coral;">{{ (item.percent * resalePrice)/100}} 元</span></text>
					<text class="desc" v-if="item.feeType ==2"><span style="color: coral;">{{ item.feeMoney }} 元</span></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 {
			resalePrice: '',// 金额
			id: '',// 订单id
			feeItemList: [],
		};
	},
	onLoad(e) {
		if (e.id && e.resalePrice) {
			this.resalePrice = e.resalePrice;
			this.id = e.id;
			this.http.request({
				url: '/level-two-server/app/TbFeeItem/getList',
				success: res => {
					this.feeItemList = res.data.data
				}
			});
		}
	},
	methods: {
		pay() {
			uni.showModal({
				title: '提示',
				content: '确定缴费?',
				success: res => {
					if (res.confirm) {
						this.http.request({
							url: '/level-two-server/app/TbOrders/payTax?id=' + this.id,
							success: res => {
								uni.showToast({ title: '缴费成功' });
								uni.navigateBack();
							}
						});
					}
				}
			});
		}
	}
};
</script>

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