Browse Source

report-types-fe: YELLOW 实现 — guide-list 配置化(v-for+同标题行购买钮)/删关联商品区+全部痕迹

Agnes Agent 1 day ago
parent
commit
1cdddf57c2
1 changed files with 54 additions and 213 deletions
  1. 54 213
      cfc-frontend/pages/health/report-upload.vue

+ 54 - 213
cfc-frontend/pages/health/report-upload.vue

@@ -94,57 +94,17 @@
         <text class="guide-header-title">支持的报告类型</text>
       </view>
       <view class="guide-list">
-        <view class="guide-item">
-          <view class="guide-icon-box guide-icon-blue"><text class="guide-icon">📄</text></view>
+        <view class="guide-item" v-for="(item, idx) in sortedGuideTypes" :key="item.typeId">
+          <view class="guide-icon-box" :class="guideIconClass(idx)"><text class="guide-icon">{{ guideIcon(item) }}</text></view>
           <view class="guide-info">
-            <text class="guide-name">菌群检测报告</text>
-            <text class="guide-desc">肠道菌群 PDF,后台采集解析菌群指标</text>
-            <view class="guide-link" v-if="getTypeLink('gut_flora')" @click="goProductDetail('gut_flora')">
-              <text class="guide-link-label">查看商品</text>
-              <text class="guide-link-name">{{ getTypeLink('gut_flora').productName }}</text>
-              <text class="guide-link-arrow">›</text>
+            <view class="guide-title-row">
+              <text class="guide-name">{{ item.displayName }}</text>
+              <view class="guide-buy" v-if="item.linkedProductId" @click="goProductDetail(item.typeId)">
+                <text class="guide-buy-label">购买</text>
+                <text class="guide-buy-arrow">›</text>
+              </view>
             </view>
-            <view class="guide-buy" v-if="getTypeLink('gut_flora')" @click="goProductDetail('gut_flora')">
-              <text class="guide-buy-label">购买</text>
-              <text class="guide-buy-arrow">›</text>
-            </view>
-          </view>
-        </view>
-        <view class="guide-item">
-          <view class="guide-icon-box guide-icon-purple"><text class="guide-icon">🧠</text></view>
-          <view class="guide-info">
-            <text class="guide-name">素质测评</text>
-            <text class="guide-desc">核心素养/认知发展 PDF,系统解析能力、人格、情绪等</text>
-            <view class="guide-link" v-if="getTypeLink('dan_a2')" @click="goProductDetail('dan_a2')">
-              <text class="guide-link-label">查看商品</text>
-              <text class="guide-link-name">{{ getTypeLink('dan_a2').productName }}</text>
-              <text class="guide-link-arrow">›</text>
-            </view>
-            <view class="guide-buy" v-if="getTypeLink('dan_a2')" @click="goProductDetail('dan_a2')">
-              <text class="guide-buy-label">购买</text>
-              <text class="guide-buy-arrow">›</text>
-            </view>
-          </view>
-        </view>
-        <view class="guide-item">
-          <view class="guide-icon-box guide-icon-blue"><text class="guide-icon">📄</text></view>
-          <view class="guide-info">
-            <text class="guide-name">体检报告</text>
-            <text class="guide-desc">血常规、尿常规、生化检验等,支持 PDF 或清晰照片</text>
-          </view>
-        </view>
-        <view class="guide-item">
-          <view class="guide-icon-box guide-icon-orange"><text class="guide-icon">👅</text></view>
-          <view class="guide-info">
-            <text class="guide-name">舌象照片</text>
-            <text class="guide-desc">拍摄舌象照片,AI 辅助舌诊分析</text>
-          </view>
-        </view>
-        <view class="guide-item">
-          <view class="guide-icon-box guide-icon-teal"><text class="guide-icon">⚖️</text></view>
-          <view class="guide-info">
-            <text class="guide-name">体脂秤报告</text>
-            <text class="guide-desc">拍摄体脂秤显示屏,自动提取体重、BMI、体脂率等</text>
+            <text class="guide-desc">{{ item.description }}</text>
           </view>
         </view>
       </view>
@@ -156,30 +116,6 @@
         <text class="guide-tips-item">· 确认入库后将自动生成成长方案,可再分解为每日任务</text>
       </view>
     </view>
