<template>

	<RefreshView ref="mescrollRef" :hasBack="true" text="更换手机号" :useDownScroll="false" :useUpScroll="false">

		<view class="top">
			<text class="top_text">更换手机号后，下次登录可使用新手机号登录。</text>
			<text class="top_text">当前手机号：{{phoneNumber}}</text>
		</view>

		<view class="inputLay">
			<text class="inputText">新手机号</text>
			<input class="input" type="number" maxlength="11" @input="nameText" placeholder="请输入新手机号"
				:value="mobile"></input>
		</view>

		<view style="height: 5rpx;width: 100%;background-color: #eee;margin-top: 28rpx;"></view>

		<text class="btn" @click="next()">下一步</text>
	</RefreshView>
</template>

<script>
	export default {
		data() {
			return {
				mobile: "",
				phoneNumber: ""
			}
		},
		onLoad(options) {
			console.log('=======', options)
			console.log('=======', options.phoneNumber)
			this.phoneNumber = options.phoneNumber
		},

		methods: {
			nameText(e) {
				this.mobile = e.detail.value
				console.log(this.mobile)
			},
			next() {

				var phoneLength = this.mobile.length;
				if (phoneLength == 0) {
					this.Toast("请输入手机号")
					return;
				}

				if (phoneLength != 11 || !this.mobile.startsWith("1")) {
					this.Toast("请输入正确的手机号")
					return;
				}

				let _this = this
				_this.HTTP({
					url: 'aos/v1/aosUser/verifyMobileIsExist/' + _this.mobile,
					method: 'GET',
					paramsType: "FORM",
					toast: true,
					loading: true
				}).then((res) => {
					console.log('=======', res)
					if (200 == res.code) {
						uni.navigateTo({
							url: 'ModiMobileVerify?phoneNumber=' + this.mobile
						})
					} else {
						this.Toast("手机号重复")
					}

				});
			}

		}
	}
</script>

<style lang="scss">
	.top {
		display: flex;
		flex-direction: column;
		margin-top: 32rpx;
		margin-left: 36rpx;

		.top_text {
			margin-top: 10rpx;
			font-size: 30rpx;
			color: #BBBBBB;
		}
	}

	.inputLay {
		display: flex;
		flex-direction: row;
		margin-left: 40rpx;
		margin-right: 40rpx;
		margin-top: 32rpx;
		margin-bottom: 32rpx;

		.input {
			margin-left: 40rpx;
			flex: 1;
		}
	}

	.btn {
		justify-content: center;
		width: 100%;
		display: flex;
		margin-top: 100rpx;
		padding: 30rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		background: #007AFF;
		text-align: center;
	}
</style>
