|
|
@@ -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; }
|