1. 调整页面路由,将业务页面迁移到对应分包,主包仅保留首页 2. 拆分公共服务模块,将账户、融资相关逻辑移入对应分包 3. 统一资源路径,将专属静态资源放入各分包static目录,更新导航栏图标资源 4. 修复启动引导逻辑,实现仅首次冷启动显示引导页 5. 更新README文档,补充分包配置与开发规范说明
113 lines
7.4 KiB
Plaintext
113 lines
7.4 KiB
Plaintext
<template>
|
|
<view class="page" :style="pageStyle()">
|
|
<AppHeader title="课程详情" />
|
|
<scroll-view scroll-y :scroll-into-view="scrollTarget" :style="contentStyle(96, false)">
|
|
<view v-if="available" class="lesson-detail-content">
|
|
<image class="lesson-cover" :src="lesson.image" mode="aspectFill"></image>
|
|
<text class="lesson-detail-title">{{ lesson.title }}</text>
|
|
<view class="lesson-detail-meta"><text class="lesson-tag">{{ lesson.tag }}</text><text class="lesson-duration">{{ lesson.duration }} · {{ lesson.chapters.length }} 节图文</text></view>
|
|
<text class="lesson-intro">{{ lesson.intro }}</text>
|
|
<view class="progress-head"><text class="progress-label">学习进度</text><text class="progress-value">已完成 {{ completedCount }}/{{ lesson.chapters.length }} 节</text></view>
|
|
<view class="lesson-progress"><view class="progress-fill" :style="'width:' + progress + '%;'"></view></view>
|
|
<button class="primary-button start-learning" @click="start">{{ completedCount == 0 ? '开始学习' : (completedCount == lesson.chapters.length ? '回顾课程' : '继续学习') }}</button>
|
|
<text class="chapter-heading">课程目录</text>
|
|
<view class="chapter-card" v-for="(item, index) in lesson.chapters" :key="item.title" :id="'chapter-' + index">
|
|
<view class="chapter-row" @click="toggleChapter(index)">
|
|
<view :class="completed[index] ? 'chapter-index completed-index' : 'chapter-index'"><text :class="completed[index] ? 'index-text completed-text' : 'index-text'">{{ index + 1 }}</text></view>
|
|
<view class="chapter-copy"><text class="chapter-title">{{ item.title }}</text><text :class="completed[index] ? 'chapter-state completed-state' : 'chapter-state'">{{ completed[index] ? '已完成 · 可再次阅读' : '点击展开阅读' }}</text></view>
|
|
<AppIcon name="chevron-right" :size="28" :class="activeIndex == index ? 'chapter-arrow open-arrow' : 'chapter-arrow'" muted />
|
|
</view>
|
|
<view v-if="activeIndex == index" class="chapter-content">
|
|
<text class="chapter-body">{{ item.body }}</text>
|
|
<button :class="completed[index] ? 'chapter-done chapter-already-done' : 'chapter-done'" :disabled="completed[index]" @click="completeChapter(index)">{{ completed[index] ? '本节已完成' : '我已读完,完成本节' }}</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="empty-content"><text class="empty-title">暂未找到这门课程</text><text class="empty-copy">返回融资课堂,选择其他课程。</text><button class="primary-button empty-button" @click="goClassroom">返回课堂</button></view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { usePageLayout } from '@/services/layout.uts'
|
|
import { financeLessons, findFinanceLesson, FinanceLesson } from '@/packages/content/services/content.uts'
|
|
import AppHeader from '@/components/AppHeader.uvue'
|
|
import AppIcon from '@/components/AppIcon.uvue'
|
|
const { contentStyle, pageStyle } = usePageLayout()
|
|
const lesson = ref<FinanceLesson>(financeLessons[0])
|
|
const available = ref(true)
|
|
const completed = ref<boolean[]>([])
|
|
const activeIndex = ref(-1)
|
|
const scrollTarget = ref('')
|
|
const storageKey = (index: number): string => 'finance.lesson.' + lesson.value.id + '.chapter.' + index
|
|
const restoreProgress = (): void => {
|
|
completed.value = lesson.value.chapters.map((_item, index): boolean => uni.getStorageSync(storageKey(index)) == true)
|
|
}
|
|
const completedCount = computed((): number => completed.value.filter((value: boolean): boolean => value).length)
|
|
const progress = computed((): number => Math.round(completedCount.value * 100 / lesson.value.chapters.length))
|
|
onLoad((options) => {
|
|
if (options != null) {
|
|
const id = options['id'] == null ? '' : options['id'] as string
|
|
const legacyTitle = options['title'] == null ? '' : options['title'] as string
|
|
if (id != '' || legacyTitle != '') {
|
|
const selected = findFinanceLesson(id, legacyTitle)
|
|
available.value = selected != null
|
|
if (selected != null) lesson.value = selected
|
|
}
|
|
}
|
|
restoreProgress()
|
|
})
|
|
const toggleChapter = (index: number): void => { activeIndex.value = activeIndex.value == index ? -1 : index }
|
|
const completeChapter = (index: number): void => {
|
|
uni.setStorageSync(storageKey(index), true)
|
|
const next = completed.value.slice()
|
|
next[index] = true
|
|
completed.value = next
|
|
}
|
|
const start = (): void => {
|
|
let nextIndex = completed.value.findIndex((value: boolean): boolean => !value)
|
|
if (nextIndex < 0) nextIndex = 0
|
|
activeIndex.value = nextIndex
|
|
scrollTarget.value = ''
|
|
nextTick(() => { scrollTarget.value = 'chapter-' + nextIndex })
|
|
}
|
|
const goClassroom = (): void => { uni.redirectTo({ url: '/packages/content/classroom/classroom' }) }
|
|
</script>
|
|
|
|
<style>
|
|
.lesson-detail-content { padding: 24rpx 28rpx 48rpx; }
|
|
.lesson-cover { width: 100%; height: 260rpx; border-radius: 18rpx; }
|
|
.lesson-detail-title { color: #172640; font-size: 36rpx; line-height: 50rpx; font-weight: 700; margin-top: 24rpx; }
|
|
.lesson-detail-meta { flex-direction: row; justify-content: space-between; align-items: center; margin-top: 14rpx; }
|
|
.lesson-tag { color: #0868f7; font-size: 24rpx; }
|
|
.lesson-duration { color: #66758a; font-size: 23rpx; }
|
|
.lesson-intro { color: #66758a; font-size: 26rpx; line-height: 44rpx; margin-top: 22rpx; }
|
|
.progress-head { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 26rpx; }
|
|
.progress-label { color: #172640; font-size: 24rpx; font-weight: 600; }
|
|
.progress-value { color: #0868f7; font-size: 23rpx; }
|
|
.lesson-progress { height: 10rpx; margin-top: 12rpx; border-radius: 6rpx; background-color: #e1eafa; overflow: hidden; }
|
|
.progress-fill { height: 100%; border-radius: 6rpx; background-color: #0868f7; }
|
|
.start-learning { margin-top: 24rpx; }
|
|
.chapter-heading { color: #172640; font-size: 30rpx; font-weight: 700; margin-top: 32rpx; margin-bottom: 14rpx; }
|
|
.chapter-card { border: 1rpx solid #e5ecf5; background-color: #ffffff; border-radius: 16rpx; margin-bottom: 14rpx; overflow: hidden; }
|
|
.chapter-row { min-height: 116rpx; padding: 20rpx; flex-direction: row; align-items: center; }
|
|
.chapter-index { width: 48rpx; height: 48rpx; border-radius: 14rpx; background-color: #eaf2ff; align-items: center; justify-content: center; margin-right: 16rpx; flex-shrink: 0; }
|
|
.index-text { color: #0868f7; font-size: 24rpx; font-weight: 700; }
|
|
.completed-index { background-color: #eaf7ef; }
|
|
.completed-text { color: #168454; }
|
|
.chapter-copy { flex: 1; padding-right: 8rpx; }
|
|
.chapter-title { color: #172640; font-size: 28rpx; line-height: 40rpx; font-weight: 600; }
|
|
.chapter-state { color: #66758a; font-size: 22rpx; margin-top: 6rpx; }
|
|
.completed-state { color: #168454; }
|
|
.chapter-arrow { transform: rotate(90deg); }
|
|
.open-arrow { transform: rotate(-90deg); }
|
|
.chapter-content { padding: 0 22rpx 24rpx; }
|
|
.chapter-body { color: #4d5e75; font-size: 27rpx; line-height: 48rpx; border-top: 1rpx solid #e8eef6; padding-top: 22rpx; }
|
|
.chapter-done { margin-top: 24rpx; width: 100%; height: 80rpx; line-height: 80rpx; border-radius: 12rpx; background-color: #eaf2ff; color: #0868f7; font-size: 26rpx; font-weight: 600; }
|
|
.chapter-already-done { color: #168454; background-color: #edf8f1; }
|
|
.empty-content { padding: 100rpx 40rpx; align-items: center; }
|
|
.empty-title { color: #172640; font-size: 32rpx; font-weight: 700; }
|
|
.empty-copy { color: #66758a; font-size: 26rpx; margin-top: 20rpx; }
|
|
.empty-button { width: 100%; margin-top: 38rpx; }
|
|
</style>
|