Prechádzať zdrojové kódy

fix: relationship_types enabled 修复 + 清理 body/index.vue 冗余产品链接
- DatabaseInitializer: 启动时修复 enabled=NULL 的种子数据
- schema.sql: relationship_types INSERT 补上 enabled 列
- body/index.vue: 删除菌群检测产品链接区块, showTabTransition=true, 移除废弃方法
- RelationshipPicker.vue: 组件增强
- DimensionActivities.vue: 组件增强

User 2 mesiacov pred
rodič
commit
552be64814

+ 10 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -120,6 +120,16 @@ public class DatabaseInitializer implements CommandLineRunner {
             }
         }
         log.info("商品订单增量迁移完成");
+
+        // 修复 relationship_types 表中 enabled 为 NULL 的种子数据(schema.sql 早期版本未设置 enabled)
+        try {
+            int patched = jdbcTemplate.update("UPDATE relationship_types SET enabled = 1 WHERE enabled IS NULL");
+            if (patched > 0) {
+                log.info("已修复 relationship_types NULL enabled 数据,affected={}", patched);
+            }
+        } catch (Exception e) {
+            log.debug("relationship_types enabled 修复跳过: {}", e.getMessage());
+        }
     }
 
     private void initializeDatabase() {

+ 5 - 5
cfc-backend/src/main/resources/schema.sql

@@ -1651,11 +1651,11 @@ CREATE TABLE IF NOT EXISTS relationship_types (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='关系类型配置表';
 
 -- 默认关系类型数据
-INSERT IGNORE INTO relationship_types (type_key, type_name, capability_role, sort_order) VALUES
-('spouse', '配偶', 'parent', 1),
-('parent', '父母', 'parent', 2),
-('child', '子女', 'child', 3),
-('sibling', '兄弟姐妹', 'child', 4);
+INSERT IGNORE INTO relationship_types (type_key, type_name, capability_role, sort_order, enabled) VALUES
+('spouse', '配偶', 'parent', 1, 1),
+('parent', '父母', 'parent', 2, 1),
+('child', '子女', 'child', 3, 1),
+('sibling', '兄弟姐妹', 'child', 4, 1);
 
 -- 用户收货地址表
 CREATE TABLE IF NOT EXISTS user_address (

+ 1 - 1
cfc-frontend/components/DimensionActivities.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="section">
     <view class="section-header">
-      <text class="section-title">🔥 相关活动</text>
+      <text class="section-title">🔥 推荐活动</text>
       <text class="section-more" v-if="displayActivities && displayActivities.length > 0" @click="$emit('moreActivities')">更多 ›</text>
     </view>
     <view v-if="!displayActivities || displayActivities.length === 0" class="empty-state">

+ 19 - 4
cfc-frontend/components/RelationshipPicker.vue

@@ -3,9 +3,11 @@
     <view class="form-item required" v-if="showLabel">
       <text class="label"><text class="required-mark">*</text>关系类型</text>
     </view>
-    <picker :range="typeNames" @change="onChange" :disabled="disabled">
-      <view class="picker" :class="{ 'picker-disabled': disabled }">
-        {{ selectedName || '请选择关系类型' }}
+    <picker :range="typeNames" @change="onChange" :disabled="disabled || loadError">
+      <view class="picker" :class="{ 'picker-disabled': disabled || loadError, 'picker-error': loadError }">
+        <text v-if="loading" class="status-text">加载中...</text>
+        <text v-else-if="loadError" class="status-text error-text" @tap.stop="loadTypes">加载失败,点击重试</text>
+        <text v-else>{{ selectedName || '请选择关系类型' }}</text>
       </view>
     </picker>
   </view>
@@ -24,7 +26,8 @@ export default {
   data() {
     return {
       relationshipTypes: [],
-      loading: false
+      loading: false,
+      loadError: false
     }
   },
   computed: {
@@ -51,6 +54,7 @@ export default {
   methods: {
     async loadTypes() {
       this.loading = true
+      this.loadError = false
       try {
         var res = await getRelationshipTypes()
         if (res.code === 200 && res.data) {
@@ -58,6 +62,7 @@ export default {
         }
       } catch (e) {
         console.error('加载关系类型失败', e)
+        this.loadError = true
       } finally {
         this.loading = false
       }
@@ -98,4 +103,14 @@ export default {
   color: #F97316;
   margin-right: 4rpx;
 }
+.status-text {
+  font-size: 28rpx;
+  color: #999;
+}
+.error-text {
+  color: #F97316;
+}
+.picker-error {
+  border-color: #F97316;
+}
 </style>

+ 1 - 60
cfc-frontend/pages/body/index.vue

@@ -132,53 +132,8 @@
         <text class="nutrition-arrow">›</text>
       </view>
 
-      <!-- 菌群检测产品链接 -->
-      <view class="nutrition-links">
-        <text class="links-label">🔥 相关产品</text>
-        <view class="links-row">
-          <view class="link-item" @click="goToShopProduct('gut_flora')">
-            <text class="link-icon">🧪</text>
-            <view class="link-texts">
-              <text class="link-name">肠道菌群检测</text>
-              <text class="link-desc">了解孩子的肠道健康状况</text>
-            </view>
-            <text class="link-arrow">›</text>
-          </view>
-          <view class="link-item" @click="goToShopProduct('probiotic')">
-            <text class="link-icon">🦠</text>
-            <view class="link-texts">
-              <text class="link-name">益生菌补充</text>
-              <text class="link-desc">平衡肠道菌群,增强免疫力</text>
-            </view>
-            <text class="link-arrow">›</text>
-          </view>
-        </view>
       </view>
 
-      <!-- 相关文章链接 -->
-      <view class="nutrition-links">
-        <text class="links-label">📖 相关文章</text>
-        <view class="links-row">
-          <view class="link-item" @click="goToArticle('gut_health')">
-            <text class="link-icon">📝</text>
-            <view class="link-texts">
-              <text class="link-name">肠道菌群与儿童健康</text>
-              <text class="link-desc">肠道菌群如何影响孩子的免疫力</text>
-            </view>
-            <text class="link-arrow">›</text>
-          </view>
-          <view class="link-item" @click="goToArticle('nutrition_guide')">
-            <text class="link-icon">📝</text>
-            <view class="link-texts">
-              <text class="link-name">儿童精准营养指南</text>
-              <text class="link-desc">科学搭配饮食,促进健康成长</text>
-            </view>
-            <text class="link-arrow">›</text>
-          </view>
-        </view>
-      </view>
-    </view>
-
     <!-- 维度任务 -->
     <DimensionTasks
       v-if="isLoggedIn"
@@ -307,7 +262,7 @@ export default {
     return {
       isLoggedIn: false,
       role: null,
-      showTabTransition: false,
+      showTabTransition: true,
       activeChildId: null,
       activeChildName: '',
       userName: '',
@@ -643,20 +598,6 @@ export default {
       var id = this.activeChildId || uni.getStorageSync('currentChildId') || ''
       uni.navigateTo({ url: '/pages/health/report-upload?childId=' + id + '&from=body' })
     },
-    goToShopProduct: function(type) {
-      if (type === 'gut_flora') {
-        uni.navigateTo({ url: '/pages/discover/index?type=product&domain=body&keyword=' + encodeURIComponent('肠道菌群检测') })
-      } else if (type === 'probiotic') {
-        uni.navigateTo({ url: '/pages/discover/index?type=product&domain=body&keyword=' + encodeURIComponent('益生菌') })
-      }
-    },
-    goToArticle: function(topic) {
-      if (topic === 'gut_health') {
-        uni.navigateTo({ url: '/pages/mind/articles?tag=' + encodeURIComponent('肠道健康') })
-      } else if (topic === 'nutrition_guide') {
-        uni.navigateTo({ url: '/pages/mind/articles?tag=' + encodeURIComponent('精准营养') })
-      }
-    },
     formatDate: function(dateStr) {
       if (!dateStr) return '--'
       try {