提交 15c6de13 编写于 作者: C chenruilong

新增 设置密码页面

上级 78837301
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view> <view>
<uni-captcha :focus="focusCaptchaInput" ref="captcha" scene="send-sms-code" v-model="captcha" /> <uni-captcha :focus="focusCaptchaInput" ref="captcha" scene="send-sms-code" v-model="captcha" />
<view class="box"> <view class="box">
<uni-easyinput :focus="focusSmsCodeInput" @blur="focusSmsCodeInput = false" type="number" class="input-box" :inputBorder="false" v-model="modelValue" maxlength="6" <uni-easyinput :focus="focusSmsCodeInput" @blur="focusSmsCodeInput = false" type="number" class="input-box" :inputBorder="false" v-model="modelValue" maxlength="6" :clearable="false"
placeholder="请输入短信验证码"> placeholder="请输入短信验证码">
</uni-easyinput> </uni-easyinput>
<view class="short-code-btn" hover-class="hover" @click="start"> <view class="short-code-btn" hover-class="hover" @click="start">
......
<!-- 设置密码 -->
<template>
<view class="uni-content">
<match-media :min-width="690">
<view class="login-logo">
<image :src="logo"></image>
</view>
<!-- 顶部文字 -->
<text class="title title-box ">设置密码</text>
</match-media>
<uni-forms class="set-password-form" ref="form" :value="formData" err-show-type="toast">
<text class="tip">输入密码</text>
<uni-forms-item name="newPassword">
<uni-easyinput :focus="focusNewPassword" @blur="focusNewPassword = false" class="input-box"
type="password" :inputBorder="false" v-model="formData.newPassword" placeholder="请输入密码">
</uni-easyinput>
</uni-forms-item>
<text class="tip">再次输入密码</text>
<uni-forms-item name="newPassword2">
<uni-easyinput :focus="focusNewPassword2" @blur="focusNewPassword2 = false" class="input-box"
type="password" :inputBorder="false" v-model="formData.newPassword2" placeholder="请再次输入新密码">
</uni-easyinput>
</uni-forms-item>
<uni-id-pages-sms-form v-model="formData.code" type="set-pwd-by-sms" ref="smsCode" :phone="userInfo.mobile">
</uni-id-pages-sms-form>
<view class="link-box">
<button class="uni-btn send-btn" type="primary" @click="submit">确认</button>
<button v-if="allowSkip" class="uni-btn send-btn" type="default" @click="skip">跳过</button>
</view>
</uni-forms>
<uni-popup-captcha @confirm="submit" v-model="formData.captcha" scene="set-pwd-by-sms" ref="popup"></uni-popup-captcha>
</view>
</template>
<script>
import passwordMod from '@/uni_modules/uni-id-pages/common/password.js'
import {store, mutations} from '@/uni_modules/uni-id-pages/common/store.js'
import config from '@/uni_modules/uni-id-pages/config.js'
const uniIdCo = uniCloud.importObject("uni-id-co", {
customUI:true
})
export default {
name: "set-pwd.vue",
data () {
return {
uniIdRedirectUrl: '',
loginType: '',
logo: '/static/logo.png',
focusNewPassword: false,
focusNewPassword2: false,
allowSkip: false,
formData: {
code: "",
captcha: "",
newPassword: "",
newPassword2: ""
},
rules: passwordMod.getPwdRules('newPassword', 'newPassword2')
}
},
computed: {
userInfo () {
return store.userInfo
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
onLoad (e) {
this.uniIdRedirectUrl = e.uniIdRedirectUrl
this.loginType = e.loginType
if (config.setPasswordAfterLogin && config.setPasswordAfterLogin?.allowSkip) {
this.allowSkip = true
}
},
methods: {
submit () {
if(! /^\d{6}$/.test(this.formData.code)){
this.$refs.smsCode.focusSmsCodeInput = true
return uni.showToast({
title: '验证码格式不正确',
icon: 'none'
});
}
this.$refs.form.validate()
.then(res => {
uniIdCo.setPwd({
password: this.formData.newPassword,
code: this.formData.code,
captcha: this.formData.captcha
}).then(e => {
uni.showModal({
content: '密码设置成功',
showCancel: false,
success: () => {
mutations.loginBack({
uniIdRedirectUrl: this.uniIdRedirectUrl,
loginType: this.loginType
})
}
});
}).catch(e => {
uni.showModal({
content: e.message,
showCancel: false
});
})
}).catch(e => {
if (e.errCode == 'uni-id-captcha-required') {
this.$refs.popup.open()
} else {
console.log(e.errMsg);
console.log(e.errCode);
}
}).finally(e => {
this.formData.captcha = ''
})
},
skip () {
mutations.loginBack(this.uniIdRedirectUrl)
}
}
}
</script>
<style scoped lang="scss">
@import "@/uni_modules/uni-id-pages/common/login-page.scss";
.uni-btn[type="default"] {
color: inherit!important;
}
.uni-content ::v-deep .uni-forms-item {
margin-bottom: 10px;
}
.popup-captcha {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
padding: 20rpx;
background-color: #FFF;
border-radius: 2px;
flex-direction: column;
position: relative;
}
.popup-captcha .title {
font-weight: normal;
padding: 0;
padding-bottom: 15px;
color: #666;
}
.popup-captcha .close {
position: absolute;
bottom: -40px;
margin-left: -13px;
left: 50%;
}
.popup-captcha .uni-btn {
margin: 0;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册