优化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

@ -26,11 +26,11 @@ import {
getWAppId, getWAppId,
saveWAppId, saveWAppId,
getLoginFlag getLoginFlag
} from '@/lib/java110/utils/StorageUtil.js'; } from '@/lib/java110/utils/StorageUtil.js';
import { import {
isWxOrAli isWxOrAli
} from '../../lib/java110/utils/EnvUtil.js'; } from '../../lib/java110/utils/EnvUtil.js';
const LOGIN_FLAG = 'loginFlag'; //登录标识 const LOGIN_FLAG = 'loginFlag'; //登录标识
@ -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);
@ -70,19 +71,23 @@ 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;
if(_wAppId){ if (_wAppId) {
_generatorOpenId(options, _wAppId); _generatorOpenId(options, _wAppId);
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;
} }
@ -158,12 +165,12 @@ export function _refreshWechatMiniOpenId() {
}); });
} }
export function loginByOpenId(openId){ export function loginByOpenId(openId) {
requestNoAuth({ requestNoAuth({
url: url.ownerUserLoginByOpenId, url: url.ownerUserLoginByOpenId,
method: "POST", method: "POST",
data: { data: {
openId:openId openId: openId
}, },
//动态数据 //动态数据
success: function(res) { success: function(res) {
@ -172,12 +179,14 @@ export function loginByOpenId(openId){
return; return;
} }
//todo 保存业主信息 //todo 保存业主信息
uni.setStorageSync("userInfo",_json.data); uni.setStorageSync("userInfo", _json.data);
uni.setStorageSync("currentCommunityInfo",{ uni.setStorageSync("currentCommunityInfo", {
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();