pwd-retrieve.vue 3.1 KB
Newer Older
芊里 已提交
1 2 3 4 5
<template>
	<view class="wrap">
		<view class="wrap-content">
			<view class="content">
				<!-- 顶部文字 -->
DCloud_JSON's avatar
DCloud_JSON 已提交
6
				<text class="content-top-title">重置密码</text>
芊里 已提交
7
				<login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw>
DCloud_JSON's avatar
DCloud_JSON 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
				<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
				<uni-forms ref="form" :value="formData" :rules="rules">
					<uni-forms-item name="phone">
						<!-- focus规则如果上一页携带来“手机号码”数据就focus验证码输入框,否则focus手机号码输入框 -->
						<uni-easyinput :focus="!formData.phone.length" type="number" class="phone-input-box" :inputBorder="false"
							v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput>
					</uni-forms-item>
					<uni-forms-item name="code">
						<uni-easyinput :focus="formData.phone.length" type="number" class="phone-input-box" :inputBorder="false"
							v-model="formData.code" maxlength="6" placeholder="请输入验证码">
							<template slot="right">
								<send-sms-code ref="shortCode" :phone="formData.phone"></send-sms-code>
							</template>
						</uni-easyinput>
					</uni-forms-item>
					<uni-forms-item name="pwd">
						<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
							v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
					</uni-forms-item>
					<uni-forms-item name="pwd2">
						<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
							v-model="formData.pwd2" placeholder="请确认新密码"></uni-easyinput>
					</uni-forms-item>
					<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
						@click="submit">完成</button>
芊里 已提交
33
				</uni-forms>
芊里 已提交
34 35 36 37 38
			</view>
		</view>
	</view>
</template>

DCloud_JSON's avatar
DCloud_JSON 已提交
39
<script>
40
import mixin from '../common/loginPage.mixin.js';
DCloud_JSON's avatar
DCloud_JSON 已提交
41
	export default {
芊里 已提交
42
		mixins:[mixin],
芊里 已提交
43 44
		data() {
			return {
DCloud_JSON's avatar
DCloud_JSON 已提交
45
				currenPhoneArea: ''
芊里 已提交
46 47 48 49
			}
		},
		computed: {
			tipText() {
芊里 已提交
50
				return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。密码为6 - 20位`
芊里 已提交
51 52
			},
			canSubmit() {
53
				return this.isPhone && this.isPwd && this.isCode;
芊里 已提交
54 55 56
			}
		},
		onLoad(event) {
芊里 已提交
57
			if (event && event.phoneNumber) {
芊里 已提交
58
				this.formData.phone = event.phoneNumber;
芊里 已提交
59 60 61
				this.currenPhoneArea = '+' + Number(event.phoneArea);
			}
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
		onReady() {
			if(this.formData.phone){
				this.$refs.shortCode.start();
			}
		},
		methods: {
			/**
			 * 完成并提交
			 */
			submit(){
				this.$refs.form.submit()
				.then(res=>{
					this.request('user-center/resetPwdBySmsCode',{
						"mobile":this.formData.phone,
						"code":this.formData.code,
						"password":this.formData.pwd
					},(data,result)=>{
						console.log(result);
						uni.showToast({
							title: result.msg,
							icon: 'none'
						});
						if(result.code === 0){
							uni.navigateBack()
						}
					})
				})
芊里 已提交
89 90 91 92 93
			}
		}
	}
</script>

DCloud_JSON's avatar
DCloud_JSON 已提交
94
<style>
95
	@import url("../common/loginPage.css");
DCloud_JSON's avatar
DCloud_JSON 已提交
96 97
	.content-top-title{
		margin-bottom: 6px;
芊里 已提交
98
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
99
</style>