Browse Source

app新增找回密码功能

娄底高职分支
yxq 9 months ago
parent
commit
93293b53dd
4 changed files with 163 additions and 9 deletions
  1. +2
    -2
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue
  2. +7
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json
  3. +148
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue
  4. +6
    -7
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue

+ 2
- 2
Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue View File

@@ -10,14 +10,14 @@
// H5 刷新时获取当前页面路径
const pagePath = "/" + param.path;
// 如果 H5 刷新后访问的不是首页/登录页/注册页,直接跳转回首页
if (!["/pages/login", "/pages/home","/pages/weixinLogin", "/pages/signup"].includes(pagePath)) {
if (!["/pages/login", "/pages/home","/pages/forgotPassword","/pages/weixinLogin", "/pages/signup"].includes(pagePath)) {
this.$nextTick(() => {
this.TAB_TO("/pages/home");
return;
});
}
// 判断登陆过期
if (!["/pages/login", "/pages/weixinLogin", "/pages/signup"].includes(pagePath)) {
if (!["/pages/login", "/pages/weixinLogin","/pages/forgotPassword", "/pages/signup"].includes(pagePath)) {
this.$nextTick(() => {
let tokenExpireTime = this.GET_STORAGE('tokenExpireTime')
if(!tokenExpireTime||tokenExpireTime<new Date().valueOf()){


+ 7
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json View File

@@ -61,6 +61,13 @@
"disableScroll": true
}
},
{
"path": "pages/forgotPassword",
"style": {
"navigationBarTitleText": "忘记密码",
"disableScroll": true
}
},

// 消息(tabBar #2)
{


+ 148
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue View File

@@ -0,0 +1,148 @@
<template>
<view class="page">
<view class="content" v-if="type == 'sendCode'">
<l-input v-model="phone" placeholder="请输入手机号" left>
<l-icon slot="title" type="phone" />
</l-input>
<view class="btn" @click="sendCode">发送验证码</view>
</view>
<view class="content" v-if="type == 'checkCode'">
<l-input v-model="verifycode" placeholder="请输入验证码" left>
<l-icon slot="title" type="lock" />
</l-input>
<view style="margin-top: 4px;color: color: #606266;">
未收到验证码?<text :style="{color:time==0?'#409EFF':'#999'}" @click="()=>{if(time==0)(type='sendCode')}">重新发送</text>
{{time?'( '+time+ 's'+' )' :''}}
</view>
<view class="btn" @click="checkverifycode">下一步</view>
</view>
<view class="content" v-if="type == 'setPassword'">
<l-input v-model="phone" placeholder="请输入手机号" left disabled>
<l-icon slot="title" type="phone" />
</l-input>
<l-input v-model="form.newpassword" placeholder="请输入新密码" left password>
<l-icon slot="title" type="lock" />
</l-input>
<l-input v-model="form.newpassword1" placeholder="请再次输入新密码" left password>
<l-icon slot="title" type="lock" />
</l-input>
<view class="btn" @click="setPassword">确认修改</view>
</view>
</view>
</template>

<script>
import moment from 'moment';
export default{
data() {
return {
type:'sendCode',
phone:'',
verifycode:'',
time: 0,
timeT: '',
form:{
newpassword:'',
newpassword1:'',
},
}
},
methods:{
// 发送验证码
sendCode(){
if(!this.phone){
this.TOAST('请输入手机号!')
return
}else if(!/^1[0-9]{10}$/.test(this.phone)){
this.TOAST('手机号格式不正确!')
return
}
this.LOADING()
this.HTTP_POST('learun/adms/usernologin/sendcode',{username:this.phone}).then(res=>{
this.HIDE_LOADING()
if(!res){
return
}
this.type = 'checkCode'
this.time = 60
this.timeT = setInterval(() => {
this.time--
if (this.time == 0) {
clearInterval(this.timeT)
this.timeT = ''
return
}
}, 1000);
})
},
// 验证码校验
async checkverifycode() {
if (!this.verifycode) {
this.TOAST('请输入验证码');
return
}
this.LOADING('正在校验...')
let codeResult = await this.POST('learun/adms/user/logincodeverify', {
mobile: this.phone,
verifycode: this.verifycode
})
this.HIDE_LOADING()
if (!codeResult || !codeResult[1] || !codeResult[1].data) {
return
}
if (!codeResult[1].data.code || codeResult[1].data.code != 200) {
this.TOAST(codeResult[1].data.info);
return
}
this.type = 'setPassword'
},
// 设置密码
async setPassword(){
if(!this.form.newpassword){
this.TOAST('请输入新密码');
return
}
if(!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(this.form.newpassword)){
this.TOAST('密码格式不正确,请重新输入');
return
}
if(!this.form.newpassword1){
this.TOAST('请再次输入新密码');
return
}
if(this.form.newpassword != this.form.newpassword1){
this.TOAST('两次密码输入不一致');
return
}
this.LOADING()
let result = await this.POST('learun/adms/user/forgetpass', {
newpassword:this.MD5(this.form.newpassword),
phone:this.phone
}).then(res=>{
this.HIDE_LOADING()
if(!res)return
this.TOAST('修改成功')
setTimeout(()=>{
this.NAV_TO('/pages/login')
},500)
})
}
},
}
</script>

<style scoped>
.page {
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.content{
width: 80%;
padding-bottom: 60px;
}
</style>

+ 6
- 7
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue View File

@@ -45,7 +45,8 @@
block>重新登录</l-button>
<!-- #ifndef APP-PLUS -->
<view class="otherLogin" v-if="!isCode">
<navigator url="/pages/weixinLogin" class="textBtn">微信登录</text></navigator>
<navigator url="/pages/forgotPassword">忘记密码?</text></navigator>
<navigator url="/pages/weixinLogin">微信登录</text></navigator>
</view>
<!-- #endif -->
<!-- <l-button v-if="enableSignUp" @click="signUp" size="lg" line="blue" class="margin-top-sm block" block>
@@ -460,12 +461,10 @@

.otherLogin {
display: flex;
justify-content: flex-end;

.textBtn {
width: 100px;
color: #606266;
}
justify-content: space-between;
margin-top: 4px;
// color: #606266;
color: #2e82ff;
}

.footer {


Loading…
Cancel
Save