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

feat(reading-checkin): 阅读打卡 T03 前端三模式入口——create-task 三模式 UI+任务列表跳转分派+article-center 未完成标记+article-detail 双门槛+api.js

Agnes Agent 1 цаг өмнө
parent
commit
6576c2b5ac

+ 109 - 15
cfc-frontend/pages/article-center/article-detail.vue

@@ -100,6 +100,7 @@
         <text class="result-icon">{{ resultIcon }}</text>
         <text class="result-text">答对 {{ quizResult.correctCount }}/{{ quizResult.totalQuestions }} 题</text>
         <text class="result-energy">获得 {{ quizResult.cfEarned }} CF值 + {{ quizResult.energyEarned }} 能量 ⚡</text>
+        <button v-if="quizResult.allowRetake" class="result-btn" @click="retakeQuiz">重新答题</button>
         <button class="result-btn" @click="closeResult">知道了</button>
       </view>
     </view>
@@ -108,7 +109,7 @@
 
 <script>
 import { BrandColors } from '../../utils/brand-colors.js'
-import { getArticleDetail, getArticleAudio, reportReadingTime, getShareQrCode, completeArticleRead, generateQuiz, submitQuiz, completeTask } from '@/utils/api.js'
+import { getArticleDetail, getArticleAudio, reportReadingTime, getShareQrCode, completeArticleRead, generateQuiz, submitQuiz, getReadingTaskProgress } from '@/utils/api.js'
 import shareMixin from '../../components/share-mixin.js'
 import ContentSharePoster from '@/components/ContentSharePoster.vue'
 import RelatedContent from '@/components/RelatedContent.vue'
