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

修复已知问题

上级 e08be6a1
## 1.0.12(2022-09-07)
- 优化 适配pc端样式
- 新增 邮箱验证码注册
- 新增 邮箱验证码找回密码
## 1.0.11(2022-09-01)
- 修复 iOS端,一键登录功能卡在showLoading的问题
- 更新 合并密码强度与长度配置 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#config)
- uni-id-co 修复 调用 removeAuthorizedApp 接口报错的Bug
- uni-id-co 新增 管理端接口 updateUser [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#update-user)
- uni-id-co 调整 为兼容旧版本,未配置密码强度时提供最简单的密码规则校验(长度大于6即可)
- uni-id-co 调整 注册、登录时如果携带了token则尝试对此token进行登出操作
- uni-id-co 调整 管理端接口 addUser 增加 mobile、email等参数 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#add-user)
## 1.0.10(2022-08-25) ## 1.0.10(2022-08-25)
- 修复 导入uni-id-pages插件时未自动导入uni-open-bridge-common的Bug - 修复 导入uni-id-pages插件时未自动导入uni-open-bridge-common的Bug
## 1.0.9(2022-08-23) ## 1.0.9(2022-08-23)
......
// 导入配置 // 导入配置
import config from '@/uni_modules/uni-id-pages/config.js' import config from '@/uni_modules/uni-id-pages/config.js'
const passwordLength = config.password.length const {passwordStrength} = config
const passwordStrength = config.password.strength
let minPasswordLength = 6
let maxPasswordLength = 20
if (passwordLength) {
if (passwordLength[0]) {
minPasswordLength = passwordLength[0]
}
if (passwordLength[1]) {
maxPasswordLength = passwordLength[1]
}
}
// 密码强度表达式 // 密码强度表达式
const passwordRules = { const passwordRules = {
// 密码必须包含大小写字母、数字和特殊符号 // 密码必须包含大小写字母、数字和特殊符号
...@@ -37,11 +26,6 @@ const ERROR = { ...@@ -37,11 +26,6 @@ const ERROR = {
strong: '密码必须包含字母、数字和特殊符号,密码长度必须在8-16位之间', strong: '密码必须包含字母、数字和特殊符号,密码长度必须在8-16位之间',
medium: '密码必须为字母、数字和特殊符号任意两种的组合,密码长度必须在8-16位之间', medium: '密码必须为字母、数字和特殊符号任意两种的组合,密码长度必须在8-16位之间',
weak: '密码必须包含字母,密码长度必须在6-16位之间' weak: '密码必须包含字母,密码长度必须在6-16位之间'
},
passwordLengthError: {
normal: '密码长度必须在' + minPasswordLength + '-' + maxPasswordLength + '位之间',
minLimit: '密码长度不得少于' + minPasswordLength + '',
maxLimit: '密码长度不得超过' + maxPasswordLength + ''
} }
} }
...@@ -52,16 +36,6 @@ function validPwd(password) { ...@@ -52,16 +36,6 @@ function validPwd(password) {
return ERROR.passwordStrengthError[passwordStrength] return ERROR.passwordStrengthError[passwordStrength]
} }
} }
//长度校验
if (passwordLength) {
if (passwordLength[0] && password.length < passwordLength[0]) {
return ERROR.passwordLengthError.minLimit
}
if (passwordLength[1] && password.length > passwordLength[1]) {
return ERROR.passwordLengthError.maxLimit
}
}
return true return true
} }
...@@ -106,8 +80,6 @@ function getPwdRules(pwdName = 'password', rePwdName = 'password2') { ...@@ -106,8 +80,6 @@ function getPwdRules(pwdName = 'password', rePwdName = 'password2') {
export default { export default {
ERROR, ERROR,
minPasswordLength,
maxPasswordLength,
validPwd, validPwd,
getPwdRules getPwdRules
} }
export default { export default {
//调试模式 //调试模式
"debug": true, "debug": false,
/* /*
登录类型 未列举到的或运行环境不支持的,将被自动隐藏。 登录类型 未列举到的或运行环境不支持的,将被自动隐藏。
如果需要在不同平台有不同的配置,直接用条件编译即可 如果需要在不同平台有不同的配置,直接用条件编译即可
...@@ -43,16 +43,13 @@ export default { ...@@ -43,16 +43,13 @@ export default {
"web": "xxxxxx" "web": "xxxxxx"
} }
}, },
/** /**
* 密码强度 * 密码强度
* super(超强:密码必须包含大小写字母、数字和特殊符号) * super(超强:密码必须包含大小写字母、数字和特殊符号,长度范围:8-16位之间)
* strong(强: 密码必须包含字母、数字和特殊符号) * strong(强: 密密码必须包含字母、数字和特殊符号,长度范围:8-16位之间)
* medium (中:密码必须为字母、数字和特殊符号任意两种的组合) * medium (中:密码必须为字母、数字和特殊符号任意两种的组合,长度范围:8-16位之间)
* weak(弱:密码必须包含字母) * weak(弱:密码必须包含字母和数字,长度范围:6-16位之间)
* 为空或false则不验证密码强度 * 为空或false则不验证密码强度
*/ */
"password": { "passwordStrength":"medium"
"strength": "medium",
"length": [6, 20] //密码长度,默认在6-20位之间
}
} }
...@@ -190,6 +190,9 @@ ...@@ -190,6 +190,9 @@
.quickLoginBtn { .quickLoginBtn {
margin: 20px 0; margin: 20px 0;
width: 450rpx; width: 450rpx;
/* #ifndef APP-NVUE */
max-width: 230px;
/* #endif */
height: 82rpx; height: 82rpx;
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="password" v-model="formData.password" required> <uni-forms-item name="password" v-model="formData.password" required>
<uni-easyinput :inputBorder="false" :focus="focusPassword" @blur="focusPassword = false" <uni-easyinput :inputBorder="false" :focus="focusPassword" @blur="focusPassword = false"
class="input-box" maxlength="20" :placeholder="'请输入' + passwordLength[0] + '-' + passwordLength[1] + '位密码'" type="password" class="input-box" maxlength="20" :placeholder="'请输入' + (config.passwordStrength == 'weak'?'6':'8') + '-16位密码'" type="password"
v-model="formData.password" trim="both" /> v-model="formData.password" trim="both" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="password2" v-model="formData.password2" required> <uni-forms-item name="password2" v-model="formData.password2" required>
...@@ -116,11 +116,6 @@ ...@@ -116,11 +116,6 @@
logo: "/static/logo.png" logo: "/static/logo.png"
} }
}, },
computed:{
passwordLength(){
return config.password.length
}
},
onReady() { onReady() {
this.$refs.form.setRules(this.rules) this.$refs.form.setRules(this.rules)
}, },
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="password" v-model="formData.password" required> <uni-forms-item name="password" v-model="formData.password" required>
<uni-easyinput :inputBorder="false" :focus="focusPassword" @blur="focusPassword = false" <uni-easyinput :inputBorder="false" :focus="focusPassword" @blur="focusPassword = false"
class="input-box" maxlength="20" :placeholder="'请输入' + passwordLength[0] + '-' + passwordLength[1] + '位密码'" type="password" class="input-box" maxlength="20" :placeholder="'请输入' + (config.passwordStrength == 'weak'?'6':'8') + '-16位密码'" type="password"
v-model="formData.password" trim="both" /> v-model="formData.password" trim="both" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="password2" v-model="formData.password2" required> <uni-forms-item name="password2" v-model="formData.password2" required>
...@@ -67,11 +67,6 @@ ...@@ -67,11 +67,6 @@
logo: "/static/logo.png" logo: "/static/logo.png"
} }
}, },
computed:{
passwordLength(){
return config.password.length
}
},
onReady() { onReady() {
this.$refs.form.setRules(this.rules) this.$refs.form.setRules(this.rules)
}, },
......
<!-- 用户资料页 --> <!-- 用户资料页 -->
<template> <template>
<view class="uni-content"> <view class="uni-content">
<view class="avatar"> <view class="avatar">
<uni-id-pages-avatar width="260rpx" height="260rpx"></uni-id-pages-avatar> <uni-id-pages-avatar width="260rpx" height="260rpx"></uni-id-pages-avatar>
</view> </view>
<uni-list> <uni-list>
<uni-list-item class="item" @click="setNickname('')" title="昵称" :rightText="userInfo.nickname||'未设置'" link> <uni-list-item class="item" @click="setNickname('')" title="昵称" :rightText="userInfo.nickname||'未设置'" link>
</uni-list-item> </uni-list-item>
<uni-list-item class="item" @click="bindMobile" title="手机号" :rightText="userInfo.mobile||'未绑定'" link> <uni-list-item class="item" @click="bindMobile" title="手机号" :rightText="userInfo.mobile||'未绑定'" link>
</uni-list-item> </uni-list-item>
<uni-list-item v-if="hasPwd" class="item" @click="changePassword" title="修改密码" link> <uni-list-item v-if="hasPwd" class="item" @click="changePassword" title="修改密码" link>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
<uni-list class="mt10"> <uni-list class="mt10">
<uni-list-item @click="deactivate" title="注销账号" link="navigateTo"></uni-list-item> <uni-list-item @click="deactivate" title="注销账号" link="navigateTo"></uni-list-item>
</uni-list> </uni-list>
<uni-popup ref="dialog" type="dialog"> <uni-popup ref="dialog" type="dialog">
<uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" title="设置昵称" <uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" title="设置昵称"
placeholder="请输入要设置的昵称"> placeholder="请输入要设置的昵称">
</uni-popup-dialog> </uni-popup-dialog>
</uni-popup> </uni-popup>
<uni-id-pages-bind-mobile ref="bind-mobile-by-sms" @success="getUserInfo"></uni-id-pages-bind-mobile> <uni-id-pages-bind-mobile ref="bind-mobile-by-sms" @success="getUserInfo"></uni-id-pages-bind-mobile>
<button v-if="hasLogin" @click="logout">退出登录</button> <button v-if="hasLogin" @click="logout">退出登录</button>
<button v-else @click="login">去登录</button> <button v-else @click="login">去登录</button>
</view> </view>
</template> </template>
<script> <script>
const db = uniCloud.database(); const db = uniCloud.database();
const usersTable = db.collection('uni-id-users') const usersTable = db.collection('uni-id-users')
const uniIdCo = uniCloud.importObject("uni-id-co") const uniIdCo = uniCloud.importObject("uni-id-co")
export default { export default {
data() { data() {
return { return {
univerifyStyle: { univerifyStyle: {
authButton: { authButton: {
"title": "本机号码一键绑定", // 授权按钮文案 "title": "本机号码一键绑定", // 授权按钮文案
}, },
otherLoginButton: { otherLoginButton: {
"title": "其他号码绑定", "title": "其他号码绑定",
} }
}, },
userInfo: { userInfo: {
mobile:'', mobile:'',
nickname:'' nickname:''
}, },
hasLogin: false, hasLogin: false,
hasPwd:false hasPwd:false
} }
}, },
async onShow() { async onShow() {
this.univerifyStyle.authButton.title = "本机号码一键绑定" this.univerifyStyle.authButton.title = "本机号码一键绑定"
this.univerifyStyle.otherLoginButton.title = "其他号码绑定" this.univerifyStyle.otherLoginButton.title = "其他号码绑定"
}, },
async onLoad() { async onLoad() {
this.getUserInfo() this.getUserInfo()
//判断当前用户是否有密码,否则就不显示密码修改功能 //判断当前用户是否有密码,否则就不显示密码修改功能
let res = await uniIdCo.getAccountInfo() let res = await uniIdCo.getAccountInfo()
this.hasPwd = res.isPasswordSet this.hasPwd = res.isPasswordSet
}, },
methods: { methods: {
login() { login() {
uni.navigateTo({ uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd', url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
complete: (e) => { complete: (e) => {
console.log(e); console.log(e);
} }
}) })
}, },
async logout() { async logout() {
await uniIdCo.logout() await uniIdCo.logout()
uni.removeStorageSync('uni_id_token'); uni.removeStorageSync('uni_id_token');
uni.setStorageSync('uni_id_token_expired', 0) uni.setStorageSync('uni_id_token_expired', 0)
uni.redirectTo({ uni.redirectTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd', url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
}); });
}, },
changePassword(){ changePassword(){
uni.navigateTo({ uni.navigateTo({
...@@ -82,165 +82,155 @@ ...@@ -82,165 +82,155 @@
console.log(e); console.log(e);
} }
}) })
}, },
getUserInfo(e) { getUserInfo(e) {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
usersTable.where("'_id' == $cloudEnv_uid").field('mobile,nickname').get().then(res => { usersTable.where("'_id' == $cloudEnv_uid").field('mobile,nickname').get().then(res => {
console.log({res}); console.log({res});
this.userInfo = res.result.data[0] this.userInfo = res.result.data[0]
console.log('this.userInfo', this.userInfo); console.log('this.userInfo', this.userInfo);
this.hasLogin = true this.hasLogin = true
}).catch(e => { }).catch(e => {
this.userInfo = {} this.userInfo = {}
this.hasLogin = false this.hasLogin = false
console.log(e.message, e.errCode); console.log(e.message, e.errCode);
}).finally(e => { }).finally(e => {
// console.log(e); // console.log(e);
uni.hideLoading() uni.hideLoading()
}) })
}, },
bindMobile() { bindMobile() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.preLogin({ uni.preLogin({
provider: 'univerify', provider: 'univerify',
success: this.univerify(), //预登录成功 success: this.univerify(), //预登录成功
fail: (res) => { // 预登录失败 fail: (res) => { // 预登录失败
// 不显示一键登录选项(或置灰) // 不显示一键登录选项(或置灰)
console.log(res) console.log(res)
this.bindMobileBySmsCode() this.bindMobileBySmsCode()
} }
}) })
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
this.$refs['bind-mobile'].open() this.$refs['bind-mobile'].open()
// #endif // #endif
// #ifdef H5 // #ifdef H5
//...去用验证码绑定 //...去用验证码绑定
this.bindMobileBySmsCode() this.bindMobileBySmsCode()
// #endif // #endif
}, },
univerify() { univerify() {
uni.login({ uni.login({
"provider": 'univerify', "provider": 'univerify',
"univerifyStyle": this.univerifyStyle, "univerifyStyle": this.univerifyStyle,
success: async e => { success: async e => {
console.log(e.authResult); console.log(e.authResult);
uniIdCo.bindMobileByUniverify(e.authResult).then(res => { uniIdCo.bindMobileByUniverify(e.authResult).then(res => {
console.log(res); console.log(res);
this.getUserInfo() this.getUserInfo()
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
}).finally(e=>{ }).finally(e=>{
console.log(e); console.log(e);
uni.closeAuthView() uni.closeAuthView()
}) })
}, },
fail: (err) => { fail: (err) => {
console.log(err); console.log(err);
if (err.code == '30002' || err.code == '30001') { if (err.code == '30002' || err.code == '30001') {
this.bindMobileBySmsCode() this.bindMobileBySmsCode()
} }
} }
}) })
}, },
bindMobileBySmsCode() { bindMobileBySmsCode() {
uni.navigateTo({ uni.navigateTo({
url: './bind-mobile/bind-mobile', url: './bind-mobile/bind-mobile',
events: { events: {
getUserInfo: () => { getUserInfo: () => {
this.getUserInfo() this.getUserInfo()
} }
}, },
complete(e) { complete(e) {
console.log(e); console.log(e);
} }
}) })
}, },
setNickname(nickname) { setNickname(nickname) {
console.log(nickname); console.log(nickname);
if (nickname) { if (nickname) {
usersTable.where('_id==$env.uid').update({ usersTable.where('_id==$env.uid').update({
nickname nickname
}).then(e => { }).then(e => {
console.log(e); console.log(e);
if (e.result.updated) { if (e.result.updated) {
uni.showToast({ uni.showToast({
title: "更新成功", title: "更新成功",
icon: 'none' icon: 'none'
}); });
this.userInfo.nickname = nickname this.userInfo.nickname = nickname
} else { } else {
uni.showToast({ uni.showToast({
title: "没有改变", title: "没有改变",
icon: 'none' icon: 'none'
}); });
} }
}) })
this.$refs.dialog.close() this.$refs.dialog.close()
} else { } else {
this.$refs.dialog.open() this.$refs.dialog.open()
} }
}, },
deactivate(){ deactivate(){
uni.navigateTo({ uni.navigateTo({
url:"/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate" url:"/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate"
}) })
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import url("/uni_modules/uni-id-pages/common/login-page.scss"); @import url("/uni_modules/uni-id-pages/common/login-page.scss");
.uni-content { .uni-content {
padding: 0; padding: 0;
} }
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
view { view {
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
} }
@media screen and (min-width: 690px) {
.uni-content { /* #endif */
padding: 0; .avatar {
max-width: 690px; align-items: center;
margin-left: calc(50% - 200px); justify-content: center;
border: none; margin: 22px 0;
max-height: none; width: 100%;
border-radius: 0; }
box-shadow: none;
} .item {
} flex: 1;
/* #endif */ flex-direction: row;
.avatar { justify-content: space-between;
align-items: center; align-items: center;
justify-content: center; }
margin: 22px 0;
width: 100%; button {
} margin: 10%;
margin-top: 40px;
.item { border-radius: 0;
flex: 1; background-color: #FFFFFF;
flex-direction: row; width: 80%;
justify-content: space-between; }
align-items: center;
} .mt10{
margin-top: 10px;
button { }
margin: 10%; </style>
margin-top: 40px;
border-radius: 0;
background-color: #FFFFFF;
width: 80%;
}
.mt10{
margin-top: 10px;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册