From 44db498cedee7573d090797b1fe5c331c413b00a Mon Sep 17 00:00:00 2001
From: zzzz <690498789@qq.com>
Date: Mon, 22 Apr 2024 19:03:57 +0800
Subject: [PATCH] first

---
 src/page/login/login.vue |  317 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 176 insertions(+), 141 deletions(-)

diff --git a/src/page/login/login.vue b/src/page/login/login.vue
index c5f74ac..e99e719 100644
--- a/src/page/login/login.vue
+++ b/src/page/login/login.vue
@@ -1,145 +1,144 @@
 <template>
   <div class="login_page">
-    <headers :mess="loginWay" />
-    <!-- <div class="img_mess">
-      <div class="logo_content animated fadeInRight">
-        <img :src="Logo" alt />
-      </div>
-    </div> -->
+    <headers />
+    <div class="login_title animated slideInDown">
+      <span>{{ $t("登錄賬號") }}</span>
+    </div>
     <div class="logins_content">
-      <div class="login_title animated slideInDown">
-        <span>{{ $t('hj8') }}</span>
-      </div>
       <div class="login_forms">
         <div class="top_forms">
-          <!-- <div class="user_name">
-            <input type="text" :placeholder="placeholder" v-model="userName" />
-          </div>
-          <div class="password">
-            <input type="password"  placeholder="登录密码" v-model="userPassword" @input="handleInput()" />
-          </div> -->
-          <el-input :placeholder="$t('hj9')" :size="medium" maxlength="11" v-model="userName" clearable>
+          <el-input
+            :placeholder="$t('hj9')"
+            :size="medium"
+            v-model="userName"
+            clearable
+          >
           </el-input>
-          <el-input style="margin-top: 0.46rem;" show-password :placeholder="$t('hj10')" :size="medium"
-            v-model="userPassword" @input="handleInput()">
+          <el-input
+            style="margin-top: 0.46rem"
+            show-password
+            :placeholder="$t('hj10')"
+            :size="medium"
+            v-model="userPassword"
+            @input="handleInput()"
+          >
           </el-input>
         </div>
-        <div class="bottom_btns" :class="btnClass ? 'on' : 'off'">
-          <div class="top_btn " @click="loginIN" :class="dengl ? 'animated pulse' : ''">
-            <span>{{ $t('hj11') }}</span>
-          </div>
-          <div class="mes" @click="getApp()">
-            <span>{{ $t('hj12') }}</span>
+        <div class="bottom_btns">
+          <van-button
+            type="info"
+            :disabled="!btnClass"
+            class="butn"
+            @click="loginIN"
+            >{{ $t("立即登录") }}</van-button
+          >
+          <div class="password-operate" data-v-8cc76a7b="">
+            <div class="forget" data-v-8cc76a7b="" @click="getApp()">
+              {{ $t("hj12") }}
+            </div>
+            <div class="remember" data-v-8cc76a7b="">
+              <van-checkbox @change="checkboxChange" v-model="checked">{{
+                $t("記住帳戶密碼")
+              }}</van-checkbox>
+            </div>
           </div>
         </div>
       </div>
-    </div>
-    <div class="login_bom">
 
-      <div class="line">
-        <div class="left_line"></div>
-        <div class="center_line">
-          <span>{{ $t('hj13') }}</span>
-        </div>
-        <div class="right_line"></div>
+      <div class="register" data-v-8cc76a7b="">
+        {{ $t("還沒賬號?")
+        }}<span
+          @click="$router.push('/register')"
+          data-v-8cc76a7b=""
+          style="color: rgb(5, 106, 239)"
+          >{{ $t("免費註冊") }}</span
+        >
       </div>
-      <div class="imgDemo">
-        <div class="appImg" @click="getApp()"><img src="@/assets/img/apple.png" /></div>
-        <div class="appImg" @click="getApp()"><img src="@/assets/img/google.png" /></div>
-        <div class="appImg" @click="getApp()"><img src="@/assets/img/facebook.png" /></div>
-      </div>
-      <div class="myzh"><span class="mes">{{ $t('hj14') }}?</span><span @click="$router.push('/register')" class="mes"
-          style="color: rgb(54,124,248);">{{ $t('hj15') }}</span> </div>
     </div>
-    <el-alert v-show="alertShow" :closable="closable" :title="texts" :type="eltype" center></el-alert>
   </div>
 </template>
 <script>
-import { Toast } from 'mint-ui'
 import headers from "./components/header.vue";
