| | |
| | | import React, {Component} from 'react' |
| | | import { Spin } from 'antd' |
| | | import { Spin, notification } from 'antd' |
| | | import { connect } from 'react-redux' |
| | | import md5 from 'md5' |
| | | import moment from 'moment' |
| | |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | |
| | | if (typeof(_param) === 'object') { |
| | | _param.UserID && sessionStorage.setItem('UserID', _param.UserID) |
| | | _param.LoginUID && sessionStorage.setItem('LoginUID', _param.LoginUID) |
| | | _param.User_Name && sessionStorage.setItem('User_Name', _param.User_Name) |
| | | _param.Full_Name && sessionStorage.setItem('Full_Name', _param.Full_Name) |
| | | _param.debug && sessionStorage.setItem('debug', _param.debug) |
| | | _param.dataM && sessionStorage.setItem('dataM', _param.dataM) |
| | | _param.dataM && sessionStorage.setItem('localDataM', _param.dataM) |
| | | _param.avatar && sessionStorage.setItem('avatar', _param.avatar) |
| | | _param.role_id && sessionStorage.setItem('role_id', _param.role_id) |
| | | _param.role_id && sessionStorage.setItem('localRole_id', _param.role_id) |
| | | this.authLogin(_param.appid, _param.openid, _param.memberId, _param.key) |
| | | } else { |
| | | this.props.history.replace('/login') |
| | | } |
| | | this.getMessage() |
| | | } catch (e) { |
| | | this.props.history.replace('/login') |
| | | } |
| | | } |
| | | |
| | | authLogin = (appid, openid, memberid, scanId) => { |
| | | Api.getTouristMsg(appid, openid, memberid, scanId).then(res => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('UserID', res.UserID) |
| | | sessionStorage.setItem('LoginUID', res.LoginUID) |
| | | sessionStorage.setItem('User_Name', res.UserName) |
| | | sessionStorage.setItem('Full_Name', res.FullName) |
| | | sessionStorage.setItem('avatar', res.icon || '') |
| | | sessionStorage.setItem('dataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('localDataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('debug', res.debug || '') |
| | | sessionStorage.setItem('role_id', res.role_id || '') |
| | | sessionStorage.setItem('departmentcode', res.departmentcode || '') |
| | | sessionStorage.setItem('organization', res.organization || '') |
| | | sessionStorage.setItem('localRole_id', res.role_id || '') |
| | | |
| | | this.getMessage() |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | this.props.history.replace('/login') |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getMessage = () => { |
| | |
| | | |
| | | Api.getSystemConfig(_param).then(res => { |
| | | if (res.status) { |
| | | let _url = window.location.href.split('#')[0] + 'system' |
| | | if (/^https/.test(window.location.protocol)) { // https转换 |
| | | res.Banner = res.Banner ? res.Banner.replace(/^http:/ig, 'https:') : '' |
| | | res.doclogo = res.doclogo ? res.doclogo.replace(/^http:/ig, 'https:') : '' |
| | | res.indexlogo = res.indexlogo ? res.indexlogo.replace(/^http:/ig, 'https:') : '' |
| | | res.loginlogo = res.loginlogo ? res.loginlogo.replace(/^http:/ig, 'https:') : '' |
| | | res.titlelogo = res.titlelogo ? res.titlelogo.replace(/^http:/ig, 'https:') : '' |
| | | } |
| | | |
| | | const _href = window.location.href.split('#')[0] |
| | | let _url = _href + 'system' |
| | | let systemMsg = { |
| | | favicon: res.titlelogo || '', |
| | | platTitle: res.titleName || '', |
| | |
| | | mainlogo: res.indexlogo || '', |
| | | doclogo: res.doclogo || '', |
| | | style: res.CSS || '', |
| | | webSite: res.WebSite || '' |
| | | showline: res.split_line_show || 'true', |
| | | webSite: res.WebSite || '', |
| | | navBar: res.menu_type, |
| | | app_version: res.app_version |
| | | } |
| | | |
| | | let level = res.pwd_level || '' |
| | | |
| | | if (level && !['letter_num', 'char_num', 'char_num_90'].includes(level)) { |
| | | level = '' |
| | | } |
| | | |
| | | localStorage.setItem(_href + 'pwdlevel', level) |
| | | |
| | | if (res.srcid) { |
| | | localStorage.setItem(_href + 'srcId', res.srcid) |
| | | } else { |
| | | localStorage.removeItem(_href + 'srcId') |
| | | } |
| | | |
| | | sessionStorage.setItem('home_background', res.index_background_color || '') |
| | | if (res.sys_datetime) { |
| | | sessionStorage.setItem('sys_datetime', res.sys_datetime) |
| | | sessionStorage.setItem('app_datetime', new Date().getTime()) |
| | | } |
| | | |
| | | // url标题 |
| | |
| | | localStorage.removeItem(_url) |
| | | } |
| | | |
| | | let _loginurl = window.location.href.split('#')[0] + 'loginways' |
| | | let login_ways = [] |
| | | let login_types = [] |
| | | if (res.login_ways && res.login_ways.length > 0) { |
| | | res.login_ways.forEach(item => { |
| | | // 短信验证码登录,必须设置短信Id |
| | | if (item.way_no === 'sms_vcode' && !item.sms_id) return |
| | | if (login_types.includes(item.way_no)) return |
| | | |
| | | login_types.push(item.way_no) |
| | | |
| | | login_ways.push({ |
| | | label: item.way_name, |
| | | type: item.way_no, |
| | | smsId: item.sms_id |
| | | }) |
| | | }) |
| | | } else { |
| | | login_ways.push({ |
| | | label: '账号密码登录', |
| | | type: 'uname_pwd', |
| | | smsId: '' |
| | | }) |
| | | } |
| | | |
| | | try { |
| | | localStorage.setItem(_loginurl, window.btoa(window.encodeURIComponent(JSON.stringify(login_ways)))) |
| | | } catch (e) { |
| | | localStorage.removeItem(_loginurl) |
| | | } |
| | | |
| | | window.GLOB.mainlogo = systemMsg.mainlogo |
| | | window.GLOB.style = systemMsg.style |
| | | window.GLOB.navBar = systemMsg.navBar |
| | | window.GLOB.appVersion = systemMsg.app_version |
| | | |
| | | if (window.GLOB.style && styles[window.GLOB.style]) { |
| | | document.body.className = styles[window.GLOB.style] |
| | | document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') |
| | | } |
| | | |
| | | if (res.titlelogo && window.GLOB.favicon !== res.titlelogo) { |
| | |
| | | } |
| | | this.props.history.replace('/main') |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | this.props.history.replace('/login') |
| | | } |
| | | }, () => { |