| | |
| | | import React, { Component } from 'react' |
| | | import { message, Modal } from 'antd' |
| | | 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 options, { styles } from '@/store/options.js' |
| | | import { styles } from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/login.js' |
| | | import enUS from '@/locales/en-US/login.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | const LoginForm = asyncLoadComponent(() => import('./loginform')) |
| | | const Resetpwd = asyncLoadComponent(() => import('@/components/resetPassword')) |
| | | const LoginCloudForm = asyncComponent(() => import('./logincloudform')) |
| | | const LoginCodeForm = asyncComponent(() => import('./logincodeform')) |
| | | const iszhCN = sessionStorage.getItem('lang') !== 'en-US' |
| | | |
| | | const _href = window.location.href.split('#')[0] |
| | |
| | | sessionStorage.removeItem('visitorUserID') |
| | | sessionStorage.removeItem('visitorLoginUID') |
| | | |
| | | if (param.remember) { // 记住密码时账号密码存入localStorage |
| | | localStorage.setItem(_href, window.btoa(window.encodeURIComponent(JSON.stringify({username: param.username, password: param.password})))) |
| | | let users = localStorage.getItem(_href + 'users') |
| | | |
| | | if (users) { |
| | | try { |
| | | users = JSON.parse(window.decodeURIComponent(window.atob(users))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | users = [] |
| | | } |
| | | } else { |
| | | localStorage.removeItem(_href) |
| | | 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(_href + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(users)))) |
| | | |
| | | let level = localStorage.getItem(_href + 'pwdlevel') |
| | | |
| | |
| | | } else { |
| | | this.props.history.replace('/main') |
| | | } |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') { |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') { |
| | | message.warning('应用尚未创建,请向云端同步应用!') |
| | | |
| | | this.setState({ |
| | |
| | | input.select() |
| | | } |
| | | } else if (res.message.indexOf('登录权限') > -1) { |
| | | const input = document.getElementById('username') |
| | | const wrap = document.getElementById('username') |
| | | const input = wrap ? wrap.getElementsByTagName('input')[0] : null |
| | | if (input) { |
| | | input.select() |
| | | } |
| | |
| | | } else { |
| | | this.props.history.replace('/main') |
| | | } |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') { |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') { |
| | | message.warning('应用尚未创建,请向云端同步应用!') |
| | | |
| | | this.setState({ |
| | |
| | | } else { |
| | | this.props.history.replace('/main') |
| | | } |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') { |
| | | } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') { |
| | | message.warning('应用尚未创建,请向云端同步应用!') |
| | | |
| | | this.setState({ |
| | |
| | | }) |
| | | } |
| | | |
| | | // handleItem = (list) => { |
| | | // let param = list.shift() |
| | | // Object.keys(param).forEach(key => { |
| | | // if (param[key] === null) { |
| | | // param[key] = '' |
| | | // } |
| | | // }) |
| | | // Api.directRequest({ |
| | | // url: 'http://bms.kresstools.cn/oc/webapi/dostar/zsn_app_bddmsdealersm_add_upt', |
| | | // method: 'post', |
| | | // data: JSON.stringify({ |
| | | // func: 'zsn_app_bddmsdealersm_add_upt', |
| | | // userid: '', |
| | | // ...param |
| | | // }) |
| | | // }).then(res => { |
| | | // if (res.status && list.length > 0) { |
| | | // this.handleItem(list) |
| | | // } else { |
| | | // console.log(list) |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | 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") |
| | | |
| | | // Api.directRequest({ |
| | | // url: 'http://bms.kresstools.cn/saas-mp-open-api/shop/shopStore/getAllStoreList', |
| | | // method: 'get' |
| | | // }).then(res => { |
| | | // if (res && res.code === 0 && res.data && res.data.length > 0) { |
| | | // this.handleItem(res.data) |
| | | // } |
| | | // }) |
| | | setTimeout(() => { |
| | | Api.delCacheConfig() |
| | | }, 50) |
| | |
| | | } |
| | | |
| | | if (!window.GLOB.licenseKey && (index === -1 || index > 5)) { |
| | | let _appId = window.GLOB.appId |
| | | |
| | | if (options.sysType === 'cloud') { // 云端使用系统配置appid |
| | | _appId = options.caId |
| | | } |
| | | |
| | | let str = md5('MK19' + _appId + timeStamp) |
| | | 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: _appId, |
| | | AppID: window.GLOB.appId, |
| | | TimeStamp: timeStamp, |
| | | appkey: window.GLOB.appkey, |
| | | SessionUid: localStorage.getItem('SessionUid') || '', |
| | | userid: _id, |
| | | LoginUID: _id, |
| | | nonc: Utils.getuuid() |
| | |
| | | |
| | | 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 (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 |
| | | } |
| | | } |
| | | // 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 || '') |
| | |
| | | |
| | | if (res.status) { |
| | | // positecgroup |
| | | // res.Banner = res.Banner ? res.Banner.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' |
| | | // res.doclogo = res.doclogo ? res.doclogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' |
| | | // res.indexlogo = res.indexlogo ? res.indexlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' |
| | | // res.loginlogo = res.loginlogo ? res.loginlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' |
| | | |
| | | if (options.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 (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' |
| | |
| | | showline: res.split_line_show || 'true', |
| | | webSite: res.WebSite || '', |
| | | navBar: res.menu_type, // shutter 百叶窗、linkage_navigation 联动菜单、linkage 联动菜单_无导航栏、menu_board 菜单面板、menu_board_navigation 菜单面板_标签页 |
| | | app_version: res.app_version |
| | | app_version: res.app_version, |
| | | Member_Level: 0 |
| | | } |
| | | |
| | | if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) { |
| | | systemMsg.Member_Level = md5('mksoft' + window.GLOB.appkey + res.member_level) |
| | | if (!window.GLOB.memberLevel) { |
| | | Object.defineProperty(window.GLOB, 'memberLevel', { |
| | | writable: false, |
| | | value: res.member_level |
| | | }) |
| | | } |
| | | } |
| | | |
| | | let level = res.pwd_level || '' |
| | |
| | | document.getElementsByTagName('head')[0].appendChild(link) |
| | | } |
| | | |
| | | let memberLevel = res.member_level |
| | | |
| | | if (typeof(memberLevel) === 'number' && memberLevel > 10 && parseInt(memberLevel / 10) * 10 === memberLevel) { |
| | | sessionStorage.setItem('Member_Level', md5('mksoft' + window.GLOB.appkey + new Date().getFullYear() + new Date().getMonth() + memberLevel)) |
| | | window.GLOB.memberLevel = memberLevel |
| | | } |
| | | |
| | | // positecgroup |
| | | // if (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 |
| | | // }) |
| | | // }) |
| | | // }) |
| | | // } |
| | | if (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) |
| | | } |
| | |
| | | func: 's_get_app_from_cloud', |
| | | UserName: '', |
| | | Password: '', |
| | | systemType: options.sysType, |
| | | systemType: window.GLOB.sysType, |
| | | Type: 'X', |
| | | debug: 'Y' |
| | | } |
| | | |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (options.cloudServiceApi) { |
| | | param.rduri = options.cloudServiceApi.replace('dostars', 'dostar') |
| | | if (window.GLOB.cloudServiceApi) { |
| | | param.rduri = window.GLOB.cloudServiceApi.replace('dostars', 'dostar') |
| | | } |
| | | |
| | | this.logincloudRef.handleConfirm().then(result => { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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(_href + '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更新 |
| | | */ |
| | |
| | | </div> |
| | | <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}> |
| | | {loginWays ? <LoginForm |
| | | platName={this.state.platName} |
| | | dict={this.state.dict} |
| | | auth={this.state.auth} |
| | | authError={this.state.authError} |
| | |
| | | </Modal> |
| | | {/* 修改密码 */} |
| | | <Resetpwd /> |
| | | {/* 二次验证 */} |
| | | <Modal |
| | | title="二次验证" |
| | | okText={this.state.dict['login.ok']} |
| | | cancelText={this.state.dict['login.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> |
| | | ) |
| | | } |