我的需求是:用手机号+密码的方式登录,在实际开发过程中,提交注册请求的时候,会对用户名的格式进行校验,提示不合法,我应该如何实现用手机号+密码来进行注册登录,或是者如何在注册或登录过程中允许手机号作为用户名?请大佬告知,谢谢
御剑飞天
- 发布:2024-01-26 17:54
- 更新:2024-12-15 15:33
- 阅读:651
在使用uni-id-pages中,进行二次开发,现在想实现手机号+密码的方式登录,如何实现用手机号的格式来登录
分类:uniCloud
2 个回复
y***@aliyun.com
可以将username字段改为mobile,但是手机号验证的字段必须设置为已验证才能登录,否则提示未注册
8***@qq.com
uni_modules\uni-id-pages\uniCloud\cloudfunctions\uni-id-co\common下
validator.js
// if (/^\d+$/.test(username)) {
// // 用户名不能为纯数字
// return {
// errCode
// }
// };
还有:
uni_modules\uni-id-pages\pages\login\login-withpwd.vue
// if (/^1\d{10}$/.test(this.username)) {
// data.mobile = this.username
// } else if (/@/.test(this.username)) {
// data.email = this.username
// } else {
data.username = this.username
// }
把这几行注释掉试试