Browse Source

✨ feat(login): 重构登录页面,添加响应式设计和密码可见性切换功能

陈雪 2 weeks ago
parent
commit
8d57ba9c57

+ 7 - 0
src/assets/img/login/close-one.svg

@@ -0,0 +1,7 @@
+<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Preview-close-one (&#233;&#162;&#132;&#232;&#167;&#136;-&#229;&#133;&#179;&#233;&#151;&#173;)">
+<path id="Vector" d="M6.16116 11.25C3.89911 13.125 2.5 15 2.5 15C2.5 15 8.09644 22.5 15 22.5C15.8562 22.5 16.6922 22.3846 17.5 22.1826M12.5199 7.8125C13.3215 7.6135 14.1509 7.5 15 7.5C21.9036 7.5 27.5 15 27.5 15C27.5 15 26.1009 16.875 23.8388 18.75" stroke="#333333" stroke-width="1.875" stroke-linecap="round" stroke-linejoin="round"/>
+<path id="Vector_2" d="M12.6964 12.8887C12.1863 13.4448 11.875 14.1862 11.875 15.0004C11.875 16.7262 13.2741 18.1254 15 18.1254C15.8517 18.1254 16.6238 17.7846 17.1875 17.232" stroke="#333333" stroke-width="1.875" stroke-linecap="round" stroke-linejoin="round"/>
+<path id="Vector_3" d="M26.25 26.25L3.75 3.75" stroke="#333333" stroke-width="1.875" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+</svg>

+ 6 - 0
src/assets/img/login/open-one.svg

@@ -0,0 +1,6 @@
+<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Preview-close-one (&#233;&#162;&#132;&#232;&#167;&#136;-&#229;&#133;&#179;&#233;&#151;&#173;)">
+<path id="Vector" d="M6.16116 11.25C3.89911 13.125 2.5 15 2.5 15C2.5 15 8.09644 22.5 15 22.5C15.8562 22.5 16.6922 22.3846 17.5 22.1826M12.5199 7.8125C13.3215 7.6135 14.1509 7.5 15 7.5C21.9036 7.5 27.5 15 27.5 15C27.5 15 26.1009 16.875 23.8388 18.75" stroke="#333333" stroke-width="1.875" stroke-linecap="round" stroke-linejoin="round"/>
+<circle id="Ellipse 61" cx="15" cy="15" r="3.06" stroke="#333333" stroke-width="1.88"/>
+</g>
+</svg>

+ 6 - 1
src/assets/main.scss

@@ -1,7 +1,12 @@
 @use 'sass:math';
 
 $baseWidth: 1920;
+$baseHight: 1080;
 
-@function pxToVw($px) {
+@function pxToVW($px) {
   @return #{math.div($px, $baseWidth) * 100}+ vw;
 }
+
+@function pxToVH($px) {
+  @return #{math.div($px, $baseHight) * 100}+ vh;
+}

+ 133 - 15
src/views/login/index.vue

@@ -2,28 +2,55 @@
   <div class="login-container">
     <div class="form-container">
       <img src="@/assets/img/login/right.svg" alt="" class="right-img" />
-      <div class="login-form"></div>
+      <div class="login-form">
+        <div class="title">Hi,welcome back</div>
+        <div class="sumary-title">Cashier account</div>
+        <el-form ref="formRef" :model="loginForm">
+          <el-form-item prop="username" :rules="[]">
+            <el-input v-model="loginForm.username" />
+          </el-form-item>
+          <el-form-item prop="password" :rules="[]">
+            <el-input v-model="loginForm.password" :type="inputType">
+              <template #suffix>
+                <img
+                  v-if="inputType === 'password'"
+                  src="@/assets/img/login/close-one.svg"
+                  @click="inputType = ''"
+                />
+                <img @click="inputType = 'password'" v-else src="@/assets/img/login/open-one.svg" />
+              </template>
+            </el-input>
+          </el-form-item>
+        </el-form>
+        <div class="remember-password">
+          <el-switch v-model="isRremember" />
+          <div class="remember-text">remember password</div>
+        </div>
+        <div class="login-btn">log on</div>
+      </div>
     </div>
   </div>
 </template>
 
 <script setup lang="ts">
-  import { ref } from 'vue'
+  import { reactive, ref, useTemplateRef } from 'vue'
+  const loginFormRef = useTemplateRef('formRef')
 
-  const account = ref('')
-  const password = ref('')
-  const remember = ref(false)
+  const inputType = ref('password')
+  const isRremember = ref(false)
 
-  const handleLogin = () => {
-    console.log('Account:', account.value)
-    console.log('Password:', password.value)
-    console.log('Remember:', remember.value)
-    // 处理登录逻辑
-  }
+  const loginForm = reactive({
+    username: '',
+    password: '',
+    code: '',
+    uuid: '',
+  })
+
+  const loginHandler = () => {}
 </script>
 
 <style scoped lang="scss">
-  @import '@/assets/main.scss';
+  @use '@/assets/main.scss' as *;
 
   .login-container {
     display: flex;
@@ -34,15 +61,106 @@
     background: url('@/assets/img/login/bg.svg') no-repeat center center;
     background-size: cover;
     box-sizing: border-box;
-    padding: 20px;
 
     .form-container {
-      width: pxToVw(1600);
-      height: pxToVw(900);
+      width: pxToVW(1600);
+      height: pxToVW(900);
       flex-shrink: 0;
       border-radius: 20px;
       background: #fff;
       overflow: hidden;
+      display: flex;
+      box-sizing: border-box;
+      padding: 0 pxToVW(102);
+      justify-content: space-between;
+
+      .login-form {
+        width: pxToVW(544);
+        box-sizing: border-box;
+        padding-top: pxToVH(229);
+
+        .title {
+          color: #000;
+          font-family: 'PingFang SC';
+          font-size: 40px;
+          font-style: normal;
+          font-weight: 600;
+          line-height: normal;
+          text-transform: capitalize;
+          margin-bottom: pxToVH(50);
+        }
+
+        .sumary-title {
+          color: #333;
+          font-family: 'PingFang SC';
+          font-size: 20px;
+          font-style: normal;
+          font-weight: 500;
+          line-height: normal;
+          text-transform: capitalize;
+          margin-bottom: pxToVH(8);
+        }
+
+        :deep(.el-form-item) {
+          --el-fill-color-blank: #f6f4f4;
+          .el-input {
+            height: pxToVH(64);
+          }
+
+          &:first-child {
+            margin-bottom: pxToVH(30);
+          }
+        }
+
+        .remember-password {
+          display: flex;
+          align-items: center;
+          margin-bottom: pxToVH(24);
+
+          .remember-text {
+            display: block;
+            color: #1a1a1a;
+            font-feature-settings: 'liga' off, 'clig' off;
+            font-family: 'PingFang SC';
+            font-size: 14px;
+            font-style: normal;
+            font-weight: 400;
+            line-height: 22px; /* 157.143% */
+            letter-spacing: 0.3px;
+            text-transform: capitalize;
+            margin-left: pxToVW(8);
+          }
+        }
+
+        .login-btn {
+          display: flex;
+          width: 100%;
+          height: 54px;
+          padding: 10px;
+          justify-content: center;
+          align-items: center;
+          gap: 10px;
+          flex-shrink: 0;
+          border-radius: 8px;
+          background: #f67f20;
+          color: #fff;
+          font-family: 'PingFang SC';
+          font-size: 20px;
+          font-style: normal;
+          font-weight: 500;
+          line-height: normal;
+        }
+
+        img {
+          cursor: pointer;
+          width: 30px;
+        }
+      }
+
+      .right-img {
+        width: calc(100% - pxToVW(763));
+        flex-shrink: 0;
+      }
     }
   }
 </style>