<template>
	<view class="content">
		<form>
			<view class="body user-insert">账号：{{proportionCheck.userName}}</view>
			<view class="body user-insert">旧分销：</view>
			<view class="body user-insert-line">平台：{{oldProportionCheck.adminProportion}}%</view>
			<view class="body user-insert-line">省级：{{oldProportionCheck.agencyProportion}}%</view>
			<view class="body user-insert-line">市级：{{oldProportionCheck.merchantProportion}}%</view>
			<view class="body user-insert-line">终端：{{oldProportionCheck.personageProportion}}%</view>
		</form>
		<form>
			<view class="body user-insert" style="padding-top: 40upx;">
				新分销：
			</view>
			<view class="body user-insert-line">平台：{{proportionCheck.adminProportion}}%</view>
			<view class="body user-insert-line">省级：{{proportionCheck.agencyProportion}}%</view>
			<view class="body user-insert-line">市级：{{proportionCheck.merchantProportion}}%</view>
			<view class="body user-insert-line">终端：{{proportionCheck.personageProportion}}%</view>
			<!-- <view class="body">
				省级：<input class="input"  name="oldPassword" />
			</view> -->
			<view class="btn-area">
				<button type="primary" @click="agree(proportionCheck.id)" style="margin-right: 20px;">通过</button>
				<button type="primary" @click="unagree(proportionCheck.id)">撤销</button>
			</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldProportionCheck: {},
				proportionCheck: {}
			}
		},
		onLoad: function(option) {
			const proportionCheck = JSON.parse(decodeURIComponent(option.proportionCheck));
			this.proportionCheck = proportionCheck;
			this.getOldProportion(proportionCheck.adminId);
		},
		onShow() {},
		methods: {
			getOldProportion(adminId) {
				var token = uni.getStorageSync("token");
				// var globalUser = uni.getStorageSync("globalUser");
				uni.request({
					url: this.serverurl + '/TProportion/getList?adminId=' + adminId,
					header: {
						'token': token
					},
					method: "GET",
					success: (res) => {
						if (res.data.code) {
							this.oldProportionCheck = res.data.data;
						}
					},
				});
			},
			agree(id) {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '是否通过？',
					success: function(res) {
						if (res.confirm) {
							var token = uni.getStorageSync("token");
							uni.request({
								url: that.serverurl + '/TProportionCheck/agree?id=' + id,
								header: {
									'token': token
								},
								method: "GET",
								success: (res) => {
									uni.showToast({
										title: res.data.message,
										duration: 2000
									});
								},
							});
						} else if (res.cancel) {}
					}
				});

			},
			unagree(id) {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '是否不通过？',
					success: function(res) {
						if (res.confirm) {
							var token = uni.getStorageSync("token");
							uni.request({
								url: that.serverurl + '/TProportionCheck/unagree?id=' + id,
								header: {
									'token': token
								},
								method: "GET",
								success: (res) => {
									uni.showToast({
										title: res.data.message,
										duration: 2000
									});
								},
							});
						} else if (res.cancel) {}
					}
				});

			}

		}
	}
</script>

<style>
	.content {
		padding-top: 20upx;
		margin-left: 20upx;
	}

	.body {
		background-color: #FFFFFF;
		padding: 10upx 20upx 10upx 20upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
	}

	.input {
		/* padding: 10upx 20upx 10upx 0upx; */
		padding-left: 20upx;
		padding-top: 10upx;
		background-color: #FFFFFF;
		width: 500upx;
		height: 50upx;
		box-shadow: 0upx 0upx 20upx #D3D3D3;
		border-radius: 5upx;
	}

	.button {
		margin: 0 auto;
		display: inline-block;
	}

	button[type=primary] {
		background-color: #007aff;

		display: inline-block;
	}

	.btn-area {
		padding-top: 100upx;
		margin: 0 auto;
		width: 50%;
	}

	.user-insert-line {
		width: 400upx;
		height: 23px;
		border-bottom: solid black 1px;
		margin: 0 auto;
	}

	.user-insert {
		width: 400upx;
		margin: 0 auto;
	}

	view {
		font-size: 30rpx;
	}
</style>