@@ -134,7 +135,9 @@ export default {
       showQuiz: false, quizQuestions: [], quizAnswers: [], showResult: false, quizResult: {}, quizRecordId: null, currentQuizIndex: 0,
       mascotList: [{ icon: '🐶', name: '浠宝' }, { icon: '🐼', name: '福宝' }],
       mascotIcon: '🐶', mascotName: '浠宝',
-      taskId: null
+      taskId: null,
+      // 阅读打卡任务进度缓存(mode/done/target/quizPassed/readingCompleted/minSeconds)
+      taskProgress: null
     }
   },
   computed: {
@@ -193,6 +196,10 @@ export default {
     this.taskId = options && options.taskId ? parseInt(options.taskId) : null
     this.currentChildId = uni.getStorageSync('currentChildId') || null
     this.isLogin = !!uni.getStorageSync('token')
+    // 有阅读打卡任务时拉取进度缓存(mode/minSeconds/quizPassed 等),驱动双门槛提示
+    if (this.taskId) {
+      this.loadTaskProgress()
+    }
   },
   onShow() {
     this.fontScale = getFontScale()
@@ -220,6 +227,31 @@ export default {
       finally { this.loading = false }
     },
     formatDate(d) { return d ? d.slice(0, 10) : '' },
+    /** 阅读打卡任务:拉取进度缓存(mode/done/target/quizPassed/readingCompleted/minSeconds 等) */
+    async loadTaskProgress() {
+      var memberId = this.getActiveMemberId()
+      if (!this.taskId || !memberId) return
+      try {
+        var res = await getReadingTaskProgress(this.taskId)
+        if (res && res.code === 200 && res.data) {
+          this.taskProgress = res.data
+        }
+      } catch (e) {
+        // 进度拉取失败不阻断阅读,双门槛判定由后端兜底
+      }
+    },
+    /** 当前任务模式:ARTICLE / DURATION / COUNT(无任务时不展示任务栏) */
+    getTaskMode() {
+      if (!this.taskId || !this.taskProgress) return ''
+      return this.taskProgress.mode || 'ARTICLE'
+    },
+    /** 任务要求的阅读达标秒数:优先任务配置 minSeconds,缺省用文章 readTime */
+    getTaskTargetSeconds() {
+      if (this.taskProgress && this.taskProgress.minSeconds > 0) {
+        return this.taskProgress.minSeconds
+      }
+      return (this.article && this.article.readTime ? this.article.readTime : 3) * 60
+    },
     getImageUrl: function(path) {
       if (!path) return ''
       if (path.indexOf('http://') === 0 || path.indexOf('https://') === 0) return path
@@ -294,17 +326,35 @@ export default {
       this.lastReportedSeconds = this.readingSeconds
       var memberId = this.getActiveMemberId()
       if (!this.isLogin || !this.article) return
-      reportReadingTime({ articleId: this.article.id, memberId: memberId || 0, durationSeconds: delta })
+      // 有阅读打卡任务时携带 taskId(后端按任务配置判定双门槛)
+      var reportData = { articleId: this.article.id, memberId: memberId || 0, durationSeconds: delta }
+      if (this.taskId) {
+        reportData.taskId = this.taskId
+      }
+      reportReadingTime(reportData)
 
-      // 达到阅读时长自动完成
-      var targetSeconds = (this.article.readTime || 3) * 60
+      // 达到阅读时长(任务门槛优先,缺省文章 readTime)
+      var targetSeconds = this.getTaskTargetSeconds()
       if (!this.readingCompleted && this.readingSeconds >= targetSeconds) {
         this.readingCompleted = true
         this.pauseReadingTimer()
         try { await completeArticleRead({ articleId: this.article.id, memberId: memberId || 0, durationSeconds: this.readingSeconds }) } catch (e) {}
-        uni.showToast({ title: '阅读完成 +5能量', icon: 'success' })
-        // 弹出答题(登录用户)
-        this.startQuiz()
+        var mode = this.getTaskMode()
+        // 模式 A(指定文章,需答题通过):提示双门槛
+        if (mode === 'ARTICLE') {
+          uni.showToast({ title: '阅读达标,答题通过后任务完成', icon: 'none' })
+          this.startQuiz()
+        } else if (mode === 'COUNT') {
+          // 模式 C(按数量计数):本篇需答题通过才计入
+          uni.showToast({ title: '本篇阅读完成', icon: 'none' })
+          this.startQuiz()
+        } else {
+          // 无任务 或 模式 B(按时长单门槛,后端已自动完成):保留原 +5 能量提示,不强制答题
+          uni.showToast({ title: '阅读完成 +5能量', icon: 'success' })
+          if (mode === '') {
+            this.startQuiz()
+          }
+        }
       }
     },
     formatReadingTime: function(seconds) {
@@ -407,23 +457,56 @@ export default {
         answers.push(this.quizAnswers[i] || '')
       }
       try {
-        var res = await submitQuiz({ recordId: this.quizRecordId, memberId: parseInt(memberId || 0), answers: answers })
+        var submitData = { recordId: this.quizRecordId, memberId: parseInt(memberId || 0), answers: answers }
+        if (this.taskId) {
+          submitData.taskId = this.taskId
+        }
+        var res = await submitQuiz(submitData)
         if (res.code === 200) {
           this.quizResult = res.data || {}
           this.showQuiz = false
           this.showResult = true
-          // 有关联任务:答完题即完成打卡任务
-          if (this.taskId && memberId) {
-            try {
-              var cr = await completeTask(this.taskId, parseInt(memberId), '', '阅读+答题完成', 'text')
-              if (cr && cr.data) {
+          // 阅读打卡任务:双门槛判定由后端完成(读够时长 + 答题通过),
+          // 前端仅按返回值提示;未过题允许重新答题,过题后为 C 模式刷新进度
+          if (this.taskId) {
+            var quizPassed = this.quizResult.quizPassed === true
+            var taskCompleted = this.quizResult.taskCompleted === true
+            if (quizPassed) {
+              var mode = this.getTaskMode()
+              if (taskCompleted) {
                 uni.showToast({ title: '任务已完成', icon: 'success' })
+              } else if (mode === 'COUNT') {
+                // 模式 C:过题计数,达 N 后端自动完成;刷新本地进度展示
+                uni.showToast({ title: '答题通过,进度已更新', icon: 'success' })
+                this.refreshTaskProgress()
+              } else {
+                uni.showToast({ title: '答题通过', icon: 'success' })
               }
-            } catch (e) { /* ignore */ }
+            } else {
+              // 未过题:允许重新答题
+              this.quizResult.allowRetake = true
+              uni.showToast({ title: '未通过测试题(答对需 ≥60%),可重新答题', icon: 'none' })
+            }
           }
         }
       } catch (e) {}
     },
+    /** 模式 C:答题通过后刷新任务进度(done/target,达 N 后端自动完成) */
+    async refreshTaskProgress() {
+      var memberId = this.getActiveMemberId()
+      if (!this.taskId || !memberId) return
+      try {
+        var res = await getReadingTaskProgress(this.taskId)
+        if (res && res.code === 200 && res.data) {
+          this.taskProgress = res.data
+          if (this.taskProgress.taskCompleted === true) {
+            uni.showToast({ title: '已达目标篇数,任务完成', icon: 'success' })
+          }
+        }
+      } catch (e) {
+        // 静默失败,下次进入详情页会重新拉取
+      }
+    },
     closePoster: function() {
       this.showPoster = false
     },
@@ -432,6 +515,17 @@ export default {
     },
     closeResult: function() {
       this.showResult = false
+      this.quizResult = {}
+    },
+    /** 未过题重新答题:清空上次记录后重新生成(仅任务双门槛场景展示该按钮) */
+    retakeQuiz: function() {
+      this.showResult = false
+      this.quizResult = {}
+      this.quizRecordId = null
+      this.quizQuestions = []
+      this.quizAnswers = []
+      this.currentQuizIndex = 0
+      this.startQuiz()
     },
     selectQuizAnswer: function(qi, oi) {
       // Vue 2 中数组索引直接赋值(quizAnswers[qi] = x)不触发响应式更新,

+ 100 - 3
cfc-frontend/pages/article-center/index.vue

@@ -47,6 +47,12 @@
       </view>
     </view>
 
+    <!-- 阅读打卡任务模式 banner(B 按时长 / C 按数量进入时展示) -->
+    <view class="ac-task-banner" v-if="readMode">
+      <text class="ac-task-banner__icon">📖</text>
+      <text class="ac-task-banner__text">{{ taskBannerText }}</text>
+    </view>
+
     <!-- Tab 导航(药丸式) -->
     <view class="ac-tabs">
       <scroll-view scroll-x show-scrollbar="false" class="ac-tab-scroll">
@@ -119,6 +125,8 @@
           </view>
           <view class="ac-card-body">
             <view class="ac-card-meta-top">
+              <text class="ac-card-readflag" v-if="readMode && completedSet[item.id]">已读</text>
+              <text class="ac-card-readflag ac-card-readflag--todo" v-else-if="readMode">未读</text>
               <text class="ac-card-category" v-if="item.categoryName">{{ item.categoryName }}</text>
               <text class="ac-card-readtime">&#x1F4D6; {{ item.readTime || 3 }}分钟</text>
             </view>
@@ -157,7 +165,7 @@
 
 <script>
 import { BrandColors } from '../../utils/brand-colors.js'
-import { getArticleList, getArticleTags, getFeaturedArticles } from '@/utils/api.js'
+import { getArticleList, getArticleTags, getFeaturedArticles, getUnfinishedArticleIds } from '@/utils/api.js'
 import config from '@/config.js'
 import fontScaleMixin from '@/mixins/font-scale.js'
 export default {
@@ -181,13 +189,23 @@ export default {
       searchHistory: [],
       isLoggedIn: false,
       recommendedArticles: [],
-      recommendLoading: false
+      recommendLoading: false,
+      // 阅读打卡任务模式:mode = DURATION(按时长)/ COUNT(按数量)
+      readMode: '',
+      taskId: null,
+      completedSet: {}
     }
   },
   computed: {
     // 搜索态判定:供空态文案区分「未找到相关文章 / 暂无文章」(契约 C5)
     isSearchEmpty() {
       return !!(this.searchKeyword && this.searchKeyword.trim())
+    },
+    // 阅读打卡任务模式 banner 文案(ARCH §7.3)
+    taskBannerText() {
+      if (this.readMode === 'DURATION') return '任务模式:选一篇未完成文章阅读'
+      if (this.readMode === 'COUNT') return '任务模式:选一篇阅读并完成测试题'
+      return ''
     }
   },
   components: {
@@ -200,12 +218,26 @@ onLoad(options) {
     if (options && options.dimension) {
       this.currentTab = options.dimension
     }
+    // 阅读打卡任务模式入口(ARCH §7.3):从任务列表跳转进来带 taskId + mode
+    if (options && options.taskId) {
+      this.taskId = parseInt(options.taskId)
+    }
+    if (options && options.mode) {
+      var m = String(options.mode).toUpperCase()
+      if (m === 'DURATION' || m === 'COUNT') {
+        this.readMode = m
+      } else {
+        this.readMode = ''
+      }
+    }
     this.isLoggedIn = !!uni.getStorageSync('token')
     this.currentChildId = uni.getStorageSync('currentChildId') || null
     this.loadTags()
     this.loadArticles()
     this.loadRecommendedArticles()
     this.loadSearchHistory()
+    // 任务模式下拉取已完成文章集合,标记卡片状态
+    this.loadCompletedArticleIds()
 },
   onShow() {
     this.isLoggedIn = !!uni.getStorageSync('token')
@@ -312,7 +344,40 @@ onLoad(options) {
     },
     goDetail(idOrArticle) {
       var id = idOrArticle && idOrArticle.id ? idOrArticle.id : idOrArticle
-      uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
+      var url = ''
+      // 阅读打卡任务模式(ARCH §7.3):未完成 → 进详情并带 taskId;已完成 → B 阻止进入、C 允许进入但不计
+      if (this.readMode && this.taskId) {
+        var isDone = this.completedSet[id]
+        if (isDone && this.readMode === 'DURATION') {
+          uni.showToast({ title: '该文章已阅读,请选未完成的', icon: 'none' })
+          return
+        }
+        url = '/pages/article-center/article-detail?id=' + id + '&taskId=' + this.taskId
+        uni.navigateTo({ url: url })
+        return
+      }
+      url = '/pages/article-center/article-detail?id=' + id
+      uni.navigateTo({ url: url })
+    },
+    // 阅读打卡任务模式:拉取已完成文章 id 集合,用于卡片标记与点击分派
+    async loadCompletedArticleIds() {
+      if (!this.readMode || !this.taskId) return
+      var memberId = uni.getStorageSync('currentChildId')
+      if (!memberId) return
+      try {
+        var res = await getUnfinishedArticleIds(parseInt(memberId))
+        if (res && res.code === 200 && res.data) {
+          var ids = res.data.completedArticleIds || []
+          var set = {}
+          var i
+          for (i = 0; i < ids.length; i++) {
+            set[ids[i]] = true
+          }
+          this.completedSet = set
+        }
+      } catch (e) {
+        // 静默失败:未拉到集合时标记不展示,不影响浏览
+      }
     },
     goEdit() {
       var isLoggedIn = !!uni.getStorageSync('token')
@@ -685,6 +750,38 @@ onLoad(options) {
   color: $facade-text-ghost-light;
 }
 
+/* ---- 阅读打卡任务模式 banner ---- */
+.ac-task-banner {
+  display: flex;
+  align-items: center;
+  padding: 16rpx 28rpx;
+  background: rgba(249,115,22,0.08);
+  border-bottom: 1rpx solid rgba(249,115,22,0.2);
+}
+.ac-task-banner__icon {
+  font-size: calc(28rpx * var(--font-scale, 1));
+  margin-right: 12rpx;
+}
+.ac-task-banner__text {
+  font-size: calc(26rpx * var(--font-scale, 1));
+  color: $brand-primary;
+  font-weight: var(--font-weight-medium, 500);
+}
+
+/* ---- 文章卡片阅读状态标记 ---- */
+.ac-card-readflag {
+  font-size: calc(18rpx * var(--font-scale, 1));
+  padding: 2rpx 14rpx;
+  border-radius: 12rpx;
+  margin-right: 12rpx;
+  font-weight: 500;
+}
+.ac-card-readflag--todo {
+  background: rgba(34,197,94,0.08);
+  color: $status-success-2;
+  border: 1rpx solid rgba(34,197,94,0.2);
+}
+
 /* ---- 文章卡片(新版) ---- */
 .ac-feed {
   padding: 24rpx 28rpx;

+ 67 - 2
cfc-frontend/pages/child/tasks.vue

@@ -71,6 +71,10 @@
                   ⏰ 已超时{{ getOverdueDays(task) }}
                 </text>
               </view>
+              <!-- 阅读打卡 C(按数量)模式:显示已读进度 -->
+              <view class="task-read-progress" v-if="isReadCountTask(task)">
+                <text class="task-read-progress__text">{{ getReadProgressText(task) }}</text>
+              </view>
             </view>
 
             <!-- 右侧操作 -->
@@ -125,7 +129,7 @@ import PlayfulButton from '@/components/PlayfulButton.vue'
 import BaseBadge from '@/components/BaseBadge.vue'
 import BaseEmpty from '@/components/BaseEmpty.vue'
 import BaseLoading from '@/components/BaseLoading.vue'
-import { getTodayTasks, completeTask as completeTaskApi, getChildren, switchBackToParent, verifyPassword } from '../../utils/api.js'
+import { getTodayTasks, completeTask as completeTaskApi, getChildren, switchBackToParent, verifyPassword, getReadingTaskProgress } from '../../utils/api.js'
 import { parseDate } from '../../utils/format.js'
 import fontScaleMixin from '@/mixins/font-scale.js'
 
@@ -139,7 +143,9 @@ export default {
       isSwitchedChild: false,
       loading: false,
       activeTab: 'pending',
-      completingTaskId: null
+      completingTaskId: null,
+      // 阅读打卡 C(按数量)模式进度:taskId -> { done, target }
+      progressMap: {}
     }
   },
   computed: {
@@ -240,6 +246,8 @@ export default {
         this.currentChildId = currentChild.id
         res = await getTodayTasks(currentChild.id)
         this.tasks = res.data || []
+        // 阅读打卡 C(按数量)模式:批量拉取进度
+        this.loadReadProgress()
       } catch (e) {
         console.error('加载成员任务失败', e)
       } finally {
@@ -309,6 +317,12 @@ export default {
         return true
       }
       if (at === 'article') {
+        // 阅读打卡三模式(ARCH §7.2):A 指定文章 → 文章详情;B 按时长 / C 按数量 → 文章中心选未完成文章
+        var readMode = cfg.mode || 'ARTICLE'
+        if (readMode === 'DURATION' || readMode === 'COUNT') {
+          uni.navigateTo({ url: '/pages/article-center/index?taskId=' + taskId + '&mode=' + readMode })
+          return true
+        }
         var articleId = cfg.articleId || task.sourceId
         uni.navigateTo({ url: '/pages/article-center/article-detail?taskId=' + taskId + (articleId ? '&id=' + articleId : '') })
         return true
@@ -353,6 +367,42 @@ export default {
       if (at === 'diet' || at === 'sleep' || at === 'exercise') return '✅ 去打卡'
       return '✅ 完成了!'
     },
+    /** 是否为阅读打卡 C(按数量)模式任务 */
+    isReadCountTask(task) {
+      if (task.actionType !== 'article') return false
+      var cfg = {}
+      try { cfg = typeof task.actionConfig === 'string' ? JSON.parse(task.actionConfig || '{}') : (task.actionConfig || {}) } catch (e) {}
+      return cfg.mode === 'COUNT'
+    },
+    /** C 模式进度文案:已读 done/target 篇 */
+    getReadProgressText(task) {
+      var p = this.progressMap[task.id]
+      if (!p) return '已读 0/' + ((this.getReadTarget(task)) || 1) + ' 篇'
+      return '已读 ' + (p.done || 0) + '/' + (p.target || 1) + ' 篇'
+    },
+    getReadTarget(task) {
+      var cfg = {}
+      try { cfg = typeof task.actionConfig === 'string' ? JSON.parse(task.actionConfig || '{}') : (task.actionConfig || {}) } catch (e) {}
+      return cfg.targetCount || 1
+    },
+    /** 批量拉取 C 模式任务进度(接口按 taskId 查询) */
+    async loadReadProgress() {
+      var i, task, p
+      var ids = []
+      for (i = 0; i < this.tasks.length; i++) {
+        task = this.tasks[i]
+        if (this.isReadCountTask(task)) ids.push(task.id)
+      }
+      if (ids.length === 0) return
+      var map = {}
+      for (i = 0; i < ids.length; i++) {
+        try {
+          p = await getReadingTaskProgress(ids[i])
+          if (p && p.code === 200 && p.data) map[ids[i]] = p.data
+        } catch (e) {}
+      }
+      this.progressMap = map
+    },
     getCategoryIcon(category) {
       var icons = {
         '学习类': '📚',
@@ -701,6 +751,21 @@ export default {
   font-weight: var(--font-weight-medium, 500);
 }
 
+/* 阅读打卡 C(按数量)模式进度 */
+.task-read-progress {
+  margin-top: 8rpx;
+  padding: 4rpx 16rpx;
+  border-radius: 16rpx;
+  background: rgba(249,115,22,0.08);
+  align-self: flex-start;
+}
+.task-read-progress__text {
+  font-size: calc(20rpx * var(--font-scale, 1));
+  color: $brand-primary;
+  font-weight: var(--font-weight-medium, 500);
+  line-height: 1.4;
+}
+
 /* =============================================
    右侧操作区
    ============================================= */

+ 195 - 2
cfc-frontend/pages/tasks/create-task.vue

@@ -87,6 +87,58 @@
 <text class="form-hint">购物任务:点开始自动加购并跳转购物车</text>
 </view>
 
+<!-- 阅读打卡:三模式配置(指定文章 / 按时长 / 按数量) -->
+<view class="form-item" v-if="form.actionType === 'article'">
+<text class="label">阅读模式</text>
+<radio-group class="read-mode-group" @change="onReadModeChange">
+<label class="read-mode-item" v-for="mode in readModes" :key="mode.value">
+<radio :value="mode.value" :checked="readMode === mode.value" color="#f97316" />
+<text class="read-mode-label">{{ mode.label }}</text>
+</label>
+</radio-group>
+<text class="form-hint">选择「阅读打卡」任务的完成判定方式</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode === 'ARTICLE'">
+<text class="label">指定文章</text>
+<picker :range="articleNames" @change="onArticleChange">
+<view class="picker">
+{{ articleLoading ? '加载中...' : (selectedArticleName || '请选择文章') }}
+</view>
+</picker>
+<text class="form-hint">孩子需读完指定文章并答对测试题(通过率 {{ readQuizPassRate }}%)才算完成任务</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode !== 'COUNT'">
+<text class="label">阅读时长(分钟)</text>
+<input class="input" type="number" v-model="readMinutes" placeholder="请输入阅读时长,默认 5 分钟" />
+<text class="form-hint">孩子需累计阅读满该时长才算达标(按秒累计,后端计时)</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode === 'COUNT'">
+<text class="label">阅读篇数(N)</text>
+<input class="input" type="number" v-model="readTargetCount" placeholder="请输入需完成文章篇数,默认 1" />
+<text class="form-hint">孩子每完成一篇(阅读+答题通过)累计 1 篇,达 N 篇自动完成任务</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode === 'COUNT'">
+<text class="label">每日进度</text>
+<switch :checked="readIsDailyProgress" @change="onReadIsDailyProgressChange" />
+<text class="form-hint">开启后按「每天完成 N 篇」判定;关闭后为一次性累计 N 篇</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode === 'COUNT'">
+<text class="label">每篇需答题通过</text>
+<switch :checked="readRequireQuiz" @change="onReadRequireQuizChange" />
+<text class="form-hint">开启后每篇文章需答题通过才计入进度</text>
+</view>
+
+<view class="form-item" v-if="form.actionType === 'article' && readMode !== 'DURATION' && (readMode !== 'COUNT' || readRequireQuiz)">
+<text class="label">答题通过率(%)</text>
+<input class="input" type="number" v-model="readQuizPassRate" placeholder="默认 60" />
+<text class="form-hint">答题正确率需 ≥ 该比例才算通过,默认 60%</text>
+</view>
+
 <view class="form-item">
 <text class="label">需先开始再完成(两阶段)</text>
 <switch :checked="form.startRequired" @change="onStartRequiredChange" />
@@ -145,7 +197,7 @@
 
 <script>
 import config from '@/config.js'
-import { getChildren, createTask, getTaskListForPicker } from '../../utils/api.js'
+import { getChildren, createTask, getTaskListForPicker, getArticleList } from '../../utils/api.js'
 import fontScaleMixin from '@/mixins/font-scale.js'
 
 export default {
@@ -177,6 +229,21 @@ return {
         selectedMinigame: null,
         prerequisiteTaskList: [],
         successorTaskList: [],
+        // 阅读打卡三模式(ARCH §7.1 / API_REFERENCE §4.12,mode 常量大写)
+        readModes: [
+          { value: 'ARTICLE', label: '指定文章' },
+          { value: 'DURATION', label: '按时长' },
+          { value: 'COUNT', label: '按数量' }
+        ],
+        readMode: 'DURATION',
+        articleOptions: [],
+        articleLoading: false,
+        selectedArticleIndex: -1,
+        readMinutes: 5,
+        readTargetCount: 1,
+        readRequireQuiz: true,
+        readQuizPassRate: 60,
+        readIsDailyProgress: false,
 repeatTypes: [
 { value: 'none', label: '不重复' },
 { value: 'daily', label: '每天' },
@@ -211,6 +278,22 @@ return found ? found.label : ''
 actionTypeLabel() {
 const found = this.actionTypes.find(a => a.value === this.form.actionType)
 return found ? found.label : ''
+},
+// 文章选择器 range(标题 + 可读时长标注,禁用 :key 表达式,用方法取值)
+articleNames() {
+  var list = []
+  var a, i
+  for (i = 0; i < this.articleOptions.length; i++) {
+    a = this.articleOptions[i]
+    list.push((a.title || '未命名文章') + (a.readTime ? '(' + a.readTime + '分钟)' : ''))
+  }
+  return list
+},
+selectedArticleName() {
+  if (this.selectedArticleIndex >= 0 && this.articleOptions[this.selectedArticleIndex]) {
+    return this.articleNames[this.selectedArticleIndex]
+  }
+  return ''
 }
 },
   onLoad(options) {
@@ -369,6 +452,46 @@ this.form.actionType = selected.value
 if (selected.value !== 'cart' && selected.value !== 'order') {
 this.form.actionConfig = ''
 }
+// 阅读打卡:切换为文章模式时预加载文章列表
+if (selected.value === 'article') {
+  this.readMode = 'DURATION'
+  this.selectedArticleIndex = -1
+  if (this.articleOptions.length === 0) {
+    this.loadArticles()
+  }
+}
+},
+// 阅读打卡三模式切换
+onReadModeChange(e) {
+  this.readMode = e.detail.value || 'DURATION'
+  // 进入指定文章模式时按需加载文章列表
+  if (this.readMode === 'ARTICLE' && this.articleOptions.length === 0) {
+    this.loadArticles()
+  }
+},
+// 文章选择器
+onArticleChange(e) {
+  this.selectedArticleIndex = parseInt(e.detail.value) || 0
+},
+onReadRequireQuizChange(e) {
+  this.readRequireQuiz = e.detail.value
+},
+onReadIsDailyProgressChange(e) {
+  this.readIsDailyProgress = e.detail.value
+},
+async loadArticles() {
+  if (this.articleLoading) return
+  this.articleLoading = true
+  try {
+    var res = await getArticleList({ page: 1, size: 50 })
+    if (res && res.code === 200 && res.data) {
+      this.articleOptions = res.data.records || res.data.list || []
+    }
+  } catch (e) {
+    uni.showToast({ title: '文章列表加载失败', icon: 'none' })
+  } finally {
+    this.articleLoading = false
+  }
 },
 onStartRequiredChange(e) {
     this.form.startRequired = e.detail.value
@@ -405,6 +528,53 @@ onStartRequiredChange(e) {
     } else {
       this.form.successorTaskIds.push(taskId)
     }
+  },
+  // 阅读打卡:校验并拼装 action_config JSON(键名 camelCase,与 T01 契约一致)
+  buildArticleActionConfig() {
+    var mode = this.readMode || 'DURATION'
+    var cfg = { mode: mode }
+    var minutes = parseInt(this.readMinutes) || 5
+    if (minutes <= 0) {
+      uni.showToast({ title: '请输入有效阅读时长', icon: 'none' })
+      return null
+    }
+    var minSeconds = minutes * 60
+    if (mode === 'ARTICLE') {
+      // 指定文章:articleId 必填;requireQuiz 固定 true;quizPassRate A 可配(默认 60%)
+      var article = this.articleOptions[this.selectedArticleIndex]
+      if (!article || !article.id) {
+        uni.showToast({ title: '请选择文章', icon: 'none' })
+        return null
+      }
+      cfg.articleId = article.id
+      cfg.minSeconds = minSeconds
+      cfg.requireQuiz = true
+      cfg.quizPassRate = this.normalizeQuizPassRate()
+    } else if (mode === 'DURATION') {
+      // 按时长:仅 minSeconds 单门槛(不要求答题)
+      cfg.minSeconds = minSeconds
+      cfg.requireQuiz = false
+    } else {
+      // 按数量:targetCount=N;requireQuiz 可配;达 N 后端自动完成
+      var targetCount = parseInt(this.readTargetCount) || 0
+      if (targetCount <= 0) {
+        uni.showToast({ title: '请输入有效阅读篇数', icon: 'none' })
+        return null
+      }
+      cfg.targetCount = targetCount
+      cfg.requireQuiz = !!this.readRequireQuiz
+      if (cfg.requireQuiz) {
+        cfg.quizPassRate = this.normalizeQuizPassRate()
+      }
+    }
+    return JSON.stringify(cfg)
+  },
+  // 通过率输入(百分比 0-100)→ 0-1 比例(契约口径:>0 且 ≤1,默认 0.6)
+  normalizeQuizPassRate() {
+    var rate = parseInt(this.readQuizPassRate)
+    if (!rate || rate <= 0) return 0.6
+    if (rate > 100) rate = 100
+    return Math.round((rate / 100) * 100) / 100
   },
     async submit() {
       if (this.submitting) return
@@ -426,6 +596,13 @@ onStartRequiredChange(e) {
         return
       }
 
+      // 阅读打卡:按 mode 拼装 action_config(失败时提示并中止)
+      var articleActionConfig = ''
+      if (this.form.actionType === 'article') {
+        articleActionConfig = this.buildArticleActionConfig()
+        if (!articleActionConfig) return
+      }
+
       this.submitting = true
       uni.showLoading({ title: '创建任务中...' })
       const taskData = {
@@ -441,13 +618,25 @@ onStartRequiredChange(e) {
         duration: parseInt(this.form.duration) || 0,
         // TASK-SYS-248: 行为调度中心字段
         actionType: this.form.actionType || '',
-        actionConfig: this.form.actionConfig || '',
+        actionConfig: this.form.actionType === 'article' ? articleActionConfig : (this.form.actionConfig || ''),
         requireInput: this.form.requireInput ? 1 : 0,
         startRequired: this.form.startRequired ? 1 : 0,
         prerequisiteTaskId: this.form.prerequisiteTaskIds.length > 0 ? this.form.prerequisiteTaskIds[0] : null,
         successorTaskIds: this.form.successorTaskIds.length > 0 ? this.form.successorTaskIds : null
       }
 
+      // 阅读打卡:A/B 模式同步 duration(分钟)为阅读时长;C 每日型传 isDailyProgress/targetValue=N
+      if (this.form.actionType === 'article') {
+        var readMinutes = parseInt(this.readMinutes) || 5
+        if (this.readMode === 'ARTICLE' || this.readMode === 'DURATION') {
+          taskData.duration = readMinutes
+        }
+        if (this.readMode === 'COUNT' && this.readIsDailyProgress) {
+          taskData.isDailyProgress = 1
+          taskData.targetValue = parseInt(this.readTargetCount) || 1
+        }
+      }
+
       let successCount = 0
       let failCount = 0
       try {
@@ -494,6 +683,10 @@ onStartRequiredChange(e) {
 .picker { border: 1rpx solid $facade-border-soft; border-radius: 8rpx; font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-body; box-sizing: border-box; height: 108rpx; display: flex; align-items: center; padding: 0 24rpx; }
 .form-hint { display: block; font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-muted; margin-top: 8rpx; }
 .form-hint--tight { margin-bottom: 10rpx; }
+/* 阅读打卡三模式:横向三选一 */
+.read-mode-group { display: flex; flex-direction: row; flex-wrap: wrap; gap: 20rpx; margin: 8rpx 0; }
+.read-mode-item { display: flex; flex-direction: row; align-items: center; gap: 6rpx; padding: 8rpx 0; }
+.read-mode-label { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-body; }
 .child-checkbox { display: flex; align-items: center; padding: 16rpx 0; border-bottom: 1rpx solid $facade-fill; }
 .child-checkbox:last-child { border-bottom: none; }
 .child-name { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-strong; margin-left: 10rpx; }

+ 6 - 0
cfc-frontend/pages/tasks/tasks.vue

@@ -583,6 +583,12 @@ export default {
       } else if (at === 'article') {
         var cfg = {}
         try { cfg = typeof task.actionConfig === 'string' ? JSON.parse(task.actionConfig || '{}') : (task.actionConfig || {}) } catch (e) {}
+        // 阅读打卡三模式(ARCH §7.2):A 指定文章 → 文章详情;B 按时长 / C 按数量 → 文章中心选未完成文章
+        var readMode = cfg.mode || 'ARTICLE'
+        if (readMode === 'DURATION' || readMode === 'COUNT') {
+          uni.navigateTo({ url: '/pages/article-center/index?taskId=' + taskId + '&mode=' + readMode })
+          return
+        }
         var articleId = cfg.articleId || task.sourceId
         uni.navigateTo({ url: '/pages/article-center/article-detail?taskId=' + taskId + (articleId ? '&id=' + articleId : '') })
       } else if (at === 'activity') {

+ 5 - 0
cfc-frontend/utils/api.js

@@ -2037,6 +2037,11 @@ export const completeArticleRead = (data) => request('/api/articles/complete-rea
 // AI答题
 export const generateQuiz = (data) => request('/api/articles/quiz/generate', 'POST', data)
 export const submitQuiz = (data) => request('/api/articles/quiz/submit', 'POST', data)
+// 阅读打卡任务(T01 契约登记见 API_REFERENCE §4.12)
+// 查询阅读任务进度:data { mode(ARTICLE/DURATION/COUNT), done, target, quizPassed, readingCompleted, minSeconds, articleId }
+export const getReadingTaskProgress = (taskId) => request('/api/articles/reading-task/progress', 'POST', { taskId })
+// 查询已完成文章 id 集合:data { completedArticleIds: [..], total: n }
+export const getUnfinishedArticleIds = (memberId) => request('/api/articles/unfinished-ids', 'POST', { memberId })
 
 // ===== EMI蹇冪悊鎶ュ憡 =====
 export const getEmiReport = (memberId) => request('/api/emireport/latest', 'POST', { memberId })