From 4b0a798f81ea4ad201421ae02fa896d55a20beb0 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 07 May 2024 13:56:20 +0800
Subject: [PATCH] 新增表单登录接口

---
 src/store/modules/user.js |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index b71edea..ab19a55 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -10,6 +10,7 @@
 import { deepClone } from "@/util/util";
 import website from "@/config/website";
 import {
+  loginForm,
   loginByUsername,
   loginBySocial,
   loginBySso,
@@ -27,6 +28,10 @@
   } else {
     return data[0];
   }
+}
+
+function findChildrenRole(data, str) {
+  return data.split(",").find((item) => item == str);
 }
 
 function addPath(ele, first) {
@@ -67,6 +72,20 @@
     homeFirstTagPage: getStore({ name: "firstTagPage" }) || {},
   },
   actions: {
+    //表单登录
+    loginForm({ dispatch,commit }, userInfo) {
+      return new Promise((resolve) => {
+        loginForm(userInfo.tenantId,
+          userInfo.username,
+          md5(userInfo.password)).then((res) => {
+          // const data = res.data.data;
+          // commit("SET_TOKEN", data);
+          // commit("DEL_ALL_TAG");
+          // commit("CLEAR_LOCK");
+          resolve();
+        });
+      });
+    },
     //根据用户名登录
     LoginByUsername({ dispatch, commit }, userInfo) {
       return new Promise((resolve, reject) => {
@@ -87,6 +106,7 @@
                 message: data.error_description,
                 type: "error",
               });
+              resolve({ error: "error" });
             } else {
               commit("SET_TOKEN", data.access_token);
               commit("SET_REFRESH_TOKEN", data.refresh_token);
@@ -97,7 +117,12 @@
 
               dispatch("GetMenu").then((menuData) => {
                 let fistMenu = findChildrenUrl(menuData);
-                if (data.role_name == "jdgly" || data.role_name == "sqgly") {
+                if (
+                  findChildrenRole(data.role_name, "admin") ||
+                  findChildrenRole(data.role_name, "administrator") ||
+                  findChildrenRole(data.role_name, "jdgly") ||
+                  findChildrenRole(data.role_name, "sqgly")
+                ) {
                   setStore({ name: "showMenu", content: true });
 
                   commit("SET_HOMEFIRSTTAGPAGE", {
@@ -114,7 +139,12 @@
 
                   commit("SET_HOMEFIRSTPAGE", "/wel");
 
-                  resolve({});
+                  resolve({
+                    fistMenu: {
+                      path: "/wel",
+                    },
+                    menuData,
+                  });
                 } else {
                   setStore({ name: "showMenu", content: false });
 

--
Gitblit v1.9.3