优化bug

Signed-off-by: java110 <928255095@qq.com>
This commit is contained in:
java110 2024-07-18 15:32:55 +00:00 committed by Gitee
parent 2ca31c8801
commit ceaed2cfc5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -57,6 +57,7 @@ export function autoLogin(options) {
if (hasLogin()) { if (hasLogin()) {
return; return;
} }
//todo 如果是 h5 或者 微信小程序 ,检查是否做了配置,如果没有做配置不做自登陆 //todo 如果是 h5 或者 微信小程序 ,检查是否做了配置,如果没有做配置不做自登陆
// #ifdef H5 || MP-WEIXIN // #ifdef H5 || MP-WEIXIN
autoLoginWechat(options); autoLoginWechat(options);
@ -71,10 +72,13 @@ export function autoLogin(options) {
export function autoLoginWechat(options) { export function autoLoginWechat(options) {
let _openId = options.openId; let _openId = options.openId;
if (_openId) { //h5 自登陆的情况 if (_openId) { //h5 自登陆的情况
let _time = uni.getStorageSync('refreshUserOpenId');
if(_time){
loginByOpenId(_openId); loginByOpenId(_openId);
uni.removeStorageSync('refreshUserOpenId');
return; return;
} }
}
//todo 如果参数中带了wAppId //todo 如果参数中带了wAppId
let _wAppId = options.wAppId; let _wAppId = options.wAppId;
@ -83,6 +87,7 @@ export function autoLoginWechat(options) {
return; return;
} }
let _objType = "1100"; // todo public let _objType = "1100"; // todo public
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
_objType = "1000"; _objType = "1000";
@ -121,6 +126,8 @@ export function _refreshWechatOpenId(options, appId) {
wAppId: appId, wAppId: appId,
}).then(_data => { }).then(_data => {
if (_data.code == 0) { if (_data.code == 0) {
let _date = new Date();
uni.setStorageSync("refreshUserOpenId", _data.getTime());
window.location.href = _data.data.openUrl; window.location.href = _data.data.openUrl;
return; return;
} }
@ -177,7 +184,9 @@ export function loginByOpenId(openId){
communityId: _json.data.communityId, communityId: _json.data.communityId,
communityName: _json.data.communityName, communityName: _json.data.communityName,
}); });
uni.removeStorageSync("ownerInfo");
saveUserLoginInfo(_json.data.userId, _json.data.token, _json.data.key); saveUserLoginInfo(_json.data.userId, _json.data.token, _json.data.key);
}, },
fail: function(e) { fail: function(e) {
uni.hideLoading(); uni.hideLoading();