pwd-retrieve.vue 2.8 KB
Newer Older
芊里 已提交
1 2 3 4 5
<template>
	<view class="wrap">
		<view class="wrap-content">
			<view class="content">
				<!-- 顶部文字 -->
芊里 已提交
6
				<text class="content-top-title">重置密码</text>
芊里 已提交
7
				<login-ikonw class="login-iknow" :text="tipText"></login-ikonw>
芊里 已提交
8 9 10 11 12 13 14 15 16 17
				<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
				<uni-forms ref="form" :value="formData" :rules="rules">
					<uni-forms-item name="phone">
						<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
							v-model="formData.code" maxlength="6" placeholder="请输入验证码">
							<template slot="right">
								<login-short-code @getCode="getCode"></login-short-code>
							</template>
						</uni-easyinput>
						<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
芊里 已提交
18
							v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
芊里 已提交
19 20 21 22
					</uni-forms-item>
					<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
						@click="submit">完成</button>
				</uni-forms>
芊里 已提交
23 24 25 26 27 28 29 30 31 32 33 34
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneNumber: '',
				phoneCode: '',
				password: '',
芊里 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
				currenPhoneArea: '',
				
				formData:{
					code:'',
					pwd:''
				},
				rules: {
					code: {
						rules: [{
								required: true,
								errorMessage: '请输入验证码',
							},
							{
								legn: /^.{6}$/,
								errorMessage: '请输入6位验证码',
							}
						]
					},
					pwd:{
						rules: [{
								required: true,
								errorMessage: '请输入密码',
							},
							{
								pattern: /^.{6,20}$/,
								errorMessage: '密码应为6到20位',
							}
						]
					}
				}
芊里 已提交
65 66 67 68 69 70 71 72 73 74 75
			}
		},
		computed: {
			tipText() {
				return `验证码已通过短信发送至${this.currenPhoneArea} ${this.phoneNumber}。密码为6 - 20位`
			},
			canSubmit() {
				let reg_phone = /^1\d{10}$/;
				let reg_pwd = /^.{6,20}$/;
				let reg_code = /^\d{6}$/;
				let isPhone = reg_phone.test(this.phoneNumber);
芊里 已提交
76 77
				let isPwd = reg_pwd.test(this.formData.pwd);
				let isCode = reg_code.test(this.formData.code);
芊里 已提交
78 79 80 81
				return isPhone && isPwd && isCode;
			}
		},
		onLoad(event) {
芊里 已提交
82
			if (event && event.phoneNumber) {
芊里 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
				this.phoneNumber = event.phoneNumber;
				this.currenPhoneArea = '+' + Number(event.phoneArea);
			}
		},
		methods: {
			/**
			 * 获取验证码倒计时
			 * 倒计时期间不会触发该方法
			 */
			getCode(done) {
				if (this.phoneNumber == '') return uni.showToast({
					title: '请填写手机号',
					icon: 'none'
				});
				// 发送成功后开启倒计时
				done();
			},
			/**
			 * 完成并提交
			 */
			submit(){
				
			}
		}
	}
</script>

<style>
	@import url("../../common/loginPage.css");
	.phone-input-box{
		margin-top: 20rpx;
	}
</style>