From 0519dcda8b6fb2914987f8d4d58e1d14bcf98dc3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 30 六月 2023 14:33:06 +0800
Subject: [PATCH] 2023-06-30

---
 src/views/login/loginform.jsx |  193 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 132 insertions(+), 61 deletions(-)

diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx
index 0da7d35..fe22bd9 100644
--- a/src/views/login/loginform.jsx
+++ b/src/views/login/loginform.jsx
@@ -1,6 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Icon, Input, Button, Checkbox, Select, Modal, message } from 'antd'
+import { Form, Input, Button, Checkbox, Select, Modal, message } from 'antd'
+import { UserOutlined, LockOutlined, QrcodeOutlined, RedoOutlined } from '@ant-design/icons'
 import md5 from 'md5'
 import moment from 'moment'
 
@@ -40,6 +41,7 @@
     loginWays: [],
     smsId: '',
     verdisabled: false,
+    hasScan: false,
     timeout: false
   }
 
@@ -54,17 +56,24 @@
     if (localStorage.getItem(_url + 'remember') === 'false') {
       remember = false
     }
+    if (!window.GLOB.keepKey) {
+      remember = false
+    }
 
     let smsId = ''
+    let hasScan = false
     let _loginWays = []
     loginWays.forEach(item => {
       if (item.type === 'sms_vcode') {
+        item.label = '鐭俊鐧诲綍'
         smsId = item.smsId
         _loginWays.push(item)
       } else if (item.type === 'uname_pwd') {
+        item.label = '璐﹀彿鐧诲綍'
         _loginWays.push(item)
       } else if (item.type === 'app_scan') {
         _loginWays.push(item)
+        hasScan = true
       }
     })
 
@@ -76,7 +85,8 @@
       activeKey,
       scanId: activeKey === 'app_scan' ? Utils.getuuid() : '',
       timeout: false,
-      remember
+      remember,
+      hasScan
     })
 
     if (activeKey === 'app_scan') {
@@ -129,6 +139,13 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
+          if (activeKey === 'uname_pwd') {
+            values.username = values.username.replace(/\t*|\v*|\s*/g, '')
+            values.password = values.password.replace(/\t*|\v*|\s*/g, '')
+          } else if (activeKey === 'sms_vcode') {
+            values.phone = values.phone.replace(/\t*|\v*|\s*/g, '')
+            values.vercode = values.vercode.replace(/\t*|\v*|\s*/g, '')
+          }
           resolve({type: activeKey, ...values})
         } else {
           reject(err)
@@ -289,7 +306,7 @@
       param.LText = md5(`${_phone}mingke${window.GLOB.appkey}${param.timestamp}`)
       param.secretkey = md5(`${param.LText}mingke${param.timestamp}`)
 
-      param.rduri = 'http://sso.mk9h.cn/webapi/dostars'
+      param.rduri = 'https://sso.mk9h.cn/webapi/dostars'
       param.userid = 'bh0bapabtd45epsgra79segbch6c1ibk'
       param.LoginUID = 'bh0bapabtd45epsgra79segbch6c1ibk'
   
@@ -299,7 +316,7 @@
       })
       LoginVerCodeTimer = setTimeout(this.resetVerCodeDelay, 1000)
   