-
-    <!-- 关联商品(后台配置的报告类型→商品;按商品 id 去重,点击可查看并购买) -->
-    <view class="linked-products-section" v-if="linkedProducts.length > 0">
-      <view class="linked-products-header">
-        <text class="linked-products-header-icon">🛒</text>
-        <text class="linked-products-title">关联商品</text>
-      </view>
-      <text class="linked-products-desc">以下商品与您的报告类型对应,点击可查看并购买</text>
-      <view class="linked-products-grid">
-        <view
-          class="linked-product-card"
-          v-for="(product, pIdx) in linkedProducts"
-          :key="getProductKey(product)"
-          hover-class="linked-product-hover"
-          @click="goProductDetailByProduct(product.productId)">
-          <view class="linked-product-info">
-            <text class="linked-product-name">{{ product.productName }}</text>
-            <text class="linked-product-tag">报告关联商品</text>
-          </view>
-          <view class="linked-product-btn">查看 / 购买</view>
-        </view>
-      </view>
-    </view>
-  </view>
 </template>
 
 <script>
@@ -212,22 +148,19 @@ export default {
     tipText: function() {
       return '上传报告后由系统自动识别类型并解析:菌群检测、素质测评 A2、体检报告等'
     },
-    // 关联商品:遍历报告类型→商品链接配置,按商品 id(linkedProductId)去重(Set 语义),
-    // 多个报告类型关联同一商品时只展示一次;未配置/接口失败返回 [],页面静默隐藏卡片区
-    linkedProducts: function() {
+    // 支持的报告类型(后台可配置):对 reportTypeLinks 排序(sortOrder 空按 100 兜底,升序,
+    // 相等按 typeId 字符串稳定),空/非数组返回 [],不修改原数组(拷贝)
+    sortedGuideTypes: function() {
       var list = this.reportTypeLinks || []
-      var seen = {}
-      var result = []
-      for (var i = 0; i < list.length; i++) {
-        var link = list[i]
-        if (!link || !link.linkedProductId) continue
-        var pid = parseInt(link.linkedProductId)
-        if (!pid || isNaN(pid) || pid <= 0) continue
-        if (seen[pid]) continue
-        seen[pid] = true
-        result.push({ productId: pid, productName: link.productName || '' })
-      }
-      return result
+      if (!(list instanceof Array)) return []
+      return list.slice().sort(function(a, b) {
+        var sa = (a && a.sortOrder !== null && a.sortOrder !== undefined) ? a.sortOrder : 100
+        var sb = (b && b.sortOrder !== null && b.sortOrder !== undefined) ? b.sortOrder : 100
+        if (sa !== sb) return sa - sb
+        var ta = String((a && a.typeId) || '')
+        var tb = String((b && b.typeId) || '')
+        return ta < tb ? -1 : (ta > tb ? 1 : 0)
+      })
     }
   },
   onLoad: function(options) {
@@ -321,14 +254,19 @@ if (options.type === 'a2' || options.reportKind === 'a2') {
       if (!link || !link.linkedProductId) return
       uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + link.linkedProductId })
     },
