优化监控功能

This commit is contained in:
wuxw 2024-07-18 23:33:06 +08:00
parent f05adbec2d
commit f449c7c7f2
3 changed files with 35 additions and 28 deletions

View File

@ -20,17 +20,17 @@ import {
} from '../../api/community/communityApi.js'; } from '../../api/community/communityApi.js';
import { import {
saveOwnerStorage, saveOwnerStorage,
saveUserLoginInfo, saveUserLoginInfo,
removeUserLoginInfo, removeUserLoginInfo,
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'; //登录标识
@ -71,15 +71,18 @@ 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');
loginByOpenId(_openId); if(_time){
return; loginByOpenId(_openId);
uni.removeStorageSync('refreshUserOpenId');
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;
} }
@ -123,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;
} }
@ -160,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) {
@ -174,13 +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"); 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();

View File

@ -35,6 +35,7 @@
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'; import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
/** index.js **/ /** index.js **/
import context from '../../lib/java110/Java110Context.js'; import context from '../../lib/java110/Java110Context.js';
import { getCommunityId } from '../../api/community/communityApi.js';
const constant = context.constant; //app const constant = context.constant; //app
//app //app
const app = getApp().globalData; const app = getApp().globalData;
@ -61,7 +62,7 @@
onLoad: function(options) { onLoad: function(options) {
let that = this; let that = this;
context.onLoad(options); context.onLoad(options);
that.communityId = context.getUserInfo().communityId; that.communityId = getCommunityId();
that._loadNotices(); that._loadNotices();
}, },
onShow: function() { onShow: function() {