Browse Source

重置密码

master
453530270@qq.com 2 years ago
parent
commit
7e0a9eef82
  1. 7
      api/user.js
  2. 434
      pages/findpass/findpass.vue
  3. 11
      pages/reg/reg.vue

7
api/user.js

@ -8,6 +8,8 @@ const api = {
personal: 'user/personal', personal: 'user/personal',
// 操作日志 // 操作日志
oplogs: "slb/userself/v1/account/operation", oplogs: "slb/userself/v1/account/operation",
//重置密码
resetpwd:'slb/userself/v1/account/reset-pwd',
} }
// 当前登录的用户信息 // 当前登录的用户信息
@ -38,4 +40,9 @@ export const personal = (data, option) => {
// 操作日志 // 操作日志
export const oplogs = (param, option) => { export const oplogs = (param, option) => {
return request.get(api.oplogs, param, option) return request.get(api.oplogs, param, option)
}
// 重置用户密码
export const resetpass = (data,option) =>{
return request.post(api.resetpwd,data,option)
} }

434
pages/findpass/findpass.vue

@ -2,39 +2,42 @@
<view class="container"> <view class="container">
<!-- 页面头部 --> <!-- 页面头部 -->
<view class="header"> <view class="header">
<view class="title"> <view class="title">
<text>找回密码</text> <text>找回密码</text>
</view> </view>
</view> </view>
<!-- 表单 --> <!-- 表单 -->
<view class="login-form"> <view class="login-form">
<form> <form>
<!-- 手机号 --> <!-- 手机号 -->
<view class="form-item"> <view class="form-item">
<input class="form-item--input" type="number" v-model="mobile" maxlength="11" autocomplete="off" placeholder="输入手机号码" <input class="form-item--input" type="number" v-model="mobile" maxlength="11" autocomplete="off"
@input="onInputStepper($event, item)"/> placeholder="输入手机号码" @input="onInputStepper($event, item)" />
</view> </view>
<!-- 验证码 --> <!-- 验证码 -->
<view class="form-item"> <view class="form-item">
<input class="form-item--input" type="number" v-model="chkcode" maxlength="11" autocomplete="off" placeholder="输入6位验证码" /> <input class="form-item--input" type="number" v-model="chkcode" maxlength="11" autocomplete="off"
<button class="abtn" href="" @click="getsmscode" ref="abtn">获取验证码 </button> placeholder="输入6位验证码" />
</view> <button class="abtn" href="" @click="getsmscode" ref="abtn">获取验证码 </button>
<!-- 密码 --> </view>
<view class="form-item"> <!-- 密码 -->
<input class="form-item--input" type="password" v-model="vpass" autocomplete="off" placeholder="请输入密码" /> <view class="form-item">
</view> <input class="form-item--input" type="password" v-model="vpass" autocomplete="off"
<!-- 重复密码 --> placeholder="请输入密码" />
<view class="form-item"> </view>
<input class="form-item--input" type="password" v-model="repass" autocomplete="off" placeholder="再次请输入密码" /> <!-- 重复密码 -->
</view> <view class="form-item">
<input class="form-item--input" type="password" v-model="repass" autocomplete="off"
<!-- 登录按钮 --> placeholder="再次请输入密码" />
<view class="login-button" @click="handleLogin"> </view>
<text>确认修改</text>
</view> <!-- 登录按钮 -->
</form> <view class="login-button" @click="handleRestpass">
<text>确认修改</text>
</view>
</form>
</view> </view>
<!-- 找回密码 注册 --> <!-- 找回密码 注册 -->
<view class="regtips"> <view class="regtips">
<view>已拥有账户?<a class="loginnow" @tap="gologin">登录</a></view> <view>已拥有账户?<a class="loginnow" @tap="gologin">登录</a></view>
@ -43,118 +46,289 @@
</template> </template>
<script> <script>
import * as regApi from '@/api/reg/index'
import * as Verify from '@/utils/verify'
import * as userApi from '@/api/user'
export default { export default {
data() { data() {
return { return {
//
mobile: '',
//
chkcode: '',
//
vpass: '',
//
repass: '',
} }
}, },
methods: { methods: {
//
getsmscode() {
//
let mb = this.mobile
if (this.validteMobile(mb) && this.isCutdown != true) {
//
regApi.sendSms(mb).then(res => {
if (res.resultCode == "00000000") {
if (res.data != 1) {
this.$toast("手机号没有被注册")
this.st = 60
} else { //
//
let pars = {
username: mb,
purpose: 2
}
regApi.sendVerifyCode(pars).then(res => {
// console.log("verify code",res)
if (res.resultCode === "00000000") {
//
this.countDown()
this.$toast("发送成功")
} else {
this.$error(res.resultMsg)
}
})
}
//
}
console.log(res)
});
}
},
//
countDown() {
let app = this
app.$refs.abtn.$el.innerText = app.st + "秒"
let qq = app.st
// console.log(qq)
setTimeout(function() {
if (app.st > 1) {
app.st--
app.countDown(app.st)
//ing
app.isCutdown = true
} else {
app.st = 0
app.$refs.abtn.$el.innerText = "获取验证码"
}
}, 1000)
},
//
formValidation() {
const app = this
//
if (!app.validteMobile(app.mobile) || !app.validtePass(app.vpass) || !app.validteRepass(app.repass)
|| !app.chkpass() || !app.validteVerify(
app.chkcode)) {
return false
}
return true
},
//
validtePass(str) {
if (Verify.isEmpty(str)) {
this.$toast('请先输入登录密码')
return false
}
return true;
},
//
validteRepass(str){
if(Verify.isEmpty(str)){
this.$toast("请再次输入密码")
return false
}
return true
},
//
chkpass() {
let that = this
if (that.vpass != that.repass) {
this.$toast('两次输入的密码不一样')
return false
}
return true;
},
//
validteMobile(str) {
//
if (Verify.isEmpty(str)) {
this.$toast('请先输入手机号')
return false
}
if (!Verify.isMobile(str)) {
this.$toast("输入正确格式手机号码")
return false
}
return true
},
//
validteVerify(str) {
if (Verify.isEmpty(str)) {
this.$toast("请输入手机验证码")
}
if (str.length != 6) {
this.$toast("请输入6位数的验证码")
}
return true
},
//
async handleRestpass() {
const app = this
if (!app.isLoading && app.formValidation()) {
await app.submitReset()
}
},
//
submitReset() {
let app = this
// doreset
let data = {
accountId: app.mobile,
verifyCode: app.chkcode,
password: $.md5(app.vpass).toUpperCase(),
passMd5ed: true,
st: "2",
}
userApi.resetpass(data).then(res=>{
if(res.resultCode === "00000000"){
app.$toast("重置成功")
//
setTimeout(() => app.onNavigateBack(1), 2000)
}else{
app.$toast(res.resultMsg)
}
});
},
/**
* 跳转回原页面
*/
onNavigateBack(delta = 1) {
const pages = getCurrentPages()
if (pages.length > 1) {
uni.navigateBack({
delta: Number(delta || 1)
})
} else {
this.$navTo('pages/index/index')
}
},
// //
gologin(){ gologin() {
this.$navTo("pages/login/index") this.$navTo("pages/login/index")
}, },
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
padding: 100rpx 60rpx; padding: 100rpx 60rpx;
min-height: 100vh; min-height: 100vh;
background-color: #fff; background-color: #fff;
} }
// //
.header { .header {
margin-bottom: 60rpx; margin-bottom: 60rpx;
.title { .title {
color: #191919; color: #191919;
font-size: 54rpx; font-size: 54rpx;
} }
} }
//
.form-item { //
display: flex; .form-item {
padding: 18rpx; display: flex;
border-bottom: 1rpx solid #f3f1f2; padding: 18rpx;
margin-bottom: 30rpx; border-bottom: 1rpx solid #f3f1f2;
height: 96rpx; margin-bottom: 30rpx;
height: 96rpx;
&--input {
font-size: 28rpx; &--input {
letter-spacing: 1rpx; font-size: 28rpx;
flex: 1; letter-spacing: 1rpx;
height: 100%; flex: 1;
} height: 100%;
}
&--parts {
min-width: 100rpx; &--parts {
height: 100%; min-width: 100rpx;
} height: 100%;
}
&--radgrp{
display: flex; &--radgrp {
flex:1; display: flex;
height: 100%; flex: 1;
} height: 100%;
}
.abtn{
font-size: 26rpx; .abtn {
} font-size: 26rpx;
}
//
.captcha-sms { //
font-size: 28rpx; .captcha-sms {
line-height: 50rpx; font-size: 28rpx;
padding-right: 20rpx; line-height: 50rpx;
padding-right: 20rpx;
.activate {
color: #cea26a; .activate {
} color: #cea26a;
}
.un-activate {
color: #9e9e9e; .un-activate {
} color: #9e9e9e;
} }
} }
}
//
.login-button { //
width: 100%; .login-button {
height: 86rpx; width: 100%;
margin-top: 80rpx; height: 86rpx;
background: linear-gradient(to right, #242e4b, #242e4b); margin-top: 80rpx;
color: #fff; background: linear-gradient(to right, #242e4b, #242e4b);
// border-radius: 80rpx; color: #fff;
box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.1); // border-radius: 80rpx;
letter-spacing: 15rpx; box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.1);
display: flex; letter-spacing: 15rpx;
justify-content: center; display: flex;
align-items: center; justify-content: center;
} align-items: center;
// }
.regtips{
display: flex; //
margin-top: 26rpx; .regtips {
line-height: 1.4; display: flex;
padding-right: 32rpx; margin-top: 26rpx;
line-height: 1.4;
.loginnow{ padding-right: 32rpx;
color: #5299dc;
.loginnow {
&:hover{ color: #5299dc;
color: #a60000;
} &:hover {
} color: #a60000;
}
}
}
</style> }
</style>

11
pages/reg/reg.vue

@ -38,7 +38,7 @@
</view> </view>
<!-- 登录按钮 --> <!-- 登录按钮 -->
<view class="login-button" @click="debounce(handleReg,500)"> <view class="login-button" @click="handleReg">
<text>注册</text> <text>注册</text>
</view> </view>
</form> </form>
@ -46,7 +46,7 @@
<!-- 找回密码 注册 --> <!-- 找回密码 注册 -->
<view class="regtips"> <view class="regtips">
<view>已拥有账户?<a class="loginnow" @tap="debounce(gologin,500)">登录</a></view> <view>已拥有账户?<a class="loginnow" @tap="gologin">登录</a></view>
</view> </view>
<!-- 弹框 --> <!-- 弹框 -->
@ -58,7 +58,6 @@
</template> </template>
<script> <script>
import { inArray, debounce } from '@/utils/util'
import store from '@/store' import store from '@/store'
import * as regApi from '@/api/reg/index' import * as regApi from '@/api/reg/index'
import * as Verify from '@/utils/verify' import * as Verify from '@/utils/verify'
@ -66,8 +65,6 @@
export default { export default {
components: { components: {
// nothing
// "popup":Popup,
whpop whpop
}, },
@ -190,7 +187,7 @@
this.$toast('两次输入的密码不一样') this.$toast('两次输入的密码不一样')
return false return false
} }
return ture; return true;
}, },
// //
@ -241,7 +238,7 @@
regApi.doreg(rdata,{isLoading:true}) regApi.doreg(rdata,{isLoading:true})
.then(res=>{ .then(res=>{
if(res.resultCode === "00000000"){ if(res.resultCode === "00000000"){
app.$toast(result.message) app.$toast("注册成功")
// //
setTimeout(() => app.onNavigateBack(1), 2000) setTimeout(() => app.onNavigateBack(1), 2000)
} }

Loading…
Cancel
Save