-import Logo from "@/assets/img/LOGO2.png";
-import * as api from '@/axios/api';
+import * as api from "@/axios/api";
+import { Notify } from "vant";
+import { mapActions, mapMutations } from "vuex";
 
 export default {
   name: "newLogin",
   data() {
     return {
-      loginWay: this.$t('hj8'),
+      checked: false,
+      loginWay: this.$t("hj8"),
       currentLoginMode: "email",
-      placeholder: this.$t('hj16'),
-      Logo,
+      placeholder: this.$t("hj16"),
       userPassword: "",
       userName: "",
       btnClass: false,
       medium: "medium",
-      alertShow: false,
-      closable: false,
-      eltype: 'warning',
-      texts: "",
-      dengl: false,
-      loginBtn: false,
     };
   },
   components: {
-    headers
+    headers,
   },
+  mounted() {
+    const ret = window.localStorage.getItem("login_admin");
+    this.checked = window.localStorage.getItem("login_checked") === "true";
+    if (ret && this.checked) {
+      this.userPassword = JSON.parse(ret).userPassword;
+      this.userName = JSON.parse(ret).phone;
+      this.btnClass = true;
+    }
+  },
+
   methods: {
+    ...mapActions(["setUseInfo"]),
+    ...mapMutations(["undataToken"]),
+    checkboxChange(e) {
+      window.localStorage.setItem("login_checked", e);
+    },
     getApp() {
       // Toast('您所在的地区暂未开通此服务')
       //Toast 弹窗大小
-      this.texts = this.$t('hj17')
-      this.alertShow = true
-      setTimeout(() => {
-        this.alertShow = false
-      }, 2000)
+      Notify({ type: "warning", message: this.$t("hj17") });
     },
     handleInput() {
-      console.log(this.userPassword !== "" && this.userName !== '');
-      if (this.userPassword !== "" && this.userName !== '') {
+      if (this.userPassword !== "" && this.userName !== "") {
         this.btnClass = true;
       } else {
         this.btnClass = false;
       }
     },
     async loginIN() {
-
-      this.dengl = true
-      setTimeout(() => {
-        this.dengl = false
-      }, 1000)
-      if (this.loginBtn) {
-        return;
-      }
-      this.loginBtn = true;
       let opts = {
         phone: this.userName,
-        userPwd: this.userPassword
-      }
-      let data = await api.login(opts)
+        userPwd: this.userPassword,
+      };
+      let data = await api.login(opts);
+
       if (data.status === 0) {
-        this.$store.state.userInfo.phone = this.userName
-        this.$store.state.userInfo.token = data.data.token
-        this.texts = this.$t('hj36')
-        this.eltype = 'success'
-        this.alertShow = true
-        setTimeout(() => {
-          this.alertShow = false
-          this.eltype = 'warning'
-          this.$router.push('/home')
-        }, 1000)
-        this.loginBtn = false;
-        window.localStorage.clear()
+        this.setUseInfo();
+        if (this.checked) {
+          window.localStorage.setItem(
+            "login_admin",
+            JSON.stringify({
+              phone: this.userName,
+              userPassword: this.userPassword,
+            })
+          );
+        } else {
+          window.localStorage.setItem("login_admin", "");
+        }
+        this.$store.state.userInfo.phone = this.userName;
+        this.$store.state.userInfo.token = data.data.token;
+        this.undataToken(data.data.token);
         window.localStorage.setItem("USERTOKEN", data.data.token);
+        Notify({ type: "success", message: this.$t("hj36") });
 
-
-      } else {
-        this.texts = data.msg
-        this.alertShow = true
-        this.loginBtn = false;
         setTimeout(() => {
-          this.alertShow = false
-        }, 2000)
-        //Toast(data.msg)
+          this.$router.push("/home");
+        }, 1000);
+      } else {
+        Notify({ type: "warning", message: data.msg });
       }
       if (navigator.vibrate) {
         // 支持
@@ -147,47 +146,81 @@
       }
     },
   },
-  beforeDestroy() { },
-  created() { }
+  beforeDestroy() {},
+  created() {},
 };
 </script>
 
 <style scoped lang="less">
