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