From 6ca240a14ccf55d4e0a94fff77e95f64db2cdfcc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 11 十月 2024 17:34:25 +0800
Subject: [PATCH] 2024-10-11

---
 src/views/login/loginform.jsx |   88 ++++++++++++++++++++++++++------------------
 1 files changed, 52 insertions(+), 36 deletions(-)

diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx
index 8939de7..067b948 100644
--- a/src/views/login/loginform.jsx
+++ b/src/views/login/loginform.jsx
@@ -15,10 +15,9 @@
   static propTpyes = {
     isDisabled: PropTypes.bool,
     handleSubmit: PropTypes.func,
-    dict: PropTypes.object,
+    authLogin: PropTypes.func,
     auth: PropTypes.bool,
-    touristLogin: PropTypes.bool,
-    lang: PropTypes.string,
+    authError: PropTypes.string,
     langList: PropTypes.array,
     loginWays: PropTypes.array
   }
@@ -33,14 +32,23 @@
     verdisabled: false,
     hasScan: false,
     timeout: false,
-    users: []
+    vispwd: window.GLOB.vispwd,
+    wayLabels: {},
+    dict: window.GLOB.dict,
+    users: [],
+    lang: sessionStorage.getItem('lang')
   }
 
   UNSAFE_componentWillMount () {
     let remember = true
-    let _url = window.location.href.split('#')[0]
+
+    if (localStorage.getItem(window.location.href.split('#')[0] + 'users')) { // 杩囨浮
+      localStorage.setItem(window.GLOB.sysSign + 'users', localStorage.getItem(window.location.href.split('#')[0] + 'users'))
+      localStorage.setItem(window.GLOB.sysSign + 'remember', localStorage.getItem(window.location.href.split('#')[0] + 'remember'))
+      localStorage.removeItem(window.location.href.split('#')[0] + 'users')
+    }
     
-    if (localStorage.getItem(_url + 'remember') === 'false') {
+    if (localStorage.getItem(window.GLOB.sysSign + 'remember') === 'false') {
       remember = false
     }
     if (!window.GLOB.keepKey) {
@@ -48,9 +56,26 @@
     }
 
     let smsId = ''
-    let _loginWays = []
+    // let wayLabels = {app_scan: 'APP鎵爜', weixin_scan: '寰俊鎵爜', uname_pwd: '璐﹀彿鐧诲綍', sms_vcode: '鐭俊鐧诲綍'}
 
-    let users = localStorage.getItem(_url + 'users')
+    // loginWays.forEach(item => {
+    //   item.label = window.GLOB.dict[item.type] || wayLabels[item.type]
+    //   wayLabels[item.type] = item.label
+    //   if (item.type === 'sms_vcode') {
+    //     smsId = item.smsId
+    //     _loginWays.push(item)
+    //   } else if (item.type === 'uname_pwd') {
+    //     _loginWays.push(item)
+    //   } else if (item.type === 'app_scan') {
+    //     _loginWays.push(item)
+    //     hasScan = true
+    //   } else if (item.type === 'weixin_scan') {
+    //     _loginWays.push(item)
+    //     hasScan = true
+    //   }
+    // })
+
+    let users = localStorage.getItem(window.GLOB.sysSign + 'users')
     let _user = null
     
     if (users) {
@@ -63,16 +88,11 @@
       users = []
     }
 
-    if (users[0]) {
-      _user = users[0]
-    }
-
     this.setState({
       users: users,
       username: _user ? _user.username : '',
       password: _user ? _user.password : '',
       smsId: smsId,
-      loginWays: _loginWays,
       remember
     })
   }
@@ -94,21 +114,20 @@
   }
 
   changelang = (val) => {
-    const _href = window.location.href.split('#')[0]
-    localStorage.setItem(_href + 'lang', val)
+    localStorage.setItem(window.location.href.split('#')[0] + 'lang', val)
     sessionStorage.setItem('lang', val)
 
     window.location.reload()
   }
 
   handleSubmit = e => {
+    const { dict } = this.state
     // 鐧诲綍鍙傛暟妫�楠�
     e && e.preventDefault()
     if (!this.props.auth) {
       warning({
-        title: this.props.dict['login.auth.tip'],
-        okText: this.props.dict['login.auth.ok'],
-        cancelText: this.props.dict['login.auth.cancel'],
+        title: this.props.authError || dict['auth_tip'] || '绯荤粺鏈巿鏉冿紝璇疯仈绯荤鐞嗗憳銆�',
+        okText: dict['got_it'] || '鐭ラ亾浜�',
         onOk() {},
         onCancel() {}
       })
@@ -140,16 +159,16 @@
   }
 
   getvercode = () => {
-    const { smsId } = this.state
+    const { smsId, dict } = this.state
     let _phone = this.props.form.getFieldValue('phone')
     if (!_phone) {
-      message.warning('璇疯緭鍏ユ墜鏈哄彿锛�')
+      message.warning(dict['phone_no_required'] || '璇疯緭鍏ユ墜鏈哄彿锛�')
       return
     } else if (!/^1[3456789]\d{9}$/.test(_phone)) {
-      message.warning('鎵嬫満鍙锋牸寮忛敊璇紝璇烽噸濉紒')
+      message.warning(dict['phone_error'] || '鎵嬫満鍙锋牸寮忛敊璇紝璇烽噸濉紒')
       return
-    } else if (!this.props.touristLogin) {
-      message.warning('鏈幏鍙栭獙璇佺爜璁剧疆锛岃绋嶅悗鎴栧埛鏂伴噸璇曪紒')
+    } else if (!sessionStorage.getItem('visitorUserID') || !sessionStorage.getItem('visitorLoginUID')) {
+      message.warning(dict['vercode_error'] || '鏈幏鍙栭獙璇佺爜璁剧疆锛岃绋嶅悗鎴栧埛鏂伴噸璇曪紒')
       return
     }
 
@@ -257,9 +276,8 @@
 
   rememberChange = (e) => {
     let val = e.target.checked
-    let _url = window.location.href.split('#')[0]
 
-    localStorage.setItem(_url + 'remember', val)
+    localStorage.setItem(window.GLOB.sysSign + 'remember', val)
   }
 
   complete = (val) => {
@@ -287,9 +305,7 @@
     
     this.setState({users: _users})
 
-    let _url = window.location.href.split('#')[0]
-
-    localStorage.setItem(_url + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(_users))))
+    localStorage.setItem(window.GLOB.sysSign + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(_users))))
   }
 
   /**
@@ -304,7 +320,7 @@
   render() {
     const { langList } = this.props
     const { getFieldDecorator } = this.props.form
-    const { remember, users } = this.state
+    const { remember, users, dict, lang, vispwd } = this.state
 
     return (
       <Form className={`login-form login-form-1`} id="login-form" onSubmit={this.handleSubmit}>
@@ -312,7 +328,7 @@
         <div className="form-item-wrap">
           <Form.Item>
             {getFieldDecorator('username', {
-              rules: [{ required: true, message: this.props.dict['login.username.empty'] }],
+              rules: [{ required: true, message: dict['username_required'] || '璇疯緭鍏ョ敤鎴峰悕' }],
               initialValue: this.state.username || '',
             })(
               <AutoComplete
@@ -329,7 +345,7 @@
               >
                 <Input
                   prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />}
-                  placeholder={this.props.dict['login.username']}
+                  placeholder={dict['username'] || '鐢ㄦ埛鍚�'}
                   autoComplete="off"
                 />
               </AutoComplete>
@@ -341,20 +357,20 @@
               rules: [
                 {
                   required: true,
-                  message: this.props.dict['login.password.empty'],
+                  message: dict['password_required'] || '璇疯緭鍏ュ瘑鐮�',
                 }
               ]
-            })(<Input.Password placeholder={this.props.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
+            })(<Input.Password placeholder={dict['password'] || '瀵嗙爜'} visibilityToggle={vispwd} 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>)}
+            })(<Checkbox onChange={this.rememberChange}>{dict['remember_me'] || '璁颁綇瀵嗙爜'}</Checkbox>)}
           </Form.Item> : <div style={{height: '30px', float: 'left'}}></div>}
           {langList && langList.length > 0 ? <Form.Item className="minline right">
             {getFieldDecorator('lang', {
-              initialValue: this.props.lang,
+              initialValue: lang,
             })(
               <Select
                 onChange={(value) => {this.changelang(value)}}
@@ -368,7 +384,7 @@
           </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']}
+              {dict['log_in'] || '鐧诲綍'}
             </Button>
           </Form.Item>
         </div>

--
Gitblit v1.8.0