<template>
	<view class="container">
		<view class="wrapper">
			<view style="padding-left:60upx;" class="margin-tb-lg">
				<view style="color:#333333;font-size:42upx;">商户登录体验更多功能</view>
				<view style="color:#999999" class="text-sm margin-top-xs">商户入驻信息修改，获取已入驻的信息</view>
			</view>
			<view class="input-content">
				<view class="cu-form-group margin-top" style="border-bottom: 1px solid #E6E6E6;">
					<input type="text" :value="phone" placeholder="请输入入驻提交的手机号码" maxlength="11" data-key="phone"
						@input="inputChange" />
				</view>
				<view class="cu-form-group margin-top" style="border-bottom: 1px solid #E6E6E6;">
					<input type="number" placeholder="请输入验证码" maxlength="6" v-model="codes" @input="inputChange"
						@confirm="toLogin" />
					<button class="send-msg" @click="sendMsg">{{sendTime}}</button>
				</view>
			</view>
			<button class="confirm-btn" @click="toLogin">立即查询</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				codes: '',
				banners: [],
				invitation: '',
				loginName: '',
				sending: false,
				sendTime: '获取验证码',
				count: 60,
				captcha: '',
				captchaPath: '',
				uuid: '',
				show: false
			}
		},
		onLoad() {
			// this.getCaptcha()
		},
		methods: {
			//申请商户入驻
			bindRuzhu() {
				uni.navigateTo({
					url: '/my/publish/index'
				})
			},
			bindRuzhus() {
				uni.navigateTo({
					url: '/pages/my/phoneSettled'
				})
			},
			// 获取验证码
			sendMsg() {
				const {
					phone
				} = this;
				if (!phone) {
					this.$queue.showToast("请输入手机号");
				} else if (phone.length !== 11) {
					this.$queue.showToast("请输入正确的手机号");
				} else {
					this.$queue.showLoading("正在发送验证码...");
					this.$Request.getT("/app/Login/sendMsg/" + phone + "/selectShop").then(res => {
						if (res.code === 0) {
							this.sending = true;
							this.$queue.showToast('验证码发送成功请注意查收');
							this.countDown();
							uni.hideLoading();
						} else {
							uni.hideLoading();
							uni.showModal({
								showCancel: false,
								title: '短信发送失败',
								content: res.msg ? res.msg : '请一分钟后再获取验证码'
							});
						}
					});
				}
			},
			countDown() {
				const {
					count
				} = this;
				if (count === 1) {
					this.count = 60;
					this.sending = false;
					this.sendTime = '获取验证码'
				} else {
					this.count = count - 1;
					this.sending = true;
					this.sendTime = count - 1 + '秒后重新获取';
					setTimeout(this.countDown.bind(this), 1000);
				}
			},
			forget() {
				uni.navigateTo({
					url: '/pages/public/forgetPwd'
				});
			},
			register() {
				uni.navigateTo({
					url: '/pages/public/register'
				});
			},
			inputChange(e) {
				const key = e.currentTarget.dataset.key;
				this[key] = e.detail.value;
			},
			navBack() {
				uni.navigateBack();
			},
			toLogin() {
				// 获取入驻信息
				const {
					phone,
					codes
				} = this;
				console.log(phone, codes)
				if (!phone) {
					this.$queue.showToast("请输入手机号");
				} else if (phone.length !== 11) {
					this.$queue.showToast("请输入正确的手机号");
				} else if (!codes) {
					this.$queue.showToast("请输入六位数验证码");
				} else {
					let data = {
						msg: codes,
						phone: phone
					}
					this.$Request.getA("/admin/goodsShop/selectGoodsShop", data).then(res => {
						if (res.code == 0 && res.data) {
							//0待审核 1通过 （你就可以直接弹框提示 您已审核通过，点击跳转登录）类似这种 2拒绝的话 就让他修改信息
							if (res.data.status == 1) {
								this.$queue.showToast('您已审核通过，可以直接登录！');
							} else {
								uni.setStorageSync("Settedlist", res.data)
								uni.navigateTo({
									url: '/my/publish/index'
								})
							}
						} else {
							this.$queue.showToast(res.msg);
						}
					});
				}
			}
		},

	}
</script>

<style lang='scss'>
	page {
		height: 100%;
		background: #FFFFFF !important;
	}

	.send-msg {
		border-radius: 30px;
		/* color: #FFFFFF; */
		background: #FCD202;
		height: 30px;
		font-size: 14px;
		line-height: 30px;
	}

	.container {
		top: 0;
		padding-top: 32upx;
		position: relative;
		width: 100%;
		height: 100%;
		overflow: hidden;
		/* background: #1E1F31 !important; */
	}

	.wrapper {
		position: relative;
		z-index: 90;
		/* background: #1E1F31; */
		padding-bottom: 32upx;
	}


	.input-content {
		/* margin-top: 300upx; */
		/* padding-top: 300upx; */
		padding: 40upx 60upx;

	}


	.confirm-btn {
		width: 600upx;
		line-height: 88upx;
		height: 88upx;
		border-radius: 10upx;
		margin-top: 32upx;
		background: #FCD202;
		/* color: #fff; */
		font-size: 32upx;

		&:after {
			border-radius: 10px;
		}
	}

	.ruzhu {
		width: 100%;
		text-align: center;
		color: #999999;
		margin-top: 20upx;
	}
</style>
