Commit b9e40121 authored by 邓晓峰's avatar 邓晓峰

add noMatch

parent 9a582b20
......@@ -4,9 +4,11 @@ module.exports = {
dev: {
'/CityInterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
......@@ -17,8 +19,10 @@ module.exports = {
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
......@@ -26,6 +30,20 @@ module.exports = {
pathRewrite: {
'/cityinterface': '/cityinterface'
}
},
'/Publish': {
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
pathRewrite: {
'/Publish': '/Publish'
}
}
}
};
\ No newline at end of file
......@@ -2,9 +2,11 @@ module.exports = {
dev: {
'/CityInterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......@@ -15,8 +17,10 @@ module.exports = {
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......@@ -25,5 +29,19 @@ module.exports = {
'/cityinterface': '/cityinterface',
},
},
'/Publish': {
// target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
// target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/Publish': '/Publish',
},
}
},
};
......@@ -23,8 +23,8 @@ class HttpRequest {
// }
// ------------------------------------------------------------------------------------
if (!config.ignoreSite && this.getSite()) {
config.headers['civ-site'] = this.getSite();
if ( (!config.ignoreSite && this.getSite(config)) && (Array.isArray(window.globalConfig.userInfo.Groups) && (Array.isArray(window.globalConfig.userInfo.Industries) && window.globalConfig.userInfo.Industries.length > 0)) ) {
config.headers['civ-site'] = this.getSite(config);
// config.headers['civ-site'] = "192_168_19_105_site_c8de50fc";
}
this.removePending(config); //在一个ajax发送前执行一下取消操作
......@@ -118,13 +118,8 @@ class HttpRequest {
pending.splice(p, 1); //把这条记录从数组中移除
}
};
getSite() {
return (
(window.globalConfig &&
window.globalConfig.userInfo &&
window.globalConfig.userInfo.site) ||
''
);
getSite(config) {
return window.globalConfig && window.globalConfig.userInfo && window.globalConfig.userInfo.site && !config.ignoreSite ? window.globalConfig.userInfo.site: ""
}
get(url, params, config = {}) {
return this.requestApi.get(url, { ...config, params });
......
......@@ -26,7 +26,7 @@ import { actionCreators } from './containers/App/store';
import { initMicroApps } from './micro';
import history from './utils/history';
const namespace = `__PANDA_STORE__${location.hostname}}`
const namespace = `__PANDA_STORE__${location.hostname}`
window.createStoreage = new Storeage(namespace);
window.Http = Http;
const initialState = Immutable.Map();
......
......@@ -42,6 +42,7 @@
width: 280px;
min-width: 120px;
max-width: 280px;
border-radius: 20px;
}
:global(.anticon-search) {
color: #888888;
......
......@@ -13,10 +13,8 @@ import { dyRoutes } from '../../routes/config';
function App(props) {
return (
<>
<Helmet
titleTemplate={`%s - ${props.global && props.global.title}`}
defaultTitle={`${props.global && props.global.title}`}
>
<Helmet title={`${props.global && props.global.title}`}>
<title>{`${props.global && props.global.title}`}</title>
<link
rel="shortcut icon"
href={`https://panda-water.cn/web4/${props.global &&
......
......@@ -77,7 +77,7 @@ var initMicroApps = function initMicroApps(loader) {
scopedCSS: true,
getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
excludeAssetFilter: function excludeAssetFilter(url) {
return url.indexOf('webapi.amap.com') !== -1 || url.indexOf('api.map.baidu.com') !== -1 || url.indexOf('map.baidu.com') !== -1 || url.indexOf('pv.sohu.com') !== -1 || url.indexOf('mt0.google.cn') !== -1 || url.indexOf('mt1.google.cn') !== -1 || url.indexOf('mt2.google.cn') !== -1 || url.indexOf('mt3.google.cn') !== -1;
return url.indexOf('webapi.amap.com') !== -1 || url.indexOf('api.map.baidu.com') !== -1 || url.indexOf('map.baidu.com') !== -1 || url.indexOf('pv.sohu.com') !== -1 || url.indexOf('mt0.google.cn') !== -1 || url.indexOf('mt1.google.cn') !== -1 || url.indexOf('mt2.google.cn') !== -1 || url.indexOf('mt3.google.cn') !== -1 || url.indexOf('hm.baidu.com') !== -1 || url.indexOf('https://maponline0.bdimg.com') !== -1 || url.indexOf('https://maponline1.bdimg.com') !== -1 || url.indexOf('https://maponline2.bdimg.com') !== -1 || url.indexOf('https://maponline3.bdimg.com') !== -1 || url.indexOf('https://api.map.baidu.com/getscript') !== -1;
}
});
(0, _qiankun.runAfterFirstMounted)(function () {
......@@ -102,7 +102,7 @@ var defaultApp = function defaultApp() {
if (config && config.token) {
// const startWith = config.homepage ? config.homepage.split('/') : [];
var basePath = _constants.FILTER_FOLER_REG.test(config.homepage) ? 'civweb4' : 'civweb';
var basePath = _constants.FILTER_FOLER_REG.test(config.homepage) ? 'civweb4' : 'civweb4';
(0, _qiankun.setDefaultMountApp)("/".concat(_package["default"].name.toLocaleLowerCase(), "/").concat(basePath, "/?client=").concat(config.client) // config.homepage
// ? `/${pkg.name.toLocaleLowerCase()}/${basePath}/${config.homepage}`
// : `/${pkg.name.toLocaleLowerCase()}/${basePath}/?client=${
......
......@@ -27,8 +27,9 @@ ul,
ol {
list-style: none;
}
a {
text-decoration: underline;
body a {
text-decoration: none;
color: inherit;
// color: #fff!important;
}
......
......@@ -10,6 +10,7 @@ import {
Popover,
Radio,
Result,
Spin,
} from 'antd';
import classNames from 'classnames';
import { connect } from 'react-redux';
......@@ -74,11 +75,12 @@ const menuExtraRender = currentRoutes => {
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
color: 'rgba(255, 255, 255, 0.65)'
}}
>
{currentRoutes && currentRoutes.name}
</span>
<MenuFoldOutlined onClick={() => setToggleSystem(!toggleSystem)} />
<MenuFoldOutlined onClick={() => setToggleSystem(!toggleSystem)} style={{color: '#888'}}/>
</a>
);
}
......@@ -90,6 +92,9 @@ const menuExtraRender = currentRoutes => {
};
const HOT = ["HOT", "县", "市", "New"]
const StationsItem = (item, action) => {
const changeGroup = (event, data) => {
action.changeGroup && action.changeGroup(event, data)
}
return (
<li key={item.groupID} style={{marginRight: `${item.style.marginRight}px`}}>
<a className={classNames(styles.city_select, styles.showTip)}
......@@ -97,7 +102,7 @@ const StationsItem = (item, action) => {
index={item.promoteIndex}
data-GroupID={item.groupID}
data-Site={item.site}
style={{fontSize: '13px'}} onClick={action.changeGroup.bind(action)}>
style={{fontSize: '13px'}} onClick={(event) => changeGroup(event, item)}>
{item.groupName}
{
item.promoteTip && HOT.includes(item.promoteTip) && (
......@@ -121,7 +126,6 @@ const Stations = props => {
const handleClick = (event, link) => {
event.preventDefault();
console.log(link);
}
const handleTabChange = (event) => {
......@@ -143,7 +147,7 @@ const Stations = props => {
options={optionsWith}
optionType="button"
buttonStyle="solid" size="small" value={defaultTab} onChange={handleTabChange} style={{marginTop: '6px'}}/>
<div style={{maxWidth: '520px'}}>
<div style={{maxWidth: '520px', position: 'relative'}}>
{
defaultTab === 'site' ? (
<div className={classNames(styles.city_pane, styles.station_container)} ref={cityPane}>
......@@ -168,14 +172,14 @@ const Stations = props => {
</div>
)
}
<Spin spinning={props.loading}></Spin>
</div>
</>
)
}
const renderTitle = (title, action, data) => {
console.log("renderTitle", data)
const renderTitle = (title, action, data, loading, setLoading) => {
return {
render: (
<>
......@@ -185,7 +189,7 @@ const renderTitle = (title, action, data) => {
<div className={styles.cityContent}>
<Popover placement="bottomLeft"
trigger="click"
content={<Stations data={data} action={action}/>}
content={<Stations data={data} action={action} loading={loading} setLoading={setLoading}/>}
arrowPointAtCenter
overlayClassName={styles.stationsWrapper}>
{
......@@ -213,7 +217,6 @@ const renderTitle = (title, action, data) => {
};
};
const BasicLayout = props => {
console.log("props", props)
/* eslint-disable no-unused-vars */
const {
children,
......@@ -222,6 +225,7 @@ const BasicLayout = props => {
pathname: '/',
},
} = props;
document.title= props.global && props.global.title;
const basename = getBaseName();
const history = useHistory();
const [pathname, setPathname] = useState(props.location.pathname);
......@@ -233,6 +237,7 @@ const BasicLayout = props => {
const [cityData, setCityData] = useState({});
const menuDataRef = useRef([]);
const [pageLoading, setPageLoading] = useState(true)
const [siteLoading, setSiteLoading] = useState(false)
const handleMenuCollapse = collapse => {
setCollapse(collapse);
};
......@@ -240,7 +245,7 @@ const BasicLayout = props => {
const isMounted = useMountedState();
const [siteAction, setSiteAction] = useState(() => {
return new Site(props);
return new Site(props, setSiteLoading);
});
matchRoutes(props.route.routes, props.location.pathname);
......@@ -282,12 +287,10 @@ const BasicLayout = props => {
};
const handleLogo = event => {
setTimeout(() => {
history.replace(`/industry`);
}, 300);
props.global.userInfo.site ? history.replace(`/industry`): null;
};
const headerContentRender = renderTitle(props.global.title, siteAction, cityData);
const headerContentRender = renderTitle(props.global.title, siteAction, cityData, siteLoading, setSiteLoading);
const others = {
history: props.history,
location: props.location,
......@@ -299,7 +302,7 @@ const BasicLayout = props => {
<ProLayout
logo="http://panda-water.cn/web4/assets/images/logo/单独图案-白色.svg"
siderWidth="145px"
title=""
title={props.global && props.global.title}
fixSiderbar={true}
onMenuHeaderClick={event => handleLogo(event)}
onCollapse={collapse => handleMenuCollapse(collapse)}
......
......@@ -17,12 +17,13 @@ const { Link } = Anchor;
const ERR_OK = '0000'
class Site {
constructor(props) {
constructor(props, callback) {
this.weatherCity = null
this.globalConfig = props.global
this.updateConfig = props.updateConfig
this.props = props
this.init()
this.setLoading = callback
}
init(config) {
......@@ -284,7 +285,9 @@ class Site {
const loginSite = this.getLocalSites()
loginSite[token] = site
localStorage.setItem("loginSite", JSON.stringify(loginSite));
const self = this;
const login = new Login(this.props, () => {
self.setLoading(false)
window.location.reload();
});
login.init()
......@@ -296,6 +299,7 @@ class Site {
event.persist();
const site = item ? item.site : event.target.dataset.site
const loginName = this.globalConfig.userInfo.loginName
this.setLoading(true)
Http.generateTokenQuick({
loginName: loginName
}, {
......
......@@ -190,6 +190,7 @@
}
}
}
}
.city_pane {
// padding: 10px;
......@@ -247,6 +248,7 @@
flex-wrap: wrap;
flex: 1;
font-size: 12px;
padding: 0!important;
li {
margin-right: 8px;
margin-bottom: 6px;
......@@ -255,5 +257,15 @@
}
}
}
:global(.ant-spin) {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
:global(.ant-pro-basicLayout .ant-pro-sider-logo h1) {
display: none;
}
\ No newline at end of file
......@@ -113,7 +113,14 @@ export const initMicroApps = loader => {
url.indexOf('mt0.google.cn') !== -1 ||
url.indexOf('mt1.google.cn') !== -1 ||
url.indexOf('mt2.google.cn') !== -1 ||
url.indexOf('mt3.google.cn') !== -1
url.indexOf('mt3.google.cn') !== -1 ||
url.indexOf('hm.baidu.com') !== -1 ||
url.indexOf('https://maponline0.bdimg.com') !== -1 ||
url.indexOf('https://maponline1.bdimg.com') !== -1 ||
url.indexOf('https://maponline2.bdimg.com') !== -1 ||
url.indexOf('https://maponline3.bdimg.com') !== -1 ||
url.indexOf('https://api.map.baidu.com/getscript') !== -1
);
},
});
......@@ -137,7 +144,7 @@ export const defaultApp = () => {
// const startWith = config.homepage ? config.homepage.split('/') : [];
const basePath = FILTER_FOLER_REG.test(config.homepage)
? 'civweb4'
: 'civweb';
: 'civweb4';
setDefaultMountApp(
`/${pkg.name.toLocaleLowerCase()}/${basePath}/?client=${config.client}`,
// config.homepage
......
......@@ -55,11 +55,11 @@ export default {
rules: [
{
required: true,
message: 'Please enter mobile number!',
message: '请输入手机号码!',
},
{
pattern: /^1\d{10}$/,
message: 'Wrong mobile number format!',
pattern: /^1[34578]\d{9}$/,
message: '输入手机号码格式错误!',
},
],
},
......@@ -67,12 +67,12 @@ export default {
props: {
size: 'large',
prefix: <MailTwoTone className={styles.prefixIcon} />,
placeholder: 'captcha',
placeholder: '请输入短信验证码',
},
rules: [
{
required: true,
message: 'Please enter Captcha!',
message: '请输入短信验证码',
},
],
},
......
import React from 'react';
const WxLogin = props => {
let self_redirect = "default";
props.self_redirect === !0 ? self_redirect= "true": props.self_redirect === !1 && (self_redirect = "false");
let url = `https://open.weixin.qq.com/connect/qrconnect?appid=${props.appid}&scope=${props.scope}&redirect_uri=${props.redirect_uri}&state=${props.state}&login_type=jssdk&self_redirect=${self_redirect}&styletype=${props.styletype || ''}&sizetype=${props.sizetype || ''}&bgcolor=${props.bgcolor|| ''}&rst=${props.rst || ''}`;
url += props.style ? "&stylle=" + props.style: "";
url += props.href ? "&href=" + props.href: "";
return <iframe frameBorder="0" allowTransparency="true" scrolling="no" width="250px" height="250px" src={url}></iframe>
}
export default WxLogin;
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _antd = require("antd");
var _jsBase = require("js-base64");
var _jsCookie = _interopRequireDefault(require("js-cookie"));
var _sha = _interopRequireDefault(require("sha1"));
var _SlideVerify = _interopRequireDefault(require("../../../components/SlideVerify"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _readOnlyError(name) { throw new Error("\"" + name + "\" is read-only"); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Login =
/*#__PURE__*/
function () {
function Login(props, callback) {
_classCallCheck(this, Login);
this.events = window.share.event;
this.globalConfig = props.global;
this.updateConfig = props.updateConfig;
this.createContext = props.createContext;
this.history = props.history;
this.callback = callback;
this.hasTry = false; // this.init();
}
_createClass(Login, [{
key: "init",
value: function init() {
this.loginFailed = false;
this.guid = Math.round(Math.random() * 10000 + Date.now()).toString(16);
this.redirect_state = _jsCookie["default"].get('redirect_state');
var token = this.globalConfig.initToken || _jsCookie["default"].get('token');
var self = this;
if (!!token) {
this.globalConfig.token = token;
Http.getUserInfo({
token: this.globalConfig.token,
subOID: 'subOID',
site: this.getLocalSiteBytoken(token),
'request.preventCache': Date.now()
}, {
ignoreSite: true
}).then(function (response) {
if (response && !response.errMsg) {
self.globalConfig.userInfo = {};
if (response.Groups && response.Groups instanceof Array && response.Groups.length) {
self.globalConfig.userInfo.Groups = response.Groups;
}
self.globalConfig.userInfo = Object.assign({}, response, self.globalConfig.userInfo);
self.updateConfig && self.updateConfig(self.globalConfig);
self.getUserInfoAndConfig();
}
});
}
}
}, {
key: "writeLogs",
value: function writeLogs() {
if (this.globalConfig.userInfo.UserImge === '') {
// _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png";
this.globalConfig.userInfo.UserImge = 'https://panda-water.cn/web4/assets/images/icon/熊猫新2.png';
}
if (this.globalConfig.userInfo.site) {
Http.writeLogs({
origin: window.location.origin,
client: this.globalConfig.client,
site: this.globalConfig.userInfo && this.globalConfig.userInfo.site ? this.globalConfig.userInfo.site : '',
loginName: this.globalConfig.userInfo && this.globalConfig.userInfo.fullName ? this.globalConfig.userInfo.fullName : ''
})["catch"](function (error) {
console.log(error);
});
}
}
}, {
key: "getIndustry",
value: function getIndustry(flag, token, _getIndustry) {
var _this2 = this;
this.globalConfig.userInfo.Industries = new Array();
if (this.globalConfig.userInfo.Groups && this.globalConfig.userInfo.Groups.length) {
this.globalConfig.userInfo.Groups.forEach(function (group) {
if (group.industry && _this2.globalConfig.userInfo.Industries.indexOf(group.industry) < 0) _this2.globalConfig.userInfo.Industries.push(group.industry);
});
}
if (!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1) {
this.createContext(this); //console.log('云平台');
this.history.push('/industry');
return false;
}
this.getWebConfig(token, _getIndustry);
}
}, {
key: "getWebConfig",
value: function getWebConfig(token, getIndustry) {
var _this3 = this;
var self = this;
Http.getWebSiteConfig({
client: this.globalConfig.client,
token: token,
'request.preventCache': Date.now()
}).then(function (response) {
if (response && response.length > 0) {
self.globalConfig = Object.assign(self.globalConfig, response.shift(), {
theme: self.globalConfig.theme,
menu: self.globalConfig.menu,
style: self.globalConfig.style
});
self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then(function (res) {
window.subSysCfg = {};
response.forEach(function (item) {
window.subSysCfg[item.client] = item;
});
if (!!self.globalConfig.isShared) {
self.globalConfig.mode = 'single';
self.globalConfig.style = 'sandbox';
self.globalConfig.uiwidgets = [self.globalConfig.shareWidget];
self.globalConfig.widgets = [];
} // this.events.removeAllListeners('loginSuccess')
// this.events.removeAllListeners('toggleIndustry')
// window.share.event = this.events;
if (self.globalConfig.userInfo.site && self.globalConfig.userInfo.site.length > 0) {
Http.getWebSiteConfig({
client: self.globalConfig.client,
token: token,
'request.preventCache': Date.now()
}, {
ignoreSite: true
}).then(function (response) {
if (response && response.length > 0) {
var mainConf = response.shift();
if (mainConf.homepage) self.globalConfig.homepage = mainConf.homepage;
if (mainConf.bannerLogo) self.globalConfig.bannerLogo = mainConf.bannerLogo;
if (mainConf.logo) self.globalConfig.logo = mainConf.logo;
if (mainConf.mdi) self.globalConfig.mdi = mainConf.mdi;
if (mainConf.menu) self.globalConfig.menu = mainConf.menu;
if (mainConf.shortcutIcon) self.globalConfig.shortcutIcon = mainConf.shortcutIcon;
}
self.updateConfig && self.updateConfig(self.globalConfig);
getIndustry ? self.events.emit('toggleIndustry') : self.events.emit('loginSuccess');
window.share.event = self.events;
self.callback && self.callback();
});
} else {
//loginSuccess
self.updateConfig && self.updateConfig(self.globalConfig);
getIndustry ? self.events.emit('toggleIndustry') : self.events.emit('loginSuccess');
window.share.event = self.events;
self.callback && self.callback();
}
});
} else {
if (_this3.goLogin()) {
return false;
}
_this3.handleLoginError();
console.log('获取网络配置失败');
}
})["catch"](function (error) {
console.log(error);
_this3.handleLoginError();
console.log('获取网络配置失败');
});
}
}, {
key: "getProjectItems",
value: function getProjectItems() {
var MAX_BOTTOM = 0;
var isScale = false;
var widgetIndex = -1;
this.globalConfig.uiwidgets.map(function (item, index) {
if (parseInt(item['bottom']) > MAX_BOTTOM) {
MAX_BOTTOM = parseInt(item['bottom']);
}
if (!isScale && item.url.toLowerCase().indexOf('widgets/zoom') > -1) isScale = true;
if (widgetIndex == -1 && item.url.indexOf('ToggleProject/ToggleProject') > -1) widgetIndex = index;
});
var layers = this.globalConfig.mapsettings.layers;
if (layers.length === 0) {
widgetIndex != -1 && this.globalConfig.uiwidgets.splice(widgetIndex, 1);
return Promise.resolve({});
}
var layer = layers[0];
if (!layer.id) {
layer.layerType = 'dynamic';
} else {
layer.layerType = 'PipenetLayer';
}
if (layers.length > 1 && widgetIndex == -1) {
this.globalConfig.uiwidgets.push({
bottom: isScale ? MAX_BOTTOM + 70 : MAX_BOTTOM + 35,
config: '',
label: '方案切换',
right: 15,
url: 'product/webgisPanda/ToggleProject/ToggleProject'
});
}
if (layer.areaName) this.globalConfig.mapsettings.areasettings.areaName = layer.areaName;
if (layer.backgroundColor) this.globalConfig.mapsettings.areasettings.backgroundColor = layer.backgroundColor;
if (layer.boundColor) this.globalConfig.mapsettings.areasettings.boundColor = layer.boundColor;
if (layer.boundWidth) this.globalConfig.mapsettings.areasettings.boundWidth = layer.boundWidth;
if (Number.isInteger(parseInt(layer.backgroundOpacity))) {
this.globalConfig.mapsettings.areasettings.backgroundOpacity = layer.backgroundOpacity;
}
if (layer.extent) this.globalConfig.mapsettings.areasettings.extent = layer.extent;
if (layer.basemaps && layer.basemaps.length > 0) this.globalConfig.mapsettings.basemaps = layer.basemaps;
this.updateConfig && this.updateConfig(this.globalConfig);
return Promise.resolve({});
}
}, {
key: "handleLoginError",
value: function handleLoginError() {
_jsCookie["default"].set(this.globalConfig.client, '', {
path: '/'
});
_jsCookie["default"].set('token', '', {
path: '/'
});
_jsCookie["default"].set('site', '', {
path: '/'
});
_jsCookie["default"].set('loginMode', '', {
path: '/'
});
_jsCookie["default"].set('redirect_state', '', {
path: '/'
});
this.loginFailed = true;
}
}, {
key: "goLogin",
value: function goLogin() {
if (this.globalConfig.style === 'ios' && this.globalConfig.loginTemplate === 'IOSCloud.html') {
window.location.href = window.location.origin + '/#login';
return true;
} else {
return false;
}
}
}, {
key: "isRememberPWD",
value: function isRememberPWD(status) {
this.isRememberPWD = status;
}
}, {
key: "getLocalSiteBytoken",
value: function getLocalSiteBytoken(tk) {
var sStr = localStorage.getItem('loginSite'),
s = null;
if (sStr) {
var sObj = JSON.parse(sStr);
if (sObj && sObj[tk]) {
s = sObj[tk];
}
}
return s;
}
}, {
key: "loginByDD",
value: function loginByDD() {
var gotoUrl = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' + encodeURIComponent(window.location.href);
var obj = DDLogin({
id: 'login_container',
"goto": encodeURIComponent(gotoUrl),
style: 'border:none;background-color:#FFFFFF;',
width: '365',
height: '400'
});
var handleMessage = function handleMessage(event) {
var origin = event.origin;
console.log('origin', event.origin);
if (origin == 'https://login.dingtalk.com') {
//判断是否来自ddLogin扫码事件。
var loginTmpCode = event.data;
var redirectUrl = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoakne99srqra6hldv2&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=' + encodeURIComponent(window.location.href) + '&loginTmpCode=' + loginTmpCode; //获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了
window.location.href = redirectUrl;
}
};
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', handleMessage, false);
} else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', handleMessage);
}
}
}, {
key: "ddLoginIn",
value: function ddLoginIn(code) {
var _this4 = this;
Http.getOA({
query: {
TmpAuthCode: code
},
cacheBust: true
}).then(function (response) {
if (response && response.data && response.data.getMe) {
var tk = response.data.getMe[0].token;
_this4.globalConfig.token = tk;
var url = window.location.href; //获取当前页面的url
if (url.indexOf('&code') != -1) {
//判断是否存在参数
url = (_readOnlyError("url"), url.replace(/(\&code|#)[^'"]*/, '')); //去除参数
window.history.pushState({}, 0, url);
}
_this4.isSignIn = true;
_this4.getUserInfoAndConfig();
} else {
_this4.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码");
// msgUtils.fault("登录失败," + error.message);
_this4.hasTry = true; //已经输错过密码
}
});
}
}, {
key: "otherLoginIn",
value: function otherLoginIn(usr, pwd) {
var _this5 = this;
var uesrName = (0, _jsBase.decode)(usr.substring(0, usr.length - 3)),
password = (0, _jsBase.decode)(pwd.substring(0, pwd.length - 3));
Http.generateToken({
query: {
f: 'json',
expiration: this.globalConfig.expiration,
//token过期时间(单位:秒)
client: 'referer',
username: uesrName,
password: (0, _sha["default"])(password).toUpperCase(),
referer: this.globalConfig.client,
skipMenuTest: 1
},
cacheBust: true
}).then(function (response) {
if (response && response.data && response.data.token) {
var tk = response.data.token; // token一天不过期
_this5.globalConfig.token = tk;
request(userInfoUrl, {
query: {
token: tk,
subOID: 'subOID',
site: _this5.getLocalSiteBytoken(tk)
},
cacheBust: true,
ignoreSite: true
}).then(function (response) {
if (response && response.data && response.data.errMsg) {
this.globalConfig.userInfo = {};
if (response.data.Groups && response.data.Groups instanceof Array && response.data.Groups.length) {
this.globalConfig.userInfo.Groups = response.data.Groups;
}
this.getUserInfoAndConfig();
}
});
} else {
_this.handleLoginError(); // msgUtils.fault("登录失败,请检查用户名或密码");
msgUtils.fault('登录失败,' + error.message);
_this.hasTry = true; //已经输错过密码
}
});
}
}, {
key: "getUserInfoAndConfig",
value: function getUserInfoAndConfig(failCallback, flag, industry) {
var _this6 = this;
var token = this.globalConfig.token;
var site = _jsCookie["default"].get('site');
var self = this;
var _industrySite = null;
if (industry) {
var userInfo = self.globalConfig.userInfo && self.globalConfig.userInfo.Groups && self.globalConfig.userInfo.Groups instanceof Array ? self.globalConfig.userInfo.Groups.find(function (enter) {
return enter.industry === industry;
}) : null;
if (userInfo) {
self.globalConfig.userInfo = {
site: userInfo.site ? userInfo.site : null,
Groups: self.globalConfig.userInfo.Groups
};
_industrySite = userInfo.site ? userInfo.site : null;
}
} else if (!!site && self.isSignIn) {
self.globalConfig.userInfo = {
site: decodeURIComponent((0, _jsBase.decode)(site)),
Groups: self.globalConfig.userInfo && self.globalConfig.userInfo.Groups && self.globalConfig.userInfo.Groups instanceof Array ? self.globalConfig.userInfo.Groups : null
};
}
self.updateConfig && self.updateConfig(self.globalConfig);
if (this.isSignIn || !!industry) {
Http.getUserInfo({
token: token,
subOID: 'subOID',
industry: industry,
site: _industrySite ? _industrySite : this.getLocalSiteBytoken(token),
'request.preventCache': Date.now()
}, {
ignoreSite: true
}).then(function (response) {
try {
if (response && !response.errMsg) {
self.globalConfig.userInfo = Object.assign({}, response, _this6.globalConfig.userInfo); // Cookies.set('site', this.globalConfig.userInfo.site);
self.writeLogs();
self.getIndustry(flag, token, industry);
} else {
if (self.goLogin()) {
return false;
}
self.handleLoginError(failCallback);
}
self.updateConfig && self.updateConfig(self.globalConfig);
} catch (error) {
if (self.goLogin()) {
return false;
}
self.handleLoginError(failCallback);
console.log(error);
}
})["catch"](function (error) {
if (self.goLogin()) {
return false;
}
self.handleLoginError(failCallback);
console.log(error);
});
} else {
try {
self.writeLogs();
self.getIndustry(flag, token);
} catch (error) {
if (self.goLogin()) {
return false;
}
self.handleLoginError(failCallback);
console.log(error);
}
}
}
}, {
key: "login",
value: function login(usr, pwd, userPhone, isRememberPWD) {
var _this7 = this;
this.events.removeAllListeners('loginError');
var self = this;
Http.generateToken({
f: 'json',
expiration: this.globalConfig.expiration,
//token过期时间(单位:秒)
client: 'referer',
username: usr,
password: (0, _sha["default"])(pwd).toUpperCase(),
referer: this.globalConfig.client,
skipMenuTest: 1,
userPhone: userPhone,
'request.preventCache': Date.now()
}, {
ignoreSite: true
}).then(function (response) {
if (response && response.token) {
var token = response.token;
_jsCookie["default"].set('token', token);
var exp = 86400000;
_this7.globalConfig.token = token;
if (isRememberPWD) {
_jsCookie["default"].set(_this7.globalConfig.client, token, {
expires: exp / (24 * 60 * 60 * 1000),
path: '/'
});
_jsCookie["default"].set('token', token, {
expires: exp / (24 * 60 * 60 * 1000),
path: '/'
});
}
_this7.isSignIn = true;
_this7.updateConfig && _this7.updateConfig(_this7.globalConfig);
_this7.getUserInfoAndConfig();
} else {
self.hasTry = true;
self.events.emit('loginError', response);
_antd.message.error(response.error.message);
self.callback && self.callback(false);
}
})["catch"](function (error) {
self.hasTry = true;
self.handleLoginError();
self.events.emit('loginError', error.message);
_antd.message.error("登录服务异常");
console.log('登录失败', error.message);
});
}
}, {
key: "loginHandler",
value: function loginHandler(user, pwd, userPhone, isRememberPWD, ref) {
var self = this;
if (user && pwd) {
if (self.loginFailed && self.captchaObj) {
self.captchaObj.verify();
} else {
if (self.hasTry) {
self.slideVerify(ref, function () {
self.login(user, pwd, userPhone, isRememberPWD);
});
} else {
self.login(user, pwd, userPhone, isRememberPWD);
}
}
}
}
}, {
key: "slideVerify",
value: function slideVerify(ref, _onSuccess, onFail, onRefresh) {
this.events.emit('loginVisible', true);
if (this.renderVerify) {
this.renderVerify.destroy();
}
this.renderVerify = new _SlideVerify["default"]();
this.renderVerify.render({
container: ref.current,
onSuccess: function onSuccess() {
_onSuccess && _onSuccess();
}
});
}
}]);
return Login;
}();
var _default = Login;
exports["default"] = _default;
\ No newline at end of file
import 'kit_utils/lib/format';
import React, {
useEffect,
useRef,
......@@ -11,6 +13,7 @@ import {
Popover,
} from 'antd';
import classNames from 'classnames';
import { encode } from 'js-base64';
import { dom } from 'kit_utils';
import QRCode from 'qrcode.react';
import { connect } from 'react-redux';
......@@ -18,11 +21,16 @@ import { withRouter } from 'react-router-dom';
import { actionCreators } from '../../../containers/App/store';
import LoginForm from './components/Login';
import WxLogin from './components/WxLogin';
import LoginAction from './login';
import styles from './style.less';
const { UserName, Password, Submit } = LoginForm;
const { UserName, Password, Mobile,Captcha, Submit } = LoginForm;
const Display = {
Account: "Account",
WeChart: "WeChart",
Mobile: "Mobile"
}
const LoginMessage = ({ content }) => (
<Alert
style={{
......@@ -67,6 +75,7 @@ const useRenderQcode = (props) => {
</div>
)
break;
case "Android":
element.push(
<div className={classNames(styles["quickMark-single"], "miniIOT-single")} key={index}>
......@@ -82,7 +91,6 @@ const useRenderQcode = (props) => {
case "iPhone":
element.push(
<div className={classNames(styles["quickMark-single"], "miniIOT-single")} key={index}>
{/* <img src="https://panda-water.cn/web4/assets/images/智联小程序二维码.jpg" class="QuickMark-cont"/> */}
<Popover placement="top" content={<QRCode value={firstValue[1].replace(/{ip}/ig, props.ip || window.location.host)}/>}>
<div className={styles['icon-Container']}>
<span className={styles.Wechat}></span>
......@@ -112,6 +120,105 @@ const useRenderQcode = (props) => {
}
const Account = props => {
return (
<LoginForm onSubmit={props.onSubmit}>
{props.status === 'error' && props.type === 'account' && !props.submitting && (
<LoginMessage content="账户或密码错误" />
)}
<UserName
name="userName"
placeholder="请输入你的用户名"
rules={[
{
required: true,
message: '请输入用户名!',
},
]}
/>
<Password
name="password"
placeholder="请输入你的密码"
rules={[
{
required: true,
message: '请输入密码!',
},
]}
/>
<div>
<Checkbox
checked={props.autoLogin}
onChange={e => props.setAutoLogin(e.target.checked)}
>
下次自动登录
</Checkbox>
</div>
<Submit loading={props.submitting}>登录</Submit>
</LoginForm>
)
}
const IOTQRCode = () => {
const REDIRECT_URI = "https://panda-water.com/web4/?client=city";
const APPID = "wx8bfa8b02cb95010b"
const [rstate, setRstate] = useState(() => {
return encode("panda_" + Math.round(Math.random() * 10000 + Date.now()).toString(16));
})
const props = Object.assign({}, {
self_redirect: false,
scope: "snsapi_login",
appid: APPID,
state: rstate,
redirect_uri: REDIRECT_URI,
href: "https://panda-water.cn/web4/styles/PandaIOTQrcodeStyle.css"
})
return (
<WxLogin {...props}/>
)
}
const Phone = props => {
return (
<LoginForm onSubmit={props.onSubmit}>
{props.status === 'error' && props.type === 'account' && !props.submitting && (
<LoginMessage content="账户或密码错误" />
)}
<Mobile name="phone" placeholder="请输入手机号码" />
<Captcha name="captcha"/>
<div className={styles.captcha}>
获取短信验证码
</div>
<Submit loading={props.submitting}>登录</Submit>
</LoginForm>
)
}
const IotComponent = props => {
const handlerType = (type) => {
props.setType(Display[type])
}
return (
<div className={styles.wechatQRcode}>
{
props.type === Display["Account"] ?
<Account {...props}/> :
props.type === Display["WeChart"] ?
<IOTQRCode {...props}/>: props.type === Display["Mobile"] ? <Phone {...props}/>: <Account {...props}/>
}
<div className={styles.loginDisplay}>
<a onClick={() => handlerType('Account')} style={{display: props.type === Display["Account"] ? 'none': 'block' }}>账号密码登录</a>
<a onClick={() => handlerType('WeChart')} style={{display: props.type === Display["WeChart"] ? 'none': 'block' }}>微信扫码登录</a>
<a onClick={() => handlerType('Mobile')} style={{display: props.type === Display["Mobile"] ? 'none': 'block' }}>手机验证码登录</a>
</div>
</div>
)
}
const Login = props => {
const videoRef = useRef();
......@@ -126,7 +233,7 @@ const Login = props => {
const [autoLogin, setAutoLogin] = useState(true);
const [submitting, setSubmitting] = useState(false);
const [currentDate, setCurrentDate] = useState({});
const [type, setType] = useState('account');
const [type, setType] = useState('Account');
const [visible, setVisible] = useState(false)
const [action, setAction] = useState(() => {
return new LoginAction(props, setVisible)
......@@ -169,7 +276,7 @@ const Login = props => {
setCurrentDate({
time: time,
dayofweek: weekday[date.getDay()],
date: date.pattern('yyyy/mm/dd'),
date: date.pattern('yyyy/MM/dd'),
});
}, 1000);
return () => {
......@@ -206,7 +313,6 @@ const Login = props => {
setSubmitting(false);
}, [visible])
const renderAddons = useRenderQcode(props.global)
return (
<div className={styles.main}>
<video
......@@ -271,44 +377,14 @@ const Login = props => {
<img src="https://panda-water.cn/web4/assets/images/login/dark/login.png" />
</div>
<div className={styles['login-form']}>
<LoginForm
activeKey={type}
onTabChange={setType}
onSubmit={handleSubmit}
>
{status === 'error' && type === 'account' && !submitting && (
<LoginMessage content="账户或密码错误" />
)}
<UserName
name="userName"
placeholder="请输入你的用户名"
rules={[
{
required: true,
message: '请输入用户名!',
},
]}
/>
<Password
name="password"
placeholder="请输入你的密码"
rules={[
{
required: true,
message: '请输入密码!',
},
]}
/>
<div>
<Checkbox
checked={autoLogin}
onChange={e => setAutoLogin(e.target.checked)}
>
下次自动登录
</Checkbox>
</div>
<Submit loading={submitting}>登录</Submit>
</LoginForm>
<IotComponent
type={type}
setType={setType}
status={status}
submitting={submitting}
autoLogin={autoLogin}
setAutoLogin={setAutoLogin}
onSubmit={handleSubmit}/>
</div>
</div>
</div>
......
......@@ -416,6 +416,7 @@ class Login {
});
}
getUserInfoAndConfig(failCallback, flag, industry) {
debugger
const token = this.globalConfig.token;
const site = Cookies.get('site');
const self = this;
......@@ -432,7 +433,7 @@ class Login {
if (userInfo) {
self.globalConfig.userInfo = {
site: userInfo.site ? userInfo.site : null,
site: userInfo.site ? userInfo.site : "",
Groups: self.globalConfig.userInfo.Groups,
};
_industrySite = userInfo.site ? userInfo.site : null;
......@@ -469,10 +470,13 @@ class Login {
self.globalConfig.userInfo = Object.assign(
{},
response,
this.globalConfig.userInfo,
self.globalConfig.userInfo,
{
site: response.site === "" ? "": self.globalConfig.userInfo.site
}
);
// Cookies.set('site', this.globalConfig.userInfo.site);
console.log("self.globalConfig.userInfo", self.globalConfig.userInfo)
self.writeLogs();
self.getIndustry(flag, token, industry);
} else {
......
......@@ -243,5 +243,28 @@
margin-top: 24px;
}
}
.wechatQRcode {
width: 250px;
height: 220px;
margin: 0 15px;
}
.loginDisplay {
width: 100%;
display: flex;
justify-content: space-between;
font-size: 12px;
a {
&:hover {
color: @primary-color;
transition: all .3s ease-in-out;
}
}
}
.captcha {
color: @primary-6;
font-weight: 400;
cursor: pointer;
font-size: 12px;
}
}
"use strict";
\ No newline at end of file
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