import React, { Component } from 'react'
|
import { message, Modal, notification } from 'antd'
|
import md5 from 'md5'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import Utils from '@/utils/utils.js'
|
import MKEmitter from '@/utils/events.js'
|
import { styles } from '@/store/options.js'
|
import asyncComponent from '@/utils/asyncComponent'
|
import asyncLoadComponent from '@/utils/asyncLoadComponent'
|
import './index.scss'
|
|
const LoginForm = asyncLoadComponent(() => import('./loginform'))
|
const Resetpwd = asyncLoadComponent(() => import('@/components/resetPassword'))
|
const LoginCloudForm = asyncComponent(() => import('./logincloudform'))
|
const LoginCodeForm = asyncComponent(() => import('./logincodeform'))
|
|
class Login extends Component {
|
state = {
|
isDisabled: false,
|
auth: false,
|
authError: '',
|
loginlogo: window.GLOB.loginlogo || '',
|
bgImage: window.GLOB.bgImage || '',
|
platName: window.GLOB.platName || '',
|
copyRight: window.GLOB.copyRight || '',
|
ICP: window.GLOB.ICP || '',
|
lineColor: window.GLOB.lineColor || '',
|
webSite: window.GLOB.webSite || '',
|
prolType: window.GLOB.prolType || '',
|
prolCont: window.GLOB.prolCont || '',
|
langList: [],
|
syncApp: false,
|
loginWays: null,
|
syncing: false,
|
}
|
|
handleSubmit = () => {
|
this.loginformRef.handleConfirm().then(res => {
|
this.setState({
|
isDisabled: true
|
})
|
|
if (res.type === 'uname_pwd') {
|
this.loginsubmit(res)
|
} else if (res.type === 'sms_vcode') {
|
this.phoneloginsubmit(res)
|
}
|
})
|
}
|
|
/**
|
* @description 账号密码登录
|
* @param {Object} param 用户名密码等信息
|
*/
|
async loginsubmit (param) {
|
// 登录提交
|
let res = await Api.getusermsg(param.username, param.password, false)
|
if (res.status) {
|
if (res.check_mob) {
|
let loginWays = this.state.loginWays.filter(item => item.type === 'sms_vcode')
|
|
if (loginWays.length > 0) {
|
this.setState({loginWays: null, isDisabled: false}, () => {
|
this.setState({loginWays: loginWays})
|
})
|
Modal.warning({
|
title: '为确认是您本人操作,请使用手机短信验证码进行身份认证',
|
okText: '知道了'
|
})
|
return
|
}
|
}
|
|
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('debug', res.debug || '')
|
sessionStorage.setItem('role_id', res.role_id || '')
|
sessionStorage.setItem('departmentcode', res.departmentcode || '')
|
sessionStorage.setItem('organization', res.organization || '')
|
sessionStorage.setItem('mk_user_type', res.mk_user_type || '')
|
|
if (res.paas_externalDatabase) {
|
sessionStorage.setItem('externalDatabase', res.paas_externalDatabase)
|
window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
|
}
|
|
sessionStorage.removeItem('visitorUserID')
|
sessionStorage.removeItem('visitorLoginUID')
|
|
let users = localStorage.getItem(window.GLOB.sysSign + 'users')
|
|
if (users) {
|
try {
|
users = JSON.parse(window.decodeURIComponent(window.atob(users)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
users = []
|
}
|
} else {
|
users = []
|
}
|
|
// positecgroup
|
if (res.token) {
|
this.setState({
|
isDisabled: false,
|
verify: {...res, $password: param.password},
|
codeVisible: true
|
})
|
return
|
}
|
|
users = users.filter(item => item.username !== param.username)
|
|
if (users.length > 4) {
|
users.length = 4
|
}
|
|
users.unshift({username: param.username, password: param.remember ? param.password : ''})
|
|
localStorage.setItem(window.GLOB.sysSign + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(users))))
|
|
let level = localStorage.getItem(window.GLOB.sysSign + 'pwdlevel')
|
|
if (level && process.env.NODE_ENV === 'production') {
|
let visible = false
|
let tip = '密码强度不够,请修改密码!'
|
if (param.password.length < 8) {
|
visible = true
|
} else if (level === 'letter_num' && /^([^0-9]*|[^a-zA-Z]*)$/.test(param.password)) {
|
visible = true
|
} else if ((level === 'char_num' || level === 'char_num_90' || level === 'char_num_90_sms') && /^([^0-9]*|[^a-zA-Z]*|[^!@#$%^&*()_]*)$/.test(param.password)) {
|
visible = true
|
} else if ((level === 'char_num_90' || level === 'char_num_90_sms') && res.modifydate) {
|
let s = (new Date().getTime() - new Date(res.modifydate).getTime()) / (1000 * 24 * 60 * 60)
|
if (!isNaN(s) && s > 90) {
|
visible = true
|
tip = '您已90天未修改密码,请更换密码后使用!'
|
}
|
}
|
|
if (visible) {
|
message.warning(tip)
|
this.setState({
|
isDisabled: false
|
})
|
|
MKEmitter.emit('resetpassword', () => {
|
const input = document.getElementById('password')
|
if (input) {
|
input.select()
|
}
|
})
|
return
|
}
|
}
|
|
if (['20210626201522493D7AD7591D7A547278685', '20210626201956190740F1DF384914A3CA9EF'].includes(window.GLOB.appkey) && process.env.NODE_ENV === 'production' && param.username !== 'IF_DMS_APP') {
|
let _param = {
|
UserName: param.username,
|
Password: param.password,
|
BasePath: '/'
|
}
|
Api.loginAndRedirect(_param).then(result => {
|
if (result.IsError) {
|
this.setState({
|
isDisabled: false
|
})
|
message.warning('登录失败,用户名或密码错误!')
|
} else {
|
let lang = sessionStorage.getItem('lang') !== 'en-US' ? '/zh-CN' : '/en-US'
|
window.location.replace(document.location.origin + lang + '/Home/Index')
|
}
|
})
|
} else {
|
let iframe = sessionStorage.getItem('iframe')
|
if (iframe) {
|
sessionStorage.removeItem('iframe')
|
this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
|
} else {
|
this.props.history.replace('/main')
|
}
|
}
|
} else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
|
message.warning('应用尚未创建,请向云端同步应用!')
|
|
this.setState({
|
isDisabled: false,
|
syncApp: true
|
})
|
} else {
|
message.warning(res.message)
|
if (res.message.indexOf('密码错误') > -1) {
|
const input = document.getElementById('password')
|
if (input) {
|
input.select()
|
}
|
} else if (res.message.indexOf('登录权限') > -1) {
|
const wrap = document.getElementById('username')
|
const input = wrap ? wrap.getElementsByTagName('input')[0] : null
|
if (input) {
|
input.select()
|
}
|
}
|
this.setState({
|
isDisabled: false
|
})
|
}
|
}
|
|
async phoneloginsubmit (param) {
|
// 登录提交
|
let res = await Api.getphoneusermsg(param.phone, param.vercode, false)
|
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('debug', res.debug || '')
|
sessionStorage.setItem('role_id', res.role_id || '')
|
sessionStorage.setItem('departmentcode', res.departmentcode || '')
|
sessionStorage.setItem('organization', res.organization || '')
|
sessionStorage.setItem('mk_user_type', res.mk_user_type || '')
|
|
if (res.paas_externalDatabase) {
|
sessionStorage.setItem('externalDatabase', res.paas_externalDatabase)
|
window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
|
}
|
|
sessionStorage.removeItem('visitorUserID')
|
sessionStorage.removeItem('visitorLoginUID')
|
|
let iframe = sessionStorage.getItem('iframe')
|
if (iframe) {
|
sessionStorage.removeItem('iframe')
|
this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
|
} else {
|
this.props.history.replace('/main')
|
}
|
} else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
|
message.warning('应用尚未创建,请向云端同步应用!')
|
|
this.setState({
|
isDisabled: false,
|
syncApp: true
|
})
|
} else {
|
message.warning(res.message)
|
this.setState({
|
isDisabled: false
|
})
|
}
|
}
|
|
authLogin = (appid, openid, memberid, scanId) => {
|
Api.getTouristMsg('mk', 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('debug', res.debug || '')
|
sessionStorage.setItem('role_id', res.role_id || '')
|
sessionStorage.setItem('departmentcode', res.departmentcode || '')
|
sessionStorage.setItem('organization', res.organization || '')
|
sessionStorage.setItem('mk_user_type', res.mk_user_type || '')
|
|
if (res.paas_externalDatabase) {
|
sessionStorage.setItem('externalDatabase', res.paas_externalDatabase)
|
window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
|
}
|
|
sessionStorage.removeItem('visitorUserID')
|
sessionStorage.removeItem('visitorLoginUID')
|
|
let iframe = sessionStorage.getItem('iframe')
|
if (iframe) {
|
sessionStorage.removeItem('iframe')
|
this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID))
|
} else {
|
this.props.history.replace('/main')
|
}
|
} else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') {
|
message.warning('应用尚未创建,请向云端同步应用!')
|
|
this.setState({
|
isDisabled: false,
|
syncApp: true
|
})
|
} else {
|
message.warning(res.message)
|
this.setState({
|
isDisabled: false
|
})
|
}
|
})
|
}
|
|
jsonp(url) {
|
return new Promise((resolve, reject) => {
|
window.jsonCallBack = (result) => {
|
resolve(result)
|
}
|
|
const JSONP = document.createElement('script')
|
JSONP.type = 'text/javascript'
|
JSONP.src = url
|
|
document.getElementsByTagName('head')[0].appendChild(JSONP)
|
|
setTimeout(() => {
|
document.getElementsByTagName('head')[0].removeChild(JSONP)
|
},500)
|
})
|
}
|
|
componentDidMount () {
|
// md5("/ws/location/v1/ip?callback=callbackFunction&key=key&output=jsonp secret key")
|
// md5("/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonpuThL4ZM3XOj642ksEQh76tyHFjh4")
|
|
sessionStorage.removeItem('langList')
|
|
setTimeout(() => {
|
Api.delCacheConfig()
|
}, 50)
|
|
if (window.GLOB.filter) {
|
let view = document.getElementById('mk-login-view')
|
|
if (view) {
|
view.style.filter = 'grayscale(100%)'
|
}
|
}
|
|
const _addressUrl = window.location.href.split('#')[0] + 'queryAddress'
|
|
if (localStorage.getItem(_addressUrl) === 'true') {
|
this.queryAddress()
|
}
|
|
const timeStamp = new Date().getTime()
|
const _authUrl = window.location.href.split('#')[0] + 'AuthCode'
|
|
let authCode = localStorage.getItem(_authUrl)
|
let _s = md5('mksoft' + moment().format('YYYYMMDD'))
|
authCode = authCode ? authCode.split(',') : []
|
let index = authCode.findIndex(key => key === _s)
|
let license = false
|
let appkey = window.GLOB.localkey || window.GLOB.appkey
|
|
if (window.GLOB.licenseKey) {
|
if (window.GLOB.licenseKey.length !== 20) {
|
Modal.warning({
|
title: `本地授权码已失效,请联系管理员。`,
|
okText: '知道了'
|
})
|
} else {
|
let key = md5(window.GLOB.appId + 'minke_software' + appkey).toUpperCase().substr(-6)
|
|
let key1 = window.GLOB.licenseKey.substring(0, 6)
|
let key2 = window.GLOB.licenseKey.substring(6, 14)
|
let key3 = window.GLOB.licenseKey.substring(14)
|
let key4 = md5(key1 + key2).toUpperCase().substr(-6)
|
|
if (key === key1 && key3 === key4) {
|
let last = appkey[appkey.length - 1]
|
let offset = 0
|
let keys = {}
|
|
if (!isNaN(+last)) {
|
offset = (10 - last) % 10
|
} else {
|
last = last.charCodeAt() - 65
|
offset = (30 - last) % 10
|
}
|
|
for (let i = 0; i < 26; i++) {
|
let char = String.fromCharCode(65 + i)
|
keys[char] = (offset + i) % 10
|
}
|
|
let lictime = key2.replace(/[A-Z]/ig, (s) => {
|
return keys[s]
|
})
|
lictime = lictime.slice(0,4) + '/' + lictime.slice(4,6) + '/' + lictime.slice(6)
|
lictime = Math.floor(new Date(lictime).getTime() / 86400000)
|
let curtime = Math.floor(new Date().getTime() / 86400000)
|
let licday = lictime - curtime
|
let _mindUrl = window.location.href.split('#')[0] + 'notMind'
|
|
if (licday < 0 || isNaN(licday)) {
|
Modal.warning({
|
title: '本地授权码已失效,请联系管理员。',
|
okText: '知道了'
|
})
|
} else if (licday > 20) {
|
license = true
|
localStorage.removeItem(_mindUrl)
|
} else {
|
license = true
|
|
if (localStorage.getItem(_mindUrl) !== 'false') {
|
Modal.confirm({
|
title: `距离授权到期还剩${licday}天,请联系管理员。`,
|
okText: '不在提醒',
|
cancelText: '关闭',
|
onOk() {
|
localStorage.setItem(_mindUrl, 'false')
|
},
|
onCancel() {},
|
})
|
}
|
}
|
} else {
|
Modal.warning({
|
title: '本地授权码已失效,请联系管理员。',
|
okText: '知道了'
|
})
|
}
|
}
|
}
|
|
if ((!window.GLOB.licenseKey && index > -1) || license) {
|
this.setState({
|
auth: true
|
})
|
}
|
|
if (!window.GLOB.licenseKey && (index === -1 || index > 5)) {
|
let str = md5('MK19' + window.GLOB.appId + timeStamp)
|
let _rduri = window.atob('aHR0cHM6Ly9lcGMubWs5aC5$mkjbi93ZWJhcGkvZG9zdGFycw=='.replace(/\$mk/ig, ''))
|
let _func = window.atob('c0VtcG93ZXJDbG91$mkZF9HZXRfTGlua1VybA=='.replace(/\$mk/ig, ''))
|
let _id = window.atob('YmgwYmFwYWJ0ZDQ1ZXBz$mkZ3JhNzlzZWdiY2g2YzFpYms='.replace(/\$mk/ig, ''))
|
|
let param = {
|
func: _func,
|
AppID: window.GLOB.appId,
|
TimeStamp: timeStamp,
|
appkey: appkey,
|
SessionUid: localStorage.getItem('SessionUid') || '',
|
userid: _id,
|
LoginUID: _id,
|
nonc: Utils.getuuid()
|
}
|
|
// param = {
|
// func: _func,
|
// VerificationCode: '授权码',
|
// TimeStamp: timeStamp,
|
// userid: _id,
|
// LoginUID: _id,
|
// nonc: Utils.getuuid()
|
// }
|
|
let keys = Object.keys(param).sort()
|
let values = ''
|
keys.forEach(key => {
|
values += key + param[key]
|
})
|
param.sign = md5(values)
|
param.t = new Date().getTime()
|
|
Api.directRequest({
|
url: _rduri + '/' + _func,
|
method: 'post',
|
data: JSON.stringify(param)
|
}).then(res => {
|
if (res.status) {
|
if (res.EPC === str) {
|
let box = []
|
for (let i = 0; i < 15; i++) {
|
let s = 'mksoft' + moment().add(i, 'days').format('YYYYMMDD')
|
box.push(md5(s))
|
}
|
box = box.join(',')
|
localStorage.setItem(_authUrl, box)
|
|
if (res.e_files === 'true') {
|
localStorage.setItem(window.GLOB.sysSign + 'files', md5(window.GLOB.sysSign + 'files'))
|
localStorage.setItem(window.GLOB.sysSign + 'filesDate', res.e_files_end_date)
|
window.GLOB.storeFiles = true
|
window.GLOB.storeDate = Math.ceil((new Date(res.e_files_end_date).getTime() - new Date().getTime()) / 86400000)
|
} else {
|
localStorage.removeItem(window.GLOB.sysSign + 'files')
|
window.GLOB.storeFiles = false
|
}
|
|
this.setState({
|
auth: true
|
})
|
|
if (res.warning_day && res.warning_day < 20) {
|
Modal.warning({
|
title: `距离授权到期还剩${res.warning_day}天,请联系管理员。`,
|
okText: '知道了'
|
})
|
}
|
} else {
|
localStorage.removeItem(_authUrl)
|
localStorage.removeItem(window.GLOB.sysSign + 'files')
|
window.GLOB.storeFiles = false
|
|
this.setState({
|
auth: false
|
})
|
}
|
|
if (res.query_address !== 'true') {
|
localStorage.removeItem(_addressUrl)
|
} else {
|
localStorage.setItem(_addressUrl, 'true')
|
this.queryAddress()
|
}
|
if (res.deekseek !== 'true') {
|
localStorage.removeItem(window.GLOB.sysSign + 'ds')
|
} else {
|
localStorage.setItem(window.GLOB.sysSign + 'ds', 'true')
|
}
|
} else if (res.ErrCode === 'N') {
|
localStorage.removeItem(_authUrl)
|
this.setState({
|
auth: false,
|
authError: res.message
|
})
|
}
|
}, (error) => {
|
if (error && error.ErrCode === 'LoginError') {
|
let param = {
|
func: 's_visitor_login',
|
timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
|
SessionUid: _id,
|
TypeCharOne: 'pc',
|
appkey: '202004041613277377A6A2456D34A4948AE84'
|
}
|
|
param.LText = md5(window.btoa(_id + param.timestamp))
|
param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
|
|
let params = {
|
url: _rduri.replace('dostars', 'dologon'),
|
method: 'post',
|
data: JSON.stringify(param)
|
}
|
|
Api.directRequest(params)
|
|
return
|
}
|
|
if (index === -1 || index > 10) {
|
this.setState({
|
auth: false,
|
authError: '网络错误导致系统授权失败,请联系管理员。'
|
})
|
}
|
})
|
}
|
|
Api.getTouristMsg().then(result => {
|
if (result.status) {
|
// if (result.website && process.env.NODE_ENV === 'production') {
|
// let website = result.website.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
|
// let current = window.GLOB.baseurl.replace(/http(s)?:\/\/|\/$/ig, '').toLowerCase()
|
|
// if (website !== current) {
|
// try {
|
// window.history.replaceState(null, null, result.website.replace(/\/$/ig, '') + '/admin/index.html#/login')
|
// window.location.reload()
|
// } catch(e) {
|
// window.location.href = result.website.replace(/\/$/ig, '') + '/admin/index.html#/login'
|
// }
|
// return
|
// }
|
// }
|
|
sessionStorage.setItem('visitorUserID', result.UserID || '')
|
sessionStorage.setItem('visitorLoginUID', result.LoginUID || '')
|
|
// 获取系统信息
|
let _param = {
|
func: 's_Get_style',
|
TypeCharOne: 'PC',
|
LText: `select '${appkey}'`,
|
appkey: appkey
|
}
|
|
if (window.GLOB.style_appkey) {
|
_param.style_appkey = window.GLOB.style_appkey
|
}
|
|
_param.userid = result.UserID
|
_param.LoginUID = result.LoginUID
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
Api.getSystemConfig(_param).then(res => {
|
if (!res) return
|
|
if (res.status) {
|
// positecgroup
|
// if (res.member_type && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
|
// if (md5(('mk' + window.GLOB.appkey + res.sys_datetime + res.member_type + res.registry_date).toLowerCase()) !== res.secret_key) {
|
// Modal.warning({
|
// title: '密钥错误,请联系管理员!',
|
// okText: '知道了'
|
// })
|
// this.setState({
|
// auth: false,
|
// authError: '密钥错误,请联系管理员!'
|
// })
|
// return
|
// } else if (res.member_type === 'personal' && res.registry_date) {
|
// let saveDelay = 0
|
// try {
|
// saveDelay = parseInt((new Date().getTime() - new Date(res.registry_date).getTime()) / 4320000)
|
// sessionStorage.setItem('mkDelay', saveDelay)
|
// } catch(e) {}
|
// }
|
// }
|
|
if (!['shutter', 'linkage_navigation', 'linkage', 'menu_board', 'menu_board_navigation'].includes(res.menu_type)) {
|
res.menu_type = 'shutter'
|
}
|
|
let loginOtop = ''
|
let loginOleft = ''
|
let windowWidth = window.innerWidth
|
let fix = null
|
res.login_screen_offset && res.login_screen_offset.forEach(item => {
|
if (!item.offset_x && !item.offset_y) return
|
|
if (fix === null || Math.abs(windowWidth - item.resolution_width) < fix) {
|
fix = Math.abs(windowWidth - item.resolution_width)
|
loginOtop = item.offset_y + item.y_unit
|
loginOleft = item.offset_x + item.x_unit
|
}
|
})
|
|
let systemMsg = {
|
favicon: res.titlelogo || '',
|
platTitle: res.titleName || '',
|
platName: res.SysName || '',
|
bgImage: res.Banner || '',
|
loginlogo: res.loginlogo || '',
|
copyRight: res.CopyRightYear && res.CopyRightOrg ? `Copyright©${res.CopyRightYear} ${window.GLOB.dict['copyrights_by'] || '所有相关版权归'} ${res.CopyRightOrg}` : '',
|
ICP: res.ICP || '',
|
mainlogo: res.indexlogo || '',
|
doclogo: res.doclogo || '',
|
style: res.CSS || '',
|
showline: res.split_line_show || 'true',
|
webSite: res.WebSite || '',
|
prolType: '',
|
prolCont: '',
|
navBar: res.menu_type, // shutter 百叶窗、linkage_navigation 联动菜单、linkage 联动菜单_无导航栏、menu_board 菜单面板、menu_board_navigation 菜单面板_标签页
|
app_version: res.app_version,
|
Member_Level: 0,
|
appname: res.appname || '',
|
loginOtop: loginOtop,
|
loginOleft: loginOleft
|
}
|
|
if (['every_time', 'once', 'not_required'].includes(res.require_legal_consent) && res.legal_documents) {
|
systemMsg.prolCont = res.legal_documents
|
try {
|
systemMsg.prolCont = window.decodeURIComponent(window.atob(systemMsg.prolCont))
|
if (res.require_legal_consent !== 'not_required') {
|
systemMsg.prolType = res.require_legal_consent
|
}
|
} catch(e) {
|
systemMsg.prolType = ''
|
systemMsg.prolCont = ''
|
}
|
}
|
|
if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) {
|
systemMsg.Member_Level = md5('mksoft' + appkey + res.member_level)
|
if (!window.GLOB.memberLevel) {
|
Object.defineProperty(window.GLOB, 'memberLevel', {
|
writable: false,
|
value: res.member_level
|
})
|
}
|
}
|
|
let level = res.pwd_level || ''
|
|
if (level && !['letter_num', 'char_num', 'char_num_90', 'char_num_90_sms'].includes(level)) {
|
level = ''
|
}
|
|
localStorage.setItem(window.GLOB.sysSign + 'pwdlevel', level)
|
|
res.index_background_color && sessionStorage.setItem('home_background', res.index_background_color)
|
|
let seconds = 0
|
if (res.sys_datetime) {
|
seconds = Math.floor((new Date(res.sys_datetime).getTime() - new Date().getTime()) / 1000)
|
}
|
sessionStorage.setItem('sys_time_shim', isNaN(seconds) ? 0 : seconds)
|
|
// url标题
|
document.title = systemMsg.platTitle
|
|
try {
|
localStorage.setItem(window.GLOB.sysSign + 'system', window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg))))
|
} catch (e) {
|
localStorage.removeItem(window.GLOB.sysSign + 'system')
|
}
|
|
if (res.lang_translation_js && res.lang_data && res.lang_data[0] && (res.lang_data.length > 1 || res.lang_data[0].Lang !== 'zh-CN')) {
|
let lang = sessionStorage.getItem('lang')
|
let js_trans = res.lang_translation_js.map(item => {
|
if (['not_empty', 'not_zero', 'max_limit', 'less_limit'].includes(item.msn_code)) {
|
item.translation = ' ' + item.translation
|
}
|
if (['input_tip', 'select_tip', 'max_limit', 'less_limit'].includes(item.msn_code)) {
|
item.translation = item.translation + ' '
|
}
|
if (lang === item.lang) {
|
window.GLOB.dict[item.msn_code] = item.translation
|
}
|
|
return {
|
lang: item.lang,
|
key: item.msn_code,
|
val: item.translation
|
}
|
})
|
|
localStorage.setItem(window.GLOB.sysSign + 'js_trans', JSON.stringify(js_trans))
|
}
|
|
let _loginurl = window.GLOB.sysSign + 'loginways'
|
let login_ways = []
|
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 (!['sms_vcode', 'uname_pwd', 'app_scan', 'weixin_scan'].includes(item.way_no)) return
|
|
login_ways.push({
|
type: item.way_no,
|
smsId: item.sms_id
|
})
|
|
if (item.way_no === 'sms_vcode' && item.sms_id) {
|
sessionStorage.setItem('mk_sms_id', item.sms_id)
|
}
|
})
|
} else {
|
login_ways.push({
|
type: 'uname_pwd',
|
smsId: ''
|
})
|
}
|
|
try {
|
localStorage.setItem(_loginurl, window.btoa(window.encodeURIComponent(JSON.stringify(login_ways))))
|
} catch (e) {
|
localStorage.removeItem(_loginurl)
|
}
|
|
if (res.lang_data && res.lang_data.length > 1 && window.GLOB.systemType !== 'production') {
|
let list = res.lang_data.map(item => item.Lang).filter(n => n !== 'zh-CN')
|
sessionStorage.setItem('langList', JSON.stringify(list))
|
}
|
|
if (res.lang_data.length === 1 && res.lang_data[0].Lang !== sessionStorage.getItem('lang')) {
|
localStorage.setItem(window.location.href.split('#')[0] + 'lang', res.lang_data[0].Lang)
|
sessionStorage.setItem('lang', res.lang_data[0].Lang)
|
window.location.reload()
|
return
|
}
|
|
let langList = res.lang_data.map(item => ({Lang: item.Lang, LangName: item.LangName}))
|
|
localStorage.setItem(window.GLOB.sysSign + 'langList', JSON.stringify(langList))
|
|
window.GLOB.loginOtop = systemMsg.loginOtop
|
window.GLOB.loginOleft = systemMsg.loginOleft
|
|
this.setState({
|
loginWays: login_ways,
|
langList: langList,
|
...systemMsg
|
})
|
|
window.GLOB.mainlogo = systemMsg.mainlogo
|
window.GLOB.style = systemMsg.style
|
window.GLOB.navBar = systemMsg.navBar
|
window.GLOB.appVersion = systemMsg.app_version
|
sessionStorage.setItem('appname', res.appname || '')
|
|
if (window.GLOB.style && 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) {
|
let link = document.querySelector("link[rel*='icon']") || document.createElement('link')
|
link.type = 'image/x-icon'
|
link.rel = 'shortcut icon'
|
link.href = res.titlelogo
|
document.getElementsByTagName('head')[0].appendChild(link)
|
}
|
|
// positecgroup
|
if (['20210626201522493D7AD7591D7A547278685', '20210626201956190740F1DF384914A3CA9EF'].includes(window.GLOB.appkey) && res.users_upt === 'true' && window.GLOB.systemType === 'production') {
|
Api.genericInterface({
|
func: 's_Get_local_u_deleted',
|
users_upt_date: res.users_upt_date,
|
userid: result.UserID,
|
LoginUID: result.LoginUID
|
}).then(localres => {
|
if (!localres.status) return
|
Api.getSystemConfig({
|
func: 's_get_sso_u_create',
|
user_ids: localres.user_ids,
|
user_ids_local: localres.user_ids_local,
|
users_upt_date: localres.users_upt_date,
|
userid: result.UserID,
|
LoginUID: result.LoginUID
|
}).then(ssores => {
|
if (!ssores.status) return
|
Api.genericInterface({
|
func: 's_get_local_u_create',
|
user_ids_local: ssores.user_ids_local,
|
userid: result.UserID,
|
LoginUID: result.LoginUID
|
})
|
})
|
})
|
}
|
} else {
|
message.warning(res.message)
|
}
|
})
|
} else {
|
message.warning(result.message)
|
}
|
})
|
|
let loginWays = localStorage.getItem(window.GLOB.sysSign + 'loginways')
|
if (loginWays) {
|
try {
|
loginWays = JSON.parse(window.decodeURIComponent(window.atob(loginWays)))
|
} catch (e) {
|
loginWays = null
|
}
|
|
this.setState({
|
loginWays: loginWays
|
})
|
}
|
|
let langs = localStorage.getItem(window.GLOB.sysSign + 'langList')
|
if (langs) {
|
try {
|
langs = JSON.parse(langs)
|
} catch (e) {
|
langs = []
|
}
|
|
this.setState({
|
langList: langs
|
})
|
}
|
}
|
|
queryAddress = () => {
|
window.callbackFunction = (res) => {
|
if (res.result && res.result.ad_info) {
|
sessionStorage.setItem('nation', res.result.ad_info.nation || '')
|
sessionStorage.setItem('province', res.result.ad_info.province || '')
|
sessionStorage.setItem('city', res.result.ad_info.city || '')
|
sessionStorage.setItem('district', res.result.ad_info.district || '')
|
sessionStorage.setItem('address', res.result.ad_info.address || '')
|
sessionStorage.setItem('ipAddress', res.result.ip || '')
|
}
|
}
|
|
const JSONP = document.createElement('script')
|
JSONP.type = 'text/javascript'
|
JSONP.src = 'https://apis.map.qq.com/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonp&sig=3e5ebecb324ba266bf80014dcc8380db'
|
document.getElementsByTagName('head')[0].appendChild(JSONP)
|
|
setTimeout(() => {
|
document.getElementsByTagName('head')[0].removeChild(JSONP)
|
},500)
|
}
|
|
syncSubmit = () => {
|
this.setState({
|
syncing: true
|
})
|
|
let param = {
|
func: 's_get_app_from_cloud',
|
UserName: '',
|
Password: '',
|
systemType: window.GLOB.sysType,
|
Type: 'X',
|
debug: 'Y'
|
}
|
|
param.appkey = window.GLOB.appkey || ''
|
|
if (window.GLOB.cloudServiceApi) {
|
param.rduri = window.GLOB.cloudServiceApi.replace('dostars', 'dostar')
|
}
|
|
this.logincloudRef.handleConfirm().then(result => {
|
param.UserName = result.cloudusername
|
param.Password = result.cloudpassword
|
|
param.Password = Utils.formatOptions(param.Password)
|
|
Api.dostarInterface(param).then(res => {
|
if (res.status) {
|
let _param = {
|
func: 's_sDataDictb_TBBack',
|
LTextOut: res.LTextOut,
|
lid: res.Lid,
|
Appkey: window.GLOB.appkey || ''
|
}
|
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
_param.secretkey = Utils.encrypt(_param.LTextOut, _param.timestamp)
|
_param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp)
|
|
Api.dostarInterface(_param).then(response => {
|
if (response.status) {
|
message.success('应用创建成功。')
|
this.setState({
|
syncing: false,
|
syncApp: false
|
})
|
} else {
|
this.setState({
|
syncing: false
|
})
|
message.warning(response.message)
|
}
|
})
|
|
} else {
|
this.setState({
|
syncing: false
|
})
|
message.warning(res.message)
|
}
|
})
|
})
|
}
|
|
codeSubmit = () => {
|
const { verify } = this.state
|
this.codeRef.handleConfirm().then(res => {
|
this.setState({
|
codeLoading: true
|
})
|
Api.verifycode({...verify, code: res.code}).then(result => {
|
this.setState({
|
codeVisible: false,
|
codeLoading: false
|
})
|
|
if (result.verifyResult === 'success') {
|
let level = localStorage.getItem(window.GLOB.sysSign + 'pwdlevel')
|
if (level) {
|
let visible = false
|
let tip = '密码强度不够,请修改密码!'
|
if (verify.$password.length < 8) {
|
visible = true
|
} else if (level === 'letter_num' && /^([^0-9]*|[^a-zA-Z]*)$/.test(verify.$password)) {
|
visible = true
|
} else if ((level === 'char_num' || level === 'char_num_90') && /^([^0-9]*|[^a-zA-Z]*|[^!@#$%^&*()_]*)$/.test(verify.$password)) {
|
visible = true
|
} else if (level === 'char_num_90' && verify.modifydate) {
|
let s = (new Date().getTime() - new Date(verify.modifydate).getTime()) / (1000 * 24 * 60 * 60)
|
if (!isNaN(s) && s > 90) {
|
visible = true
|
tip = '您已90天未修改密码,请更换密码后使用!'
|
}
|
}
|
|
if (visible) {
|
message.warning(tip)
|
this.setState({
|
isDisabled: false,
|
visible: true
|
})
|
return
|
}
|
}
|
|
this.props.history.replace('/main')
|
} else {
|
notification.warning({
|
top: 92,
|
message: '验证码无效,请重新登录!',
|
duration: 5
|
})
|
}
|
})
|
}, () => {})
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render () {
|
const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays, prolType, prolCont } = this.state
|
|
let wrapStyle = {}
|
|
if (bgImage) {
|
wrapStyle.backgroundImage = `url(${bgImage})`
|
}
|
if (window.GLOB.loginOtop) {
|
wrapStyle['--mk-login-offset-top'] = window.GLOB.loginOtop
|
}
|
if (window.GLOB.loginOleft) {
|
wrapStyle['--mk-login-offset-left'] = window.GLOB.loginOleft
|
}
|
|
return (
|
<div className="login-container" id="mk-login-view" style={wrapStyle}>
|
<div className="logo" style={lineColor ? {borderColor: lineColor} : {}}>
|
{loginlogo ? <img src={loginlogo} alt=""/> : null}
|
{this.state.platName ? <p className="plat-name">{this.state.platName}</p> : null}
|
</div>
|
<div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}>
|
{loginWays ? <LoginForm
|
auth={this.state.auth}
|
authError={this.state.authError}
|
loginWays={loginWays}
|
prolType={prolType}
|
prolCont={prolCont}
|
langList={this.state.langList}
|
isDisabled={this.state.isDisabled}
|
handleSubmit={() => this.handleSubmit()}
|
authLogin={this.authLogin}
|
wrappedComponentRef={(inst) => this.loginformRef = inst}
|
/> : null}
|
</div>
|
<div className="login-bottom">
|
<p>
|
{webSite && copyRight ?
|
<a target="_blank" rel="noopener noreferrer" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> :
|
<span dangerouslySetInnerHTML={{ __html: copyRight ? copyRight.replace(/\s/ig, ' ') : '' }}></span>
|
}
|
{prolCont && !prolType ? <span style={{marginLeft: '15px'}} dangerouslySetInnerHTML={{ __html: prolCont }}></span> : null}
|
</p>
|
{ICP ? <a target="_blank" rel="noopener noreferrer" href="https://beian.miit.gov.cn/#/Integrated/index" dangerouslySetInnerHTML={{ __html: ICP.replace(/\s/ig, ' ') }}></a> : null}
|
</div>
|
{/* 编辑状态登录 */}
|
<Modal
|
title="同步云端应用"
|
visible={this.state.syncApp}
|
onOk={this.syncSubmit}
|
maskClosable={false}
|
className="sync-cloud-application"
|
width={'430px'}
|
confirmLoading={this.state.syncing}
|
onCancel={() => {this.setState({ syncApp: false, syncing: false })}}
|
destroyOnClose
|
>
|
<LoginCloudForm handleSubmit={() => this.syncSubmit()} wrappedComponentRef={(inst) => this.logincloudRef = inst}/>
|
</Modal>
|
{/* 修改密码 */}
|
<Resetpwd />
|
{/* 二次验证 */}
|
<Modal
|
title="二次验证"
|
okText={window.GLOB.dict['ok'] || '确定'}
|
cancelText={window.GLOB.dict['cancel'] || '取消'}
|
visible={this.state.codeVisible}
|
onOk={this.codeSubmit}
|
maskClosable={false}
|
confirmLoading={this.state.codeLoading}
|
onCancel={() => this.setState({codeVisible: false, codeLoading: false})}
|
destroyOnClose
|
>
|
<LoginCodeForm verify={this.state.verify} wrappedComponentRef={(inst) => this.codeRef = inst} handleSubmit={this.codeSubmit}/>
|
</Modal>
|
</div>
|
)
|
}
|
}
|
|
export default Login
|