<template>
	<view class="page">
		<u-navbar title="修改信息" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='58'></u-navbar>
        <view class="box">
        	<view class="title">
        		基本信息
        	</view>
			<!-- 代理 -->
			<view class="list">
				<view class="list_val">
					<view class="" style="padding-top:12rpx">代理级别</view> <input type="text" disabled="false" :placeholder="jibie" />
				</view>
				<view class="list_val">
					<view class="" style="padding-top:12rpx">代理名称</view> <input type="text" v-model="name" placeholder="请输入代理名称" />
				</view>
				<view class="list_val">
					<view class="" style="padding-top:12rpx">分成比例</view> <input type="text" v-model="fenc" placeholder="请输入分成比例  %" />
				</view>
			<!-- 	<view class="list_val">
					<view class="" style="padding-top:12rpx">手机号码</view> <input type="text" v-model="tel" placeholder="请输入手机号码" />
				</view> -->
				<view class="list_val">
					<view class="" style="padding-top:12rpx;margin-right: 88rpx;">省市区</view> <input @click="show = true" disabled="true" type="text" :placeholder="sheng" />
					<u-picker v-model="show" mode="region" @confirm="confirm"></u-picker>
				</view>
			</view>
       
			<view class="baocun" @click="brnbc">
				保存
			</view>
        </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				bgc: {
					backgroundColor: " #25CE88",
				},
				name:'',
				fenc:'',
				tel:'',
				sheng:'请选择省市区',
				listobj:{},
				jibie:'',
				agentId:'',
				shengarr:[]
			}
		},
		onLoad(option) {
			this.listobj = JSON.parse(option.obj)
			this.jibie = this.listobj.level + '级代理'
			this.name = this.listobj.name
			this.fenc = this.listobj.point
			this.tel = this.listobj.mobile
			this.sheng = this.listobj.area[0]+ '/' + this.listobj.area[1]+ '/' + this.listobj.area[2]
			this.agentId = this.listobj.agentId
			this.shengarr.push(this.listobj.area[0])
			this.shengarr.push(this.listobj.area[1])
			this.shengarr.push(this.listobj.area[2])
		},
		methods: {
            confirm(e){
				this.shengarr = []
				this.sheng = e.province.label + '/' + e.city.label + '/' + e.area.label 
				this.shengarr.push(e.province.label)
				this.shengarr.push(e.city.label)
				this.shengarr.push(e.area.label)
			},
			brnbc(){
				let data = {
					agentId:this.agentId,
					name:this.name,
					point:this.fenc,
					// mobile:this.tel,
					area:this.shengarr
				}
				this.$u.put('/agent/agent',data).then(res => {
					if(this.name == ''){
						uni.showToast({
							title: '请输入姓名',
							icon: 'none',
							duration: 1000
						})
					}else{
						if (res.code == 200) {
						    uni.showToast({
						    	title: '修改成功',
						    	icon: 'success',
						    	duration: 1000
						    })
						    setTimeout(()=>{
						    	uni.navigateBack({
									delta:2
								})
						    },1500)
						}else if(res.msg == '请输入正确的手机号'){
							uni.showToast({
								title: '请输入正确的手机号',
								icon: 'none',
								duration: 1000
							})
						}else if(res.msg == '分成比例不允许超过上级代理，最高：90.00'){
							uni.showToast({
								title: '分成比例不允许超过上级代理，最高：90.00',
								icon: 'none',
								duration: 1000
							})
						}else if(res.code == 500){
							uni.showToast({
								title: '分成比例请填写数值，最高：90.00',
								icon: 'none',
								duration: 1000
							})
						}
					}
					
				})
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title,
	/deep/ .uicon-nav-back {
		padding-bottom: 40rpx;
	}
	page {
		// background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
	}

	.page {
		width: 750rpx;
		// position: fixed;
		// top: 0;
		// left: 0;
		.box{
			width: 750rpx;
			height: 100%;
			overflow-y:scroll;
			background: #F4F5F7;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			padding: 32rpx 36rpx; 
			box-sizing: border-box;
			padding-bottom: 100rpx;
			.baocun{
				width: 584rpx; 
				height: 90rpx;
				margin: auto;
				background: linear-gradient( 270deg, #54DAA1 0%, #19CD82 100%);
				border-radius: 54rpx 54rpx 54rpx 54rpx;
				margin-top: 62rpx;
				margin-bottom: 78rpx;
				font-weight: 500;
				font-size: 40rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 90rpx;
			}
			.swlist{
				margin-top: 34rpx;
				display: flex;
				justify-content: space-between;
				 flex-wrap: wrap;
				.swlist_val{
					display: flex;
					justify-content: space-between;
                    width: 324rpx;
                    height: 144rpx;
                    background: #FFFFFF;
                    border-radius: 24rpx 24rpx 24rpx 24rpx;		
					padding-top: 28rpx;
					padding-left: 38rpx;
					box-sizing: border-box;
					margin-top: 18rpx;
				}
				.lt{
					.one{
						font-size: 28rpx;
						color: #3D3D3D;
					}
					.two{
						font-size: 24rpx;
						color: #808080;
						margin-top: 12rpx;
					}
				}
				.rt{
					margin-top: 24rpx;
					padding-right: 12rpx;
				}
			}
			.title{
				font-size: 32rpx;
				color: #3D3D3D;
			}
			.list{
					width: 680rpx;
					height: 578rpx;
					background: #FFFFFF;
					border-radius: 24rpx 24rpx 24rpx 24rpx;
					padding: 46rpx 36rpx;
					box-sizing: border-box;
					margin-top: 34rpx;
					margin-bottom: 47rpx;
				.list_val{
					display: flex;
					font-size: 32rpx;
					color: #3D3D3D;
					justify-content: space-between;
					margin-bottom: 32rpx;
					input{
						width: 430rpx;
						height: 70rpx;
						background: #F0F0F0;
						border-radius: 12rpx 12rpx 12rpx 12rpx;
						padding-left: 32rpx;
						box-sizing: border-box;
						font-size: 28rpx;
						color: #808080;
					}
				}
			}
		}
	}
</style>