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

更新重置密码逻辑

上级 276bef28
...@@ -3,5 +3,6 @@ unpackage/ ...@@ -3,5 +3,6 @@ unpackage/
node_modules node_modules
.DS_Store .DS_Store
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/config.json 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/grid/banner.json
pages/list/list.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 ...@@ -16,9 +16,9 @@ export default function request(name,params,callback=false,{showLoading=false,lo
name = routers[0] name = routers[0]
action = routers[1] action = routers[1]
} }
console.log({name,data: {action,params}}) console.log({name,data:{action,params}})
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
uniCloud.callFunction({name,data: {action,params}, uniCloud.callFunction({name,data:{action,params},
success(e){ success(e){
// console.log(e); // console.log(e);
const {result:{data,code}} = e const {result:{data,code}} = e
......
{ {
"name": "uni-config-center", "name": "uni-config-center",
"version": "0.0.1", "version": "0.0.2",
"description": "配置中心", "description": "配置中心",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
"author": "fxy060608", "author": "DCloud",
"license": "Apache-2.0" "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) ## 3.0.12(2021-04-13)
- 调整bindTokenToDevice默认值为false - 调整bindTokenToDevice默认值为false
## 3.0.11(2021-04-12) ## 3.0.11(2021-04-12)
......
{ {
"id": "uni-id", "id": "uni-id",
"displayName": "uni-id", "displayName": "uni-id",
"version": "3.0.12", "version": "3.1.0",
"description": "简单、统一、可扩展的用户中心", "description": "简单、统一、可扩展的用户中心",
"keywords": [ "keywords": [
"uniid", "uniid",
......
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.0.12", "version": "3.0.12",
"lockfileVersion": 1, "lockfileVersion": 2,
"requires": true, "requires": true,
"dependencies": { "packages": {
"uni-config-center": { "": {
"version": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" "version": "3.0.12",
"license": "Apache-2.0"
} }
} }
} }
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
computed: { computed: {
innerText() { innerText() {
if (this.reverseNumber == 0) return '获取验证码'; if (this.reverseNumber == 0) return '获取验证码';
return this.reverseNumber; return '重新发送('+this.reverseNumber+'s)';
} }
}, },
created() { created() {
...@@ -136,11 +136,10 @@ ...@@ -136,11 +136,10 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.inner-text {
.inner-text { font-size: 28rpx;
font-size: 28rpx; color: #AAAAAA;
} }
.inner-text-active { .inner-text-active {
color: #007aff; color: #007aff;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<uni-forms ref="form" :value="formData" :rules="rules"> <uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone"> <uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false" <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" <uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码"> v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right"> <template slot="right">
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput> v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'" <button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="checkCode(submit)">完成</button> @click="submit">完成</button>
</uni-forms> </uni-forms>
</view> </view>
</view> </view>
...@@ -33,7 +33,7 @@ import mixin from '../../common/loginPage.mixin.js'; ...@@ -33,7 +33,7 @@ import mixin from '../../common/loginPage.mixin.js';
mixins:[mixin], mixins:[mixin],
data() { data() {
return { return {
currenPhoneArea: '', currenPhoneArea: ''
} }
}, },
computed: { computed: {
...@@ -56,91 +56,22 @@ import mixin from '../../common/loginPage.mixin.js'; ...@@ -56,91 +56,22 @@ import mixin from '../../common/loginPage.mixin.js';
} }
}, },
methods: { 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(){ submit(){
uniCloud.callFunction({ this.request('user-center/resetPwdBySmsCode',{
name:"user-center", "mobile":this.formData.phone,
"data":{ "code":this.formData.code,
"action":"resetPwd", "password":this.formData.pwd
"params":{ },(data,result)=>{
"password":this.formData.pwd console.log(result);
} uni.showToast({
}, title: result.msg,
success:async (e) => { icon: 'none'
uni.hideLoading() });
console.log(e.result); if(result.code === 0){
uni.showToast({ uni.navigateBack()
title: e.result.msg,
icon: 'none'
});
if(e.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) => { ...@@ -36,7 +36,7 @@ exports.main = async (event, context) => {
let noCheckAction = [ let noCheckAction = [
'register', 'checkToken','login', 'logout', 'sendSmsCode', 'register', 'checkToken','login', 'logout', 'sendSmsCode',
'createCaptcha', 'verifyCaptcha','refreshCaptcha', 'inviteLogin', '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; let payload;
console.log(event.action); console.log(event.action);
...@@ -83,7 +83,7 @@ exports.main = async (event, context) => { ...@@ -83,7 +83,7 @@ exports.main = async (event, context) => {
let res = {} let res = {}
switch (event.action) { switch (event.action) {
case 'register': case 'register':
let {username,password,gender,nickname,password} = params let {username,password,gender,nickname} = params
if(/^1\d{10}$/.test(username)){ if(/^1\d{10}$/.test(username)){
return { return {
code: 401, code: 401,
...@@ -195,6 +195,27 @@ exports.main = async (event, context) => { ...@@ -195,6 +195,27 @@ exports.main = async (event, context) => {
...params, ...params,
type: 'register' 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; break;
case 'getInviteCode': case 'getInviteCode':
res = await uniID.getUserInfo({ res = await uniID.getUserInfo({
...@@ -221,9 +242,6 @@ exports.main = async (event, context) => { ...@@ -221,9 +242,6 @@ exports.main = async (event, context) => {
case 'refreshCaptcha': case 'refreshCaptcha':
res = await uniCaptcha.refresh(params) res = await uniCaptcha.refresh(params)
break; break;
case 'resetPwd':
res = await uniID.resetPwd({...params,"uid":payload.uid})
break;
default: default:
res = { res = {
code: 403, code: 403,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册