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

1.1.0

上级 118ea01d
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
"quickapp" : {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wx1002f172d7719592",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },
......
...@@ -23,13 +23,15 @@ ...@@ -23,13 +23,15 @@
"style": { "style": {
"navigationBarTitleText": "绑定手机号码" "navigationBarTitleText": "绑定手机号码"
} }
}, },
// #ifndef MP-WEIXIN
{ {
"path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage", "path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
}, },
// #endif
{ {
"path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd", "path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"style": { "style": {
...@@ -53,14 +55,16 @@ ...@@ -53,14 +55,16 @@
"style": { "style": {
"navigationBarTitleText": "注册" "navigationBarTitleText": "注册"
} }
}, },
// #ifndef MP-WEIXIN
{ {
"path": "uni_modules/uni-id-pages/pages/register/register-admin", "path": "uni_modules/uni-id-pages/pages/register/register-admin",
"style": { "style": {
"navigationBarTitleText": "注册管理员账号", "navigationBarTitleText": "注册管理员账号",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
{ {
"path": "uni_modules/uni-id-pages/pages/register/register-by-email", "path": "uni_modules/uni-id-pages/pages/register/register-by-email",
"style": { "style": {
......
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
}) })
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: "/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType url: "/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType,
animationType:"none",
animationDuration:0
}) })
} }
}, },
......
## 1.1.1(2023-02-02)
- 修复 Vue3下 一键登录条款勾选框选中状态未同步到页面 的问题
## 1.1.0(2023-01-31)
- 【重要】优化 小程序端资源包大小(运行时大小为:731KB,发行后为:583KB;注:可以直接将本插件作为分包使用)
- 更新 微信小程序端 上传头像功能 用`wx.cropImage`实现图片裁剪
- 修复 选择一键登录时会先显示 非密码登录页面的问题
- 修复 一键登录 点击右上角的关闭按钮没有返回上一页的问题
## 1.0.41(2023-01-16) ## 1.0.41(2023-01-16)
- 优化 压缩依赖的文件资源大小 - 优化 压缩依赖的文件资源大小
## 1.0.40(2023-01-16) ## 1.0.40(2023-01-16)
......
...@@ -67,7 +67,8 @@ let mixin = { ...@@ -67,7 +67,8 @@ let mixin = {
} }
} }
}, },
set(agree) { set(agree) {
console.log('set(agree)',agree);
if (this.$refs.agreements) { if (this.$refs.agreements) {
this.$refs.agreements.isAgree = agree this.$refs.agreements.isAgree = agree
} else { } else {
......
<template> <template>
<view @click="onClick" :style="{width,height}"> <view @click="onClick" :style="{width,height}" style="justify-content: center;">
<image v-if="cSrc" :style="{width,height}" :src="cSrc" :mode="mode"></image> <image v-if="cSrc" :style="{width,height}" :src="cSrc" :mode="mode"></image>
</view> </view>
</template> </template>
...@@ -46,13 +46,10 @@ ...@@ -46,13 +46,10 @@
watch: { watch: {
src:{ src:{
handler(src) { handler(src) {
// console.log(src);
// console.log(src.substring(0, 8));
if (src&&src.substring(0, 8) == "cloud://") { if (src&&src.substring(0, 8) == "cloud://") {
uniCloud.getTempFileURL({ uniCloud.getTempFileURL({
fileList: [src] fileList: [src]
}).then(res=>{ }).then(res=>{
// console.log(res);
this.cSrc = res.fileList[0].tempFileURL this.cSrc = res.fileList[0].tempFileURL
}) })
}else{ }else{
...@@ -61,9 +58,6 @@ ...@@ -61,9 +58,6 @@
}, },
immediate: true immediate: true
} }
},
async mounted() {
}, },
methods:{ methods:{
onClick(){ onClick(){
......
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
}, },
methods: { methods: {
popupConfirm(){ popupConfirm(){
// console.log("popupConfirm");
this.isAgree = true this.isAgree = true
retryFun() retryFun()
// this.$emit('popupConfirm') // this.$emit('popupConfirm')
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
async mounted() { async mounted() {
// #ifdef H5 // #ifdef H5
this.isPC = !['ios', 'android'].includes(uni.getSystemInfoSync().platform); this.isPC = !['ios', 'android'].includes(uni.getSystemInfoSync().platform);
// console.log(' this.isPC', this.isPC, uni.getSystemInfoSync().platform);
// #endif // #endif
}, },
computed: { computed: {
...@@ -68,7 +67,6 @@ ...@@ -68,7 +67,6 @@
mutations.updateUserInfo({avatar_file}) mutations.updateUserInfo({avatar_file})
}, },
uploadAvatarImg(res) { uploadAvatarImg(res) {
// console.log(this.hasLogin);
if(!this.hasLogin){ if(!this.hasLogin){
return uni.navigateTo({ return uni.navigateTo({
url:'/uni_modules/uni-id-pages/pages/login/login-withoutpwd' url:'/uni_modules/uni-id-pages/pages/login/login-withoutpwd'
...@@ -84,7 +82,6 @@ ...@@ -84,7 +82,6 @@
count: 1, count: 1,
crop, crop,
success: async (res) => { success: async (res) => {
// console.log(res);
let tempFile = res.tempFiles[0], let tempFile = res.tempFiles[0],
avatar_file = { avatar_file = {
// #ifdef H5 // #ifdef H5
...@@ -95,10 +92,12 @@ ...@@ -95,10 +92,12 @@
// #endif // #endif
}, },
filePath = res.tempFilePaths[0] filePath = res.tempFilePaths[0]
//非app端剪裁头像,app端用内置的原生裁剪
// #ifndef APP-PLUS // #ifndef APP-PLUS
//非app端用前端组件剪裁头像,app端用内置的原生裁剪 filePath = await new Promise((callback) => {
if (!this.isPC) { // #ifdef H5
filePath = await new Promise((callback) => { if (!this.isPC) {
uni.navigateTo({ uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage?path=' + url: '/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage?path=' +
filePath + `&options=${JSON.stringify(crop)}`, filePath + `&options=${JSON.stringify(crop)}`,
...@@ -112,10 +111,32 @@ ...@@ -112,10 +111,32 @@
// console.log(e); // console.log(e);
} }
}); });
}
// #endif
// #ifdef MP-WEIXIN
wx.cropImage({
src:filePath,
cropScale:"1:1",
success: res => {
callback(res.tempFilePath)
},
fail(e){
console.error(e)
uni.showModal({
content: 'wx.cropImage ' + e.errMsg,
showCancel: false,
confirmText:"跳过裁剪",
complete() {
callback(filePath)
}
});
}
}) })
} // #endif
})
// #endif // #endif
// console.log(this.userInfo);
let cloudPath = this.userInfo._id + '' + Date.now() let cloudPath = this.userInfo._id + '' + Date.now()
avatar_file.name = cloudPath avatar_file.name = cloudPath
uni.showLoading({ uni.showLoading({
...@@ -129,9 +150,7 @@ ...@@ -129,9 +150,7 @@
cloudPath, cloudPath,
fileType: "image" fileType: "image"
}); });
// console.log(result)
avatar_file.url = fileID avatar_file.url = fileID
// console.log({avatar_file});
uni.hideLoading() uni.hideLoading()
this.setAvatarFile(avatar_file) this.setAvatarFile(avatar_file)
} }
......
...@@ -41,13 +41,11 @@ ...@@ -41,13 +41,11 @@
uniCloud.importObject("uni-id-co",{ uniCloud.importObject("uni-id-co",{
customUI:true customUI:true
}).loginByWeixin({code}).then(e=>{ }).loginByWeixin({code}).then(e=>{
// console.log(e);
resolve() resolve()
}).catch(e=>{ }).catch(e=>{
console.log(e); console.log(e);
reject() reject()
}).finally(e=>{ }).finally(e=>{
// console.log(e);
uni.hideLoading() uni.hideLoading()
}) })
}, },
...@@ -61,13 +59,10 @@ ...@@ -61,13 +59,10 @@
}) })
}, },
async bindMobileByMpWeixin(e) { async bindMobileByMpWeixin(e) {
// console.log(e);
if (e.detail.errMsg == "getPhoneNumber:ok") { if (e.detail.errMsg == "getPhoneNumber:ok") {
// console.log(e.detail);
//检查登录信息是否过期,否则通过重新登录刷新session_key //检查登录信息是否过期,否则通过重新登录刷新session_key
await this.beforeGetphonenumber() await this.beforeGetphonenumber()
uniIdCo.bindMobileByMpWeixin(e.detail).then(e => { uniIdCo.bindMobileByMpWeixin(e.detail).then(e => {
// console.log(e);
this.$emit('success') this.$emit('success')
}).finally(e => { }).finally(e => {
this.closeMe() this.closeMe()
...@@ -157,8 +152,8 @@ ...@@ -157,8 +152,8 @@
.agree::after { .agree::after {
border: none; border: none;
} }
/* #endif */ /* #endif */
.agree:active { .agree:active {
background-color: #F5F5F6; background-color: #F5F5F6;
} }
......
...@@ -141,7 +141,6 @@ ...@@ -141,7 +141,6 @@
const uniIdCo = uniCloud.importObject("uni-id-co", { const uniIdCo = uniCloud.importObject("uni-id-co", {
customUI: true customUI: true
}) })
// console.log('uniIdCo', uniIdCo)
console.log('sendEmailCode',{ console.log('sendEmailCode',{
"email": this.email, "email": this.email,
"scene": this.type, "scene": this.type,
...@@ -152,7 +151,6 @@ ...@@ -152,7 +151,6 @@
"scene": this.type, "scene": this.type,
"captcha": this.captcha "captcha": this.captcha
}).then(result => { }).then(result => {
// console.log(result.code);
uni.showToast({ uni.showToast({
title: "邮箱验证码发送成功", title: "邮箱验证码发送成功",
icon: 'none', icon: 'none',
...@@ -161,7 +159,6 @@ ...@@ -161,7 +159,6 @@
this.reverseNumber = Number(this.count); this.reverseNumber = Number(this.count);
this.getCode(); this.getCode();
}).catch(e => { }).catch(e => {
// console.log(JSON.stringify(e));
if (e.code == "uni-id-invalid-mail-template") { if (e.code == "uni-id-invalid-mail-template") {
this.modelValue = "123456" this.modelValue = "123456"
uni.showToast({ uni.showToast({
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view> <view>
<view class="fab-login-box"> <view class="fab-login-box">
<view class="item" v-for="(item,index) in servicesList" :key="index" <view class="item" v-for="(item,index) in servicesList" :key="index"
@click="item.path?navigateTo(item.path):login_before(item.id,false)"> @click="item.path?toPage(item.path):login_before(item.id,false)">
<image class="logo" :src="item.logo" mode="scaleToFill"></image> <image class="logo" :src="item.logo" mode="scaleToFill"></image>
<text class="login-title">{{item.text}}</text> <text class="login-title">{{item.text}}</text>
</view> </view>
...@@ -15,15 +15,8 @@ ...@@ -15,15 +15,8 @@
<script> <script>
import config from '@/uni_modules/uni-id-pages/config.js' import config from '@/uni_modules/uni-id-pages/config.js'
//前一个窗口的页面地址。控制点击切换快捷登录方式是创建还是返回 //前一个窗口的页面地址。控制点击切换快捷登录方式是创建还是返回
import { import {store,mutations} from '@/uni_modules/uni-id-pages/common/store.js'
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
const db = uniCloud.database();
const usersTable = db.collection('uni-id-users')
let allServicesList = [] let allServicesList = []
export default { export default {
computed: { computed: {
agreements() { agreements() {
...@@ -49,7 +42,6 @@ ...@@ -49,7 +42,6 @@
return this.getParentComponent().agree return this.getParentComponent().agree
}, },
set(agree) { set(agree) {
// console.log('setAgree', agree);
return this.getParentComponent().agree = agree return this.getParentComponent().agree = agree
} }
} }
...@@ -59,65 +51,67 @@ ...@@ -59,65 +51,67 @@
servicesList: [{ servicesList: [{
"id": "username", "id": "username",
"text": "账号登录", "text": "账号登录",
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/user.png", "logo": "/uni_modules/uni-id-pages/static/login/uni-fab-login/user.png",
"path": "/uni_modules/uni-id-pages/pages/login/login-withpwd" "path": "/uni_modules/uni-id-pages/pages/login/login-withpwd"
}, },
{ {
"id": "smsCode", "id": "smsCode",
"text": "短信验证码", "text": "短信验证码",
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/sms.png", "logo": "/uni_modules/uni-id-pages/static/login/uni-fab-login/sms.png",
"path": "/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=smsCode" "path": "/uni_modules/uni-id-pages/pages/login/login-withoutpwd?type=smsCode"
}, },
{ {
"id": "weixin", "id": "weixin",
"text": "微信登录", "text": "微信登录",
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/weixin.png", "logo": "/uni_modules/uni-id-pages/static/login/uni-fab-login/weixin.png",
}, },
// #ifndef MP-WEIXIN
{ {
"id": "apple", "id": "apple",
"text": "苹果登录", "text": "苹果登录",
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/apple.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/apple.png",
}, },
{ {
"id": "univerify", "id": "univerify",
"text": "一键登录", "text": "一键登录",
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/univerify.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/univerify.png",
}, },
{ {
"id": "taobao", "id": "taobao",
"text": "淘宝登录", //暂未提供该登录方式的接口示例 "text": "淘宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/taobao.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/taobao.png",
}, },
{ {
"id": "facebook", "id": "facebook",
"text": "脸书登录", //暂未提供该登录方式的接口示例 "text": "脸书登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/facebook.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/facebook.png",
}, },
{ {
"id": "alipay", "id": "alipay",
"text": "支付宝登录", //暂未提供该登录方式的接口示例 "text": "支付宝登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/alipay.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/alipay.png",
}, },
{ {
"id": "qq", "id": "qq",
"text": "QQ登录", //暂未提供该登录方式的接口示例 "text": "QQ登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/qq.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/qq.png",
}, },
{ {
"id": "google", "id": "google",
"text": "谷歌登录", //暂未提供该登录方式的接口示例 "text": "谷歌登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/google.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/google.png",
}, },
{ {
"id": "douyin", "id": "douyin",
"text": "抖音登录", //暂未提供该登录方式的接口示例 "text": "抖音登录", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/douyin.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/douyin.png",
}, },
{ {
"id": "sinaweibo", "id": "sinaweibo",
"text": "新浪微博", //暂未提供该登录方式的接口示例 "text": "新浪微博", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/uni-fab-login/sinaweibo.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/sinaweibo.png",
} }
// #endif
], ],
univerifyStyle: { //一键登录弹出窗的样式配置参数 univerifyStyle: { //一键登录弹出窗的样式配置参数
"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。 "fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
...@@ -189,7 +183,6 @@ ...@@ -189,7 +183,6 @@
let path = item.path ? item.path.split('?')[0] : ''; let path = item.path ? item.path.split('?')[0] : '';
return path != this.getRoute(1) return path != this.getRoute(1)
}) })
//console.log('servicesList', servicesList, this.servicesList);
}, },
methods: { methods: {
getParentComponent(){ getParentComponent(){
...@@ -206,24 +199,23 @@ ...@@ -206,24 +199,23 @@
}, },
getRoute(n = 0) { getRoute(n = 0) {
let pages = getCurrentPages(); let pages = getCurrentPages();
// console.log('route-pages-length', pages.length);
if (n > pages.length) { if (n > pages.length) {
return '' return ''
} }
return '/' + pages[pages.length - n].route return '/' + pages[pages.length - n].route
}, },
navigateTo(path) { toPage(path,index = 0) {
let type = ['navigateTo','redirectTo'][index]
//console.log('比较', this.getRoute(1),this.getRoute(2), path) //console.log('比较', this.getRoute(1),this.getRoute(2), path)
if (this.getRoute(1) == path.split('?')[0] && this.getRoute(1) == if (this.getRoute(1) == path.split('?')[0] && this.getRoute(1) ==
'/uni_modules/uni-id-pages/pages/login/login-withoutpwd') { '/uni_modules/uni-id-pages/pages/login/login-withoutpwd') {
//如果要被打开的页面已经打开,且这个页面是 /uni_modules/uni-id-pages/pages/index/index 则把类型参数传给他 //如果要被打开的页面已经打开,且这个页面是 /uni_modules/uni-id-pages/pages/index/index 则把类型参数传给他
let type = path.split('?')[1].split('=')[1] let loginType = path.split('?')[1].split('=')[1]
uni.$emit('uni-id-pages-set-login-type', type) uni.$emit('uni-id-pages-setLoginType', loginType)
} else if (this.getRoute(2) == path) { // 如果上一个页面就是,马上要打开的页面,直接返回。防止重复开启 } else if (this.getRoute(2) == path) { // 如果上一个页面就是,马上要打开的页面,直接返回。防止重复开启
uni.navigateBack(); uni.navigateBack();
} else if (this.getRoute(1) != path) { } else if (this.getRoute(1) != path) {
//console.log(3); uni[type]({
uni.navigateTo({
url: path, url: path,
animationType: 'slide-in-left', animationType: 'slide-in-left',
complete(e) { complete(e) {
...@@ -248,7 +240,7 @@ ...@@ -248,7 +240,7 @@
].includes(type)) { ].includes(type)) {
return uni.showToast({ return uni.showToast({
title: '该登录方式暂未实现,欢迎提交pr', title: '该登录方式暂未实现,欢迎提交pr',
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
} }
...@@ -265,7 +257,7 @@ ...@@ -265,7 +257,7 @@
}else{ }else{
return uni.showToast({ return uni.showToast({
title: '当前设备不支持此登录,请选择其他登录方式', title: '当前设备不支持此登录,请选择其他登录方式',
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
} }
...@@ -288,19 +280,16 @@ ...@@ -288,19 +280,16 @@
) { ) {
return uni.showToast({ return uni.showToast({
title: '当前设备不支持此登录,请选择其他登录方式', title: '当前设备不支持此登录,请选择其他登录方式',
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
} }
//判断是否需要弹出隐私协议授权框 //判断是否需要弹出隐私协议授权框
// console.log(type, this.agree);
let needAgreements = (config?.agreements?.scope || []).includes('register') let needAgreements = (config?.agreements?.scope || []).includes('register')
// console.log({needAgreements});
if (type != 'univerify' && needAgreements && !this.agree) { if (type != 'univerify' && needAgreements && !this.agree) {
let agreementsRef = this.getParentComponent().$refs.agreements let agreementsRef = this.getParentComponent().$refs.agreements
return agreementsRef.popup(() => { return agreementsRef.popup(() => {
// console.log(type, navigateBack);
this.login_before(type, navigateBack, options) this.login_before(type, navigateBack, options)
}) })
} }
...@@ -312,7 +301,6 @@ ...@@ -312,7 +301,6 @@
document.domain + document.domain +
(window.location.href.includes('#')?'/#':'') + (window.location.href.includes('#')?'/#':'') +
'/uni_modules/uni-id-pages/pages/login/login-withoutpwd?is_weixin_redirect=true&type=weixin' '/uni_modules/uni-id-pages/pages/login/login-withoutpwd?is_weixin_redirect=true&type=weixin'
// console.log('redirectUrl----',redirectUrl);
let ua = window.navigator.userAgent.toLowerCase(); let ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger'){ if (ua.match(/MicroMessenger/i) == 'micromessenger'){
// console.log('在微信公众号内'); // console.log('在微信公众号内');
...@@ -335,32 +323,40 @@ ...@@ -335,32 +323,40 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
if (type == 'univerify') { if (type == 'univerify') {
let univerifyManager = uni.getUniverifyManager() let univerifyManager = uni.getUniverifyManager()
let clickAnotherButtons = false
let onButtonsClickFn = async res => { let onButtonsClickFn = async res => {
// console.log('点击了第三方登录,provider:', res, res.provider, this.univerifyStyle.buttons.list); console.log('点击了第三方登录,provider:', res, res.provider, this.univerifyStyle.buttons.list);
//同步一键登录弹出层隐私协议框是否打勾 clickAnotherButtons = true
let agree = (await uni.getCheckBoxState())[1].state let checkBoxState = await uni.getCheckBoxState();
//console.log('agree',agree); // 同步一键登录弹出层隐私协议框是否打勾
this.agree = agree // #ifdef VUE2
this.agree = checkBoxState[1].state
// #endif
// #ifdef VUE3
this.agree = checkBoxState.state
// #endif
let { let {
path path
} = this.univerifyStyle.buttons.list[res.index] } = this.univerifyStyle.buttons.list[res.index]
if (path) { if (path) {
this.navigateTo(path) if( this.getRoute(1).includes('login-withoutpwd') && path.includes('login-withoutpwd') ){
this.getParentComponent().showCurrentWebview()
}
this.toPage(path,1)
closeUniverify() closeUniverify()
} else { } else {
if (agree) { if (this.agree) {
closeUniverify() closeUniverify()
setTimeout(() => { setTimeout(() => {
//console.log('login_before');
this.login_before(res.provider) this.login_before(res.provider)
}, 500) }, 500)
} else { } else {
//console.log("你未同意隐私政策协议");
uni.showToast({ uni.showToast({
title: "你未同意隐私政策协议", title: "你未同意隐私政策协议",
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
} }
...@@ -379,32 +375,34 @@ ...@@ -379,32 +375,34 @@
return univerifyManager.login({ return univerifyManager.login({
"univerifyStyle": this.univerifyStyle, "univerifyStyle": this.univerifyStyle,
success: res => { success: res => {
// console.log('login success', res)
this.login(res.authResult, 'univerify') this.login(res.authResult, 'univerify')
}, },
fail(err) { fail(err) {
uni.showToast({ console.log(err)
title: JSON.stringify(err), if(!clickAnotherButtons){
icon: 'none', uni.navigateBack()
duration: 3000 }
}); // uni.showToast({
// title: JSON.stringify(err),
// icon: 'none',
// duration: 3000
// });
}, },
complete: async e => { complete: async e => {
// console.log(e);
uni.hideLoading() uni.hideLoading()
//同步一键登录弹出层隐私协议框是否打勾 //同步一键登录弹出层隐私协议框是否打勾
this.agree = (await uni.getCheckBoxState())[1].state // this.agree = (await uni.getCheckBoxState())[1].state
// 取消订阅自定义按钮点击事件 // 取消订阅自定义按钮点击事件
univerifyManager.offButtonsClick(onButtonsClickFn) univerifyManager.offButtonsClick(onButtonsClickFn)
} }
}) })
} }
if (type === 'weixinMobile') { if (type === 'weixinMobile') {
return this.login({ return this.login({
phoneCode: options.phoneNumberCode phoneCode: options.phoneNumberCode
}, type) }, type)
} }
uni.login({ uni.login({
"provider": type, "provider": type,
...@@ -413,7 +411,6 @@ ...@@ -413,7 +411,6 @@
"univerifyStyle": this.univerifyStyle, "univerifyStyle": this.univerifyStyle,
// #endif // #endif
success: async e => { success: async e => {
// console.log(e);
if (type == 'apple') { if (type == 'apple') {
let res = await this.getUserInfo({ let res = await this.getUserInfo({
provider: "apple" provider: "apple"
...@@ -440,16 +437,15 @@ ...@@ -440,16 +437,15 @@
customUI:true customUI:true
}) })
uniIdCo[action](params).then(result => { uniIdCo[action](params).then(result => {
// console.log("login-result", result);
uni.showToast({ uni.showToast({
title: '登录成功', title: '登录成功',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}); });
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
//如果是微信小程序端的微信登录,且为首次登录,就弹出获取微信昵称+头像用于绑定资料 //如果是微信小程序端的微信登录,且为首次登录,就弹出获取微信昵称+头像用于绑定资料
if (['weixin', 'weixinMobile'].includes(type) && result.type == "register") { if (['weixin', 'weixinMobile'].includes(type) && result.type == "register") {
mutations.loginSuccess({ mutations.loginSuccess({
...result, ...result,
showToast: false, showToast: false,
autoBack: false autoBack: false
...@@ -463,7 +459,6 @@ ...@@ -463,7 +459,6 @@
mutations.loginSuccess(result) mutations.loginSuccess(result)
}) })
.catch(e=>{ .catch(e=>{
// console.log(e);
uni.showModal({ uni.showModal({
content: e.message, content: e.message,
confirmText:"知道了", confirmText:"知道了",
...@@ -513,7 +508,6 @@ ...@@ -513,7 +508,6 @@
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
} }
/* #endif */ /* #endif */
.fab-login-box { .fab-login-box {
...@@ -552,8 +546,6 @@ ...@@ -552,8 +546,6 @@
/* #endif */ /* #endif */
.logo { .logo {
width: 60rpx; width: 60rpx;
height: 60rpx; height: 60rpx;
...@@ -563,7 +555,6 @@ ...@@ -563,7 +555,6 @@
border: solid 1px #F6F6F6; border: solid 1px #F6F6F6;
} }
.login-title { .login-title {
text-align: center; text-align: center;
margin-top: 6px; margin-top: 6px;
......
...@@ -146,7 +146,6 @@ ...@@ -146,7 +146,6 @@
"scene": this.type, "scene": this.type,
"captcha": this.captcha "captcha": this.captcha
}).then(result => { }).then(result => {
// console.log(result.code);
uni.showToast({ uni.showToast({
title: "短信验证码发送成功", title: "短信验证码发送成功",
icon: 'none', icon: 'none',
...@@ -155,7 +154,6 @@ ...@@ -155,7 +154,6 @@
this.reverseNumber = Number(this.count); this.reverseNumber = Number(this.count);
this.getCode(); this.getCode();
}).catch(e => { }).catch(e => {
// console.log(JSON.stringify(e));
if (e.code == "uni-id-invalid-sms-template-id") { if (e.code == "uni-id-invalid-sms-template-id") {
this.modelValue = "123456" this.modelValue = "123456"
uni.showToast({ uni.showToast({
...@@ -209,7 +207,6 @@ ...@@ -209,7 +207,6 @@
/* #endif */ /* #endif */
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.inner-text { .inner-text {
......
...@@ -31,12 +31,10 @@ ...@@ -31,12 +31,10 @@
uni.getUserProfile({ uni.getUserProfile({
desc: "用于设置账户昵称和头像", desc: "用于设置账户昵称和头像",
complete: (e) => { complete: (e) => {
// console.log("getUserProfile:", e);
callBack(e) callBack(e)
} }
}) })
}) })
// console.log("userInfo", res.userInfo);
if(res.errMsg != "getUserProfile:ok"){ if(res.errMsg != "getUserProfile:ok"){
return this.closeMe() return this.closeMe()
} }
...@@ -46,10 +44,10 @@ ...@@ -46,10 +44,10 @@
uni.downloadFile({ uni.downloadFile({
url: avatarUrl, url: avatarUrl,
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
// console.log('下载成功'); // console.log('下载成功');
callBack(res.tempFilePath) callBack(res.tempFilePath)
} }
callBack() callBack()
}, },
fail: (err) => { fail: (err) => {
...@@ -62,13 +60,11 @@ ...@@ -62,13 +60,11 @@
}) })
const extName = tempFilePath.split('.').pop() || 'jpg' const extName = tempFilePath.split('.').pop() || 'jpg'
const cloudPath = 'user/avatar/'+ userId+'/'+Date.now()+'-avatar.'+extName; const cloudPath = 'user/avatar/'+ userId+'/'+Date.now()+'-avatar.'+extName;
// console.log(tempFilePath);
const result = await uniCloud.uploadFile({ const result = await uniCloud.uploadFile({
filePath: tempFilePath, filePath: tempFilePath,
cloudPath, cloudPath,
fileType:'image' fileType:'image'
}); });
// console.log("上传成功",{result});
let userInfo = { let userInfo = {
"nickname":nickName, "nickname":nickName,
"avatar_file":{ "avatar_file":{
...@@ -89,7 +85,6 @@ ...@@ -89,7 +85,6 @@
}) })
}, },
doUpdate(data,callback){ doUpdate(data,callback){
// console.log('dododo',data);
// 使用 clientDB 提交数据 // 使用 clientDB 提交数据
usersTable.where('_id==$env.uid').update(data).then((res) => { usersTable.where('_id==$env.uid').update(data).then((res) => {
callback(res) callback(res)
......
{
"name": "uni-id-pages",
"version": "1.0.19",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.0.19",
"dependencies": {
"jweixin-module": "^1.6.0"
},
"engines": {
"HBuilderX": "^3.4.17"
}
},
"node_modules/jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
}
},
"dependencies": {
"jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
}
}
}
{ {
"id": "uni-id-pages", "id": "uni-id-pages",
"displayName": "uni-id-pages", "displayName": "uni-id-pages",
"version": "1.0.41", "version": "1.1.0",
"description": "云端一体简单、统一、可扩展的用户中心页面模版", "description": "云端一体简单、统一、可扩展的用户中心页面模版",
"keywords": [ "keywords": [
"用户管理", "用户管理",
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
}); });
title = "页面路径错误" title = "页面路径错误"
}else{ }else{
// console.log(url,title);
this.url = url; this.url = url;
} }
if(title){ if(title){
...@@ -34,7 +33,3 @@ ...@@ -34,7 +33,3 @@
} }
} }
</script> </script>
<style lang="scss">
</style>
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
this.phone = phoneNumber; this.phone = phoneNumber;
}, },
onShow() { onShow() {
// console.log('onShow');
// #ifdef H5 // #ifdef H5
document.onkeydown = event => { document.onkeydown = event => {
var e = event || window.event; var e = event || window.event;
...@@ -68,14 +67,12 @@ ...@@ -68,14 +67,12 @@
"code": this.code, "code": this.code,
"captcha": this.captcha "captcha": this.captcha
}).then(e => { }).then(e => {
// console.log(e);
this.loginSuccess(e) this.loginSuccess(e)
}).catch(e => { }).catch(e => {
if (e.errCode == 'uni-id-captcha-required') { if (e.errCode == 'uni-id-captcha-required') {
this.$refs.popup.open() this.$refs.popup.open()
} else { } else {
console.log(e.errMsg); console.log(e.errMsg);
// console.log(e.errCode);
} }
}).finally(e => { }).finally(e => {
this.captcha = '' this.captcha = ''
......
<!-- 免密登录页 --> <!-- 免密登录页 -->
<template> <template>
<view class="uni-content"> <view class="uni-content">
<view class="login-logo"> <view class="login-logo">
<image :src="logo"></image> <image :src="logo"></image>
</view> </view>
<!-- 顶部文字 --> <!-- 顶部文字 -->
<text class="title">请选择登录方式</text> <text class="title">请选择登录方式</text>
<!-- 快捷登录框 当url带参数时有效 --> <!-- 快捷登录框 当url带参数时有效 -->
<template v-if="['apple','weixin', 'weixinMobile'].includes(type)"> <template v-if="['apple','weixin', 'weixinMobile'].includes(type)">
<text class="tip">将根据第三方账号服务平台的授权范围获取你的信息</text> <text class="tip">将根据第三方账号服务平台的授权范围获取你的信息</text>
<view class="quickLogin"> <view class="quickLogin">
<image v-if="type !== 'weixinMobile'" @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image> <image v-if="type !== 'weixinMobile'" @click="quickLogin" :src="imgSrc" mode="widthFix"
<button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="quickLogin" class="uni-btn">微信授权手机号登录</button> class="quickLoginBtn"></image>
<uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements> <button v-else type="primary" open-type="getPhoneNumber" @getphonenumber="quickLogin"
</view> class="uni-btn">微信授权手机号登录</button>
</template> <uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements>
<template v-else> </view>
<text class="tip">未注册的账号验证通过后将自动注册</text> </template>
<view class="phone-box"> <template v-else>
<view @click="chooseArea" class="area">+86</view> <text class="tip">未注册的账号验证通过后将自动注册</text>
<uni-easyinput :focus="focusPhone" @blur="focusPhone = false" class="input-box" type="number" :inputBorder="false" <view class="phone-box">
v-model="phone" maxlength="11" placeholder="请输入手机号" /> <view @click="chooseArea" class="area">+86</view>
</view> <uni-easyinput :focus="focusPhone" @blur="focusPhone = false" class="input-box" type="number"
<uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements> :inputBorder="false" v-model="phone" maxlength="11" placeholder="请输入手机号" />
<button class="uni-btn" type="primary" @click="toSmsPage">获取验证码</button> </view>
</template> <uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements>
<!-- 固定定位的快捷登录按钮 --> <button class="uni-btn" type="primary" @click="toSmsPage">获取验证码</button>
<uni-id-pages-fab-login ref="uniFabLogin"></uni-id-pages-fab-login> </template>
</view> <!-- 固定定位的快捷登录按钮 -->
</template> <uni-id-pages-fab-login ref="uniFabLogin"></uni-id-pages-fab-login>
</view>
<script> </template>
let currentWebview; //当前窗口对象
import config from '@/uni_modules/uni-id-pages/config.js' <script>
import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js'; let currentWebview; //当前窗口对象
export default { import config from '@/uni_modules/uni-id-pages/config.js'
mixins: [mixin], import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js';
data() { export default {
return { mixins: [mixin],
type: "", //快捷登录方式 data() {
phone: "", //手机号码 return {
focusPhone:false, type: "", //快捷登录方式
logo: "/static/logo.png" phone: "", //手机号码
} focusPhone: false,
}, logo: "/static/logo.png"
computed: { }
async loginTypes() { //读取配置的登录优先级 },
return config.loginTypes computed: {
}, async loginTypes() { //读取配置的登录优先级
isPhone() { //手机号码校验正则 return config.loginTypes
return /^1\d{10}$/.test(this.phone); },
}, isPhone() { //手机号码校验正则
imgSrc() { //大快捷登录按钮图 return /^1\d{10}$/.test(this.phone);
return '/uni_modules/uni-id-pages/static/login/' + this.type + '.png' },
} imgSrc() { //大快捷登录按钮图
}, return this.type == 'weixin' ? '/uni_modules/uni-id-pages/static/login/weixin.png' :
async onLoad(e) { '/uni_modules/uni-id-pages/static/app-plus/apple.png'
// console.log(e); }
//获取通过url传递的参数type设置当前登录方式,如果没传递直接默认以配置的登录 },
let type = e.type || config.loginTypes[0] async onLoad(e) {
this.type = type //获取通过url传递的参数type设置当前登录方式,如果没传递直接默认以配置的登录
if(type != 'univerify'){ let type = e.type || config.loginTypes[0]
this.focusPhone = true this.type = type
}
this.$nextTick(() => { // console.log("this.type: -----------",this.type);
//关闭重复显示的登录快捷方式 if (type != 'univerify') {
if (['weixin', 'apple'].includes(type)) { this.focusPhone = true
this.$refs.uniFabLogin.servicesList = this.$refs.uniFabLogin.servicesList.filter(item =>item.id != type) }
} this.$nextTick(() => {
}) //关闭重复显示的登录快捷方式
uni.$on('uni-id-pages-set-login-type', type => { if (['weixin', 'apple'].includes(type)) {
this.type = type this.$refs.uniFabLogin.servicesList = this.$refs.uniFabLogin.servicesList.filter(item =>
}) item.id != type)
}, }
onShow() { })
// #ifdef H5 uni.$on('uni-id-pages-setLoginType', type => {
document.onkeydown = event => { this.type = type
var e = event || window.event; })
if (e && e.keyCode == 13) { //回车键的键值为13 },
this.toSmsPage() onShow() {
} // #ifdef H5
}; document.onkeydown = event => {
// #endif var e = event || window.event;
}, if (e && e.keyCode == 13) { //回车键的键值为13
onUnload() { this.toSmsPage()
uni.$off('uni-id-pages-set-login-type') }
}, };
onReady() { // #endif
//是否优先启动一键登录。即:页面一加载就启动一键登录 },
//#ifdef APP-PLUS onUnload() {
if (this.type == "univerify") { uni.$off('uni-id-pages-setLoginType')
this.type == this.loginTypes[1] },
// console.log('开始一键登录'); onReady() {
setTimeout(() => { // 是否优先启动一键登录。即:页面一加载就启动一键登录
this.$refs.uniFabLogin.login_before('univerify') //#ifdef APP-PLUS
}, 100) if (this.type == "univerify") {
} const pages = getCurrentPages();
//#endif currentWebview = pages[pages.length - 1].$getAppWebview();
}, currentWebview.setStyle({
"top": "2000px" // 隐藏当前页面窗体
})
this.type == this.loginTypes[1]
// console.log('开始一键登录');
this.$refs.uniFabLogin.login_before('univerify')
}
//#endif
},
methods: { methods: {
quickLogin(e) { showCurrentWebview(){
let options = {} // 恢复当前页面窗体的显示 一键登录,默认不显示当前窗口
currentWebview.setStyle({
if (e.detail?.code) { "top": 0
options.phoneNumberCode = e.detail.code
}
if (this.type === 'weixinMobile' && !e.detail?.code) return
this.$refs.uniFabLogin.login_before(this.type, true, options)
},
toSmsPage() {
// console.log('toSmsPage',this.agree);
if (!this.isPhone) {
this.focusPhone = true
return uni.showToast({
title: "手机号码格式不正确",
icon: 'none',
duration: 3000
});
}
if (this.needAgreements && !this.agree) {
return this.$refs.agreements.popup(this.toSmsPage)
}
// 发送验证吗
uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/login/login-smscode?phoneNumber=' + this.phone
});
},
//去密码登录页
toPwdLogin() {
uni.navigateTo({
url: '../login/password'
}) })
}, },
chooseArea() { quickLogin(e) {
uni.showToast({ let options = {}
title: '暂不支持其他国家',
icon: 'none', if (e.detail?.code) {
duration: 3000 options.phoneNumberCode = e.detail.code
}); }
},
} if (this.type === 'weixinMobile' && !e.detail?.code) return
}
</script> this.$refs.uniFabLogin.login_before(this.type, true, options)
},
<style lang="scss" scoped> toSmsPage() {
@import "@/uni_modules/uni-id-pages/common/login-page.scss"; if (!this.isPhone) {
this.focusPhone = true
@media screen and (min-width: 690px) { return uni.showToast({
.uni-content{ title: "手机号码格式不正确",
height: 350px; icon: 'none',
} duration: 3000
} });
}
.uni-content, if (this.needAgreements && !this.agree) {
.quickLogin { return this.$refs.agreements.popup(this.toSmsPage)
/* #ifndef APP-NVUE */ }
display: flex; // 发送验证吗
flex-direction: column; uni.navigateTo({
/* #endif */ url: '/uni_modules/uni-id-pages/pages/login/login-smscode?phoneNumber=' + this.phone
} });
},
.phone-box { //去密码登录页
position: relative; toPwdLogin() {
/* #ifndef APP-NVUE */ uni.navigateTo({
display: flex; url: '../login/password'
/* #endif */ })
} },
chooseArea() {
.area { uni.showToast({
position: absolute; title: '暂不支持其他国家',
left: 10px; icon: 'none',
z-index: 9; duration: 3000
top: 12px; });
font-size: 14px; },
} }
}
.area::after { </script>
content: "";
border: 3px solid transparent; <style lang="scss" scoped>
border-top-color: #000; @import "@/uni_modules/uni-id-pages/common/login-page.scss";
top: 12px;
left: 3px; @media screen and (min-width: 690px) {
position: relative; .uni-content {
} height: 350px;
}
/* #ifdef MP */ }
// 解决小程序端开启虚拟节点virtualHost引起的 class = input-box丢失的问题 [详情参考](https://uniapp.dcloud.net.cn/matter.html#%E5%90%84%E5%AE%B6%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AE%9E%E7%8E%B0%E6%9C%BA%E5%88%B6%E4%B8%8D%E5%90%8C-%E5%8F%AF%E8%83%BD%E5%AD%98%E5%9C%A8%E7%9A%84%E5%B9%B3%E5%8F%B0%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98)
.phone-box ::v-deep .uni-easyinput__content, .uni-content,
/* #endif */ .quickLogin {
.input-box { /* #ifndef APP-NVUE */
/* #ifndef APP-NVUE */ display: flex;
box-sizing: border-box; flex-direction: column;
/* #endif */ /* #endif */
flex: 1; }
padding-left: 45px;
margin-bottom: 10px; .phone-box {
border-radius: 0; position: relative;
} /* #ifndef APP-NVUE */
display: flex;
.quickLogin { /* #endif */
// width: 650rpx; }
height: 350px;
align-items: center; .area {
justify-content: center; position: absolute;
} left: 10px;
z-index: 9;
.quickLoginBtn { top: 12px;
margin: 20px 0; font-size: 14px;
width: 450rpx; }
/* #ifndef APP-NVUE */
max-width: 230px; .area::after {
/* #endif */ content: "";
height: 82rpx; border: 3px solid transparent;
} border-top-color: #000;
top: 12px;
.tip { left: 3px;
margin-top: -15px; position: relative;
margin-bottom: 20px; }
}
/* #ifdef MP */
@media screen and (min-width: 690px) { // 解决小程序端开启虚拟节点virtualHost引起的 class = input-box丢失的问题 [详情参考](https://uniapp.dcloud.net.cn/matter.html#%E5%90%84%E5%AE%B6%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AE%9E%E7%8E%B0%E6%9C%BA%E5%88%B6%E4%B8%8D%E5%90%8C-%E5%8F%AF%E8%83%BD%E5%AD%98%E5%9C%A8%E7%9A%84%E5%B9%B3%E5%8F%B0%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98)
.quickLogin{ .phone-box ::v-deep .uni-easyinput__content,
height: auto; /* #endif */
} .input-box {
} /* #ifndef APP-NVUE */
box-sizing: border-box;
/* #endif */
flex: 1;
padding-left: 45px;
margin-bottom: 10px;
border-radius: 0;
}
.quickLogin {
height: 350px;
align-items: center;
justify-content: center;
}
.quickLoginBtn {
margin: 20px 0;
width: 450rpx;
/* #ifndef APP-NVUE */
max-width: 230px;
/* #endif */
height: 82rpx;
}
.tip {
margin-top: -15px;
margin-bottom: 20px;
}
@media screen and (min-width: 690px) {
.quickLogin {
height: auto;
}
}
</style> </style>
...@@ -108,12 +108,9 @@ ...@@ -108,12 +108,9 @@
}, },
submitForm(params) { submitForm(params) {
uniIdCo.registerAdmin(this.formData).then(e => { uniIdCo.registerAdmin(this.formData).then(e => {
// console.log(e);
uni.navigateBack() uni.navigateBack()
}) })
.catch(e => { .catch(e => {
// console.log(e);
// console.log(e.message);
//更好的体验:登录错误,直接刷新验证码 //更好的体验:登录错误,直接刷新验证码
this.$refs.captcha.getImageCaptcha() this.$refs.captcha.getImageCaptcha()
uni.showModal({ uni.showModal({
......
...@@ -109,17 +109,14 @@ ...@@ -109,17 +109,14 @@
}).catch((errors) => { }).catch((errors) => {
let key = errors[0].key let key = errors[0].key
key = key.replace(key[0], key[0].toUpperCase()) key = key.replace(key[0], key[0].toUpperCase())
// console.log(key);
this['focus' + key] = true this['focus' + key] = true
}) })
}, },
submitForm(params) { submitForm(params) {
uniIdCo.registerUser(this.formData).then(e => { uniIdCo.registerUser(this.formData).then(e => {
// console.log(e);
this.loginSuccess(e) this.loginSuccess(e)
}) })
.catch(e => { .catch(e => {
// console.log(e);
console.log(e.message); console.log(e.message);
//更好的体验:登录错误,直接刷新验证码 //更好的体验:登录错误,直接刷新验证码
this.$refs.captcha.getImageCaptcha() this.$refs.captcha.getImageCaptcha()
......
...@@ -137,8 +137,6 @@ ...@@ -137,8 +137,6 @@
* 完成并提交 * 完成并提交
*/ */
submit() { submit() {
// console.log("formData", this.formData);
// console.log('rules', this.rules);
this.$refs.form.validate() this.$refs.form.validate()
.then(res => { .then(res => {
let { let {
...@@ -153,7 +151,6 @@ ...@@ -153,7 +151,6 @@
password, password,
captcha captcha
}).then(e => { }).then(e => {
// console.log(e);
uni.navigateTo({ uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withpwd', url: '/uni_modules/uni-id-pages/pages/login/login-withpwd',
complete: (e) => { complete: (e) => {
...@@ -171,11 +168,9 @@ ...@@ -171,11 +168,9 @@
}).catch(errors=>{ }).catch(errors=>{
let key = errors[0].key let key = errors[0].key
if(key == 'code'){ if(key == 'code'){
// console.log(this.$refs.shortCode);
return this.$refs.shortCode.focusSmsCodeInput = true return this.$refs.shortCode.focusSmsCodeInput = true
} }
key = key.replace(key[0], key[0].toUpperCase()) key = key.replace(key[0], key[0].toUpperCase())
// console.log(key,'focus'+key);
this['focus'+key] = true this['focus'+key] = true
}) })
}, },
......
...@@ -166,8 +166,6 @@ ...@@ -166,8 +166,6 @@
* 完成并提交 * 完成并提交
*/ */
submit() { submit() {
// console.log("formData", this.formData);
// console.log('rules', this.rules);
this.$refs.form.validate() this.$refs.form.validate()
.then(res => { .then(res => {
let { let {
...@@ -182,7 +180,6 @@ ...@@ -182,7 +180,6 @@
password, password,
captcha captcha
}).then(e => { }).then(e => {
// console.log(e);
uni.navigateBack() uni.navigateBack()
}) })
.catch(e => { .catch(e => {
...@@ -195,11 +192,9 @@ ...@@ -195,11 +192,9 @@
}).catch(errors=>{ }).catch(errors=>{
let key = errors[0].key let key = errors[0].key
if(key == 'code'){ if(key == 'code'){
// console.log(this.$refs.shortCode);
return this.$refs.shortCode.focusSmsCodeInput = true return this.$refs.shortCode.focusSmsCodeInput = true
} }
key = key.replace(key[0], key[0].toUpperCase()) key = key.replace(key[0], key[0].toUpperCase())
// console.log(key,'focus'+key);
this['focus'+key] = true this['focus'+key] = true
}) })
}, },
...@@ -208,11 +203,11 @@ ...@@ -208,11 +203,11 @@
url: '/uni_modules/uni-id-pages/pages/retrieve/retrieve-by-email' url: '/uni_modules/uni-id-pages/pages/retrieve/retrieve-by-email'
}) })
}, },
backLogin () { backLogin () {
uni.redirectTo({ uni.redirectTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withpwd' url: '/uni_modules/uni-id-pages/pages/login/login-withpwd'
}) })
} }
} }
} }
</script> </script>
......
...@@ -65,10 +65,8 @@ ...@@ -65,10 +65,8 @@
}); });
} }
// console.log(this.formData);
const uniIdCo = uniCloud.importObject("uni-id-co") const uniIdCo = uniCloud.importObject("uni-id-co")
uniIdCo.bindMobileBySms(this.formData).then(e => { uniIdCo.bindMobileBySms(this.formData).then(e => {
// console.log(e);
uni.showToast({ uni.showToast({
title: e.errMsg, title: e.errMsg,
icon: 'none', icon: 'none',
......
...@@ -82,8 +82,6 @@ ...@@ -82,8 +82,6 @@
* 完成并提交 * 完成并提交
*/ */
submit() { submit() {
// console.log("formData", this.formData);
// console.log('rules', this.rules);
this.$refs.form.validate() this.$refs.form.validate()
.then(res => { .then(res => {
let { let {
...@@ -94,7 +92,6 @@ ...@@ -94,7 +92,6 @@
oldPassword, oldPassword,
newPassword newPassword
}).then(e => { }).then(e => {
// console.log(e);
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({
...@@ -109,7 +106,6 @@ ...@@ -109,7 +106,6 @@
}).catch(errors => { }).catch(errors => {
let key = errors[0].key let key = errors[0].key
key = key.replace(key[0], key[0].toUpperCase()) key = key.replace(key[0], key[0].toUpperCase())
// console.log(key, 'focus' + key);
this['focus' + key] = true this['focus' + key] = true
}) })
} }
......
...@@ -39,11 +39,8 @@ ...@@ -39,11 +39,8 @@
content: '已经仔细阅读注销提示,知晓可能带来的后果,并确认要注销', content: '已经仔细阅读注销提示,知晓可能带来的后果,并确认要注销',
complete: (e) => { complete: (e) => {
if (e.confirm) { if (e.confirm) {
const db = uniCloud.database();
const uniIdco = uniCloud.importObject("uni-id-co"); const uniIdco = uniCloud.importObject("uni-id-co");
uniIdco.closeAccount().then((e) => { uniIdco.closeAccount().then((e) => {
// console.log(e);
uni.showToast({ uni.showToast({
title: '注销成功', title: '注销成功',
duration: 3000 duration: 3000
......
...@@ -115,7 +115,6 @@ export default { ...@@ -115,7 +115,6 @@ export default {
this.$refs.popup.open() this.$refs.popup.open()
} else { } else {
console.log(e.errMsg); console.log(e.errMsg);
// console.log(e.errCode);
} }
}).finally(e => { }).finally(e => {
this.formData.captcha = '' this.formData.captcha = ''
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
<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>
<!-- #ifndef MP -->
<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>
<!-- #endif -->
<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="请输入要设置的昵称">
...@@ -30,8 +32,6 @@ ...@@ -30,8 +32,6 @@
</view> </view>
</template> </template>
<script> <script>
const db = uniCloud.database();
const usersTable = db.collection('uni-id-users')
const uniIdCo = uniCloud.importObject("uni-id-co") const uniIdCo = uniCloud.importObject("uni-id-co")
import { import {
store, store,
...@@ -82,12 +82,12 @@ ...@@ -82,12 +82,12 @@
} }
}) })
}, },
logout(){ logout(){
mutations.logout() mutations.logout()
}, },
bindMobileSuccess(){ bindMobileSuccess(){
mutations.updateUserInfo() mutations.updateUserInfo()
}, },
changePassword(){ changePassword(){
uni.navigateTo({ uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd', url: '/uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd',
...@@ -123,9 +123,7 @@ ...@@ -123,9 +123,7 @@
"provider": 'univerify', "provider": 'univerify',
"univerifyStyle": this.univerifyStyle, "univerifyStyle": this.univerifyStyle,
success: async e => { success: async e => {
// console.log(e.authResult);
uniIdCo.bindMobileByUniverify(e.authResult).then(res => { uniIdCo.bindMobileByUniverify(e.authResult).then(res => {
// console.log(res);
mutations.updateUserInfo() mutations.updateUserInfo()
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
...@@ -148,7 +146,6 @@ ...@@ -148,7 +146,6 @@
}) })
}, },
setNickname(nickname) { setNickname(nickname) {
// console.log(nickname);
if (nickname) { if (nickname) {
mutations.updateUserInfo({nickname}) mutations.updateUserInfo({nickname})
this.$refs.dialog.close() this.$refs.dialog.close()
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
"style": { "style": {
"navigationBarTitleText": "绑定手机号码" "navigationBarTitleText": "绑定手机号码"
} }
}, },
{ {
"path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage", "path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
}, },
{ {
"path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd", "path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"style": { "style": {
...@@ -81,14 +81,15 @@ ...@@ -81,14 +81,15 @@
"navigationBarTitleText": "修改密码", "navigationBarTitleText": "修改密码",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},
},{ {
"path": "uni_modules/uni-id-pages/pages/register/register-admin", "path": "uni_modules/uni-id-pages/pages/register/register-admin",
"style": { "style": {
"navigationBarTitleText": "注册管理员账号", "navigationBarTitleText": "注册管理员账号",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},{ },
{
"path": "uni_modules/uni-id-pages/pages/userinfo/set-pwd/set-pwd", "path": "uni_modules/uni-id-pages/pages/userinfo/set-pwd/set-pwd",
"style": { "style": {
"navigationBarTitleText": "设置密码", "navigationBarTitleText": "设置密码",
......
const assert = require('assert')
const {
Validator
} = require('./validator')
const {
ERROR
} = require('./error')
const {
getType
} = require('./utils')
const testCaseList = [{
value: {
username: 'uname'
},
schema: {
username: 'username'
},
expected: undefined
}, {
value: {
username: '123456'
},
schema: {
username: 'username'
},
expected: {
errCode: ERROR.INVALID_USERNAME
}
}, {
value: {
username: '数字天堂'
},
schema: {
username: 'username'
},
expected: {
errCode: ERROR.INVALID_USERNAME
}
}, {
value: {
password: '123456abc'
},
schema: {
password: 'password'
}
}, {
value: {
password: '123456def'
},
schema: {
password: 'password'
},
mixin: [{
type: 'password',
handler: function (password) {
if (typeof password !== 'string' || password.length < 10) {
return {
errCode: ERROR.INVALID_PASSWORD
}
}
}
}],
expected: {
errCode: ERROR.INVALID_PASSWORD
}
}, {
value: {
numberOrString: '123456'
},
schema: {
numberOrString: 'number|string'
}
}, {
value: {
numberOrString: 123456
},
schema: {
numberOrString: 'number|string'
}
}, {
value: {
numberOrString: '123456'
},
schema: {
numberOrString: 'string|number'
}
}, {
value: {
numberOrString: 123456
},
schema: {
numberOrString: 'string|number'
}
}, {
value: {
numberOrString: ['123456']
},
schema: {
numberOrString: 'array<number|string>'
}
}, {
value: {
numberOrString: [123456]
},
schema: {
numberOrString: 'array<number|string>'
}
}, {
value: {
numberOrString: [123456, '123456']
},
schema: {
numberOrString: 'array<number|string>'
}
}, {
value: {
numberOrString: ['123456']
},
schema: {
numberOrString: 'array<string|number>'
}
}, {
value: {
numberOrString: [123456]
},
schema: {
numberOrString: 'array<string|number>'
}
}, {
value: {
numberOrString: [123456, '123456']
},
schema: {
numberOrString: 'array<string|number>'
}
}, {
value: {
numberOrString: ['123456']
},
mixin: [{
type: '1to6',
handler: function (val) {
if (val !== '123456') {
return {
errCode: ERROR.INVALID_PARAM
}
}
}
}],
schema: {
numberOrString: 'array<number|1to6>'
}
}, {
value: {
username: ''
},
schema: {
username: {
required: false,
type: 'username'
}
}
}, {
value: {
username: ' '
},
schema: {
username: {
required: false,
type: 'username'
}
}
}, {
value: {
username: ' '
},
schema: {
username: 'username'
},
expected: {
errCode: ERROR.PARAM_REQUIRED
}
}, {
value: {
username: ''
},
schema: {
username: 'username'
},
expected: {
errCode: ERROR.PARAM_REQUIRED
}
}, {
value: {
mobile: '18811112222'
},
schema: {
mobile: 'mobile'
}
}, {
value: {
mobile: '18811112222'
},
schema: {
mobile: {
required: false,
type: 'mobile'
}
}
}, {
value: {
mobile: ''
},
schema: {
mobile: 'mobile'
},
expected: {
errCode: ERROR.PARAM_REQUIRED
}
}, {
value: {
mobile: ''
},
schema: {
mobile: {
required: false,
type: 'mobile'
}
}
}, {
value: {
mobile: '123456'
},
schema: {
mobile: 'mobile'
},
expected: {
errCode: ERROR.INVALID_MOBILE
}
}, {
value: {
email: 'test@dcloud.io'
},
schema: {
email: 'email'
}
}, {
value: {
email: 'test@dcloud.io'
},
schema: {
email: {
required: false,
type: 'email'
}
}
}, {
value: {
email: ''
},
schema: {
email: 'email'
},
expected: {
errCode: ERROR.PARAM_REQUIRED
}
}, {
value: {
email: ''
},
schema: {
email: {
required: false,
type: 'email'
}
}
}, {
value: {
email: 'test'
},
schema: {
email: 'email'
},
expected: {
errCode: ERROR.INVALID_EMAIL
}
}]
function execTestCase ({
value = {},
schema = {},
mixin = [],
expected = undefined,
error = ''
} = {}) {
const validator = new Validator()
for (let i = 0; i < mixin.length; i++) {
const {
type,
handler
} = mixin[i]
validator.mixin(type, handler)
}
let validateResult,
validateError
try {
validateResult = validator.validate(value, schema)
} catch (err) {
validateError = err
}
const tag = JSON.stringify({ value, schema })
if (error) {
if (typeof error === 'string') {
assert.strictEqual(validateError.message.indexOf(error) > -1, true, `[${tag}] error message error`)
} else if (getType(error) === 'regexp') {
assert.strictEqual(error.test(validateError), true, `[${tag}] error message error`)
} else {
throw new Error(`[${tag}] invalid test case`)
}
return
}
if (expected === undefined) {
assert.strictEqual(validateResult, undefined, `[${tag}] validate result error`)
return
}
const expectedKeys = Object.keys(expected)
let passResultCheck = true
for (let i = 0; i < expectedKeys.length; i++) {
const key = expectedKeys[i]
if (expected[key] !== validateResult[key]) {
passResultCheck = false
break
}
}
assert.strictEqual(passResultCheck, true, `[${tag}] validate result error`)
}
for (let i = 0; i < testCaseList.length; i++) {
console.log(`test case: ${i}`)
execTestCase(testCaseList[i])
console.log(`test case: ${i}, pass`)
}
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
"title": "头像地址", "title": "头像地址",
"trim": "both", "trim": "both",
"permission": { "permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", "read": true,
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"description": "用file类型方便使用uni-file-picker组件", "description": "用file类型方便使用uni-file-picker组件",
"title": "头像文件", "title": "头像文件",
"permission": { "permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", "read": true,
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
"title": "昵称", "title": "昵称",
"trim": "both", "trim": "both",
"permission": { "permission": {
"read": "doc._id == auth.uid || 'READ_UNI_ID_USERS' in auth.permission", "read": true,
"write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission" "write": "doc._id == auth.uid || 'CREATE_UNI_ID_USERS' in auth.permission || 'UPDATE_UNI_ID_USERS' in auth.permission"
} }
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册