<template>

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

		<view class="top">
			<text class="top_text">更换的手机号：{{phoneNumber}}</text>
		</view>

		<view class="inputLay">
			<text class="inputText">验证码</text>
			<input type="number" maxlength="6" @input="codeText" placeholder="请输入验证码" class="input" />
			<SendCodeItem :phoneNum="phoneNumber" url="aos/v1/aosUserManagement/sendCodeFromWxBindMobile" @click="send"
				ref="wxCodeItem"></SendCodeItem>

		</view>

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

		<text class="btn" @click="save()">完成</text>
	</RefreshView>
</template>

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

		methods: {
			codeText(e) {
				this.code = e.detail.value
				console.log(this.code)
			},
			save() {

				var codeLength = this.code.length;
				if (codeLength == 0) {
					this.Toast("请输入验证码")
					return;
				}

				let _this = this
				_this.HTTP({
					url: 'aos/v1/aosUserManagement/modifyMobile',
					method: 'PUT',
					paramsType: "FORM",
					data: {
						sysUserSid: getApp().globalData.memberSid,
						mobile: _this.phoneNumber,
						code: _this.code,
					},
					toast: true,
					loading: true
				}).then((res) => {
					console.log('=======', res)
					// 保存
					uni.navigateBack({
						delta: 2
					})
				});
			}

		}
	}
</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;
		align-items: center;

		.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>
