king
2020-07-31 9a9650c758bd84bef0739aa8949627af666bb1c1
src/views/login/index.jsx
@@ -32,6 +32,8 @@
    webSite: window.GLOB.webSite || '',
    langList: [],
    syncApp: false,
    loginWays: null,
    touristLogin: false,
    syncing: false
  }
@@ -53,7 +55,12 @@
      this.setState({
        isDisabled: true
      })
      if (res.type === 'uname_pwd') {
      this.loginsubmit(res)
      } else if (res.type === 'sms_vcode') {
        this.phoneloginsubmit(res)
      }
    })
  }
@@ -105,6 +112,46 @@
    }
  }
  async phoneloginsubmit (param) {
    if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 业务系统必须设置单点地址
      Modal.warning({
        title: '未设置单点服务器地址,请联系管理员!'
      })
      return
    }
    // 登录提交
    let res = await Api.getphoneusermsg(param.phone, param.vercode)
    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 || '')
      localStorage.setItem('lang', param.lang || 'zh-CN')
      if (this.props.location.state && this.props.location.state.from.pathname) {
        // 查看是否为其他页面跳转,路径存在时,跳回原页面
        this.props.history.replace(this.props.location.state.from.pathname)
      } else {
        this.props.history.replace('/main')
      }
    } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') {
      message.warning('应用尚未创建,请向云端同步应用!')
      this.setState({
        isDisabled: false,
        syncApp: true
      })
    } else {
      message.warning(res.message)
      this.setState({
        isDisabled: false
      })
    }
  }
  componentDidMount () {
    let timeStamp = new Date().getTime()
    let _appId = window.GLOB.appId
@@ -116,13 +163,15 @@
    let str = md5('MK19' + _appId + timeStamp)
    let param = {
      rduri: 'http://minkesoft.com/mksepc/webapi/dostar',
      rduri: 'http://minkesoft.com/mksepc/webapi/dostars',
      func: 'sEmpowerCloud_Get_LinkUrl',
      AppID: _appId,
      TimeStamp: timeStamp
      TimeStamp: timeStamp,
      userid: 'bh0bapabtd45epsgra79segbch6c1ibk',
      LoginUID: 'bh0bapabtd45epsgra79segbch6c1ibk'
    }
    Api.dostarInterface(param).then(res => {
    Api.dostarToDostars(param).then(res => {
      if (res.status) {
        if (res.EPC === str) {
          let box = []
@@ -158,10 +207,22 @@
      })
    }
    Api.getTouristMsg().then(result => {
      if (result.status) {
        if (!sessionStorage.getItem('UserID') && result.UserID) {
          sessionStorage.setItem('UserID', result.UserID)
        }
        if (!sessionStorage.getItem('LoginUID') && result.LoginUID) {
          sessionStorage.setItem('LoginUID', result.LoginUID)
        }
        if (result.UserID && result.LoginUID) {
          this.setState({touristLogin: true})
        }
    // 获取系统信息
    let _param = {
      func: 's_Get_style',
      Appkey: window.GLOB.appkey || '',
      TypeCharOne: 'PC',
      LText: `select '${window.GLOB.appkey}'`,
    }
@@ -169,11 +230,7 @@
    _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
    _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
    if (window.GLOB.mainSystemApi) {
      _param.rduri = window.GLOB.mainSystemApi.replace('dostars', 'dostar')
    }
    Api.dostarInterface(_param).then(res => {
        Api.getSystemConfig(_param).then(res => {
      if (res.status) {
        let _url = window.location.href.split('#')[0] + 'system'
        let systemMsg = {
@@ -199,7 +256,39 @@
          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 {
              localStorage.removeItem(_loginurl)
            }
        this.setState({
              loginWays: login_ways,
          langList: res.lang_data || [],
          ...systemMsg
        })
@@ -224,6 +313,25 @@
        message.warning(res.message)
      }
    })
      } else {
        message.warning(result.message)
      }
    })
    let loginWays = localStorage.getItem(window.location.href.split('#')[0] + 'loginways')
    if (loginWays) {
      try {
        loginWays = JSON.parse(window.decodeURIComponent(window.atob(loginWays)))
      } catch {
        localStorage.removeItem(window.location.href.split('#')[0] + 'loginways')
      }
      if (loginWays) {
        this.setState({
          loginWays: loginWays
        })
      }
    }
  }
  syncSubmit = () => {
@@ -301,7 +409,7 @@
  }
  render () {
    const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP } = this.state
    const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays, touristLogin } = this.state
    return (
      <div className="login-container" style={bgImage ? {backgroundImage: 'url(' + bgImage + ')'} : {}}>
@@ -309,17 +417,19 @@
          {loginlogo ? <img src={loginlogo} alt=""/> : null}
        </div>
        <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}>
          <LoginForm
          {loginWays ? <LoginForm
            platName={this.state.platName}
            dict={this.state.dict}
            auth={this.state.auth}
            touristLogin={touristLogin}
            loginWays={loginWays}
            lang={this.state.selectedlang}
            langList={this.state.langList}
            isDisabled={this.state.isDisabled}
            changelang={(value) => this.changelang(value)}
            handleSubmit={() => this.handleSubmit()}
            wrappedComponentRef={(inst) => this.loginformRef = inst}
          />
          /> : null}
        </div>
        <div className="login-bottom">
          {webSite && copyRight ?