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

修复 iOS端,一键登录功能卡在showLoading的问题

上级 285236c9
## 1.2.8(2022-09-01)
+ 修复 iOS端,一键登录功能卡在showLoading的问题
## 1.2.7(2022-08-10) ## 1.2.7(2022-08-10)
- 修复微信小程序绑定手机号失败的问题 - 修复微信小程序绑定手机号失败的问题
## 1.2.6(2022-06-29) ## 1.2.6(2022-06-29)
......
...@@ -190,10 +190,8 @@ ...@@ -190,10 +190,8 @@
icon: 'none' icon: 'none'
}); });
} }
uni.showLoading({mask: true}) if (type == 'univerify') {
if (type == 'univerify' && uni.getUniverifyManager) {
let univerifyManager = uni.getUniverifyManager() let univerifyManager = uni.getUniverifyManager()
console.log('是新版');
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);
//同步一键登录弹出层隐私协议框是否打勾 //同步一键登录弹出层隐私协议框是否打勾
...@@ -231,10 +229,11 @@ ...@@ -231,10 +229,11 @@
} }
// 订阅自定义按钮点击事件 // 订阅自定义按钮点击事件
univerifyManager.onButtonsClick(onButtonsClickFn) univerifyManager.onButtonsClick(onButtonsClickFn)
// 调用一键登录弹框 // 调用一键登录弹框
return univerifyManager.login({ console.log(this.univerifyStyle,univerifyManager.login);
"univerifyStyle": this.univerifyStyle, return univerifyManager.login({
success:res=> { "univerifyStyle": this.univerifyStyle,
success:res=> {
console.log('login success', res) console.log('login success', res)
this.login(res.authResult, 'univerify') this.login(res.authResult, 'univerify')
}, },
...@@ -245,16 +244,17 @@ ...@@ -245,16 +244,17 @@
}); });
}, },
complete(e){ complete(e){
console.log(e);
uni.hideLoading() uni.hideLoading()
// 取消订阅自定义按钮点击事件 // 取消订阅自定义按钮点击事件
univerifyManager.offButtonsClick(onButtonsClickFn) univerifyManager.offButtonsClick(onButtonsClickFn)
} }
}) })
} }
uni.showLoading({mask: true})
uni.login({ uni.login({
"provider": type, "provider": type,
"onlyAuthorize": true, //请勿直接使用前端获取的unionid或openid直接用于登录,前端的数据都是不可靠的 "onlyAuthorize": true, //请勿直接使用前端获取的unionid或openid直接用于登录,前端的数据都是不可靠的
"univerifyStyle": this.univerifyStyle,
complete: (e) => { complete: (e) => {
console.log(e); console.log(e);
uni.hideLoading() uni.hideLoading()
...@@ -271,63 +271,6 @@ ...@@ -271,63 +271,6 @@
}, },
fail: async (err) => { fail: async (err) => {
console.log(err); console.log(err);
// 以下代码为兼容旧版(HBuilderX3.2.13之前)HBuilderX3.2.13以上版本可直接删除
if (type == 'univerify'&& !uni.getUniverifyManager) {
if (err.metadata && err.metadata.error_data) {
uni.showToast({
title: t('oneClickLogin') + ":" + err.metadata.error_data,
icon: 'none'
});
}
if (err.errMsg) {
uni.showToast({
title: t('oneClickLogin') + ":" + err.errMsg,
icon: 'none'
});
}
switch (err.errCode) {
case 30002:
console.log('在一键登录界面,点击其他登录方式');
break;
case 30003:
console.log('关闭了登录');
if (navigateBack) {
uni.navigateBack()
}
break;
case 30006:
uni.showModal({
title: t('loginErr'),
content: err.metadata.error_data,
showCancel: false,
confirmText: t('gotIt'),
});
break;
case "30008":
console.log('点击了第三方登录,provider:', err.provider);
//同步一键登录弹出层隐私协议框是否打勾
let agree = (await uni.getCheckBoxState())[1].state
console.log('agree', agree);
uni.$emit('setAgreementsAgree', agree)
let {
path
} = this.univerifyStyle.buttons.list[res.index]
console.log('path', path);
if (path) {
this.to(path)
} else {
setTimeout(() => {
console.log('agree', this.agree);
this.login_before(err.provider)
}, 500)
}
break;
default:
console.log(err);
break;
}
}
// 以上代码为兼容旧版(HBuilderX3.2.13之前)HBuilderX3.2.13以上版本可直接删除
} }
}) })
}, },
......
{ {
"name": "uni-starter", "name": "",
"appid": "请点击重新获取", "appid": "",
"description": "", "description": "",
"versionName": "1.0.0", "versionName": "",
"versionCode": "100", "versionCode": "100",
"transformPx": false, "transformPx": false,
"app-plus": { "app-plus": {
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
"delay": 0 "delay": 0
}, },
"modules": { "modules": {
"OAuth": {
}
}, },
"distribute": { "distribute": {
"android": { "android": {
...@@ -40,6 +42,10 @@ ...@@ -40,6 +42,10 @@
"ios": { "ios": {
}, },
"sdkConfigs": { "sdkConfigs": {
"oauth": {
"univerify": {
}
}
} }
} }
}, },
...@@ -69,6 +75,5 @@ ...@@ -69,6 +75,5 @@
"uniStatistics": { "uniStatistics": {
"enable": false "enable": false
}, },
"vueVersion": "2", "vueVersion": "2"
"_spaceID": ""
} }
\ No newline at end of file
{ {
"id": "uni-starter", "id": "uni-starter",
"displayName": "uni-starter", "displayName": "uni-starter",
"version": "1.2.7", "version": "1.2.8",
"description": "云端一体应用快速开发基本项目模版", "description": "云端一体应用快速开发基本项目模版",
"keywords": [ "keywords": [
"login", "login",
......
...@@ -125,11 +125,10 @@ ...@@ -125,11 +125,10 @@
@import url("../common/login-page.css"); @import url("../common/login-page.css");
.quickLogin { .quickLogin {
width: 650rpx;
height: 350px; height: 350px;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.quickLoginBtn { .quickLoginBtn {
......
{ {
"scripts": { "scripts": {
"preupload": "node uni_modules_tools/main.js change", // "preupload": "node uni_modules_tools/main.js change",
"postupload": "node uni_modules_tools/main.js recovery" // "postupload": "node uni_modules_tools/main.js recovery"
} }
} }
\ No newline at end of file
...@@ -425,8 +425,10 @@ exports.main = async (event, context) => { ...@@ -425,8 +425,10 @@ exports.main = async (event, context) => {
await uniIdLog(loginRes) await uniIdLog(loginRes)
return loginRes return loginRes
break; break;
case 'loginByUniverify': case 'loginByUniverify':
res = await uniID.loginByUniverify(params) console.error(params)
res = await uniID.loginByUniverify(params)
console.log(999999999,res)
await uniIdLog(res) await uniIdLog(res)
break; break;
case 'loginByApple': case 'loginByApple':
......
{ {
"name": "uni-id-cf-123", "name": "uni-id-cf-123",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha", "uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center",
"uni-id": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id" "uni-id": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
} },
} "extensions": {
"uni-cloud-verify": {}
}
}
\ No newline at end of file
const fs = require('fs'); const fs = require('fs');
module.exports = function(){ module.exports = function(){
console.log('开始执行脚本change_after'); console.log('开始执行脚本change_after');
let changelog = fs.readFileSync(process.cwd() + '/changelog.md', 'utf-8').split("##")[1].split("\n").slice(1).join(' '); /* let changelog = fs.readFileSync(process.cwd() + '/changelog.md', 'utf-8').split("##")[1].split("\n").slice(1).join(' ');
console.log(changelog); console.log(changelog);
// 这里是修改完相关敏感配置后执行的脚本,你可以在这里自定义逻辑, // 这里是修改完相关敏感配置后执行的脚本,你可以在这里自定义逻辑,
// 比如执行git提交命令
// 比如执行git提交命令
var shell = require("shelljs"); var shell = require("shelljs");
var exec = shell.exec; var exec = shell.exec;
...@@ -20,5 +22,6 @@ module.exports = function(){ ...@@ -20,5 +22,6 @@ module.exports = function(){
shell.echo('Error: Git commit failed'); shell.echo('Error: Git commit failed');
shell.exit(1); shell.exit(1);
} }
shell.exec(`echo git success ${changelog}`); shell.exec(`echo git success ${changelog}`);
*/
} }
\ No newline at end of file
// "文件路径" : {"键名":"改成什么"} // "文件路径" : {"键名":"改成什么"}
{ {
"/manifest.json": { "/manifest.json": {
"appid": "请点击重新获取", "appid": "",
"mp-weixin" : { "name": "",
"appid" : "" "versionName": "",
}, "mp-weixin": {
"app-plus" : { "appid": ""
"distribute" :{ },
"sdkConfigs" : { "vueVersion": "2",
"oauth" : { "app-plus": {
"weixin" : { "modules": {
"appid" : "", "OAuth": {}
"appsecret" : "", },
"UniversalLinks" : "" "distribute": {
}, "sdkConfigs": {
"univerify" : {} "oauth": {
}, "univerify": {}
"share" : { }
"weixin" : { }
"appid" : "", }
"UniversalLinks" : "" }
}
},
"geolocation" : {
"baidu" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "请填写地图的key",
"appkey_android" : "请填写地图的key"
}
}
}
}
},
"_spaceID" : "",
"vueVersion" : "2"
}, },
"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json": { "/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json": {
"tokenExpiresIn": 7200, "tokenExpiresIn": 7200,
"app": { "app": {
"oauth": { "oauth": {
...@@ -77,4 +63,4 @@ ...@@ -77,4 +63,4 @@
} }
} }
} }
} }
\ No newline at end of file
//脚本文件目录 __dirname //脚本文件目录 __dirname
//运行脚本的目录,即:项目的目录 process.cwd() //运行脚本的目录,即:项目的目录 process.cwd()
//配置文件 //配置文件
const fs = require('fs'), const fs = require('fs'),
Hjson = require('hjson'), Hjson = require('hjson'),
config = Hjson.rt.parse(fs.readFileSync(__dirname+'/config.js', 'utf-8')) config = Hjson.rt.parse(fs.readFileSync(__dirname+'/config.js', 'utf-8'))
const change_after = require('./change_after') const change_after = require('./change_after')
if(process.argv[2] == 'change'){ if(process.argv[2] == 'change'){
change(config,()=>{ change(config,()=>{
console.log('脚本change已经执行成功'); console.log('脚本change已经执行成功');
...@@ -26,7 +26,7 @@ function change(config,callback){ ...@@ -26,7 +26,7 @@ function change(config,callback){
//保持原文件名先备份一份到/uni_modules_tools/copy目录下,然后再覆盖 //保持原文件名先备份一份到/uni_modules_tools/copy目录下,然后再覆盖
writeFileRecursive(copyPath, fileText, function(err) { //创建目录并写入文件 writeFileRecursive(copyPath, fileText, function(err) { //创建目录并写入文件
if (err) { if (err) {
return console.log({err}); return console.log(err);
} }
//改写 //改写
let HfileObj = Hjson.rt.parse(fileText) let HfileObj = Hjson.rt.parse(fileText)
...@@ -56,9 +56,11 @@ function change(config,callback){ ...@@ -56,9 +56,11 @@ function change(config,callback){
function recovery(){ function recovery(){
let paths = Object.keys(config) let paths = Object.keys(config)
console.log(paths);
paths.forEach(path=>{ paths.forEach(path=>{
console.log(__dirname + '/copy' + path); console.log(__dirname + '/copy' + path);
let oldFile = fs.readFileSync(__dirname + '/copy' + path) let oldFile = fs.readFileSync(__dirname + '/copy' + path)
console.log(process.cwd() + path);
fs.writeFile(process.cwd() + path, oldFile, function(err) { fs.writeFile(process.cwd() + path, oldFile, function(err) {
if (err) { if (err) {
console.log(err); console.log(err);
...@@ -92,15 +94,10 @@ function writeFileRecursive(path, buffer, callback) { ...@@ -92,15 +94,10 @@ function writeFileRecursive(path, buffer, callback) {
function mergeJSON(minor, main) { function mergeJSON(minor, main) {
for (var key in main) { for (var key in main) {
if (typeof(main[key]) != 'object' ) { if (typeof(main[key]) != 'object' ) {
console.log({key,main});
minor[key] = main[key]; minor[key] = main[key];
}else{ }else{
console.log(9999,{minor,key,main}); console.log('[',minor[key], main[key],']');
if(minor){ mergeJSON(minor[key], main[key]);
mergeJSON(minor[key], main[key]);
}else{
console.log(minor,'不存在:'+key);
}
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册