+.password-operate {
+  display: flex;
+  justify-content: space-between;
+  margin-top: 0.53333rem;
+  .forget {
+    font-style: normal;
+    font-weight: 400;
+    font-size: 0.37333rem;
+    line-height: 0.53333rem;
+    color: #8c9fad;
+  }
+}
+
+.register {
+  font-style: normal;
+  font-weight: 400;
+  font-size: 0.37333rem;
+  color: #8c9fad;
+  margin: 0 auto;
+  padding: 0.34667rem 0.4rem;
+  span {
+    color: rgb(5, 106, 239);
+  }
+}
+.login_title {
+  font-family: "DINPro", serif;
+  font-style: normal;
+  font-weight: 500;
+  font-size: 0.48rem;
+  line-height: 0.66667rem;
+  color: #14181f;
+  margin-left: 0.53333rem;
+}
+/deep/ .van-checkbox__label {
+  font-style: normal;
+  font-weight: 400;
+  font-size: 0.37333rem;
+  line-height: 0.53333rem;
+  color: #8c9fad;
+}
+/deep/ .van-button__text {
+  font-size: 24px;
+  font-family: "DINPro";
+}
 .login_page {
-  position: relative;
-  background-color: #fff !important;
-  width: 100%;
-  height: 100%;
-  overflow: hidden;
-  overflow-y: auto;
+  display: flex;
+  flex-direction: column;
+  height: 100vh;
 }
 
 .logins_content {
-
+  display: flex;
+  flex-direction: column;
+  flex: 1;
   width: 100%;
   height: 9.7436rem;
   margin-top: 0.4359rem;
-  padding: 0 0.4564rem;
-
-  .login_title {
-    width: 100%;
-    height: 2.0513rem;
-    display: flex;
-
-    align-items: center;
-    font-size: 0.7023rem;
-    color: #000;
-    font-weight: 600 !important;
-
-    >span {
-      font-weight: 600 !important;
-    }
-  }
+  background: #fff;
+  // padding: 0 0.4564rem;
 
   .login_forms {
     width: 100%;
-    height: auto;
-    margin-top: 0.35rem;
+
+    border-top-left-radius: 0.26667rem;
+    border-top-right-radius: 0.26667rem;
+    padding: 0.34667rem 0.4rem;
+    flex: 1;
+    display: flex;
+    flex-direction: column;
 
     .top_forms {
       width: 100%;
@@ -199,12 +232,12 @@
       .user_name,
       .password {
         width: 100%;
-        height: 35%;
+        height: 50px;
         background: rgb(246, 246, 247);
         // background: #1e1e1e;
         border-radius: 0.3564rem;
 
-        >input {
+        > input {
           width: 100%;
           height: 100%;
           padding-left: 0.3564rem;
@@ -215,23 +248,30 @@
 
     /deep/.el-input__inner {
       width: 100%;
-      height: 1.45rem !important;
+      height: 70px;
       background-color: rgb(246, 246, 247) !important;
       // background: #1e1e1e;
-      border-radius: 0.3564rem;
+      border-radius: 8px;
       font-size: 0.45rem !important;
+      border: none;
     }
 
     .bottom_btns {
       width: 100%;
       height: 3.3333rem;
-      margin-top: 0.8528rem;
-
+      // margin-top: 0.8528rem;
+      .butn {
+        width: 100%;
+        margin-top: 40px;
+        height: 60px;
+        border-radius: 8px;
+      }
       .top_btn {
+        border: none;
         width: 100%;
         height: 1.25rem;
-        border-radius: 0.3564rem;
-        background: rgb(154, 197, 250);
+        border-radius: 8px;
+        background: #0066ed;
         color: #fff;
         display: flex;
         align-items: center;
@@ -239,15 +279,13 @@
         font-size: 0.5128rem;
         margin-top: 0.75rem;
 
-        >span {
+        > span {
           font-weight: 530 !important;
         }
       }
 
-
-
       .mes {
-        width: 100%;
+        // width: 100%;
         height: 20%;
         margin-top: 0.4rem;
         display: flex;
@@ -290,11 +328,10 @@
     align-items: center;
     justify-content: center;
 
-    >span {
+    > span {
       font-size: 0.3046rem;
       color: #000;
       background-color: #fff;
-
     }
   }
 
@@ -303,17 +340,18 @@
     height: 0.01rem;
     background: #e5e5e5;
   }
-
 }
 
 .myzh {
-  width: calc(100% - 4rem);
-  position: absolute;
+  // width: calc(100% - 4rem);
+  // position: absolute;
   bottom: 0.01rem;
   text-align: center;
+  display: flex;
+  align-items: center;
 
   .mes {
-    width: 100%;
+    // width: 100%;
     height: 40%;
 
     font-size: 0.3846rem;
@@ -353,7 +391,7 @@
     width: 3rem;
     height: 3.5769rem;
 
-    >img {
+    > img {
       width: 100%;
       height: 100%;
     }
@@ -368,11 +406,9 @@
 }
 
 /deep/.el-input__suffix-inner {
-
   display: flex;
   justify-content: center;
   align-items: center;
-
 }
 
 /deep/.el-input__icon {
@@ -388,7 +424,6 @@
 
 /deep/.el-icon-circle-close::before {
   font-size: 0.5rem !important;
-
 }
 
 /deep/.el-input__clear {

--
Gitblit v1.9.3