-      Api.getLocalConfig(param).then(res => {
+      Api.genericInterface(param).then(res => {
         if (res.status) {
   
         } else {
@@ -312,7 +329,30 @@
           })
           message.warning(res.message)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+          
+          param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+  
+          let params = {
+            url: 'https://sso.mk9h.cn/webapi/dologon',
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+
         if (LoginVerCodeTimer) {
           clearTimeout(LoginVerCodeTimer)
         }
@@ -356,29 +396,27 @@
 
   render() {
     const { getFieldDecorator } = this.props.form
-    const { activeKey, verdisabled, delay, loginWays, remember, scanId, timeout } = this.state
+    const { activeKey, verdisabled, delay, loginWays, remember, scanId, timeout, hasScan } = this.state
+    const wayLabels = {app_scan: '鎵爜鐧诲綍', uname_pwd: '璐﹀彿鐧诲綍', sms_vcode: '鐭俊鐧诲綍'}
 
     return (
       <Form className="login-form" id="login-form" onSubmit={this.handleSubmit}>
-        <div className={'login-way-wrap ' + (loginWays.length === 1 ? 'simple' : '')}>
-          {loginWays.map(item => (
-            <div className={'login-way' + (activeKey === item.type ? ' active' : '')} onClick={() => this.onChangeTab(item.type)} key={item.type}>{item.label}</div>
-          ))}
-        </div>
-        <div className="form-item-wrap">
-          {activeKey === 'uname_pwd' ? <Form.Item>
+        <div className="login-way-title">{wayLabels[activeKey]}</div>
+        {hasScan && activeKey !== 'app_scan' ? <div className="scan-icon" onClick={() => this.onChangeTab('app_scan')}><QrcodeOutlined /></div> : null}
+        {activeKey === 'uname_pwd' ? <div className="form-item-wrap">
+          <Form.Item>
             {getFieldDecorator('username', {
               rules: [{ required: true, message: this.props.dict['login.username.empty'] }],
               initialValue: this.state.username || '',
             })(
               <Input
-                prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
+                prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />}
                 placeholder={this.props.dict['login.username']}
                 autoComplete="off"
               />,
             )}
-          </Form.Item> : null}
-          {activeKey === 'uname_pwd' ? <Form.Item>
+          </Form.Item>
+          <Form.Item>
             {getFieldDecorator('password', {
               initialValue: this.state.password || '',
               rules: [
@@ -387,47 +425,15 @@
                   message: this.props.dict['login.password.empty'],
                 }
               ]
-            })(<Input.Password placeholder={this.props.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
-          </Form.Item> : null}
-          {activeKey === 'sms_vcode' ? <Form.Item>
-            {getFieldDecorator('phone', {
-              rules: [{ required: true, message: this.props.dict['login.phone.empty'] }],
-              initialValue: '',
-            })(
-              <Input
-                placeholder={this.props.dict['login.phone']}
-                autoComplete="off"
-              />
-            )}
-          </Form.Item> : null}
-          {activeKey === 'sms_vcode' ? <Form.Item className="vercode">
-            {getFieldDecorator('vercode', {
-              initialValue: '',
-              rules: [
-                {
-                  required: true,
-                  message: this.props.dict['login.vercode.empty'],
-                }
-              ]
-            })(
-              <Input
-                addonAfter={
-                  <Button type="link" className="vercode" size="small" disabled={verdisabled} onClick={this.getvercode}>
-                    {delay ? this.props.dict['login.vercode.queryagain'].replace('@', delay) : this.props.dict['login.vercode.query']}
-                  </Button>
-                }
-                placeholder={this.props.dict['login.vercode']}
-                autoComplete="off"
-              />
-            )}
-          </Form.Item> : null}
-          {activeKey === 'uname_pwd' ? <Form.Item className="minline">
+            })(<Input.Password placeholder={this.props.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
+          </Form.Item>
+          {window.GLOB.keepKey ? <Form.Item className="minline">
             {getFieldDecorator('remember', {
               valuePropName: 'checked',
               initialValue: remember,
             })(<Checkbox onChange={this.rememberChange}>{this.props.dict['login.remember']}</Checkbox>)}
-          </Form.Item> : null}
-          {activeKey !== 'app_scan' && this.props.langList && this.props.langList.length > 0 ? <Form.Item className="minline right">
+          </Form.Item> : <div style={{height: '30px', float: 'left'}}></div>}
+          {this.props.langList && this.props.langList.length > 0 ? <Form.Item className="minline right">
             {getFieldDecorator('lang', {
               initialValue: this.props.lang,
             })(
@@ -441,25 +447,90 @@
               </Select>
             )}
           </Form.Item> : null}
-          {['uname_pwd', 'sms_vcode'].includes(activeKey) ? <Form.Item className="btn-login">
+          <Form.Item className="btn-login">
             <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.props.isDisabled} loading={this.props.isDisabled}>
               {this.props.dict['login.submit']}
             </Button>
+          </Form.Item>
+          {options.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line">
+            <a href="http://www.minkesoft.com/signup" target="_blank" rel="noopener noreferrer" className="register">娉ㄥ唽</a>
+            <a href="http://www.minkesoft.com/forgotPwd" target="_blank" rel="noopener noreferrer" className="forgot">蹇樿瀵嗙爜锛�</a>
           </Form.Item> : null}
-          {activeKey === 'app_scan' ? <div className="form-scan-wrap">
+        </div> : null}
+        {activeKey === 'sms_vcode' ? <div className="form-item-wrap">
+          <Form.Item>
+            {getFieldDecorator('phone', {
+              rules: [{ required: true, message: this.props.dict['login.phone.empty'] }],
+              initialValue: '',
+            })(
+              <Input
+                placeholder={this.props.dict['login.phone']}
+                autoComplete="off"
+              />
+            )}
+          </Form.Item>
+          <Form.Item className="vercode">
+            {getFieldDecorator('vercode', {
+              initialValue: '',
+              rules: [
+                {
+                  required: true,
+                  message: this.props.dict['login.vercode.empty'],
+                }
+              ]
+            })(
+              <Input
+                addonAfter={
+                  <Button type="link" className="vercode" size="small" disabled={verdisabled} onClick={this.getvercode}>
+                    {delay ? `${delay}s鍚庨噸鏂拌幏鍙朻 : '鑾峰彇楠岃瘉鐮�'}
+                  </Button>
+                }
+                placeholder={this.props.dict['login.vercode']}
+                autoComplete="off"
+              />
+            )}
+          </Form.Item>
+          {this.props.langList && this.props.langList.length > 0 ? <Form.Item className="minline right">
+            {getFieldDecorator('lang', {
+              initialValue: this.props.lang,
+            })(
+              <Select
+                onChange={(value) => {this.changelang(value)}}
+                getPopupContainer={() => document.getElementById('login-form')}
+              >
+                {this.props.langList.map((item, index) => {
+                  return <Select.Option key={index} value={item.Lang}>{item.LangName}</Select.Option>
+                })}
+              </Select>
+            )}
+          </Form.Item> : null}
+          <Form.Item className="btn-login">
+            <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.props.isDisabled} loading={this.props.isDisabled}>
+              {this.props.dict['login.submit']}
+            </Button>
+          </Form.Item>
+          {options.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line">
+            <a href="http://www.minkesoft.com/signup" target="_blank" rel="noopener noreferrer" className="register">娉ㄥ唽</a>
+            <a href="http://www.minkesoft.com/forgotPwd" target="_blank" rel="noopener noreferrer" className="forgot">蹇樿瀵嗙爜锛�</a>
+          </Form.Item> : null}
+        </div> : null}
+        {activeKey === 'app_scan' ? <div className="form-item-wrap">
+          <div className="form-scan-wrap">
             <div className="qr-wrap">
               {scanId ? <QrCode card={{qrWidth: 500, color: '#000000'}} value={`mkpcscan,${window.GLOB.appkey},${scanId}`}/> : null}
               {timeout ? <div className="qrcode-out">
-                <Icon onClick={this.reCode} type="redo" />
+                <RedoOutlined onClick={this.reCode} />
                 浜岀淮鐮佸凡澶辨晥銆�
               </div> : null}
             </div>
             璇蜂娇鐢ㄥ鎴风鎵竴鎵櫥褰�
-          </div> : null}
-          {options.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line">
-            <a href="http://minkesoft.com/#/signup" target="_blank" rel="noopener noreferrer" className="register">娉ㄥ唽</a>
-            <a href="http://minkesoft.com/#/forgotPwd" target="_blank" rel="noopener noreferrer" className="forgot">蹇樿瀵嗙爜锛�</a>
-          </Form.Item> : null}
+          </div>
+        </div> : null}
+        <div className={'login-ways ' + (activeKey === 'app_scan' ? 'center' : '')}>
+          {loginWays.map(item => {
+            if (item.type === 'app_scan' || activeKey === item.type) return null
+            return (<span key={item.type} onClick={() => this.onChangeTab(item.type)}>{item.label}</span>)
+          })}
         </div>
       </Form>
     )

--
Gitblit v1.8.0