From 27821f7b598e9e87de8fb179bdcbfdc5e2cb31fa Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 25 九月 2019 00:17:55 +0800
Subject: [PATCH] 2019-09-25update

---
 src/views/login/index.jsx |   95 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx
index 18b6ecf..ef1511d 100644
--- a/src/views/login/index.jsx
+++ b/src/views/login/index.jsx
@@ -1,27 +1,43 @@
 import React, {Component} from 'react'
-import { Form, Icon, Input, Button, Checkbox, Dropdown, Menu, message } from 'antd'
+import { Form, Icon, Input, Button, Checkbox, Dropdown, Menu, message, Modal } from 'antd'
 import md5 from 'md5'
+import moment from 'moment'
 import Api from '@/api'
 import zhCN from '@/locales/zh-CN/login.js'
 import enUS from '@/locales/en-US/login.js'
+import options from '@/store/options.js'
 import logourl from '../../assets/img/login-logo.png'
 import './index.scss'
 
+const { confirm } = Modal
+
 class Login extends Component {
-  state = {
-    langs: [{
-      name: '涓枃绠�浣�',
-      value: 'zh-CN'
-    }, {
-      name: 'English',
-      value: 'en-US'
-    }],
-    selectedlang: {
-      name: '涓枃绠�浣�',
-      value: 'zh-CN'
-    },
-    dict: zhCN,
-    isDisabled: false
+  constructor (props) {
+    super(props)
+
+    const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN'
+
+    this.state = {
+      langs: [{
+        name: '涓枃绠�浣�',
+        value: 'zh-CN'
+      }, {
+        name: 'English',
+        value: 'en-US'
+      }],
+      selectedlang: iszhCN ?
+        {
+          name: '涓枃绠�浣�',
+          value: 'zh-CN'
+        } :
+        {
+          name: 'English',
+          value: 'en-US'
+        },
+      dict: iszhCN ? zhCN : enUS,
+      isDisabled: false,
+      auth: false
+    }
   }
 
   changelang (item) {
@@ -36,11 +52,22 @@
     // md5瀵嗙爜鍔犲瘑
     const salt = 'minkesoft'
     return md5(md5(pwd + salt))
+    // return pwd
   }
 
   handleSubmit = e => {
     // 鐧诲綍鍙傛暟妫�楠�
     e.preventDefault()
+    if (!this.state.auth) {
+      confirm({
+        title: this.state.dict['login.auth.tip'],
+        okText: this.state.dict['login.auth.ok'],
+        cancelText: this.state.dict['login.auth.cancel'],
+        onOk() {},
+        onCancel() {}
+      })
+      return
+    }
     this.props.form.validateFields((err, values) => {
       if (err) return
       this.setState({
@@ -55,8 +82,9 @@
     let password = this.md5Password(param.password)
     let result = await Api.loginsystem(param.username, password)
     if (result.status) {
+    // if (!result.IsError) {
       sessionStorage.setItem('UserID', result.userid)
-      sessionStorage.setItem('lang', this.state.selectedlang.value)
+      localStorage.setItem('lang', this.state.selectedlang.value)
 
       if (param.remember) { // 璁颁綇瀵嗙爜鏃惰处鍙峰瘑鐮佸瓨鍏ocalStorage
         localStorage.setItem('username', param.username)
@@ -74,12 +102,47 @@
       }
     } else {
       message.warning(result.message)
+      // message.warning(result.Message)
       this.setState({
         isDisabled: false
       })
     }
   }
 
+  UNSAFE_componentWillMount () {
+    let timeStamp = new Date().getTime()
+    // let str = md5('MK19' + options.AppId + timeStamp)
+    Api.systemauth(options.AppId, timeStamp).then(res => {
+      if (res.status) {
+        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('AuthCode', box)
+
+        this.setState({
+          auth: true
+        })
+      } else {
+        localStorage.removeItem('AuthCode')
+        this.setState({
+          auth: false
+        })
+      }
+      // console.log(str)
+    })
+
+    let authCode = localStorage.getItem('AuthCode')
+    let _s = md5('mksoft' + moment().format('YYYYMMDD'))
+    if (authCode && authCode.includes(_s)) {
+      this.setState({
+        auth: true
+      })
+    }
+  }
+
   render () {
     const { getFieldDecorator } = this.props.form
     const menu = (

--
Gitblit v1.8.0