Commit 7814c14c authored by 邓晓峰's avatar 邓晓峰

feat: 添加高德地图

parents fe39bc21 e4d9a0e8
Pipeline #47060 skipped with stages
...@@ -558,7 +558,6 @@ class Notifier { ...@@ -558,7 +558,6 @@ class Notifier {
mqtt_IsSSL: true mqtt_IsSSL: true
}; };
if (Array.isArray(res.getMe) && res.getMe.length > 0) { if (Array.isArray(res.getMe) && res.getMe.length > 0) {
debugger
if (res.getMe[0]) { if (res.getMe[0]) {
const data = res.getMe[0]; const data = res.getMe[0];
mqttConfig.mqtt_IsSSL = self._siteConfig.IsSSL = data.IsSSL ? data.IsSSL : false; mqttConfig.mqtt_IsSSL = self._siteConfig.IsSSL = data.IsSSL ? data.IsSSL : false;
...@@ -583,14 +582,14 @@ class Notifier { ...@@ -583,14 +582,14 @@ class Notifier {
mqttConfig.mqtt_iotIP = self._siteConfig.mqtt_iotIP = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort; mqttConfig.mqtt_iotIP = self._siteConfig.mqtt_iotIP = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort;
self.props.updateConfig && self.props.updateConfig(Object.assign({}, self.props.global, { // self.props.updateConfig && self.props.updateConfig(Object.assign({}, self.props.global, {
...mqttConfig // ...mqttConfig
})) // }))
// 应用共享状态只在initMicro中更新了一次,异步修改了的globalConfig,子应用读取到的是旧的,需要更新一下应用共享状态 // 应用共享状态只在initMicro中更新了一次,异步修改了的globalConfig,子应用读取到的是旧的,需要更新一下应用共享状态
setGlobalState({ // setGlobalState({
globalConfig: window.globalConfig // globalConfig: window.globalConfig
}); // });
} }
} else { } else {
Logger.info('获取mqtt服务器参数失败'); Logger.info('获取mqtt服务器参数失败');
......
...@@ -48,7 +48,9 @@ export const initGlobalConfig = () => { ...@@ -48,7 +48,9 @@ export const initGlobalConfig = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
let client = params.getParams('client') || Cookies.get('city') let client = params.getParams('client') || Cookies.get('city')
client = client && client !== 'undefined' ? client : 'city'; client = client && client !== 'undefined' ? client : 'city';
appService.getWateWayConfig().then(res => { appService.getWateWayConfig({
ignoreSite: true,
}).then(res => {
const hasGateWay = const hasGateWay =
!res || !res.data ? false : isString(res.data) ? JSON.parse(res.data) : typeof res.data === 'boolean' ? res.data : false; !res || !res.data ? false : isString(res.data) ? JSON.parse(res.data) : typeof res.data === 'boolean' ? res.data : false;
// if (res.code === 0 && res.data === 'true') { // if (res.code === 0 && res.data === 'true') {
......
...@@ -6,21 +6,25 @@ import Cookies from 'js-cookie'; ...@@ -6,21 +6,25 @@ import Cookies from 'js-cookie';
import sha1 from 'sha1'; import sha1 from 'sha1';
import { SlideVerify } from '@wisdom-utils/components'; import { SlideVerify } from '@wisdom-utils/components';
import { appService } from '@/api'; import { appService, noticeService } from '@/api';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'; import { getUserInfo, getWebSiteConfig } from '@/api/service/base';
import { import {
SERVICE_APP_LOGIN_MODE, SERVICE_APP_LOGIN_MODE,
SERVICE_INTERFACE_SUCCESS_CODE, SERVICE_INTERFACE_SUCCESS_CODE,
WX_REDIRECT_URI, WX_REDIRECT_URI,
} from '@/constants'; } from '@/constants';
import store from '@/stores';
import { DEFAULT_MQTT_PATH, DEFAULT_TCP_IP, DEFAULT_TCP_PORT, DEFAULT_PARSE_LEVEL } from '@/components/Notifier/constants';
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const Logger = logger('login'); const Logger = logger('login');
const getGlobalConfig = () => store.getState().toJS().global?.globalConfig ?? {};
class Login { class Login {
constructor(props, callback, isInit) { constructor(props, callback, isInit) {
this.events = window.share.event; this.events = window.share.event;
this.globalConfig = props.global; this.globalConfig = props.global;
this.updateConfig = props.updateConfig; // this.updateConfig = props.updateConfig;
this.updateConfig = (config) => { props.updateConfig(config); this.globalConfig = getGlobalConfig(); }
this.createContext = props.createContext; this.createContext = props.createContext;
this.history = props.history; this.history = props.history;
this.callback = callback; this.callback = callback;
...@@ -207,12 +211,55 @@ class Login { ...@@ -207,12 +211,55 @@ class Login {
const self = this; const self = this;
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
getWebSiteConfig({ // 获取网站配置的同时,预先获取到mqtt配置,注册进子应用
client: self.globalConfig.client, Promise.all([
token, noticeService.getMqttSiteCode({ 'request.preventCache': Date.now() }),
'request.preventCache': Date.now(), getWebSiteConfig({
}) client: self.globalConfig.client,
.then(response => { token,
'request.preventCache': Date.now(),
})
]).then(results => {
const res = results[0] ?? {};
if (res && res.say.statusCode === '0000') {
let mqttConfig = {
mqtt_mess: {},
mqtt_path: DEFAULT_MQTT_PATH,
nginxStart: false,
mqtt_IsSSL: true
};
if (Array.isArray(res.getMe) && res.getMe.length > 0) {
if (res.getMe[0]) {
const data = res.getMe[0];
mqttConfig.mqtt_IsSSL = data.IsSSL ? data.IsSSL : false;
mqttConfig.mqtt_mess.site_code = data.SiteCode || self.globalConfig.userInfo.site;
mqttConfig.mqtt_mess.TcpIP = data.TcpIP;
mqttConfig.mqtt_mess.TcpPort = data.TcpPort ? parseInt(data.TcpPort) : 8083;
mqttConfig.mqtt_mess.MessageLevel = data.MessageLevel ? data.MessageLevel : DEFAULT_PARSE_LEVEL;
if (data.NginxStart) {
mqttConfig.NginxStart = data.NginxStart;
mqttConfig.mqtt_mess.TcpIP = window.location.hostname;
mqttConfig.mqtt_mess.TcpPort = parseInt(window.location.port);
mqttConfig.mqtt_path = '/ws/';
} else {
mqttConfig.nginxStart = data.NginxStart
}
}else {
mqttConfig.mqtt_mess.TcpIP = DEFAULT_TCP_IP;
mqttConfig.mqtt_mess.TcpPort = DEFAULT_TCP_PORT;
mqttConfig.mqtt_IsSSL = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort;
}
mqttConfig.mqtt_iotIP = mqttConfig.mqtt_mess.TcpIP + ":" + mqttConfig.mqtt_mess.TcpPort;
self.globalConfig = Object.assign(self.globalConfig, { ...mqttConfig });
}
} else {
Logger.info('获取mqtt服务器参数失败');
}
return results;
}).then(results => {
const response = results[1] ?? {};
const result = const result =
response && response.code === SERVICE_INTERFACE_SUCCESS_CODE response && response.code === SERVICE_INTERFACE_SUCCESS_CODE
? Array.isArray(response.data) ? Array.isArray(response.data)
...@@ -364,7 +411,7 @@ class Login { ...@@ -364,7 +411,7 @@ class Login {
const { layers = [] } = this.globalConfig.mapsettings || {}; const { layers = [] } = this.globalConfig.mapsettings || {};
if (layers.length === 0) { if (layers.length === 0) {
widgetIndex !== -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1); widgetIndex !== -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1);
return Promise.resolve({}); return Promise.resolve(this.globalConfig.mapsettings);
} }
const layer = layers[0]; const layer = layers[0];
......
...@@ -38,9 +38,9 @@ const Login = forwardRef((props, _ref) => { ...@@ -38,9 +38,9 @@ const Login = forwardRef((props, _ref) => {
() => new LoginAction(Object.assign({}, props, {history}), setVisible, true), () => new LoginAction(Object.assign({}, props, {history}), setVisible, true),
); );
useEffect(() => { // useEffect(() => {
action.globalConfig = props.global; // action.globalConfig = props.global;
}, [props.global]); // }, [props.global]);
const handleSubmit = values => { const handleSubmit = values => {
/* eslint-disable */ /* eslint-disable */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment