Эх сурвалжийг харах

feat(index): 首页 Next Best Action 引导条 - 解决首屏'不知道该干啥'

liaoxg 2 долоо хоног өмнө
parent
commit
3c8b043540

+ 175 - 0
cfc-frontend/pages/index-home/index.vue

@@ -59,6 +59,20 @@
       </view>
     </view>
 
+    <!-- ①.b 行动引导条 — Next Best Action(仅登录态展示,定位"现在该做的一件事") -->
+    <view v-if="nextBestAction" class="guide-bar" :class="'guide-bar-' + nextBestAction.color" @click="onGuideTap(nextBestAction)">
+      <view class="guide-bar-icon-wrap">
+        <text class="guide-bar-icon">{{ nextBestAction.icon }}</text>
+      </view>
+      <view class="guide-bar-info">
+        <text class="guide-bar-title">{{ nextBestAction.title }}</text>
+        <text class="guide-bar-sub">{{ nextBestAction.sub }}</text>
+      </view>
+      <view class="guide-bar-btn">
+        <text class="guide-bar-btn-text">{{ nextBestAction.btn }} ›</text>
+      </view>
+    </view>
+
     <!-- ② 发现区 — 能量沙盘 — Canvas 五行星图(未测评时显示引导卡) -->
 
     <GateLock v-if="sandboxLocked && sandboxLockGate" :gate="sandboxLockGate" />
@@ -549,6 +563,71 @@ membershipDays: 0,
         return '最近综合得分 ' + (this.sandboxData.overallScore || 0) + ' 分 · 点击查看'
       }
       return '15 题五维自检 · 约 20 秒'
+    },
+    // ===== Next Best Action 引导条(C 方案)=====
+    // 优先级:沙盘未解锁 > 待填调研 > 待办任务 > 未读通知 > 默认引导
+    // 只展示当前最该做的一件事,未登录态不展示
+    nextBestAction: function() {
+      if (!this.currentRole) return null
+      // 1) 沙盘未解锁 — 最高优先级,引导完成自检
+      if (this.sandboxLocked) {
+        return {
+          type: 'self-check',
+          icon: '⚡',
+          title: '先完成五维自检',
+          sub: '15 题,约 20 秒,解锁全家能量报告',
+          btn: '去自检',
+          color: 'orange'
+        }
+      }
+      // 2) 待填调研 — 定期调研是用户的实际行动邀请
+      if (this.pendingSurveys && this.pendingSurveys.length > 0) {
+        return {
+          type: 'survey',
+          icon: '📝',
+          title: '有 ' + this.pendingSurveys.length + ' 项调研待填',
+          sub: '填完解锁下一阶段内容',
+          btn: '去填写',
+          color: 'blue'
+        }
+      }
+      // 3) 待办任务 — 用户已完成自检后的执行路径
+      if (this.pendingTasks && this.pendingTasks.length > 0) {
+        return {
+          type: 'task',
+          icon: '🎯',
+          title: '今日有 ' + this.pendingTasks.length + ' 项待办',
+          sub: '完成可累积成长分',
+          btn: '去完成',
+          color: 'green'
+        }
+      }
+      // 4) 未读通知 — 私域触达优先
+      var unreadCount = 0
+      if (this.notices && this.notices.length) {
+        for (var i = 0; i < this.notices.length; i++) {
+          if (this.notices[i] && this.notices[i].unread) unreadCount++
+        }
+      }
+      if (unreadCount > 0) {
+        return {
+          type: 'notice',
+          icon: '📬',
+          title: '有 ' + unreadCount + ' 条新消息',
+          sub: '家庭动态、通知、待办提醒',
+          btn: '查看',
+          color: 'purple'
+        }
+      }
+      // 5) 默认引导 — 已完成所有任务,指向增值内容
+      return {
+        type: 'default',
+        icon: '✨',
+        title: '今日任务已清空',
+        sub: '去看看今日推荐阅读,给成长加点料',
+        btn: '逛一逛',
+        color: 'gray'
+      }
     }
   },
   onLoad(options) {
@@ -991,6 +1070,37 @@ membershipDays: 0,
         uni.navigateTo({ url: '/pages/family/self-check-entry' })
       }
     },
+    // ===== Next Best Action 引导条点击 =====
+    onGuideTap: function(action) {
+      if (!action) return
+      switch (action.type) {
+        case 'self-check':
+          this.goSelfTest()
+          break
+        case 'survey':
+          // 跳转到第一个待填调研
+          if (this.pendingSurveys && this.pendingSurveys.length > 0) {
+            var s = this.pendingSurveys[0]
+            uni.navigateTo({
+              url: '/pages/health/survey-questionnaire?templateId=' + s.templateId +
+                '&templateTitle=' + encodeURIComponent(s.title || '定期调研') +
+                '&templateDimension=' + encodeURIComponent(s.dimension || '') +
+                '&periodStart=' + (s.periodStart || '') +
+                '&periodEnd=' + (s.periodEnd || '')
+            })
+          }
+          break
+        case 'task':
+          this.navTo('/pages/tasks/tasks')
+          break
+        case 'notice':
+          this.navTo('/pages/profile/profile')
+          break
+        case 'default':
+          this.goMoreArticles()
+          break
+      }
+    },
     loadSelfCheckStatus: function() {
       var self = this
       getSelfCheckStatus().then(function(res) {
@@ -1911,6 +2021,71 @@ membershipDays: 0,
 .self-test-sub { font-size: 22rpx; color: rgba(255,255,255,0.8); display: block; margin-top: 4rpx; }
 .self-test-arrow { font-size: 36rpx; color: rgba(255,255,255,0.7); }
 
+/* ===== ①.b 行动引导条 — Next Best Action ===== */
+.guide-bar {
+  margin: 0 30rpx 16rpx;
+  border-radius: 20rpx;
+  padding: 18rpx 24rpx;
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
+}
+.guide-bar-icon-wrap {
+  width: 72rpx;
+  height: 72rpx;
+  border-radius: 18rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-right: 16rpx;
+  flex-shrink: 0;
+}
+.guide-bar-icon { font-size: 34rpx; }
+.guide-bar-info { flex: 1; min-width: 0; }
+.guide-bar-title { font-size: 27rpx; font-weight: bold; display: block; }
+.guide-bar-sub { font-size: 21rpx; margin-top: 3rpx; display: block; }
+.guide-bar-btn {
+  flex-shrink: 0;
+  margin-left: 12rpx;
+  padding: 8rpx 20rpx;
+  border-radius: 999rpx;
+  font-size: 22rpx;
+  font-weight: bold;
+}
+.guide-bar-btn-text { }
+
+/* 颜色主题 — 低饱和背景 + 深色文字,不抢自测卡风头 */
+.guide-bar-orange { background: #FFF3E7; border: 1rpx solid rgba(249,115,22,0.18); }
+.guide-bar-orange .guide-bar-icon-wrap { background: rgba(249,115,22,0.14); }
+.guide-bar-orange .guide-bar-title { color: #9A3412; }
+.guide-bar-orange .guide-bar-sub { color: #B45309; }
+.guide-bar-orange .guide-bar-btn { background: linear-gradient(135deg, #F97316, #FB923C); color: #fff; }
+
+.guide-bar-blue { background: #EFF4FF; border: 1rpx solid rgba(99,102,241,0.18); }
+.guide-bar-blue .guide-bar-icon-wrap { background: rgba(99,102,241,0.12); }
+.guide-bar-blue .guide-bar-title { color: #312E81; }
+.guide-bar-blue .guide-bar-sub { color: #4338CA; }
+.guide-bar-blue .guide-bar-btn { background: linear-gradient(135deg, #6366F1, #818CF8); color: #fff; }
+
+.guide-bar-green { background: #ECFDF5; border: 1rpx solid rgba(16,185,129,0.18); }
+.guide-bar-green .guide-bar-icon-wrap { background: rgba(16,185,129,0.12); }
+.guide-bar-green .guide-bar-title { color: #064E3B; }
+.guide-bar-green .guide-bar-sub { color: #047857; }
+.guide-bar-green .guide-bar-btn { background: linear-gradient(135deg, #10B981, #34D399); color: #fff; }
+
+.guide-bar-purple { background: #F5F3FF; border: 1rpx solid rgba(139,92,246,0.18); }
+.guide-bar-purple .guide-bar-icon-wrap { background: rgba(139,92,246,0.12); }
+.guide-bar-purple .guide-bar-title { color: #4C1D95; }
+.guide-bar-purple .guide-bar-sub { color: #6D28D9; }
+.guide-bar-purple .guide-bar-btn { background: linear-gradient(135deg, #8B5CF6, #A78BFA); color: #fff; }
+
+.guide-bar-gray { background: #F8FAFC; border: 1rpx solid rgba(100,116,139,0.15); }
+.guide-bar-gray .guide-bar-icon-wrap { background: rgba(100,116,139,0.10); }
+.guide-bar-gray .guide-bar-title { color: #334155; }
+.guide-bar-gray .guide-bar-sub { color: #64748B; }
+.guide-bar-gray .guide-bar-btn { background: linear-gradient(135deg, #94A3B8, #CBD5E1); color: #fff; }
+
 /* ===== 快捷功能入口(单排,6个横向排列) ===== */
 .quick-bar {
   display: flex;