<template>
	<view class="page" style="background: #FFFFFF;">
		<view class="feedback-title"><text>意向代理城市</text></view>
		<view class="feedback-body"><input @tap="gocity" disabled="false" class="feedback-input" v-model="name"
				placeholder="请选择需要代理的城市" /></view>
		<view class="feedback-title"><text>预计投入资金</text></view>
		<view class="feedback-body"><input class="feedback-input" v-model="money" type="number" min="0"
				placeholder="请输入投入资金" /></view>
		<view class="feedback-title"><text>团队规模</text></view>
		<view class="feedback-body"><input class="feedback-input" v-model="guimo" placeholder="请输入团队规模" /></view>
		<view class="feedback-title"><text>姓名</text></view>
		<view class="feedback-body"><input class="feedback-input" v-model="username" placeholder="请输入您的真实姓名" /></view>
		<view class="feedback-title"><text>联系电话</text></view>
		<view class="feedback-body"><input class="feedback-input" v-model="phone" maxlength="11"
				placeholder="请输入您的电话号码" /></view>
		<!-- <view class="feedback-title"><text>地址信息</text></view>
		<view class="feedback-body"><input @tap="dingwei" disabled="false" class="feedback-input" v-model="address"
				placeholder="请选择地址信息" /></view>
		<view class="feedback-title">
			<text>详细位置</text>
		</view>
		<view class="feedback-body"><textarea placeholder="小区楼栋/乡村名称" v-model="content" class="feedback-textare" />
		</view> -->

		<button type="primary" style="background: #FF4701;margin-top: 32upx;text-align: center;" class="feedback-submit"
			@tap="send">提交</button>

	</view>
</template>

<script>
	var QQMapWX = require('@/js_sdk/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js');
	var qqmapsdk;
	var citySelector = requirePlugin('citySelector');
	export default {
		data() {
			return {
				name: '',
				address: '',
				content: '',
				phone: '',
				username: '',
				city: "",
				district: "",
				province: "",
				merchantId:0,
				money: '',
				guimo: ''
			};
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			// 实例化API核心类
			qqmapsdk = new QQMapWX({
				key: 'SH4BZ-BS7CO-3X7WH-SBP6U-O7AM7-GNF4X'
			});
			// #endif
			let merchantId = this.$queue.getData('merchantId');
		},
		onShow() {
			const item = citySelector.getCity();
			if (item) {
				citySelector.clearCity();
				this.name = item.name;
				// this.$queue.setData('city', item.name);
			}
		},
		methods: {
			gocity() {
				const key = 'XOWBZ-CN5KJ-YKWF6-K24NB-JFRFF-CQBO4'; // 使用在腾讯位置服务申请的key
				const referer = 'SAC俱乐部'; // 调用插件的app的名称
				const hotCitys = ''; // 用户自定义的的热门城市
				wx.navigateTo({
					url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}`,
				})

				// uni.navigateTo({
				// 	url: '/pages/index/citys'
				// });
			},
			send() {
				let userId = this.$queue.getData('userId');
				if (this.name === '') {
					this.$queue.showToast('请选择需要代理的城市');
					return;
				}
				
				if (this.money === '') {
					this.$queue.showToast('请输入投入资金');
					return;
				}
				
				if (this.guimo === '') {
					this.$queue.showToast('请输入团队规模');
					return;
				}
				
				if (this.username === '') {
					this.$queue.showToast('请输入您的真实姓名');
					return;
				}

				if (this.phone.length != 11) {
					this.$queue.showToast('请输入您正确的电话号码');
					return;
				}

				let data = {
					"merchantId": this.merchantId,
					"city": this.name,
					"money": this.money,
					"num": this.guimo,
					"phone": this.phone,
					"userId": userId,
					"userName": this.username
				}
				this.$queue.showLoading('加载中...');
				this.$Request
					.postJson('/cityAgency/insertCityAgency', data).then(res => {
						if (res.code === 0) {
							uni.showToast({
								title: '申请成功，等待审核！'
							});
							setTimeout(function() {
								uni.navigateBack();
							}, 1000);
						} else {
							uni.hideLoading();
							uni.showModal({
								showCancel: false,
								title: '提交失败',
								content: res.msg
							});
						}
					});
			}
		}
	};
</script>

<style>
	page {
		background-color: #FFFFFF;
	}

	view {
		font-size: 28upx;
	}

	/*问题反馈*/
	.feedback-title {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 20upx;
		color: #333;
		font-size: 16px;
		font-weight: 600;
	}

	.feedback-body {
		font-size: 32upx;
		padding-left: 20rpx;
		margin: 16upx;
		border-radius: 4upx;
		/* background: #F8F8F8; */
		border-bottom: 1px solid #ccc;
	}

	.feedback-textare {
		height: 200upx;
		font-size: 28upx;
		line-height: 50upx;
		width: 100%;
		box-sizing: border-box;
		/* padding: 20upx 30upx 0; */
	}

	.feedback-input {
		font-size: 28upx;
		height: 60upx;
		/* padding: 15upx 20upx; */
		line-height: 60upx;
	}

	.feedback-submit {
		background: #007aff;
		color: #ffffff;
		margin: 20upx;
	}

	.integral {
		width: 95%;
		height: 70upx;
		color: #333;
		font-weight: 600;
		border-bottom: 1px solid #ccc;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 20upx 20upx;
	}

	.left {
		font-size: 32upx !important;
		display: flex;
		align-items: center;
		flex: 1;
	}

	.uni-picker-container div {
		position: relative;
	}

	.leftSpan {
		position: absolute;
		margin-left: 20upx;
		color: #999;
		font-size: 20upx;
		width: 600upx;
		left: 80upx;
		bottom: 8upx;
	}

	image {
		width: 42upx;
		height: 42upx;
	}

	text {
		margin-left: 20upx;
		color: #333333;
		font-size: 28upx;
	}

	button {
		flex: 1;
		padding: 0;
		margin: 0;
		border: none;
		background: transparent;
		text-align: left;
	}

	button::after {
		border: none;
	}

	button::before {
		border: none;
	}

	.view-text {
		font-size: 28upx;
		color: #333333;
		margin-left: 20upx;
	}

	.cuIcon-right {
		font-size: 28upx;
		color: #999;
	}

	uni-text {
		font-size: 32upx;
	}
</style>
