<template>
	<view class="qingshaonian">
		<view class="bd" v-html="content"></view>
		<view class="fd">
			<view class="btn" @click="show = true">申请合作</view>
		</view>
		<u-popup v-model="show" mode="center" border-radius="20" :mask-close-able="true" zIndex="21">
			<view class="hezuo">
				<view class="title">合作信息<image src="@/static/cha.png"></image></view>
				<view class="content">
					<view class="item">
						<view class="a"><text>*</text>姓名</view>
						<view class="b">
							<input v-model="name" type="text" placeholder="请输入" />
						</view>
					</view>
					<view class="item">
						<view class="a"><text>*</text>手机号</view>
						<view class="b">
							<input v-model="phone" type="number" placeholder="请输入" />
						</view>
					</view>
					<view class="item">
						<view class="a">所在区域</view>
						<view class="b">
							<view class="picker picker-on" @click="show1 = true">{{province?(province+"-"+city+"-"+district):'请选择'}}</view>
						</view>
					</view>
					<view class="item">
						<view class="a">公司名称</view>
						<view class="b">
							<input v-model="companyname" type="text" placeholder="请输入" />
						</view>
					</view>
				</view>
				<view class="btns" @click="toReg()">提交</view>
			</view>
		</u-popup>
		<u-picker mode="region" v-model="show1" :defaultRegion="defaultRegion" @cancel="cancel" @confirm="confirm" ></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show1: false,
				content: "",
				show: false,
				defaultRegion: [],
				phone: "",
				name: "",
				companyname: "",
				province: "",
				city: "",
				district: ""
			}
		},
		onLoad() {
			this.getInfo();
		},
		methods: {
			cancel() {
				this.show1 = false;
			},
			confirm(e) {
				this.show1 = false;
				this.defaultRegion = [e.province.name,e.city.name,e.area.name]
				this.province = e.province.name;
				this.city = e.city.name;
				this.district = e.area.name;
			},
			async toReg() {
				if(!this.name){
					uni.showToast({
						icon: "none",
						position: "bottom",
						title: "姓名不能为空！"
					})
					return ;
				}
				if(!this.phone){
					uni.showToast({
						icon: "none",
						position: "bottom",
						title: "手机号不能为空！"
					})
					return ;
				}
				const {code, data, msg} = await this.$api.urbanCooperation({
					userId: uni.getStorageSync("userInfo").id,
					name: this.name,
					phone: this.phone,
					quyu: this.defaultRegion.join(","),
					companyname: this.companyname,
				})
				if(code == 200){
					uni.showToast({
						title: "提交成功"
					})
					this.show  = false
				}else{
					uni.showToast({
						icon: "none",
						position: "bottom",
						title: msg
					})
				}
			},
			async getInfo() {
				const { code,data } = await this.$api.getConfigData({dictType: 'CONFIG_URBAN_COOPERATION'});
				if(code == 200){
					this.content = data.content.replace(/style=""/g, '')
								.replace(/<img " src=/g, '<img src=')
								.replace(/<img src=/g, '<img style="width: 100%; height:100%; display:block" src=');
				}
			},
		}
	}
</script>

<style scoped lang="scss">
page{
	background-color: #fff;
}
.qingshaonian{
	padding: 0 25rpx;
	overflow: hidden;
	.hezuo{
		width: 670rpx;
		height: 951rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		.btns{
			width: 300rpx;
			height: 80rpx;
			background: linear-gradient(0deg, #000000, #3D3B38);
			box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
			border-radius: 80rpx;
			text-align: center;
			line-height: 80rpx;
			font-weight: 500;
			font-size: 26rpx;
			color: #FFFFFF;
			margin: 0 auto;
			margin-top: 50rpx;
		}
		.title{
			text-align: center;
			padding: 30rpx;
			font-weight: 500;
			font-size: 36rpx;
			color: #222222;
			border-bottom: 1px solid #EAEAEA;
			image{
				width: 50rpx;
				height: 50rpx;
				float: right;
			}
		}
		.content{
			.item{
				margin-top: 10rpx;
				padding: 0 30rpx;
				overflow: hidden;
				.a{
					padding: 20rpx 0;
					font-weight: 500;
					font-size: 30rpx;
					color: #212121;
					text{
						color: #E70C0C;
					}
				}
				.b{
					width: 100%;
					input{
						line-height: 80rpx;
						height: 80rpx;
						background: #FFFFFF;
						border-radius: 10rpx;
						border: 1px solid #E5E5E5;
						padding: 0 20rpx;
						box-sizing: border-box;
						font-size: 28rpx;
						color: #000000;
					}
					.picker{
						line-height: 80rpx;
						height: 80rpx;
						background: #FFFFFF;
						border-radius: 10rpx;
						border: 1px solid #E5E5E5;
						padding: 0 20rpx;
						box-sizing: border-box;
						font-size: 28rpx;
						color: #000000;
						&-on{
							color: #808080;
						}
					}
				}
			}
		}
	}
	.fd{
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 25rpx;
		overflow: hidden;
		z-index: 8;
		box-sizing: border-box;
		.btn{
			width: 100%;
			line-height: 98rpx;
			background: linear-gradient(0deg, #000000, #3D3B38);
			box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
			border-radius: 98rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
		}
	}
	.bd{
		
	}
}
</style>
