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

1. 改造微信登陆逻辑,直接使用参数实现 2. 修复,一键登录弹出层,已勾选“同意隐私政策协议”点击自定义登陆按钮,报“你未同意隐私政策协议”的bug

上级 e7d17999
## 1.1.12(2021-09-28)
1. 改造微信登陆逻辑,直接使用`uni.login`参数`"onlyAuthorize":true`实现
2. 修复,一键登录弹出层,已勾选“同意隐私政策协议”点击自定义登陆按钮,报“你未同意隐私政策协议”的bug
## 1.1.11(2021-09-24) ## 1.1.11(2021-09-24)
优化邀请下载app页(`pages/ucenter/invite`)下载按钮闪烁的问题 优化邀请下载app页(`pages/ucenter/invite`)下载按钮闪烁的问题
## 1.1.10(2021-09-23) ## 1.1.10(2021-09-23)
......
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
this.$emit('setAgree',this.isAgree) this.$emit('setAgree',this.isAgree)
} }
}, },
created() {
uni.$on('setAgreementsAgree',state=>{
this.$emit('setAgree',state)
})
},
data() { data() {
return { return {
isAgree:false isAgree:false
......
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
"logo": "/static/uni-quick-login/univerify.png", "logo": "/static/uni-quick-login/univerify.png",
} }
], ],
oauthServices: [],
config: {}, config: {},
univerifyStyle: { //一键登录弹出窗的样式配置参数 univerifyStyle: { //一键登录弹出窗的样式配置参数
"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。 "fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
...@@ -110,7 +109,7 @@ ...@@ -110,7 +109,7 @@
}, },
async created() { async created() {
let servicesList = this.servicesList let servicesList = this.servicesList
//去掉配置中不存在的 //去掉配置中不存在的 注意,在/common/appInit.js中已清除有配置但设备环境不支持的登陆项
servicesList = servicesList.filter(item => this.loginConfig.includes(item.id)) servicesList = servicesList.filter(item => this.loginConfig.includes(item.id))
//处理一键登录 //处理一键登录
if (this.loginConfig.includes('univerify')) { if (this.loginConfig.includes('univerify')) {
...@@ -128,6 +127,7 @@ ...@@ -128,6 +127,7 @@
} }
}) })
} }
console.log(servicesList);
//如果当前页面为默认登陆界面。当前第一优先级的“微信和苹果登陆”要隐藏,因为他已经被渲染在默认登陆界面顶部 //如果当前页面为默认登陆界面。当前第一优先级的“微信和苹果登陆”要隐藏,因为他已经被渲染在默认登陆界面顶部
if ( if (
this.getRoute(1) == '/pages/ucenter/login-page/index/index' && ['weixin', 'apple'].includes(this this.getRoute(1) == '/pages/ucenter/login-page/index/index' && ['weixin', 'apple'].includes(this
...@@ -143,18 +143,6 @@ ...@@ -143,18 +143,6 @@
console.log('servicesList', servicesList, this.servicesList); console.log('servicesList', servicesList, this.servicesList);
}, },
mounted() { mounted() {
// #ifdef APP-PLUS
plus.oauth.getServices(oauthServices => {
this.oauthServices = oauthServices
}, err => {
uni.showModal({
title: this.$t('uniQuickLogin').getProviderFail + '' + JSON.stringify(err),
showCancel: false,
confirmText: this.$t('common').gotIt
});
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
// #endif
}, },
methods: { methods: {
...mapMutations({ ...mapMutations({
...@@ -189,36 +177,12 @@ ...@@ -189,36 +177,12 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
// console.log(arguments);
let oauthService = this.oauthServices.find((service) => service.id == type)
// console.log(type);
// #ifdef APP-PLUS
//请勿直接使用前端获取的unionid或openid直接用于登录,前端的数据都是不可靠的
if (type == 'weixin') {
return oauthService.authorize(({
code
}) => {
// console.log(code);
this.login({
code
}, type)
},
err => {
uni.hideLoading()
console.error(err);
uni.showModal({
content: JSON.stringify(err),
showCancel: false
});
})
}
// #endif
uni.login({ uni.login({
"provider": type, "provider": type,
"onlyAuthorize":true, //请勿直接使用前端获取的unionid或openid直接用于登录,前端的数据都是不可靠的
"univerifyStyle": this.univerifyStyle, "univerifyStyle": this.univerifyStyle,
complete: (e) => { complete: (e) => {
uni.hideLoading()
console.log(e); console.log(e);
}, },
success: async e => { success: async e => {
...@@ -227,22 +191,12 @@ ...@@ -227,22 +191,12 @@
let res = await this.getUserInfo({ let res = await this.getUserInfo({
provider: "apple" provider: "apple"
}) })
uni.hideLoading()
Object.assign(e.authResult, res.userInfo) Object.assign(e.authResult, res.userInfo)
} }
// #ifdef MP-WEIXIN this.login( type == 'weixin'?e.code:e.authResult , type)
if (type == 'weixin') {
return this.login({
code: e.code
}, type)
}
// #endif
this.login(e.authResult, type)
}, },
fail: (err) => { fail:async (err) => {
uni.hideLoading()
console.log(err); console.log(err);
if (type == 'univerify') { if (type == 'univerify') {
if (err.metadata && err.metadata.error_data) { if (err.metadata && err.metadata.error_data) {
uni.showToast({ uni.showToast({
...@@ -280,6 +234,11 @@ ...@@ -280,6 +234,11 @@
icon: 'none' icon: 'none'
}); });
console.log('点击了第三方登陆,provider:', err.provider); console.log('点击了第三方登陆,provider:', err.provider);
//同步一键登陆弹出层隐私协议框是否打勾
let agree = (await uni.getCheckBoxState())[1].state
console.log('agree',agree);
uni.$emit('setAgreementsAgree',agree)
let { let {
path path
} = this.servicesList.find(item => item.id == err.provider) || {} } = this.servicesList.find(item => item.id == err.provider) || {}
...@@ -287,7 +246,10 @@ ...@@ -287,7 +246,10 @@
if (path && path != this.getRoute(1)) { //存在路径,且并不是当前已经打开的路径 if (path && path != this.getRoute(1)) { //存在路径,且并不是当前已经打开的路径
this.to(path) this.to(path)
} else { } else {
this.login_before(err.provider) setTimeout(()=>{
console.log('agree',this.agree);
this.login_before(err.provider)
},500)
} }
break; break;
default: default:
......
...@@ -62,9 +62,9 @@ ...@@ -62,9 +62,9 @@
}, },
"FaceID": { "FaceID": {
}, },
"Push": {
},
"Geolocation": { "Geolocation": {
},
"Push": {
} }
}, },
"distribute": { "distribute": {
......
{ {
"id": "uni-starter", "id": "uni-starter",
"displayName": "uni-starter", "displayName": "uni-starter",
"version": "1.1.11", "version": "1.1.12",
"description": "云端一体应用快速开发基本项目模版", "description": "云端一体应用快速开发基本项目模版",
"keywords": [ "keywords": [
"login", "login",
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
"permission": { "permission": {
"create": "auth.uid != null", "create": "auth.uid != null",
"read": true, "read": true,
"delete": true, "delete": false,
"update": true "update": false
}, },
"properties": { "properties": {
"_id": { "_id": {
......
{ {
"name" : "统一应用基本项目", "name" : "统一应用基本项目",
"appid" : "__UNI__E5373F7", "appid" : "__UNI__03B096E",
"description" : "云端一体应用快速开发模版", "description" : "云端一体应用快速开发模版",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
"Share" : {}, "Share" : {},
"OAuth" : {}, "OAuth" : {},
"FaceID" : {}, "FaceID" : {},
"Push" : {}, "Geolocation" : {},
"Geolocation" : {} "Push" : {}
}, },
"distribute" : { "distribute" : {
"android" : { "android" : {
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
"weixin" : { "weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0", "appid" : "wxffdd8fa6ec4ef2a0",
"appsecret" : "", "appsecret" : "",
"UniversalLinks" : "" "UniversalLinks" : "https://uniapp.dcloud.io/ulink/"
}, },
"univerify" : {} "univerify" : {}
}, },
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
"share" : { "share" : {
"weixin" : { "weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0", "appid" : "wxffdd8fa6ec4ef2a0",
"UniversalLinks" : "" "UniversalLinks" : "https://uniapp.dcloud.io/ulink/"
} }
}, },
"geolocation" : { "geolocation" : {
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
} }
} }
}, },
"_spaceID" : "", "_spaceID" : "76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e",
"vueVersion" : "2" "vueVersion" : "2"
} }
//... //...
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册