article-detail.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="detail-container" :style="{ '--font-scale': fontScale }">
  3. <!-- 登录浮层(全局组件,页面内弹出底部登录) -->
  4. <login-sheet ref="loginSheet" @success="onSheetLoginSuccess" />
  5. <view v-if="loading" class="loading-wrap">
  6. <view class="loading-spinner"></view>
  7. <text class="loading-text">加载中...</text>
  8. </view>
  9. <view v-else-if="error" class="error-wrap">
  10. <text class="error-icon">📄</text>
  11. <text class="error-text">{{ errorMsg }}</text>
  12. <button class="retry-btn" @click="loadDetail(articleId)">重新加载</button>
  13. </view>
  14. <template v-else-if="article">
  15. <scroll-view scroll-y class="content-scroll" @scrolltolower="onScrollToBottom">
  16. <image v-if="article.coverImage" class="detail-cover" :src="article.coverImage" mode="widthFix" />
  17. <text class="detail-title">{{ article.title }}</text>
  18. <view class="detail-meta">
  19. <text class="meta-author">{{ article.author || '浠艾福' }}</text>
  20. <text class="meta-sep">|</text>
  21. <text class="meta-date">{{ formatDate(article.publishedAt) }}</text>
  22. <text class="meta-sep">|</text>
  23. <text class="meta-readtime">{{ article.readTime || 3 }}分钟阅读</text>
  24. <text class="reading-time-badge" v-if="isLogin && !readingCompleted">{{ formatReadingTime(readingSeconds) }}</text>
  25. <text class="reading-time-badge completed" v-else-if="isLogin && readingCompleted">✅ 阅读完成</text>
  26. <text class="meta-sep" v-if="isLogin">|</text>
  27. <text class="meta-readcount">{{ article.viewCount || 0 }}人阅读</text>
  28. </view>
  29. <view class="detail-category-row">
  30. <text class="detail-category">{{ article.categoryName || '' }}</text>
  31. </view>
  32. <view v-if="article.relatedDimensions" class="detail-dimensions">
  33. <view v-for="dim in parseDimensions(article)" :key="dim.code" class="dim-bar-item">
  34. <view class="dim-bar" :style="{ background: dim.color, width: dim.weight + '%' }"></view>
  35. <text class="dim-label">{{ dim.name }}</text>
  36. </view>
  37. </view>
  38. <view class="detail-summary" v-if="article.summary">
  39. <text class="detail-summary-text">{{ article.summary }}</text>
  40. </view>
  41. <view class="divider"></view>
  42. <view class="detail-body"><mp-html :content="article.content" :domain="config.API_BASE_URL" :tag-style="contentTagStyle" /></view>
  43. <!-- 关联商品推荐(文章标签 ↔ 商品标签匹配,登录/匿名均可返回) -->
  44. <view v-if="relatedProducts.length > 0" class="related-section">
  45. <view class="related-header">
  46. <text class="related-title">相关商品</text>
  47. <text class="related-subtitle">根据文章内容推荐</text>
  48. </view>
  49. <dimension-products :products="relatedProducts" @productClick="goRelatedProduct" />
  50. </view>
  51. <!-- 评论区(已屏蔽) -->
  52. <view style="height: 200rpx;"></view>
  53. </scroll-view>
  54. <!-- 底部 -->
  55. <view class="detail-footer">
  56. <view v-if="isLogin" class="listen-btn" :class="{ playing: audioPlaying }" @click="toggleArticleAudio">
  57. <text class="listen-btn-icon">{{ audioLoading ? '⏳' : (audioPlaying ? '⏸' : '🔊') }}</text>
  58. <text class="listen-btn-text">{{ audioLoading ? '生成中' : (audioPlaying ? '停止' : '听文章') }}</text>
  59. </view>
  60. <view class="share-btn" @click="generatePoster">
  61. <text class="share-btn-icon">🖼</text>
  62. <text class="share-btn-text">生成海报</text>
  63. </view>
  64. </view>
  65. </template>
  66. <ContentSharePoster :show="showPoster" :title="(article && article.title) || ''" :coverImage="(article && article.coverImage) || ''" :qrCodeBase64="posterQrCode || ''" typeLabel="好文推荐" :dimensionCode="posterDimension || ''" :summary="posterSummary || ''" :inviteText="posterInviteText || ''" @close="closePoster" />
  67. <!-- 浠宝答题弹窗(一题一页) -->
  68. <view class="quiz-mask" v-if="showQuiz" @click="closeQuiz">
  69. <view class="quiz-dialog" @click.stop>
  70. <view class="quiz-mascot">
  71. <text class="mascot-icon">{{ mascotIcon }}</text>
  72. <text class="mascot-name">{{ mascotName }}</text>
  73. </view>
  74. <template v-if="currentQuestion">
  75. <view class="quiz-step-bar">
  76. <text class="quiz-step-text">第 {{ currentQuizIndex + 1 }} / {{ quizQuestions.length }} 题</text>
  77. <view class="quiz-dots">
  78. <view v-for="(q, qi) in quizQuestions" :key="qi" class="quiz-dot" :class="{ active: qi === currentQuizIndex, done: quizAnswers[qi] }"></view>
  79. </view>
  80. </view>
  81. <text class="q-title">{{ currentQuestion.question }}</text>
  82. <view class="q-options">
  83. <text v-for="(opt, oi) in currentQuestion.options" :key="oi" class="q-option" :class="{ selected: quizAnswers[currentQuizIndex] === String.fromCharCode(65 + oi) }" @click="selectQuizAnswer(currentQuizIndex, oi)">{{ opt }}</text>
  84. </view>
  85. <view class="quiz-nav">
  86. <button v-if="currentQuizIndex > 0" class="quiz-prev" @click="goPrevQuestion">上一题</button>
  87. <button v-if="currentQuizIndex < quizQuestions.length - 1" class="quiz-submit" @click="goNextQuestion">下一题</button>
  88. <button v-else class="quiz-submit" @click="submitQuiz">提交答案</button>
  89. </view>
  90. </template>
  91. </view>
  92. </view>
  93. <!-- 答题结果 -->
  94. <view class="result-mask" v-if="showResult">
  95. <view class="result-dialog">
  96. <text class="result-icon">{{ resultIcon }}</text>
  97. <text class="result-text">答对 {{ quizResult.correctCount }}/{{ quizResult.totalQuestions }} 题</text>
  98. <text class="result-energy">获得 {{ quizResult.cfEarned }} CF值 + {{ quizResult.energyEarned }} 能量 ⚡</text>
  99. <button class="result-btn" @click="closeResult">知道了</button>
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import { getArticleDetail, getArticleAudio, getArticleRelatedProducts, reportReadingTime, getShareQrCode, completeArticleRead, generateQuiz, submitQuiz } from '@/utils/api.js'
  106. import shareMixin from '../../components/share-mixin.js'
  107. import ContentSharePoster from '@/components/ContentSharePoster.vue'
  108. import DimensionProducts from '@/components/DimensionProducts.vue'
  109. import MpHtml from '@/components/mp-html/mp-html.vue'
  110. import config from '@/config.js'
  111. import { getFontScale } from '@/utils/fontScale.js'
  112. export default {
  113. mixins: [shareMixin],
  114. components: { ContentSharePoster, DimensionProducts, MpHtml },
  115. data() {
  116. return {
  117. articleId: '', article: null, loading: true, error: false, errorMsg: '',
  118. relatedProducts: [],
  119. readingSeconds: 0, lastReportedSeconds: 0, readingCompleted: false,
  120. isTimerRunning: false, timerHandle: null, syncHandle: null,
  121. currentChildId: null, isLogin: false,
  122. // 听文章(AI 朗读)
  123. audioUrls: [], audioPlaying: false, audioLoading: false, audioContext: null, audioChunkIndex: 0,
  124. showPoster: false, posterQrCode: '',
  125. posterDimension: '', posterSummary: '', posterInviteText: '',
  126. fontScale: 1,
  127. // 答题
  128. showQuiz: false, quizQuestions: [], quizAnswers: [], showResult: false, quizResult: {}, quizRecordId: null, currentQuizIndex: 0,
  129. mascotList: [{ icon: '🐶', name: '浠宝' }, { icon: '🐼', name: '福宝' }],
  130. mascotIcon: '🐶', mascotName: '浠宝'
  131. }
  132. },
  133. computed: {
  134. contentTagStyle() {
  135. var scale = this.fontScale || 1
  136. var fontSize = 32 * scale
  137. return { p: 'font-size:' + fontSize + 'rpx;color:#444;line-height:1.8;', div: 'font-size:' + fontSize + 'rpx;color:#444;line-height:1.8;', section: 'font-size:' + fontSize + 'rpx;color:#444;line-height:1.8;', li: 'font-size:' + fontSize + 'rpx;color:#444;line-height:1.8;', blockquote: 'font-size:' + fontSize + 'rpx;color:#444;line-height:1.8;' }
  138. },
  139. // 当前展示的一题(一题一页)
  140. currentQuestion: function() {
  141. if (!this.quizQuestions || !this.quizQuestions.length) return null
  142. return this.quizQuestions[this.currentQuizIndex] || null
  143. }
  144. },
  145. onLoad(options) {
  146. this.mascotIcon = this.mascotList[Math.floor(Math.random() * 2)].icon
  147. this.mascotName = this.mascotList[Math.floor(Math.random() * 2)].name
  148. // 兼容旧分享链接:refCode / inviteCode 参数(shareMixin onLoad 也会处理,此处显式兜底)
  149. if (options && (options.refCode || options.inviteCode)) {
  150. this.autoBindInviteCode(options.refCode || options.inviteCode)
  151. }
  152. var aid = ''
  153. if (options && options.id) {
  154. aid = options.id
  155. } else if (options && options.scene) {
  156. try {
  157. var sceneDecoded = decodeURIComponent(options.scene)
  158. var idMatch = sceneDecoded.match(/id=(\d+)/)
  159. if (idMatch && idMatch[1]) aid = idMatch[1]
  160. var refMatch = sceneDecoded.match(/ref=([^&]+)/)
  161. if (refMatch && refMatch[1]) this.autoBindInviteCode(refMatch[1])
  162. } catch (e) {}
  163. }
  164. if (aid) { this.articleId = aid; this.loadDetail(aid) }
  165. else { this.error = true; this.errorMsg = '参数错误'; this.loading = false }
  166. this.currentChildId = uni.getStorageSync('currentChildId') || null
  167. this.isLogin = !!uni.getStorageSync('token')
  168. },
  169. onShow() {
  170. this.fontScale = getFontScale()
  171. var memberId = uni.getStorageSync('currentChildId')
  172. if (!this.article || this.error) return
  173. // 已登录用户(家长/成员/规划师)均可计时,匿名用户不计时
  174. if (this.isLogin) this.startNewReadingSession()
  175. },
  176. onHide() { this.pauseReadingTimer(); this.stopArticleAudio() },
  177. onUnload() { this.pauseReadingTimer(); this.stopArticleAudio() },
  178. methods: {
  179. async loadDetail(id) {
  180. this.loading = true; this.error = false
  181. try {
  182. var res = await getArticleDetail({ id: id })
  183. if (res.code === 200 && res.data) {
  184. this.article = res.data
  185. this.article.coverImage = this.getImageUrl(this.article.coverImage)
  186. this.article.content = this.resolveContentUrls(this.article.content)
  187. this.setShareInfo('推荐阅读: ' + (res.data.title || ''), '/pages/article-center/article-detail?id=' + id)
  188. this.startReadingTimer()
  189. // 关联商品:放在 loadDetail 内只走一次(onShow 不重复请求,避免双发)
  190. this.loadRelatedProducts(id)
  191. } else { this.error = true; this.errorMsg = '文章不存在或无权限查看' }
  192. } catch (e) { this.error = true; this.errorMsg = '加载失败' }
  193. finally { this.loading = false }
  194. },
  195. // 加载文章关联商品(后端按 标签匹配数 > 用户权重 > 家庭权重 > 销量 排序)
  196. loadRelatedProducts: function(articleId) {
  197. var self = this
  198. if (!articleId) return
  199. getArticleRelatedProducts({ articleId: articleId, size: 4 }).then(function(res) {
  200. if (res && res.code === 200 && res.data && Array.isArray(res.data)) {
  201. self.relatedProducts = res.data
  202. }
  203. }).catch(function() { self.relatedProducts = [] })
  204. },
  205. // 跳转商品详情(优先使用后端返回的 url)
  206. goRelatedProduct: function(prod) {
  207. if (!prod) return
  208. var pid = prod.productId || prod.id
  209. var url = prod.url || ('/pages/discover-detail/product-detail/product-detail?id=' + (pid || ''))
  210. if (url.indexOf('/pages/') !== 0) return
  211. uni.navigateTo({ url: url })
  212. },
  213. formatDate(d) { return d ? d.slice(0, 10) : '' },
  214. getImageUrl: function(path) {
  215. if (!path) return ''
  216. if (path.indexOf('http://') === 0 || path.indexOf('https://') === 0) return path
  217. return config.API_BASE_URL + path
  218. },
  219. resolveContentUrls: function(html) {
  220. if (!html) return html
  221. // 将富文本内容中的相对图片路径(/uploads/...)拼接为绝对 URL
  222. return html.replace(/(src|href)=["']\/(uploads\/[^"']+)/g, function(match, attr, path) {
  223. return attr + '="' + config.API_BASE_URL + '/' + path + '"'
  224. })
  225. },
  226. parseDimensions: function(article) {
  227. var dimMap = { body: { code: 'body', color: '#FF8C42', name: '身' }, mind: { code: 'mind', color: '#FF6B9D', name: '心' }, wisdom: { code: 'wisdom', color: '#6366F1', name: '智' }, action: { code: 'action', color: '#10B981', name: '行' }, wealth: { code: 'wealth', color: '#F59E0B', name: '富' } }
  228. var raw = article && article.relatedDimensions ? article.relatedDimensions.split(',').map(function(s) { return s.trim().toLowerCase() }) : []
  229. var weights = null
  230. if (article && article.dimensionWeights) try { var w = JSON.parse(article.dimensionWeights); if (w && typeof w === 'object') weights = w } catch (e) {}
  231. if (!weights) {
  232. var n = raw.filter(function(c) { return dimMap[c] }).length
  233. if (n > 0) { var base = Math.floor(100 / n); var rem = 100 - base * n; weights = {}; var i = 0; raw.forEach(function(c) { if (!dimMap[c]) return; weights[c] = i < rem ? base + 1 : base; i++ }) }
  234. }
  235. return raw.filter(function(c) { return dimMap[c] }).map(function(c) { return { code: dimMap[c].code, name: dimMap[c].name, color: dimMap[c].color, weight: (weights && weights[c]) ? weights[c] : 20 } })
  236. },
  237. getMainDimension: function() {
  238. var dims = this.article ? this.parseDimensions(this.article) : []
  239. var best = null
  240. var i
  241. for (i = 0; i < dims.length; i++) {
  242. if (!best || dims[i].weight > best.weight) best = dims[i]
  243. }
  244. return best ? best.code : ''
  245. },
  246. onScrollToBottom() {},
  247. startNewReadingSession: function() {
  248. // 每次进入文章详情页都从 0 开始新会话,时长不延续上一次
  249. this.readingSeconds = 0
  250. this.lastReportedSeconds = 0
  251. this.startReadingTimer()
  252. },
  253. // 获取当前操作对象的 memberId:优先 currentChildId(切换视角),否则用 userId
  254. getActiveMemberId: function() {
  255. var mid = uni.getStorageSync('currentChildId')
  256. if (mid) return parseInt(mid)
  257. var uid = uni.getStorageSync('userId')
  258. return uid ? parseInt(uid) : null
  259. },
  260. startReadingTimer: function() {
  261. // 无登录态时不计时(匿名浏览只显示时长要求,不计时)
  262. if (!this.isLogin) return
  263. if (this.isTimerRunning || this.readingCompleted) return
  264. this.isTimerRunning = true
  265. var self = this
  266. this.timerHandle = setInterval(function() { self.readingSeconds++ }, 1000)
  267. // 每 10 秒自动记录一次该用户已读时长
  268. this.syncHandle = setInterval(function() { self.reportReadingTime() }, 10000)
  269. },
  270. pauseReadingTimer: function() {
  271. if (!this.isTimerRunning) return
  272. this.isTimerRunning = false
  273. if (this.timerHandle) { clearInterval(this.timerHandle); this.timerHandle = null }
  274. if (this.syncHandle) { clearInterval(this.syncHandle); this.syncHandle = null }
  275. this.reportReadingTime()
  276. },
  277. async reportReadingTime() {
  278. var delta = this.readingSeconds - this.lastReportedSeconds
  279. if (delta <= 0) return
  280. this.lastReportedSeconds = this.readingSeconds
  281. var memberId = this.getActiveMemberId()
  282. if (!this.isLogin || !this.article) return
  283. reportReadingTime({ articleId: this.article.id, memberId: memberId || 0, durationSeconds: delta })
  284. // 达到阅读时长自动完成
  285. var targetSeconds = (this.article.readTime || 3) * 60
  286. if (!this.readingCompleted && this.readingSeconds >= targetSeconds) {
  287. this.readingCompleted = true
  288. this.pauseReadingTimer()
  289. try { await completeArticleRead({ articleId: this.article.id, memberId: memberId || 0, durationSeconds: this.readingSeconds }) } catch (e) {}
  290. uni.showToast({ title: '阅读完成 +5能量', icon: 'success' })
  291. // 弹出答题(登录用户)
  292. this.startQuiz()
  293. }
  294. },
  295. formatReadingTime: function(seconds) {
  296. if (seconds < 60) return '已读 ' + seconds + '秒'
  297. var min = Math.floor(seconds / 60); var sec = seconds % 60
  298. return '已读 ' + min + '分' + (sec > 0 ? sec + '秒' : '')
  299. },
  300. // 听文章:首次点击拉取(或复用已生成)音频,多段顺序播放;播放期间保证阅读计时运行
  301. async toggleArticleAudio() {
  302. if (this.audioPlaying) { this.stopArticleAudio(); return }
  303. if (this.audioLoading || !this.article) return
  304. if (this.audioUrls && this.audioUrls.length > 0) { this.playAudioChunk(0); return }
  305. this.audioLoading = true
  306. try {
  307. var res = await getArticleAudio({ articleId: this.article.id })
  308. if (res.code === 200 && res.data && res.data.audioUrls && res.data.audioUrls.length > 0) {
  309. this.audioUrls = res.data.audioUrls
  310. this.playAudioChunk(0)
  311. } else {
  312. uni.showToast({ title: (res && res.message) || '抱歉,音频暂不可用', icon: 'none' })
  313. }
  314. } catch (e) {
  315. uni.showToast({ title: '音频生成失败,请稍后重试', icon: 'none' })
  316. } finally {
  317. this.audioLoading = false
  318. }
  319. },
  320. playAudioChunk: function(index) {
  321. var self = this
  322. // 播放期间保证阅读计时运行(未登录不计时)
  323. if (this.isLogin && !this.isTimerRunning && !this.readingCompleted) this.startReadingTimer()
  324. this.audioChunkIndex = index
  325. var ctx = uni.createInnerAudioContext()
  326. this.audioContext = ctx
  327. ctx.src = this.audioUrls[index]
  328. ctx.onEnded(function() {
  329. if (index + 1 < self.audioUrls.length) { self.playAudioChunk(index + 1) }
  330. else { self.stopArticleAudio() }
  331. })
  332. ctx.onError(function() {
  333. uni.showToast({ title: '播放失败', icon: 'none' })
  334. self.stopArticleAudio()
  335. })
  336. ctx.play()
  337. this.audioPlaying = true
  338. },
  339. stopArticleAudio: function() {
  340. if (this.audioContext) {
  341. try { this.audioContext.stop() } catch (e) {}
  342. try { this.audioContext.destroy() } catch (e) {}
  343. this.audioContext = null
  344. }
  345. this.audioPlaying = false
  346. },
  347. async generatePoster() {
  348. if (!this.articleId) return
  349. uni.showLoading({ title: '生成海报中...' })
  350. try {
  351. if (!this.referralCode) {
  352. await this.loadReferralCode()
  353. }
  354. var scene = 'id=' + this.articleId + (this.referralCode ? '&ref=' + this.referralCode : '')
  355. if (scene.length > 32) {
  356. scene = scene.substring(0, 32)
  357. }
  358. var res = await getShareQrCode('pages/article-center/article-detail', scene)
  359. if (res && res.data) {
  360. this.posterQrCode = res.data.qrCodeBase64 || ''
  361. this.posterDimension = this.getMainDimension()
  362. this.posterSummary = (this.article && this.article.summary) || ''
  363. this.posterInviteText = '「' + (uni.getStorageSync('nickname') || '好友') + '」邀请你一起阅读这篇文章'
  364. this.showPoster = true
  365. }
  366. } catch (e) { uni.showToast({ title: '生成失败', icon: 'none' }) }
  367. finally { uni.hideLoading() }
  368. },
  369. // 答题
  370. async startQuiz() {
  371. if (!this.isLogin) {
  372. uni.showToast({ title: '登录后即可完成知识测评', icon: 'none' })
  373. setTimeout(() => { this.openLoginSheet() }, 1500)
  374. return
  375. }
  376. var memberId = this.getActiveMemberId()
  377. try {
  378. var res = await generateQuiz({ articleId: this.articleId, memberId: memberId || 0 })
  379. if (res.code === 200 && res.data && res.data.questions && res.data.questions.length > 0) {
  380. this.quizRecordId = res.data.recordId
  381. this.quizQuestions = res.data.questions
  382. this.quizAnswers = []
  383. this.currentQuizIndex = 0
  384. this.showQuiz = true
  385. }
  386. } catch (e) {}
  387. },
  388. async submitQuiz() {
  389. var memberId = this.getActiveMemberId()
  390. var answers = []
  391. for (var i = 0; i < this.quizQuestions.length; i++) {
  392. answers.push(this.quizAnswers[i] || '')
  393. }
  394. try {
  395. var res = await submitQuiz({ recordId: this.quizRecordId, memberId: parseInt(memberId || 0), answers: answers })
  396. if (res.code === 200) {
  397. this.quizResult = res.data || {}
  398. this.showQuiz = false
  399. this.showResult = true
  400. }
  401. } catch (e) {}
  402. },
  403. closePoster: function() {
  404. this.showPoster = false
  405. },
  406. closeQuiz: function() {
  407. this.showQuiz = false
  408. },
  409. closeResult: function() {
  410. this.showResult = false
  411. },
  412. selectQuizAnswer: function(qi, oi) {
  413. this.quizAnswers[qi] = String.fromCharCode(65 + oi)
  414. },
  415. // 一题一页:上一题 / 下一题
  416. goPrevQuestion: function() {
  417. if (this.currentQuizIndex > 0) this.currentQuizIndex--
  418. },
  419. goNextQuestion: function() {
  420. if (this.currentQuizIndex < this.quizQuestions.length - 1) this.currentQuizIndex++
  421. }
  422. }
  423. }
  424. </script>
  425. <style scoped lang="scss">
  426. .detail-container { min-height: 100vh; background: #fff; }
  427. .loading-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 300rpx; }
  428. .loading-spinner { width: 60rpx; height: 60rpx; border: 4rpx solid #e0e0e0; border-top-color: $uni-info; border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 20rpx; }
  429. @keyframes spin { 0% { transform: rotate(0deg); } 360% { transform: rotate(360deg); } }
  430. .loading-text { font-size: 26rpx; color: #999; }
  431. .error-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 300rpx; }
  432. .error-icon { font-size: 100rpx; margin-bottom: 24rpx; }
  433. .error-text { font-size: 28rpx; color: #999; margin-bottom: 30rpx; }
  434. .retry-btn { width: 240rpx; height: 72rpx; line-height: 72rpx; background: $brand-primary; color: #fff; font-size: 28rpx; border-radius: 36rpx; text-align: center; border: none; }
  435. .content-scroll { height: calc(100vh - 120rpx); }
  436. .detail-cover { width: 100%; display: block; }
  437. .detail-title { display: block; font-size: calc(36rpx * var(--font-scale, 1)); font-weight: bold; color: #333; line-height: 1.4; padding: 30rpx 30rpx 0; }
  438. .detail-meta { display: flex; align-items: center; padding: 16rpx 30rpx 0; font-size: 22rpx; color: #999; flex-wrap: wrap; }
  439. .meta-author { color: $uni-info; }
  440. .meta-sep { margin: 0 12rpx; color: #ddd; }
  441. .reading-time-badge { margin-left: auto; font-size: 20rpx; color: $uni-info; background: rgba(14, 165, 233, 0.08); padding: 4rpx 12rpx; border-radius: 20rpx; white-space: nowrap; }
  442. .reading-time-badge.completed { color: #10B981; background: rgba(16,185,129,0.1); }
  443. .meta-readcount {
  444. font-size: 20rpx;
  445. color: #bbb;
  446. }
  447. .detail-category-row { padding: 16rpx 30rpx 0; }
  448. .detail-category { display: inline-block; font-size: 20rpx; color: $uni-info; background: rgba(14, 165, 233, 0.1); padding: 4rpx 16rpx; border-radius: 8rpx; }
  449. .detail-dimensions { padding: 16rpx 30rpx 0; display: flex; gap: 12rpx; }
  450. .dim-bar-item { flex: 1; }
  451. .dim-bar { height: 8rpx; border-radius: 4rpx; }
  452. .dim-label { font-size: 18rpx; color: #999; text-align: center; display: block; margin-top: 4rpx; }
  453. .detail-summary { padding: 20rpx 30rpx; }
  454. .detail-summary-text { font-size: calc(26rpx * var(--font-scale, 1)); color: #888; line-height: 1.7; display: block; border-left: 4rpx solid #F97316; padding-left: 20rpx; }
  455. .divider { height: 1rpx; background: #eee; margin: 24rpx 30rpx; }
  456. .detail-body { padding: 0 30rpx; font-size: calc(32rpx * var(--font-scale, 1)); color: #444; line-height: 1.8; }
  457. /* 关联商品推荐 */
  458. .related-section { margin-top: 20rpx; padding: 0 30rpx 8rpx; }
  459. .related-header { display: flex; align-items: baseline; margin-bottom: 16rpx; }
  460. .related-title { font-size: 30rpx; font-weight: bold; color: #333; }
  461. .related-subtitle { font-size: 20rpx; color: #999; margin-left: 12rpx; }
  462. .detail-footer { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; padding: 20rpx 30rpx; display: flex; align-items: center; gap: 16rpx; box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.06); z-index: 10; }
  463. .share-btn { height: 72rpx; padding: 0 30rpx; background: linear-gradient(135deg, #F97316, #FB923C); border-radius: 36rpx; display: flex; align-items: center; justify-content: center; border: none; }
  464. .share-btn::after { border: none; }
  465. .share-btn-icon { font-size: 30rpx; margin-right: 8rpx; }
  466. .share-btn-text { font-size: 26rpx; color: #fff; font-weight: 600; }
  467. .listen-btn { height: 72rpx; padding: 0 30rpx; background: rgba(14, 165, 233, 0.1); border: 2rpx solid $uni-info; border-radius: 36rpx; display: flex; align-items: center; justify-content: center; }
  468. .listen-btn.playing { background: rgba(14, 165, 233, 0.2); }
  469. .listen-btn-icon { font-size: 30rpx; margin-right: 8rpx; }
  470. .listen-btn-text { font-size: 26rpx; color: $uni-info; font-weight: 600; }
  471. /* 答题弹窗 */
  472. .quiz-mask, .result-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; display: flex; align-items: center; justify-content: center; }
  473. .quiz-dialog, .result-dialog { background: #fff; border-radius: 24rpx; width: 650rpx; padding: 32rpx; }
  474. .quiz-mascot { display: flex; align-items: center; justify-content: center; gap: 12rpx; margin-bottom: 16rpx; }
  475. .mascot-icon { font-size: 60rpx; }
  476. .mascot-name { font-size: 32rpx; font-weight: 700; color: #F97316; }
  477. .quiz-step-bar { display: flex; align-items: center; justify-content: center; margin-bottom: 24rpx; }
  478. .quiz-step-text { font-size: 24rpx; color: #999; margin-right: 12rpx; }
  479. .quiz-dots { display: flex; align-items: center; gap: 8rpx; }
  480. .quiz-dot { width: 12rpx; height: 12rpx; border-radius: 50%; background: #E5E7EB; }
  481. .quiz-dot.active { background: #F97316; }
  482. .quiz-dot.done { background: #FDBA74; }
  483. .q-title { font-size: 30rpx; font-weight: 600; color: #333; line-height: 1.5; margin-bottom: 20rpx; }
  484. .q-options { display: flex; flex-direction: column; gap: 12rpx; }
  485. .q-option { padding: 16rpx 20rpx; border: 2rpx solid #E5E7EB; border-radius: 12rpx; font-size: 26rpx; color: #333; }
  486. .q-option.selected { border-color: #F97316; background: #FFF7ED; color: #92400E; }
  487. .quiz-nav { display: flex; gap: 16rpx; margin-top: 28rpx; }
  488. .quiz-prev { flex: 1; padding: 20rpx; background: #fff; color: #F97316; border: 2rpx solid #F97316; font-size: 28rpx; border-radius: 12rpx; }
  489. .quiz-prev::after { border: none; }
  490. .quiz-submit { flex: 1; padding: 20rpx; background: linear-gradient(135deg, #F97316, #FB923C); color: #fff; font-size: 28rpx; border-radius: 12rpx; border: none; }
  491. .quiz-submit::after { border: none; }
  492. .result-btn { width: 100%; padding: 20rpx; background: linear-gradient(135deg, #F97316, #FB923C); color: #fff; font-size: 28rpx; border-radius: 12rpx; border: none; margin-top: 20rpx; }
  493. .result-dialog { text-align: center; }
  494. .result-icon { font-size: 80rpx; }
  495. .result-text { font-size: 32rpx; font-weight: 700; color: #333; margin: 16rpx 0; }
  496. .result-energy { font-size: 28rpx; color: #F97316; }
  497. </style>