提交 be8c2899 编写于 作者: DCloud_JSON's avatar DCloud_JSON

更新重置密码逻辑

上级 276bef28
......@@ -3,5 +3,6 @@ unpackage/
node_modules
.DS_Store
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/config.json
uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json
pages/grid/banner.json
pages/list/list.json
\ No newline at end of file
......@@ -16,9 +16,9 @@ export default function request(name,params,callback=false,{showLoading=false,lo
name = routers[0]
action = routers[1]
}
console.log({name,data: {action,params}})
console.log({name,data:{action,params}})
return new Promise((resolve,reject)=>{
uniCloud.callFunction({name,data: {action,params},
uniCloud.callFunction({name,data:{action,params},
success(e){
// console.log(e);
const {result:{data,code}} = e
......
{
"name": "uni-config-center",
"version": "0.0.1",
"version": "0.0.2",
"description": "配置中心",
"main": "index.js",
"keywords": [],
"author": "fxy060608",
"author": "DCloud",
"license": "Apache-2.0"
}
\ No newline at end of file
## 3.1.0(2021-04-19)
- 增加对用户名、邮箱、密码字段的两端去空格
- 默认忽略用户名、邮箱的大小写 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=case-sensitive)
- 修复 customToken导出async方法报错的Bug
## 3.0.12(2021-04-13)
- 调整bindTokenToDevice默认值为false
## 3.0.11(2021-04-12)
......
{
"id": "uni-id",
"displayName": "uni-id",
"version": "3.0.12",
"version": "3.1.0",
"description": "简单、统一、可扩展的用户中心",
"keywords": [
"uniid",
......
{
"name": "uni-id",
"version": "3.0.12",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"dependencies": {
"uni-config-center": {
"version": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
"packages": {
"": {
"version": "3.0.12",
"license": "Apache-2.0"
}
}
}
......@@ -46,7 +46,7 @@
computed: {
innerText() {
if (this.reverseNumber == 0) return '获取验证码';
return this.reverseNumber;
return '重新发送('+this.reverseNumber+'s)';
}
},
created() {
......@@ -136,11 +136,10 @@
justify-content: center;
align-items: center;
}
.inner-text {
font-size: 28rpx;
color: #AAAAAA;
}
.inner-text-active {
color: #007aff;
}
......
......@@ -9,7 +9,7 @@
<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.phone" placeholder="请输入手机号"></uni-easyinput>
v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput>
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
......@@ -20,7 +20,7 @@
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="checkCode(submit)">完成</button>
@click="submit">完成</button>
</uni-forms>
</view>
</view>
......@@ -33,7 +33,7 @@ import mixin from '../../common/loginPage.mixin.js';
mixins:[mixin],
data() {
return {
currenPhoneArea: '',
currenPhoneArea: ''
}
},
computed: {
......@@ -56,92 +56,23 @@ import mixin from '../../common/loginPage.mixin.js';
}
},
methods: {
checkCode(callback){
uniCloud.callFunction({//联网验证登陆
"name": "user-center",
"data": {
"action": "loginBySms",
"params":{
"mobile":this.formData.phone,
"code":this.formData.code
}
},
success:async (e) => {
uni.hideLoading()
console.log(e.result);
if(e.result.code === 0){
uni.setStorageSync('uni_id_uid', e.result.uid)
uni.setStorageSync('uni_id_token', e.result.token)
uni.setStorageSync('uni_id_token_expired', e.result.tokenExpired)
// uni.showToast({
// title: '登陆成功',
// icon: 'none'
// });
callback()
}else{
uni.showModal({
title: '错误',
content: e.result.msg,
showCancel: false,
confirmText: '知道了',
});
}
},
fail: (err) => {
console.log(err);
uni.showModal({
title: '错误',
content: JSON.stringify(err),
showCancel: false,
confirmText: '知道了',
});
if(err.errCode===30002){
}
},
complete: () => {
uni.hideLoading()
}
})
},
/**
* 完成并提交
*/
submit(){
uniCloud.callFunction({
name:"user-center",
"data":{
"action":"resetPwd",
"params":{
this.request('user-center/resetPwdBySmsCode',{
"mobile":this.formData.phone,
"code":this.formData.code,
"password":this.formData.pwd
}
},
success:async (e) => {
uni.hideLoading()
console.log(e.result);
},(data,result)=>{
console.log(result);
uni.showToast({
title: e.result.msg,
title: result.msg,
icon: 'none'
});
if(e.result.code === 0){
if(result.code === 0){
uni.navigateBack()
}
},
fail: (err) => {
console.log(err);
uni.showModal({
title: '错误',
content: JSON.stringify(err),
showCancel: false,
confirmText: '知道了',
});
if(err.errCode===30002){
}
},
complete: () => {
uni.hideLoading()
}
})
}
}
......
......@@ -36,7 +36,7 @@ exports.main = async (event, context) => {
let noCheckAction = [
'register', 'checkToken','login', 'logout', 'sendSmsCode',
'createCaptcha', 'verifyCaptcha','refreshCaptcha', 'inviteLogin',
'login_by_weixin','login_by_univerify','login_by_apple','loginBySms'
'login_by_weixin','login_by_univerify','login_by_apple','loginBySms','resetPwdBySmsCode'
]
let payload;
console.log(event.action);
......@@ -83,7 +83,7 @@ exports.main = async (event, context) => {
let res = {}
switch (event.action) {
case 'register':
let {username,password,gender,nickname,password} = params
let {username,password,gender,nickname} = params
if(/^1\d{10}$/.test(username)){
return {
code: 401,
......@@ -196,6 +196,27 @@ exports.main = async (event, context) => {
type: 'register'
})
break;
case 'resetPwdBySmsCode':
if (!params.code) {
return {
code: 500,
msg: '请填写验证码'
}
}
if (!/^1\d{10}$/.test(params.mobile)) {
return {
code: 500,
msg: '手机号码填写错误'
}
}
let loginBySmsRes = await uniID.loginBySms(params)
console.log(loginBySmsRes);
if(loginBySmsRes.code === 0){
res = await uniID.resetPwd({password:params.password,"uid":loginBySmsRes.uid})
}else{
return loginBySmsRes
}
break;
case 'getInviteCode':
res = await uniID.getUserInfo({
uid: params.uid,
......@@ -221,9 +242,6 @@ exports.main = async (event, context) => {
case 'refreshCaptcha':
res = await uniCaptcha.refresh(params)
break;
case 'resetPwd':
res = await uniID.resetPwd({...params,"uid":payload.uid})
break;
default:
res = {
code: 403,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册