Parcourir la source

feat(login): 更新登录逻辑和系统标题

- 修改网站标题为"商品零售+点餐系统"
- 更新登录逻辑,增加对店铺配置的请求
- 优化用户认证信息的存储
- 调整请求方式,将 getShopConfigList 的请求改为 POST
tangy il y a 1 mois
Parent
commit
b95fb11309
5 fichiers modifiés avec 40 ajouts et 24 suppressions
  1. 1 1
      index.html
  2. 1 1
      src/api/shop.ts
  3. 1 1
      src/config/index.ts
  4. 1 1
      src/stores/modules/user.ts
  5. 36 20
      src/views/account/login.vue

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>电商后台管理系统</title>
+    <title>商品零售+点餐系统</title>
     <style>
       * {
         margin: 0;

+ 1 - 1
src/api/shop.ts

@@ -5,7 +5,7 @@ export function getShopConfig(params?: any) {
 }
 
 export function getShopConfigList(params?: any) {
-    return request.get({ url: '/shop/configs', params })
+    return request.post({ url: '/shop/configs', params })
 }
 
 export function changeShopStatus(params?: any) {

+ 1 - 1
src/config/index.ts

@@ -1,6 +1,6 @@
 const config = {
     terminal: 1, //终端
-    title: '后台管理系统', //网站默认标题
+    title: '商品零售+点餐系统', //网站默认标题
     version: '1.4.0', //版本号
     baseUrl: `${import.meta.env.VITE_APP_BASE_URL || 'http://203.156.249.2:5555'}/`, //请求接口域名 http://192.168.50.19:5555/elab-marketing-file
     urlPrefix: 'elab-marketing-file/api', //请求默认前缀

+ 1 - 1
src/stores/modules/user.ts

@@ -57,7 +57,7 @@ const useUserStore = defineStore({
                         window.localStorage.setItem("like_admin_token",data.single.token)
                         window.localStorage.setItem("like_admin_brandId",data.single.brandId)
                         window.localStorage.setItem("like_admin_userId",data.single.dataUserId)
-                        if(data.single.type === 2){
+                        if(data.single.type === 2 && data.single.houseList.length == 1){
                             window.localStorage.setItem("like_admin_houseId",data.single.houseList[0].houseId)
                         }
                         resolve(data.single)

+ 36 - 20
src/views/account/login.vue

@@ -79,6 +79,7 @@ import {PageEnum} from '@/enums/pageEnum'
 import {useLockFn} from '@/hooks/useLockFn'
 import {getShopConfigList} from "@/api/shop";
 import feedback from "@/utils/feedback";
+import {clearAuthInfo} from "@/utils/auth";
 
 const passwordRef = shallowRef<InputInstance>()
 const formRef = shallowRef<FormInstance>()
@@ -123,6 +124,7 @@ const handleEnterStore = () => {
   }
   if (currentRow.value.id) {
     cache.set(SHOP_ID, currentRow.value.id)
+    window.localStorage.setItem("like_admin_houseId", currentRow.value.houseId)
     const {
       query: {redirect}
     } = route
@@ -137,28 +139,12 @@ const handleEnter = () => {
   }
   handleLogin()
 }
-// 登录处理
-const handleLogin = async () => {
-  await formRef.value?.validate()
-  // 记住账号,缓存
-  cache.set(ACCOUNT_KEY, {
-    remember: remAccount.value,
-    account: formData.account
-  })
-  try {
-    let _data = {
-      "mobile": formData.account,
-      "passWord": formData.password,
-      "platform": 1,//平台 1.大麦数字营销 2.大麦后台 3.麦芽 4.淘房客 5.电商中心
-    }
-    await userStore.login(_data)
-  } catch (error) {
-    // getLoginCaptcha()
-  }
-  getShopConfigList({"contactTel": formData.account}).then((res) => {
+const handleShopConfig = (params: any) => {
+  getShopConfigList({"contactTel": formData.account, houseIds: params}).then((res) => {
     if (res && res.length > 0) {
       if (res.length == 1) {
         cache.set(SHOP_ID, res[0].id)
+        window.localStorage.setItem("like_admin_houseId",res[0].houseId)
         const {
           query: {redirect}
         } = route
@@ -169,14 +155,44 @@ const handleLogin = async () => {
         tableData.value = res.map((item: any) => {
           return {
             id: item.id,
-            name: item.name
+            name: item.name,
+            houseId: item.houseId
           }
         })
       }
     } else {
+      clearAuthInfo()
       router.push(PageEnum.ERROR_403)
     }
   })
+}
+// 登录处理
+const handleLogin = async () => {
+  await formRef.value?.validate()
+  // 记住账号,缓存
+  cache.set(ACCOUNT_KEY, {
+    remember: remAccount.value,
+    account: formData.account
+  })
+  try {
+    let _data = {
+      "mobile": formData.account,
+      "passWord": formData.password,
+      "platform": 1,//平台 1.大麦数字营销 2.大麦后台 3.麦芽 4.淘房客 5.电商中心
+    }
+    await userStore.login(_data).then((res: any) => {
+      if(res.type === 1){
+        clearAuthInfo()
+        router.push(PageEnum.ERROR_403)
+      } else {
+        const houseIds = res.houseList.map((item: any) => item.houseId)
+        handleShopConfig(houseIds)
+      }
+    })
+  } catch (error) {
+    // getLoginCaptcha()
+  }
+
   /*const {
     query: {redirect}
   } = route