-    // 商品卡片 :key(按商品 id 唯一,避免多类型关联同商品时模板键冲突)
-    getProductKey: function(product) {
-      return 'lp' + (product && product.productId)
+    // 图标:优先 item.icon;空则按 typeId 回退默认映射,未知类型回退 '📄'
+    guideIcon: function(item) {
+      if (item && item.icon) return item.icon
+      var map = { gut_flora: '📄', dan_a2: '🧠', physical_exam: '📋', tongue: '👅', body_fat: '⚖️' }
+      var tid = item && item.typeId
+      return map[tid] || '📄'
     },
-    // 点击「关联商品」卡片 → 按商品 id 直接跳转商城商品详情页(详情页含购买/加购入口)
-    goProductDetailByProduct: function(productId) {
-      if (!productId) return
-      uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + productId })
+    // 图标底色:循环四色(保持现有视觉),按索引取模
+    guideIconClass: function(idx) {
+      var palette = ['guide-icon-blue', 'guide-icon-purple', 'guide-icon-orange', 'guide-icon-teal']
+      var i = parseInt(idx, 10)
+      if (isNaN(i) || i < 0) i = 0
+      return palette[i % palette.length]
     },
     ensureMember: function() {
       if (this.memberId) return true
@@ -958,67 +896,49 @@ if (options.type === 'a2' || options.reportKind === 'a2') {
 .guide-info {
   flex: 1;
 }
-.guide-name {
-  font-size: calc(26rpx * var(--font-scale, 1));
-  font-weight: 600;
-  color: $facade-text-slate-700;
-  display: block;
-  margin-bottom: 4rpx;
-}
-.guide-desc {
-  font-size: calc(22rpx * var(--font-scale, 1));
-  color: $app-text-subtle;
-  line-height: 1.5;
-}
-.guide-link {
+.guide-title-row {
   display: flex;
   flex-direction: row;
   align-items: center;
-  margin-top: 10rpx;
-  padding: 8rpx 16rpx;
-  border-radius: 10rpx;
-  background: $facade-brand-tint-2;
-  align-self: flex-start;
+  justify-content: space-between;
+  margin-bottom: 4rpx;
 }
-.guide-link-label {
-  font-size: calc(22rpx * var(--font-scale, 1));
-  color: $facade-violet;
+.guide-name {
+  font-size: calc(26rpx * var(--font-scale, 1));
   font-weight: 600;
-  margin-right: 8rpx;
-}
-.guide-link-name {
-  font-size: calc(22rpx * var(--font-scale, 1));
-  color: $facade-text-strong;
-  max-width: 320rpx;
+  color: $facade-text-slate-700;
+  flex: 1;
+  min-width: 0;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
 }
-.guide-link-arrow {
-  font-size: calc(26rpx * var(--font-scale, 1));
-  color: $facade-violet;
-  margin-left: 6rpx;
+.guide-desc {
+  font-size: calc(22rpx * var(--font-scale, 1));
+  color: $app-text-subtle;
+  line-height: 1.5;
 }
-/* 内联「购买」按钮:实心品牌紫,视觉强度高于 guide-link,直接唤起购买入口 */
+/* 内联「购买」按钮(缩小):实心品牌紫,与类型标题同一行,宽度自适应、不换行 */
 .guide-buy {
   display: flex;
   flex-direction: row;
   align-items: center;
-  margin-top: 10rpx;
-  padding: 10rpx 24rpx;
-  border-radius: 12rpx;
+  flex-shrink: 0;
+  margin-left: 16rpx;
+  padding: 6rpx 18rpx;
+  border-radius: 20rpx;
   background: $facade-violet;
-  align-self: flex-start;
 }
 .guide-buy-label {
-  font-size: calc(24rpx * var(--font-scale, 1));
+  font-size: calc(20rpx * var(--font-scale, 1));
   color: $app-surface;
   font-weight: 600;
-  margin-right: 6rpx;
+  white-space: nowrap;
 }
 .guide-buy-arrow {
-  font-size: calc(26rpx * var(--font-scale, 1));
+  font-size: calc(22rpx * var(--font-scale, 1));
   color: $app-surface;
+  margin-left: 4rpx;
 }
 .guide-tips {
   margin-top: 8rpx;
@@ -1039,83 +959,4 @@ if (options.type === 'a2' || options.reportKind === 'a2') {
   line-height: 1.7;
 }
 
-/* 关联商品卡片区(视觉与 guide-section 一致) */
-.linked-products-section {
-  margin: 0 $uni-space-lg $uni-space-xl;
-  background: $app-surface;
-  border-radius: 24rpx;
-  padding: 28rpx 24rpx;
-  box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
-}
-.linked-products-header {
-  display: flex;
-  flex-direction: row;
-  align-items: center;
-  margin-bottom: 8rpx;
-}
-.linked-products-header-icon {
-  font-size: calc(32rpx * var(--font-scale, 1));
-  margin-right: 12rpx;
-}
-.linked-products-title {
-  font-size: calc(28rpx * var(--font-scale, 1));
-  font-weight: 600;
-  color: $uni-text-color;
-}
-.linked-products-desc {
-  font-size: calc(22rpx * var(--font-scale, 1));
-  color: $app-text-subtle;
-  line-height: 1.5;
-  display: block;
-  margin-bottom: 20rpx;
-}
-.linked-products-grid {
-  display: flex;
-  flex-direction: row;
-  flex-wrap: wrap;
-  gap: 16rpx;
-}
-.linked-product-card {
-  width: calc((100% - 16rpx) / 2);
-  display: flex;
-  flex-direction: column;
-  background: $app-bg;
-  border: 2rpx solid $facade-fill-slate;
-  border-radius: 16rpx;
-  padding: 20rpx 16rpx;
-}
-.linked-product-hover {
-  opacity: 0.85;
-}
-.linked-product-info {
-  flex: 1;
-  display: flex;
-  flex-direction: column;
-  min-width: 0;
-}
-.linked-product-name {
-  font-size: calc(24rpx * var(--font-scale, 1));
-  font-weight: 600;
-  color: $facade-text-strong;
-  display: block;
-  overflow: hidden;
-  text-overflow: ellipsis;
-  white-space: nowrap;
-  margin-bottom: 6rpx;
-}
-.linked-product-tag {
-  font-size: calc(20rpx * var(--font-scale, 1));
-  color: $app-text-subtle;
-}
-.linked-product-btn {
-  margin-top: 14rpx;
-  height: 56rpx;
-  line-height: 56rpx;
-  text-align: center;
-  background: $facade-brand-tint-2;
-  color: $facade-violet;
-  font-size: calc(24rpx * var(--font-scale, 1));
-  font-weight: 600;
-  border-radius: 12rpx;
-}
 </style>