From 08c2033475fa42690c3246aa1510f6c6c932c2ea Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期六, 02 八月 2025 10:53:31 +0800
Subject: [PATCH] 数量可以支持小数

---
 src/views/login/index.vue |   71 +++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 9e8f838..2419b5a 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -2,13 +2,8 @@
     <div class="login-container">
         <div class="wxLogin">
             <el-card class="main_wx">
-                <wxlogin
-                    :appid="appid"
-                    :redirect_uri="redirect_uri"
-                    scope="snsapi_login"
-                    :href="href"
-                    :state="state"
-                ></wxlogin>
+                <wxlogin :appid="appid" :redirect_uri="redirect_uri" scope="snsapi_login" :href="href" :state="state">
+                </wxlogin>
             </el-card>
         </div>
     </div>
@@ -18,6 +13,7 @@
 import { validUsername } from "@/utils/validate";
 import wxlogin from "vue-wxlogin";
 import { login } from "@/api/user";
+import { findStaffByUserId } from "@/api/staff";
 export default {
     name: "Login",
     components: { wxlogin },
@@ -40,7 +36,7 @@
             appid: "wx7103925df6236723",
             redirect_uri: encodeURIComponent("https://dingdang.9village.cn/#/login"),
             state: "1",
-            href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7CiAgICAgICAgICBib3JkZXI6IG5vbmU7CiAgICAgICAgICB3aWR0aDogMTQwcHg7CiAgICAgICAgICBoZWlnaHQ6IDE0MHB4OwogICAgICAgIH0=", // 鑷畾涔夋牱寮忛摼鎺�
+            href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30g", // 鑷畾涔夋牱寮忛摼鎺�
             loginForm: {
                 username: "admin",
                 password: "111111",
@@ -66,22 +62,48 @@
             immediate: true,
         },
     },
+    beforeRouteUpdate(route, from, next) {
+        this.redirect = route.query && route.query.redirect;
+        let code = route.query.code;
+        if (code) {
+            this.getUserDate(code);
+        } else {
+            this.getWeChatUrl();
+        }
+    },
     mounted() {
-      let code = this.$route.query.code;
-      if (code) {
-          this.getUserDate(code);
-      } else {
-        this.getWeChatUrl();
-      }
+        let code = this.$route.query.code;
+        if (code) {
+            this.getUserDate(code);
+        } else {
+            this.getWeChatUrl();
+        }
     },
     methods: {
-          getUserDate(code) {
-          login({
-            code: code,
-          }).then((res) => {
-            localStorage.setItem("user", JSON.stringify(res));
-            this.$router.push("/student");
-          });
+        getUserDate(code) {
+            login({
+                code: code,
+            }).then((res) => {
+                localStorage.setItem("user", JSON.stringify(res));
+                localStorage.setItem("staffs", JSON.stringify(res.staffs));
+                localStorage.setItem("selectStaff", JSON.stringify(res.staffs[0]));
+
+                // 鍒ゆ柇鏄惁涓哄彯褰撶鐞嗗憳璐﹀彿
+                var isAdmin = false
+                res.staffs.forEach(o => {
+                    if (o.org.orgType === "PLATFORM") {
+                        isAdmin = true;
+                    }
+                })
+                if (isAdmin) {
+                    findStaffByUserId(res.id).then(staffs => {
+                        localStorage.setItem("staffs", JSON.stringify(staffs));
+                        localStorage.setItem("selectStaff", JSON.stringify(staffs[0]));
+                    })
+                }
+
+                this.$router.push("/student");
+            });
         },
         getWeChatUrl() {
             // api.wachatQrUrl().then(res => {
@@ -153,6 +175,7 @@
     display: flex;
     align-items: center;
     justify-content: center;
+
     .el-input {
         display: inline-block;
         height: 47px;
@@ -182,6 +205,7 @@
         color: #454545;
     }
 }
+
 #weixin {
     /* background-color: #fcf; */
     display: flex;
@@ -252,4 +276,9 @@
         user-select: none;
     }
 }
+
+.main_wx {
+    height: 360px;
+    margin-bottom: 100px;
+}
 </style>

--
Gitblit v1.8.0