Kaynağa Gözat

feat(user): 扩展用户信息接口并优化数据更新逻辑

- 扩展 UserState 接口中的 userInfo 字段以支持动态属性
- 在获取商户信息后更新用户缓存时保留 businessSection 字段
- 登录时合并商户数据与现有用户信息确保字段不丢失
- 注释掉店铺装修页面中的到期时间相关表单项
- 在设施服务页面增加调试日志以便排查业务板块信息
spy 2 hafta önce
ebeveyn
işleme
06481b55d3

+ 4 - 1
src/stores/interface/index.ts

@@ -29,7 +29,10 @@ export interface GlobalState {
 /* UserState */
 export interface UserState {
   token: string;
-  userInfo: { name: string };
+  userInfo: {
+    name: string;
+    [key: string]: any;
+  };
 }
 
 /* tabsMenuProps */

+ 7 - 2
src/views/home/index.vue

@@ -103,10 +103,15 @@ const getUserInfo = async () => {
       phone: geekerUser.userInfo.phone
     };
     const res: any = await getMerchantByPhone(param);
+    console.log("getMerchantByPhone返回数据:", res.data);
     storeId.value = res.data.storeId;
     if (res && res.code == 200 && res.data) {
-      // 更新缓存中的 storeId
-      geekerUser.userInfo.storeId = res.data.storeId;
+      // 更新缓存中的 storeId,确保保留businessSection字段
+      geekerUser.userInfo = {
+        ...geekerUser.userInfo,
+        ...res.data,
+        businessSection: geekerUser.userInfo.businessSection
+      };
       localSet("geeker-user", geekerUser);
       // 同时更新 createdId 缓存
       if (res.data.storeId) {

+ 4 - 2
src/views/login/index.vue

@@ -936,12 +936,14 @@ const handleLogin = async () => {
           try {
             const merchantRes: any = await getMerchantByPhone({ phone: res.data.phone });
             if (merchantRes && merchantRes.code == 200 && merchantRes.data) {
-              // 更新用户信息到本地存储
+              // 更新用户信息到本地存储,确保保留businessSection字段
               const updatedUserInfo = {
                 ...userInfo,
                 userInfo: {
                   ...userInfo.userInfo,
-                  ...merchantRes.data
+                  ...merchantRes.data,
+                  // 确保保留businessSection字段
+                  businessSection: userInfo.userInfo.businessSection
                 }
               };
               localSet("geeker-user", updatedUserInfo);

+ 20 - 20
src/views/storeDecoration/basicStoreInformation/index.vue

@@ -195,26 +195,26 @@
           </el-form-item>
 
           <!-- 到期时间(只读) -->
-          <el-form-item label="到期时间">
-            <el-input v-model="formData.expirationTime" disabled class="readonly-input">
-              <template #prefix>
-                <el-icon>
-                  <Lock />
-                </el-icon>
-              </template>
-            </el-input>
-          </el-form-item>
-
-          <!-- 食品经营许可证到期时间(只读) -->
-          <el-form-item label="食品经营许可证到期时间">
-            <el-input v-model="formData.foodLicenceExpirationTime" disabled class="readonly-input">
-              <template #prefix>
-                <el-icon>
-                  <Lock />
-                </el-icon>
-              </template>
-            </el-input>
-          </el-form-item>
+          <!--          <el-form-item label="到期时间">-->
+          <!--            <el-input v-model="formData.expirationTime" disabled class="readonly-input">-->
+          <!--              <template #prefix>-->
+          <!--                <el-icon>-->
+          <!--                  <Lock />-->
+          <!--                </el-icon>-->
+          <!--              </template>-->
+          <!--            </el-input>-->
+          <!--          </el-form-item>-->
+
+          <!--          &lt;!&ndash; 食品经营许可证到期时间(只读) &ndash;&gt;-->
+          <!--          <el-form-item label="食品经营许可证到期时间">-->
+          <!--            <el-input v-model="formData.foodLicenceExpirationTime" disabled class="readonly-input">-->
+          <!--              <template #prefix>-->
+          <!--                <el-icon>-->
+          <!--                  <Lock />-->
+          <!--                </el-icon>-->
+          <!--              </template>-->
+          <!--            </el-input>-->
+          <!--          </el-form-item>-->
         </div>
       </div>
 

+ 4 - 1
src/views/storeDecoration/facilitiesAndServices/index.vue

@@ -16,7 +16,10 @@ import FacilityManagement from "./components/FacilityManagement.vue";
 // 运动健身 -> FacilityManagement (设施管理)
 // 洗浴汗蒸 -> ServiceManagement (服务管理)
 const activeComponent = computed<"service" | "facility">(() => {
-  const userInfo: any = localGet("geeker-user")?.userInfo || {};
+  const geekerUser = localGet("geeker-user");
+  console.log("完整geeker-user:", geekerUser);
+  const userInfo: any = geekerUser?.userInfo || {};
+  console.log("userInfo.businessSection:", userInfo.businessSection);
   const businessSection = userInfo.businessSection || "";
 
   // 如果是"运动健身",显示设施管理