courseDetail.vue 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258
  1. <template>
  2. <view class="page">
  3. <view class="video-wrap" :style="{paddingTop:statusBarHeight}">
  4. <video
  5. :key="activeIndex"
  6. @timeupdate="onTimeUpdate"
  7. @loadedmetadata="onVideoLoadedMetadata"
  8. @progress="progressChange"
  9. @error="videoErrorCallback"
  10. @play="getPlay"
  11. @pause="getPause"
  12. @ended="getEnded"
  13. @fullscreenchange="fullscreenchange"
  14. :title="courseInfo.title"
  15. style="width: 100%;height: 420rpx;"
  16. :poster="poster"
  17. id="video-content-box"
  18. controls
  19. :auto-pause-if-open-native="true"
  20. :auto-pause-if-navigate="true"
  21. :enable-progress-gesture="false"
  22. :show-progress="true"
  23. :picture-in-picture-mode="[]"
  24. :show-background-playback-button="false"
  25. :src="videoUrl"
  26. >
  27. <cover-view v-if="!isFull" class="back-box" :style="{'top':menuButtonInfo.gapToStatusBar}" @click="goBack()">
  28. <cover-view :style="{'height':menuButtonInfo.height}" style="display: flex;align-items: center;justify-content: center;">
  29. <cover-image style="width: 18px;height: 18px;" src="/static/images/ai_right_icon.png"></cover-image>
  30. </cover-view>
  31. </cover-view>
  32. </video>
  33. </view>
  34. <scroll-view class="page-scroll" scroll-y @scrolltolower="loadMoreComments">
  35. <view class="content">
  36. <view class="course-title">{{ courseInfo.courseName }}</view>
  37. <view class="course-desc">{{ courseInfo.description ||'暂无简介'}}</view>
  38. <view class="course-views">{{ courseViewsDisplay }}次播放</view>
  39. </view>
  40. <view class="section-head">
  41. <view class="left">
  42. <image class="dot" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/list.png"></image>
  43. <text class="section-title">视频标题</text>
  44. </view>
  45. <view class="count" @click="showCatalog = true">共{{ catalogNum||0 }}个作品
  46. <image class="w16 h20 ml10" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/right.png"></image>
  47. </view>
  48. </view>
  49. <scroll-view class="catalog-scroll" scroll-x>
  50. <view class="catalog-row">
  51. <view
  52. v-for="(item, index) in catalogList"
  53. :key="item.videoId"
  54. class="catalog-item"
  55. :class="{ active: activeIndex == item.videoId }"
  56. @click="selectCourse(item)"
  57. >
  58. <view class="catalog-top">
  59. <view class="catalog-index-wrap">
  60. <!-- <text class="catalog-index">第{{ index + 1 }}讲</text> -->
  61. <image class="catalog-active-dot" v-if="activeIndex == item.videoId" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/live.png" /></image>
  62. </view>
  63. <text class="free-tag">限时免费</text>
  64. </view>
  65. <view class="catalog-name ellipsis2" :class="{ active: activeIndex == item.videoId }">{{ item.title }}</view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. <view class="comment-wrap">
  70. <view class="comment-title">评论</view>
  71. <view v-if="commentInitLoaded && !commentLoading && (!comments || comments.length === 0)" class="comment-empty">暂无评论</view>
  72. <view class="comment-item" v-for="item in comments" :key="item.id">
  73. <image class="avatar" :src="item.avatar" mode="aspectFill"></image>
  74. <view class="comment-main">
  75. <view class="name">
  76. {{ item.name }}
  77. <text v-if="item.selfOnly" class="self-only-tag">(仅自己可见)</text>
  78. </view>
  79. <view class="time">{{ item.time }}</view>
  80. <view class="text" style="word-break: break-all;">{{ item.content }}</view>
  81. </view>
  82. </view>
  83. <view v-if="commentInitLoaded && comments && comments.length > 0" class="comment-load-status">
  84. {{ commentLoading ? "加载中..." : (commentHasMore ? "上拉加载更多" : "没有更多评论了") }}
  85. </view>
  86. </view>
  87. <view class="bottom-space"></view>
  88. </scroll-view>
  89. <view v-if="showAnswerEntry" class="answer-entry" @click="openAnswerPopup">
  90. <image class="gift-icon" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/box.png"></image>
  91. <view class="answer-tip y-bc" :class="{ done: hasAward }">
  92. <template v-if="answerShowCountdownLines">
  93. <view class="answer-tip-line answer-tip-line-first">再观看{{ answerCountdownText }}</view>
  94. </template>
  95. <template v-else-if="answerStatus==4">
  96. <view class="answer-tip-single2">
  97. 已得
  98. <view class="jifen">{{awardScore||0}}</view>
  99. 积分
  100. </view>
  101. </template>
  102. <text v-else class="answer-tip-single">{{ answerEntryTip }}</text>
  103. <view class="answer-btn" v-if="answerStatus!==3&&answerStatus!==4">答题</view>
  104. </view>
  105. </view>
  106. <view class="bottom-bar">
  107. <input
  108. class="input comment-input"
  109. v-model.trim="commentContent"
  110. placeholder="发表我的态度"
  111. placeholder-class="comment-input-placeholder"
  112. confirm-type="send"
  113. :maxlength="50"
  114. @confirm="submitComment"
  115. />
  116. <view class="send-btn" :class="{ disabled: isSendingComment }" @click="submitComment">
  117. {{ isSendingComment ? "发送中..." : "发送" }}
  118. </view>
  119. <view class="share-btn" @click="handleShare">
  120. <image class="share" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/share.png" mode="aspectFit"></image>
  121. <text>分享</text>
  122. </view>
  123. </view>
  124. <view class="answer-mask" v-if="showAnswerPopup" @click="closeAnswerPopup">
  125. <view class="answer-panel" @click.stop>
  126. <view class="answer-head">
  127. <view class="left">
  128. <image class="dot" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/qus.png" mode="aspectFit"></image>
  129. <text class="section-title">问答题</text>
  130. </view>
  131. <view class="close-btn" @click="closeAnswerPopup">
  132. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/close.png"></image>
  133. </view>
  134. </view>
  135. <view class="answer-divider"></view>
  136. <scroll-view class="popup-scroll" scroll-y>
  137. <view v-for="(ques, idx) in answerQuestion" :key="idx">
  138. <view class="question-title">{{ ques.title }}</view>
  139. <view
  140. v-for="(option, index) in ques.options"
  141. :key="option.indexId"
  142. class="answer-option"
  143. :class="{ active: selectedAnswers[idx] === index, disabled: !canAnswer }"
  144. @click="selectAnswer(idx, index)"
  145. >
  146. {{ option.name }}
  147. </view>
  148. </view>
  149. </scroll-view>
  150. <view
  151. class="submit-btn"
  152. :class="{ active: isAnswerReady, disabled: !isAnswerReady }"
  153. @click="submitAnswer"
  154. >
  155. {{ canAnswer ? "提交答案" : ("再观看" + answerCountdownText + "可答题") }}
  156. </view>
  157. </view>
  158. </view>
  159. <view class="answer-result-mask" v-if="showAnswerResultPopup" @click="closeAnswerResultPopup">
  160. <view class="answer-result-panel" @click.stop>
  161. <view class="result-title">{{ resultConfig.title }}</view>
  162. <view class="result-subtitle" v-if="answerResultType === 'success'">
  163. 获得<text class="result-score">{{ awardScore }}</text>积分,自动到账
  164. </view>
  165. <view class="result-subtitle" v-else-if="answerResultType === 'completed'">
  166. <text v-if="awardScore > 0">已获得<text class="result-score">{{ awardScore }}</text>积分</text>
  167. <text v-else>{{ resultConfig.subtitle }}</text>
  168. </view>
  169. <view class="result-subtitle" v-else>{{ resultConfig.subtitle }}</view>
  170. <view class="result-chance">{{ resultConfig.chanceText }}</view>
  171. <view class="result-primary-btn" v-if="resultConfig.showPrimary" @click="goToIntegralMall">
  172. 前往积分商城兑换
  173. </view>
  174. <view class="result-second-btn" @click="closeAnswerResultPopup">继续观看</view>
  175. </view>
  176. <view class="result-close" @click.stop="closeAnswerResultPopup">&#10005;</view>
  177. </view>
  178. <view class="share-mask" v-if="showSharePopup" @click="closeSharePopup">
  179. <view class="share-panel" @click.stop>
  180. <view class="share-card">
  181. <view class="share-item">
  182. <image class="share-avatar wechat" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/weixin.png"></image>
  183. <text class="share-text">分享给微信好友</text>
  184. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  185. </view>
  186. <!-- <view class="share-item">
  187. <image class="share-avatar moments" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/pyq.png"></image>
  188. <text class="share-text">分享到朋友圈</text>
  189. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  190. </view> -->
  191. </view>
  192. <view class="cancel-btn" @click="closeSharePopup">取消</view>
  193. </view>
  194. </view>
  195. <view class="popup-mask" v-if="showCatalog" @click="showCatalog = false">
  196. <view class="popup-panel" @click.stop>
  197. <view class="popup-head">
  198. <view class="left">
  199. <image class="dot" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/list.png" mode="aspectFit"></image>
  200. <text class="section-title">视频标题</text>
  201. </view>
  202. <view class="close-btn" @click="showCatalog = false">
  203. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/close.png" mode="aspectFit"></image>
  204. </view>
  205. </view>
  206. <view class="popup-divider"></view>
  207. <scroll-view class="popup-scroll" scroll-y>
  208. <view
  209. v-for="(item, index) in catalogList"
  210. :key="item.videoId"
  211. class="popup-item"
  212. :class="{ active: activeIndex == item.videoId }"
  213. @click="selectCourse(item)"
  214. >
  215. <view class="catalog-top">
  216. <view class="catalog-index-wrap">
  217. <!-- <text class="catalog-index">第{{ index + 1 }}讲</text> -->
  218. <image class="catalog-active-dot" v-if="activeIndex == item.videoId" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/live.png" mode="aspectFit"/></image>
  219. </view>
  220. <text class="free-tag">限时免费</text>
  221. </view>
  222. <view class="popup-name" :class="{ active: activeIndex == item.videoId }">{{ item.title }}</view>
  223. </view>
  224. </scroll-view>
  225. </view>
  226. </view>
  227. </view>
  228. </template>
  229. <script>
  230. import {
  231. getCourseDetail as fetchCourseDetail,
  232. addStudyCourse as addStudyCourseApi,
  233. getCourseVideoList,
  234. addCommentt,
  235. getCommentList,
  236. videoDetails,
  237. courseAnswer as submitCourseAnswerApi,
  238. courseAnswerStatus,
  239. claimCourseAnswerIntegral,
  240. getInternetTraffic
  241. } from '@/api/class.js'
  242. import dayjs from 'dayjs'
  243. import { generateRandomString } from '@/utils/courseTool.js'
  244. export default {
  245. computed: {
  246. /** 播放数:<10万 原样;≥10万且<100万 如 10.0w、11.3w;≥100万 100w+ */
  247. courseViewsDisplay() {
  248. const raw = this.courseInfo && this.courseInfo.views;
  249. const n = Number(raw);
  250. if (!Number.isFinite(n) || n < 0) {
  251. return "0";
  252. }
  253. if (n < 100000) {
  254. return String(Math.floor(n));
  255. }
  256. if (n < 1000000) {
  257. return (n / 10000).toFixed(1) + "w";
  258. }
  259. return "100w+";
  260. },
  261. poster() {
  262. const item = (this.catalogList || []).find((v) => v.videoId === this.activeIndex);
  263. return (item && item.imgUrl) || this.courseInfo.imgUrl;
  264. },
  265. /** 无有效视频地址,或当前小节无 watchDurationMinutes / 为 null / 非法 / 明确为 0 时,不展示答题浮层 */
  266. showAnswerEntry() {
  267. const url = (this.videoUrl && String(this.videoUrl).trim()) || "";
  268. if (!url) {
  269. return false;
  270. }
  271. const currentLesson =
  272. (this.catalogList || []).find((v) => v.videoId === this.activeIndex) ||
  273. (this.catalogList || [])[0] ||
  274. {};
  275. const raw = currentLesson.watchDurationMinutes;
  276. if (raw === undefined || raw === null) {
  277. return false;
  278. }
  279. const minutes = Number(raw);
  280. if (!Number.isFinite(minutes) || minutes === 0) {
  281. return false;
  282. }
  283. return true;
  284. },
  285. canAnswer() {
  286. return this.answerCountdown <= 0;
  287. },
  288. answerCountdownText() {
  289. const second = this.answerCountdown < 0 ? 0 : this.answerCountdown;
  290. const minuteNum = Math.floor(second / 60);
  291. const secondNum = second % 60;
  292. const ss = String(secondNum).padStart(2, "0");
  293. if (minuteNum > 0) {
  294. return minuteNum + ":" + ss;
  295. }
  296. return "00:" + ss;
  297. },
  298. answerShowCountdownLines() {
  299. if (this.answerStatus === 4 || this.hasAward) {
  300. return false;
  301. }
  302. // 仅 status===3 表示已达上限;勿用 attemptsLeft<=0:换课后接口若未返回剩余次数会沿用上一节 attemptsLeft=0,误隐藏倒计时
  303. if (this.answerStatus === 3) {
  304. return false;
  305. }
  306. return !this.canAnswer && this.answerStatus !== 2;
  307. },
  308. answerEntryTip() {
  309. if (this.answerStatus === 4 || this.hasAward) {
  310. if (this.awardScore > 0) {
  311. return "已得" + this.awardScore + "积分";
  312. }
  313. return "已完成本节答题";
  314. }
  315. if (this.answerStatus === 3) {
  316. return "未答对\n明天再来";
  317. }
  318. return "答题得奖励";
  319. },
  320. isAnswerReady() {
  321. if (!this.canAnswer) {
  322. return false;
  323. }
  324. const questionList = this.answerQuestion || [];
  325. if (questionList.length === 0) {
  326. return false;
  327. }
  328. const selectedCount = Object.keys(this.selectedAnswers || {}).length;
  329. return selectedCount === questionList.length;
  330. },
  331. resultConfig() {
  332. const configMap = {
  333. success: {
  334. title: "恭喜你,回答正确",
  335. subtitle: "",
  336. chanceText: "每节课拥有" + this.maxAttempts + "次答题机会",
  337. showPrimary: true
  338. },
  339. fail: {
  340. title: "很遗憾答错了",
  341. subtitle: "请继续努力哦",
  342. chanceText: "每节课拥有" + this.maxAttempts + "次答题机会",
  343. showPrimary: false
  344. },
  345. exhausted: {
  346. title: "答题次数已用完",
  347. subtitle: "下次开课再接再厉",
  348. chanceText: "每节课拥有" + this.maxAttempts + "次答题机会",
  349. showPrimary: false
  350. },
  351. completed: {
  352. title: "您已完成本节答题",
  353. subtitle: "奖励已发放,可在积分明细中查看",
  354. chanceText: "每节课拥有" + this.maxAttempts + "次答题机会",
  355. showPrimary: true
  356. }
  357. };
  358. return configMap[this.answerResultType] || configMap.fail;
  359. }
  360. },
  361. data() {
  362. return {
  363. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  364. isShu: false,
  365. isFull: false,
  366. videoUrl: "",
  367. videoContext: null,
  368. playTime: 0,
  369. videoDuration: 0,
  370. bufferRate: 0,
  371. errorCount: 0,
  372. showCatalog: false,
  373. showSharePopup: false,
  374. showAnswerPopup: false,
  375. showAnswerResultPopup: false,
  376. activeIndex: 0,
  377. answerTimer: null,
  378. answerCountdown: 90,
  379. selectedAnswers: {},
  380. answerResultType: "success",
  381. maxAttempts: 3,
  382. attemptsLeft: 3,
  383. correctAnswer: "C",
  384. awardScore:0,
  385. hasAward: false,
  386. /** 答题状态:1未答题 2可答题 3已达上限 4已完成 */
  387. answerStatus: null,
  388. answerQuestion: [],
  389. courseInfo: {
  390. // title: "邹方斌讲《毛笔书法修心课》",
  391. // desc: "零基础名师教学零起步,邹方斌讲《毛笔书法修心课》在家也能轻松学书法。",
  392. // views: "4127946",
  393. // duration: "45:38",
  394. // cover: "https://picsum.photos/900/520"
  395. },
  396. catalogList: [
  397. // { id: 1, name: "毛笔书法修心课》在家也能学", free: true },
  398. // { id: 2, name: "毛笔书法修心课》在家也能轻松学", free: true },
  399. // { id: 3, name: "毛笔书法修心课》在家也能轻松学", free: false },
  400. // { id: 4, name: "书法艺术概论", free: true },
  401. // { id: 5, name: "运笔的基础知识", free: true },
  402. // { id: 6, name: "字形结构与章法", free: true }
  403. ],
  404. catalogNum:0,//小节数量
  405. comments: [
  406. // {
  407. // id: 1,
  408. // name: "app用户32781",
  409. // time: "今天08:38",
  410. // content: "讲的真好,循序渐进,让小白也很容易能入门观看!",
  411. // avatar: "https://picsum.photos/80/80?1"
  412. // },
  413. // {
  414. // id: 2,
  415. // name: "app用户32781",
  416. // time: "2026-02-10 12:37",
  417. // content: "讲的通俗易懂,很好!",
  418. // avatar: "https://picsum.photos/80/80?2"
  419. // },
  420. // {
  421. // id: 3,
  422. // name: "app用户32781",
  423. // time: "2026-02-10 12:37",
  424. // content: "赞赞赞,我要好好学!",
  425. // avatar: "https://picsum.photos/80/80?3"
  426. // }
  427. ],
  428. menuButtonInfo:{},
  429. courseId:null,
  430. videoId:null,
  431. // 当前课时:已上报过“开始播放”后,才在暂停/离开等时机更新进度
  432. studyStartReported: false,
  433. pendingSeekTime: 0,
  434. hasAppliedInitialStudyLog: false,
  435. commentContent: "",
  436. isSendingComment: false,
  437. commentPageNum: 1,
  438. commentPageSize: 10,
  439. commentHasMore: true,
  440. commentLoading: false,
  441. commentInitLoaded: false,
  442. sensitiveWords: ["加微信", "vx", "v信", "微信号", "手机号", "电话", "qq", "QQ", "赌博", "色情"],
  443. studyLog:{},
  444. videoInfo:{},
  445. /** course_auto 流量统计:与 pages_course/video.vue 对齐 */
  446. trafficCourseExtras: {},
  447. trafficUrlOption: {},
  448. trafficUuId: '',
  449. trafficInterval: null,
  450. /** 避免 getCourseDetail 与 getCourseVideoList 各调一次 initLessonVideo 导致答题状态接口重复请求 */
  451. _firstLessonBootstrapped: false,
  452. _catalogFetchDone: false,
  453. _detailFetchDone: false,
  454. };
  455. },
  456. onLoad(opt) {
  457. this.getMenuButtonInfo(); // 初始化获取胶囊信息
  458. if (opt.course) {
  459. try {
  460. this.trafficCourseExtras = JSON.parse(decodeURIComponent(opt.course))
  461. } catch (e) {
  462. this.trafficCourseExtras = {}
  463. }
  464. }
  465. if(opt.courseId){
  466. this.courseId=opt.courseId
  467. this._firstLessonBootstrapped = false;
  468. this._catalogFetchDone = false;
  469. this._detailFetchDone = false;
  470. this.getCourseDetail(opt.courseId);
  471. this.getCommentList(opt.courseId, true);
  472. this.getCourseVideoList(opt.courseId);
  473. }
  474. },
  475. //发送给朋友
  476. onShareAppMessage(res) {
  477. return {
  478. title:this.videoInfo.title,
  479. path: '/pages_index/courseDetail?courseId='+this.courseId,
  480. imageUrl: this.videoInfo.thumbnail //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  481. }
  482. },
  483. //分享到朋友圈
  484. onShareTimeline(res) {
  485. return {
  486. title: this.videoInfo.title,
  487. query:'courseId='+this.courseId,
  488. imageUrl: this.courseInfo.imgUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  489. }
  490. },
  491. onReady() {
  492. this.$nextTick(() => {
  493. this.videoContext = uni.createVideoContext("video-content-box", this);
  494. this.tryPlayVideo();
  495. });
  496. },
  497. onHide() {
  498. this.flushStudyProgress();
  499. this.clearTrafficInterval();
  500. },
  501. onShow() {
  502. this.trafficUuId = generateRandomString(16)
  503. if (this.courseId && this.videoId) {
  504. this.syncTrafficUrlOption()
  505. }
  506. },
  507. onUnload() {
  508. this.flushStudyProgress();
  509. this.clearAnswerTimer();
  510. this.clearTrafficInterval();
  511. },
  512. methods: {
  513. // 获取胶囊按钮布局参数
  514. getMenuButtonInfo() {
  515. // 微信小程序API(Uniapp可直接用uni.getMenuButtonBoundingClientRect)
  516. const menuBtn = uni.getMenuButtonBoundingClientRect();
  517. const sHeight = uni.getSystemInfoSync().statusBarHeight;
  518. if (menuBtn) {
  519. const gapToStatusBar = menuBtn.top - sHeight;
  520. this.menuButtonInfo = {
  521. top: menuBtn.top + 'px', // 胶囊顶部距离
  522. height: menuBtn.height + 'px', // 胶囊高度
  523. centerY: (menuBtn.top + menuBtn.height / 2) + 'px', // 胶囊垂直居中Y坐标
  524. right: menuBtn.right + 'px' ,// 胶囊右侧距离
  525. gapToStatusBar:gapToStatusBar+'px'
  526. };
  527. }
  528. },
  529. getCourseDetail(courseId){
  530. fetchCourseDetail({courseId:courseId}).then(
  531. res => {
  532. if (res.code == 200) {
  533. this.courseInfo = res.data?res.data:{},
  534. this.studyLog = this.courseInfo.studyLog
  535. //this.videoUrl = res.data.studyLo
  536. } else {
  537. uni.showToast({
  538. icon: 'none',
  539. title: res.msg,
  540. });
  541. }
  542. },
  543. rej => {}
  544. ).finally(() => {
  545. this._detailFetchDone = true;
  546. this.tryBootstrapFirstLesson();
  547. });
  548. },
  549. getCommentList(courseId, reset = false){
  550. const targetCourseId = courseId || this.courseId;
  551. if (!targetCourseId) {
  552. return;
  553. }
  554. if (this.commentLoading) {
  555. return;
  556. }
  557. if (!reset && !this.commentHasMore) {
  558. return;
  559. }
  560. if (reset) {
  561. this.commentPageNum = 1;
  562. this.commentHasMore = true;
  563. this.commentInitLoaded = false;
  564. this.comments = [];
  565. }
  566. const currentPageNum = this.commentPageNum;
  567. const param = {
  568. courseId: targetCourseId,
  569. pageNum: currentPageNum,
  570. pageSize: this.commentPageSize,
  571. sortType:2
  572. }
  573. this.commentLoading = true;
  574. getCommentList(param).then(
  575. res => {
  576. if (res.code == 200) {
  577. const list = Array.isArray(res.data)
  578. ? res.data
  579. : (res.data && Array.isArray(res.data.list) ? res.data.list : []);
  580. const normalizedList = list.map((item, index) => this.normalizeCommentItem(item, ((currentPageNum - 1) * this.commentPageSize) + index));
  581. this.comments = reset ? normalizedList : (this.comments || []).concat(normalizedList);
  582. const total = Number(res.data && res.data.total);
  583. if (Number.isFinite(total) && total >= 0) {
  584. this.commentHasMore = this.comments.length < total;
  585. } else {
  586. this.commentHasMore = normalizedList.length >= this.commentPageSize;
  587. }
  588. if (normalizedList.length > 0) {
  589. this.commentPageNum = currentPageNum + 1;
  590. } else {
  591. this.commentHasMore = false;
  592. }
  593. } else {
  594. uni.showToast({
  595. icon: 'none',
  596. title: res.msg,
  597. });
  598. }
  599. },
  600. rej => {}
  601. ).finally(() => {
  602. this.commentLoading = false;
  603. this.commentInitLoaded = true;
  604. });
  605. },
  606. loadMoreComments() {
  607. this.getCommentList(this.courseId, false);
  608. },
  609. normalizeCommentItem(item, index) {
  610. const avatar = item.avatar || item.avatarUrl || item.headImg || item.headImage || "https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/default-avatar.png";
  611. const name = item.name || item.nickName || item.nickname || item.userName || "匿名用户";
  612. const time = item.time || item.createTime || item.gmtCreate || "";
  613. const content = item.content || item.commentContent || item.comment || "";
  614. return {
  615. id: item.id || item.commentId || (Date.now() + "_" + index),
  616. avatar,
  617. name,
  618. time,
  619. content,
  620. selfOnly: !!item.selfOnly
  621. };
  622. },
  623. /** 进入页或切课后尝试自动播放(部分端需与 autoplay 配合) */
  624. tryPlayVideo() {
  625. if (!this.videoContext) {
  626. this.videoContext = uni.createVideoContext("video-content-box", this);
  627. }
  628. const ctx = this.videoContext;
  629. if (!ctx || !ctx.play) {
  630. return;
  631. }
  632. this.$nextTick(() => {
  633. setTimeout(() => {
  634. try {
  635. ctx.play();
  636. } catch (e) {
  637. console.warn("tryPlayVideo", e);
  638. }
  639. }, 100);
  640. });
  641. },
  642. /** 课程详情与目录均返回后再 init,保证 studyLog 与 catalog 同时可用且 courseAnswerStatus 只请求一次 */
  643. tryBootstrapFirstLesson() {
  644. if (!this.courseId || this._firstLessonBootstrapped) {
  645. return;
  646. }
  647. if (!this._catalogFetchDone || !this._detailFetchDone) {
  648. return;
  649. }
  650. if (!this.catalogList || this.catalogList.length === 0) {
  651. this._firstLessonBootstrapped = true;
  652. return;
  653. }
  654. this._firstLessonBootstrapped = true;
  655. if (!this.activeIndex) {
  656. this.activeIndex = this.catalogList[0].videoId;
  657. }
  658. this.studyStartReported = false;
  659. this.playTime = 0;
  660. // 须在 initLessonVideo 之后:后者会根据 studyLog 恢复 activeIndex,倒计时须对应当前高亮小节的 watchDurationMinutes
  661. this.initLessonVideo();
  662. this.resetAnswerCountdownByCurrentLesson();
  663. this.$nextTick(() => {
  664. this.videoContext = uni.createVideoContext("video-content-box", this);
  665. this.tryPlayVideo();
  666. });
  667. },
  668. initLessonVideo() {
  669. let item = this.catalogList.find(v => v.videoId === this.activeIndex);
  670. if (!this.hasAppliedInitialStudyLog) {
  671. const resumeInfo = this.getResumeInfoFromStudyLog();
  672. if (resumeInfo && resumeInfo.item) {
  673. item = resumeInfo.item;
  674. this.activeIndex = item.videoId;
  675. this.playTime = resumeInfo.seekTime;
  676. this.pendingSeekTime = resumeInfo.seekTime;
  677. this.hasAppliedInitialStudyLog = true;
  678. }
  679. }
  680. if (!item) {
  681. item = this.catalogList[0];
  682. this.activeIndex = item ? item.videoId : 0;
  683. }
  684. if (!item) {
  685. this.videoId = null;
  686. return;
  687. }
  688. this.videoInfo=item;
  689. this.videoId = item.videoId
  690. this.videoUrl=item.videoUrl
  691. this.awardScore = item.integralReward;
  692. this.selectedAnswers = {};
  693. this.hasAward = false;
  694. this.answerStatus = null;
  695. this.getVideoDetail(this.videoId)
  696. this.loadCourseAnswerStatus(this.videoId)
  697. this.syncTrafficUrlOption()
  698. },
  699. syncTrafficUrlOption() {
  700. const base = { ...(this.trafficCourseExtras || {}) }
  701. // #ifdef MP-WEIXIN
  702. try {
  703. base.appId = wx.getAccountInfoSync().miniProgram.appId
  704. } catch (e) {}
  705. // #endif
  706. base.courseId = this.courseId
  707. base.videoId = this.videoId
  708. base.companyId = 101
  709. this.trafficUrlOption = base
  710. },
  711. clearTrafficInterval() {
  712. if (this.trafficInterval != null) {
  713. clearInterval(this.trafficInterval)
  714. this.trafficInterval = null
  715. }
  716. },
  717. updateTrafficTime() {
  718. const that = this
  719. this.clearTrafficInterval()
  720. this.trafficInterval = setInterval(function () {
  721. that.getInternetTraffic()
  722. }, 60000)
  723. },
  724. getInternetTraffic() {
  725. if (!this.videoDuration) {
  726. return
  727. }
  728. const playVideoTime = Math.ceil((this.playTime / this.videoDuration) * 100)
  729. let buf = this.bufferRate
  730. if (buf == 0 || buf < playVideoTime) {
  731. buf = playVideoTime
  732. }
  733. if (buf == 0 || Number(Number(buf).toFixed(2)) == 0) {
  734. return
  735. }
  736. const param = {
  737. ...this.trafficUrlOption,
  738. uuId: dayjs().format('YYYYMMDD') + this.trafficUuId,
  739. duration: this.playTime,
  740. bufferRate: Number(Number(buf).toFixed(2)),
  741. }
  742. if (!param.bufferRate) {
  743. return
  744. }
  745. getInternetTraffic(param)
  746. },
  747. applyAnswerStatusPayload(raw) {
  748. const d = raw && typeof raw === 'object' ? raw : {};
  749. const max = Number(d.maxAttempts);
  750. if (Number.isFinite(max) && max >= 0) {
  751. this.maxAttempts = max;
  752. }
  753. const st = Number(d.status);
  754. if (Number.isFinite(st)) {
  755. this.answerStatus = st;
  756. }
  757. let left = d.remainingAttempts;
  758. if (left === undefined || left === null) {
  759. left = d.remain;
  760. }
  761. if ((left === undefined || left === null) && d.usedAttempts != null && Number.isFinite(max)) {
  762. left = max - Number(d.usedAttempts);
  763. }
  764. if (Number.isFinite(Number(left))) {
  765. this.attemptsLeft = Math.max(0, Math.floor(Number(left)));
  766. } else if (st === 3 || st === 4) {
  767. this.attemptsLeft = 0;
  768. }
  769. const integral =
  770. d.integralReward ?? d.integral ?? d.awardIntegral ?? d.score ?? d.awardScore;
  771. if (integral !== undefined && integral !== null && integral !== '') {
  772. const n = Number(integral);
  773. if (Number.isFinite(n)) {
  774. this.awardScore = n;
  775. }
  776. }
  777. if (st === 4) {
  778. this.hasAward = true;
  779. this.answerCountdown = 0;
  780. this.clearAnswerTimer();
  781. } else if (st === 3) {
  782. this.answerCountdown = 0;
  783. this.clearAnswerTimer();
  784. } else if (st === 2) {
  785. this.answerCountdown = 0;
  786. this.clearAnswerTimer();
  787. }
  788. },
  789. loadCourseAnswerStatus(videoId) {
  790. if (!this.courseId) {
  791. return;
  792. }
  793. courseAnswerStatus({ courseId: this.courseId, videoId: videoId }).then(
  794. (res) => {
  795. if (res.code == 200 && res.data) {
  796. this.answerStatus = res.data.status
  797. this.applyAnswerStatusPayload(res.data);
  798. } else if (res.code != 200) {
  799. uni.showToast({
  800. icon: 'none',
  801. title: res.msg || '获取答题状态失败'
  802. });
  803. }
  804. },
  805. () => {}
  806. );
  807. },
  808. getResumeInfoFromStudyLog() {
  809. const log = this.studyLog || {};
  810. const logVideoId = Number(log.videoId);
  811. if (!logVideoId || !Array.isArray(this.catalogList) || this.catalogList.length === 0) {
  812. return null;
  813. }
  814. const item = this.catalogList.find(v => Number(v.videoId) === logVideoId);
  815. if (!item) {
  816. return null;
  817. }
  818. const seekTime = Math.max(0, Math.floor(Number(log.currentTimes) || 0));
  819. return {
  820. item,
  821. seekTime
  822. };
  823. },
  824. getCourseVideoList(courseId) {
  825. const param = {
  826. courseId: courseId,
  827. pageNum:1,
  828. pageSize:50,
  829. }
  830. getCourseVideoList(param).then(
  831. res => {
  832. if (res.code == 200) {
  833. this.catalogList = (res.data && res.data.list) ? res.data.list : [];
  834. this.catalogNum=res.data.total
  835. if (this.catalogList.length > 0) {
  836. // 首次进入优先走 studyLog 对应课时,否则回落第一节(真正 init 在 tryBootstrapFirstLesson)
  837. if (!this.activeIndex) {
  838. this.activeIndex = this.catalogList[0].videoId;
  839. }
  840. } else {
  841. this.videoId = null;
  842. this.videoUrl = "";
  843. }
  844. } else {
  845. uni.showToast({
  846. icon: 'none',
  847. title: res.msg,
  848. });
  849. }
  850. },
  851. rej => {}
  852. ).finally(() => {
  853. this._catalogFetchDone = true;
  854. this.tryBootstrapFirstLesson();
  855. });
  856. },
  857. getVideoDetail(videoId) {
  858. videoDetails({videoId:videoId}).then(
  859. res => {
  860. if (res.code == 200) {
  861. this.answerQuestion= res.data.questionBankList || [],
  862. this.answerQuestion = this.answerQuestion.map(item => ({
  863. ...item,
  864. options: JSON.parse(item.question),
  865. answer: ''
  866. }))
  867. } else {
  868. uni.showToast({
  869. icon: 'none',
  870. title: res.msg,
  871. });
  872. }
  873. },
  874. rej => {}
  875. );
  876. },
  877. onTimeUpdate(e) {
  878. const d = (e && e.detail) || {};
  879. this.playTime = Math.floor(d.currentTime || 0);
  880. if (d.duration) {
  881. this.videoDuration = d.duration;
  882. }
  883. },
  884. onVideoLoadedMetadata() {
  885. if (this.pendingSeekTime <= 0) {
  886. return;
  887. }
  888. if (!this.videoContext) {
  889. this.videoContext = uni.createVideoContext("video-content-box", this);
  890. }
  891. const seekTime = this.pendingSeekTime;
  892. this.pendingSeekTime = 0;
  893. this.$nextTick(() => {
  894. setTimeout(() => {
  895. try {
  896. this.videoContext.seek(seekTime);
  897. this.playTime = seekTime;
  898. } catch (e) {
  899. console.warn("onVideoLoadedMetadata seek failed", e);
  900. }
  901. }, 120);
  902. });
  903. },
  904. /** 开始播放时调用一次:建立观看记录 */
  905. reportStudyOnPlayStart() {
  906. if (!this.courseId) {
  907. return;
  908. }
  909. if (this.studyStartReported) {
  910. return;
  911. }
  912. this.studyStartReported = true;
  913. this.saveStudyProgress(this.playTime || 0);
  914. },
  915. /** 暂停/离开/结束等:再上报一次,更新已学进度 */
  916. flushStudyProgress() {
  917. if (!this.courseId) {
  918. return;
  919. }
  920. if (!this.studyStartReported) {
  921. return;
  922. }
  923. this.saveStudyProgress(this.playTime);
  924. },
  925. saveStudyProgress(playTime) {
  926. let user = uni.getStorageSync('userInfo') || {};
  927. // 兼容 userInfo 可能被存成 JSON 字符串或对象
  928. if (typeof user === "string") {
  929. try {
  930. user = JSON.parse(user);
  931. } catch (e) {
  932. user = {};
  933. }
  934. }
  935. const param = {
  936. courseId: this.courseId,
  937. duration: playTime,
  938. videoId: this.videoId,
  939. userId: user.userId || user.id || null
  940. }
  941. if (!param.userId) {
  942. console.warn("saveStudyProgress: userId is empty", user);
  943. return;
  944. }
  945. addStudyCourseApi(param).then(
  946. res => {
  947. if (res.code == 200) {
  948. } else {
  949. uni.showToast({
  950. icon: 'none',
  951. title: res.msg,
  952. });
  953. }
  954. },
  955. rej => {}
  956. );
  957. },
  958. getCurrentUser() {
  959. let user = uni.getStorageSync("userInfo") || {};
  960. if (typeof user === "string") {
  961. try {
  962. user = JSON.parse(user);
  963. } catch (e) {
  964. user = {};
  965. }
  966. }
  967. return user || {};
  968. },
  969. ensureLogin() {
  970. const user = this.getCurrentUser();
  971. const userId = user.userId;
  972. if (userId) {
  973. return user;
  974. }
  975. uni.showModal({
  976. title: "提示",
  977. content: "请先登录后再发表评论",
  978. confirmText: "去登录",
  979. success: (res) => {
  980. if (res.confirm) {
  981. uni.navigateTo({
  982. url: "/pages/auth/login"
  983. });
  984. }
  985. }
  986. });
  987. return null;
  988. },
  989. submitComment() {
  990. if (this.isSendingComment) {
  991. return;
  992. }
  993. const content = (this.commentContent || "").trim();
  994. if (!content) {
  995. uni.showToast({
  996. title: "请输入评论内容",
  997. icon: "none"
  998. });
  999. return;
  1000. }
  1001. if (content.length > 50) {
  1002. uni.showToast({
  1003. title: "评论最多50字",
  1004. icon: "none"
  1005. });
  1006. return;
  1007. }
  1008. if (!this.courseId) {
  1009. uni.showToast({
  1010. title: "课程信息异常,请稍后重试",
  1011. icon: "none"
  1012. });
  1013. return;
  1014. }
  1015. const user = this.ensureLogin();
  1016. if (!user) {
  1017. return;
  1018. }
  1019. if (this.hasSensitiveWord(content)) {
  1020. const now = this.formatNowTime();
  1021. const localComment = this.normalizeCommentItem({
  1022. id: "local_" + Date.now(),
  1023. name: user.nickName || user.nickname || user.userName || "我",
  1024. time: now,
  1025. content: content,
  1026. avatar: user.avatar || user.avatarUrl || user.headImg || "https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/default-avatar.png",
  1027. selfOnly: true
  1028. }, 0);
  1029. this.comments = [localComment].concat(this.comments || []);
  1030. this.commentContent = "";
  1031. uni.showToast({
  1032. title: "含敏感词,评论仅自己可见",
  1033. icon: "none"
  1034. });
  1035. return;
  1036. }
  1037. const userId = user.userId;
  1038. this.isSendingComment = true;
  1039. const param = {
  1040. courseId: this.courseId,
  1041. toUserId: userId,
  1042. content: content,
  1043. type:1,
  1044. };
  1045. addCommentt(param).then(
  1046. (res) => {
  1047. if (res.code == 200) {
  1048. this.commentContent = "";
  1049. uni.showToast({
  1050. title: "评论成功",
  1051. icon: "none"
  1052. });
  1053. this.getCommentList(this.courseId, true);
  1054. } else {
  1055. uni.showToast({
  1056. icon: "none",
  1057. title: res.msg || "评论失败"
  1058. });
  1059. }
  1060. },
  1061. () => {}
  1062. ).finally(() => {
  1063. this.isSendingComment = false;
  1064. });
  1065. },
  1066. hasSensitiveWord(content) {
  1067. const text = (content || "").toLowerCase();
  1068. return this.sensitiveWords.some((word) => text.indexOf(String(word).toLowerCase()) > -1);
  1069. },
  1070. formatNowTime() {
  1071. const now = new Date();
  1072. const year = now.getFullYear();
  1073. const month = String(now.getMonth() + 1).padStart(2, "0");
  1074. const day = String(now.getDate()).padStart(2, "0");
  1075. const hour = String(now.getHours()).padStart(2, "0");
  1076. const minute = String(now.getMinutes()).padStart(2, "0");
  1077. return year + "-" + month + "-" + day + " " + hour + ":" + minute;
  1078. },
  1079. progressChange(e) {
  1080. const d = (e && e.detail) || {};
  1081. if (d.buffered != null) {
  1082. this.bufferRate = d.buffered;
  1083. }
  1084. },
  1085. videoErrorCallback(e) {
  1086. this.errorCount += 1;
  1087. console.error("courseDetail video error", e);
  1088. if (this.errorCount > 3) {
  1089. return;
  1090. }
  1091. uni.showToast({
  1092. title: "视频加载失败,请稍后重试",
  1093. icon: "none"
  1094. });
  1095. },
  1096. getPlay() {
  1097. this.errorCount = 0;
  1098. this.reportStudyOnPlayStart();
  1099. this.updateTrafficTime();
  1100. },
  1101. getPause() {
  1102. this.flushStudyProgress();
  1103. },
  1104. getEnded() {
  1105. if (this.videoDuration) {
  1106. this.playTime = Math.floor(this.videoDuration);
  1107. }
  1108. if (!this.courseId) {
  1109. return;
  1110. }
  1111. if (!this.studyStartReported) {
  1112. this.studyStartReported = true;
  1113. }
  1114. this.saveStudyProgress(this.playTime);
  1115. this.getInternetTraffic();
  1116. // 当前小节播放结束后自动切换下一讲(已在上方保存进度,避免 selectCourse 内再次 flush 重复上报)
  1117. const list = this.catalogList || [];
  1118. const idx = list.findIndex((v) => v.videoId == this.activeIndex);
  1119. if (idx >= 0 && idx < list.length - 1) {
  1120. this.$nextTick(() => {
  1121. this.selectCourse(list[idx + 1], { skipFlush: true });
  1122. });
  1123. }
  1124. },
  1125. fullscreenchange(e) {
  1126. const d = (e && e.detail) || {};
  1127. this.isFull = d.fullScreen;
  1128. },
  1129. getCurrentLessonWatchSeconds() {
  1130. const currentLesson = this.catalogList.find(v => v.videoId === this.activeIndex) || this.catalogList[0] || {};
  1131. const raw = currentLesson.watchDurationMinutes;
  1132. const minutes = Number(raw);
  1133. // 未配置或非法值:沿用默认 90 秒;明确为 0 表示不要求观看时长,不展示倒计时
  1134. if (!raw||raw === null || raw === undefined || !Number.isFinite(minutes)) {
  1135. return 0;
  1136. }
  1137. if (minutes === 0) {
  1138. return 0;
  1139. }
  1140. return Math.floor(minutes * 60);
  1141. },
  1142. resetAnswerCountdownByCurrentLesson() {
  1143. this.answerCountdown = this.getCurrentLessonWatchSeconds();
  1144. this.startAnswerCountdown();
  1145. },
  1146. startAnswerCountdown() {
  1147. this.clearAnswerTimer();
  1148. if (this.answerCountdown <= 0) {
  1149. return;
  1150. }
  1151. this.answerTimer = setInterval(() => {
  1152. if (this.answerCountdown <= 0) {
  1153. this.clearAnswerTimer();
  1154. return;
  1155. }
  1156. this.answerCountdown -= 1;
  1157. }, 1000);
  1158. },
  1159. clearAnswerTimer() {
  1160. if (this.answerTimer) {
  1161. clearInterval(this.answerTimer);
  1162. this.answerTimer = null;
  1163. }
  1164. },
  1165. openAnswerPopup() {
  1166. const user = this.getCurrentUser();
  1167. if (!user || !user.userId) {
  1168. uni.showModal({
  1169. title: '提示',
  1170. content: '请先登录后再答题',
  1171. confirmText: '去登录',
  1172. success: (res) => {
  1173. if (res.confirm) {
  1174. uni.navigateTo({ url: '/pages/auth/login' });
  1175. }
  1176. }
  1177. });
  1178. return;
  1179. }
  1180. if (!this.courseId || !this.videoId) {
  1181. uni.showToast({ title: '课程信息异常', icon: 'none' });
  1182. return;
  1183. }
  1184. courseAnswerStatus({ courseId: this.courseId, videoId: this.videoId }).then(
  1185. (res) => {
  1186. if (res.code != 200 || !res.data) {
  1187. uni.showToast({
  1188. title: res.msg || '获取答题状态失败',
  1189. icon: 'none'
  1190. });
  1191. return;
  1192. }
  1193. this.applyAnswerStatusPayload(res.data);
  1194. const st = this.answerStatus;
  1195. if (st === 3 ) {
  1196. this.answerResultType = 'exhausted';
  1197. this.showAnswerResultPopup = true;
  1198. return;
  1199. }
  1200. if (st === 4) {
  1201. this.answerResultType = 'success';
  1202. this.showAnswerResultPopup = true;
  1203. return;
  1204. }
  1205. if (!this.answerQuestion || this.answerQuestion.length === 0) {
  1206. uni.showToast({ title: '暂无题目', icon: 'none' });
  1207. return;
  1208. }
  1209. // if (st !== 2 && !this.canAnswer) {
  1210. // uni.showToast({ title: '请继续观看课程后再答题', icon: 'none' });
  1211. // return;
  1212. // }
  1213. this.selectedAnswers = {};
  1214. this.showAnswerPopup = true;
  1215. },
  1216. () => {
  1217. uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' });
  1218. }
  1219. );
  1220. },
  1221. closeAnswerPopup() {
  1222. this.showAnswerPopup = false;
  1223. },
  1224. closeAnswerResultPopup() {
  1225. this.showAnswerResultPopup = false;
  1226. },
  1227. selectAnswer(questionIndex, optionIndex) {
  1228. if (!this.canAnswer) {
  1229. return;
  1230. }
  1231. this.$set(this.selectedAnswers, questionIndex, optionIndex);
  1232. },
  1233. submitAnswer() {
  1234. if (!this.isAnswerReady) {
  1235. return;
  1236. }
  1237. this.showAnswerPopup = false;
  1238. const user = this.getCurrentUser();
  1239. const questions = this.answerQuestion.map((obj, questionIndex) => {
  1240. const { options, ...rest } = obj;
  1241. const optionList = options || [];
  1242. const selectedOptionIndex = this.selectedAnswers[questionIndex];
  1243. const opt =
  1244. selectedOptionIndex === undefined || selectedOptionIndex === null
  1245. ? null
  1246. : optionList[selectedOptionIndex];
  1247. return {
  1248. ...rest,
  1249. answer: opt ? opt.name : ''
  1250. };
  1251. });
  1252. const param = {
  1253. courseId: this.courseId,
  1254. videoId: this.videoId,
  1255. duration: this.playTime,
  1256. questions
  1257. };
  1258. if (user && user.userId) {
  1259. param.userId = user.userId;
  1260. }
  1261. submitCourseAnswerApi(param).then(
  1262. (res) => {
  1263. this.selectedAnswers = {};
  1264. if (res.code == 200) {
  1265. const wrong =
  1266. res.incorrectQuestions &&
  1267. Array.isArray(res.incorrectQuestions) &&
  1268. res.incorrectQuestions.length > 0;
  1269. if (res.msg == '答题成功' && !wrong) {
  1270. this.answerResultType = 'success';
  1271. this.hasAward = true;
  1272. this.loadCourseAnswerStatus(this.videoId);
  1273. this.claimIntegralReward();
  1274. this.showAnswerResultPopup = true;
  1275. return;
  1276. }
  1277. if (wrong || res.remain !== undefined) {
  1278. if (res.remain !== undefined && res.remain !== null) {
  1279. this.attemptsLeft = Math.max(0, Number(res.remain));
  1280. } else {
  1281. this.attemptsLeft = Math.max(0, this.attemptsLeft - 1);
  1282. }
  1283. this.answerResultType =
  1284. this.attemptsLeft > 0 ? 'fail' : 'exhausted';
  1285. this.loadCourseAnswerStatus(this.videoId);
  1286. this.showAnswerResultPopup = true;
  1287. return;
  1288. }
  1289. this.answerResultType = 'exhausted';
  1290. this.loadCourseAnswerStatus(this.videoId);
  1291. this.showAnswerResultPopup = true;
  1292. } else {
  1293. uni.showToast({
  1294. icon: 'none',
  1295. title: res.msg || '提交失败'
  1296. });
  1297. }
  1298. },
  1299. () => {}
  1300. );
  1301. },
  1302. claimIntegralReward() {
  1303. const data = {
  1304. courseId: this.courseId,
  1305. videoId: this.videoId
  1306. };
  1307. claimCourseAnswerIntegral(data).then(
  1308. (res) => {
  1309. if (res.code == 200) {
  1310. const earned =
  1311. res.data &&
  1312. (res.data.integral ??
  1313. res.data.score ??
  1314. res.data.integralReward);
  1315. if (earned !== undefined && earned !== null && earned !== '') {
  1316. const n = Number(earned);
  1317. if (Number.isFinite(n)) {
  1318. this.awardScore = n;
  1319. }
  1320. }
  1321. } else {
  1322. uni.showToast({
  1323. icon: 'none',
  1324. title: res.msg || '领取积分失败'
  1325. });
  1326. }
  1327. },
  1328. () => {}
  1329. );
  1330. },
  1331. goToIntegralMall() {
  1332. this.showAnswerResultPopup = false;
  1333. uni.navigateTo({
  1334. url: "/pages_user/user/integralGoodsList"
  1335. });
  1336. },
  1337. goBack() {
  1338. uni.navigateBack({
  1339. delta: 1,
  1340. fail: () => {
  1341. uni.switchTab({
  1342. url: "/pages/home/index"
  1343. });
  1344. }
  1345. });
  1346. },
  1347. selectCourse(item, opts) {
  1348. if (item.videoId == this.activeIndex) {
  1349. this.showCatalog = false;
  1350. return;
  1351. }
  1352. if (!opts || !opts.skipFlush) {
  1353. this.flushStudyProgress();
  1354. }
  1355. this.activeIndex = item.videoId;
  1356. this.videoInfo = item;
  1357. this.resetAnswerCountdownByCurrentLesson();
  1358. this.showCatalog = false;
  1359. this.studyStartReported = false;
  1360. this.playTime = 0;
  1361. this.pendingSeekTime = 0;
  1362. this.hasAppliedInitialStudyLog = true;
  1363. this.initLessonVideo();
  1364. this.$nextTick(() => {
  1365. this.videoContext = uni.createVideoContext("video-content-box", this);
  1366. this.tryPlayVideo();
  1367. });
  1368. },
  1369. handleShare() {
  1370. this.showSharePopup = true;
  1371. },
  1372. closeSharePopup() {
  1373. this.showSharePopup = false;
  1374. },
  1375. onShareSelect(type) {
  1376. this.showSharePopup = false;
  1377. const shareText = type === "wechat" ? "微信好友" : "朋友圈";
  1378. uni.showToast({
  1379. title: "分享至" + shareText + "待接入",
  1380. icon: "none"
  1381. });
  1382. }
  1383. }
  1384. };
  1385. </script>
  1386. <style scoped lang="scss">
  1387. .page {
  1388. background: #f6f6f6;
  1389. height: 100vh;
  1390. }
  1391. .back-box{
  1392. position: fixed;
  1393. left:12px;
  1394. z-index:9999
  1395. }
  1396. .page-scroll {
  1397. height: calc(100vh - 184rpx);
  1398. box-sizing: border-box;
  1399. padding-top: calc(420rpx + 88rpx);
  1400. }
  1401. .video-wrap {
  1402. position: fixed;
  1403. top: 0;
  1404. left: 0;
  1405. right: 0;
  1406. z-index: 20;
  1407. width: 100%;
  1408. // height: 420rpx;
  1409. }
  1410. .video-cover {
  1411. width: 100%;
  1412. height: 100%;
  1413. }
  1414. .video-mask {
  1415. position: absolute;
  1416. inset: 0;
  1417. background: rgba(0, 0, 0, 0.2);
  1418. }
  1419. .top-left {
  1420. position: absolute;
  1421. left: 24rpx;
  1422. top: 24rpx;
  1423. color: #fff;
  1424. font-size: 56rpx;
  1425. z-index: 2;
  1426. }
  1427. .top-right {
  1428. position: absolute;
  1429. right: 24rpx;
  1430. top: 24rpx;
  1431. display: flex;
  1432. gap: 12rpx;
  1433. z-index: 2;
  1434. }
  1435. .dot-btn {
  1436. min-width: 56rpx;
  1437. height: 56rpx;
  1438. padding: 0 18rpx;
  1439. border-radius: 28rpx;
  1440. background: rgba(0, 0, 0, 0.45);
  1441. color: #fff;
  1442. display: flex;
  1443. align-items: center;
  1444. justify-content: center;
  1445. font-size: 26rpx;
  1446. }
  1447. .video-control {
  1448. position: absolute;
  1449. bottom: 18rpx;
  1450. left: 24rpx;
  1451. right: 24rpx;
  1452. z-index: 2;
  1453. display: flex;
  1454. align-items: center;
  1455. color: #fff;
  1456. font-size: 24rpx;
  1457. }
  1458. .play-icon {
  1459. margin-right: 12rpx;
  1460. font-size: 28rpx;
  1461. }
  1462. .time-text {
  1463. min-width: 70rpx;
  1464. }
  1465. .progress-line {
  1466. flex: 1;
  1467. height: 4rpx;
  1468. margin: 0 14rpx;
  1469. background: rgba(255, 255, 255, 0.85);
  1470. }
  1471. .content {
  1472. background: #fff;
  1473. padding:30rpx 24rpx;
  1474. }
  1475. .course-title {
  1476. font-family: PingFangSC, PingFang SC;
  1477. font-weight: 600;
  1478. font-size: 40rpx;
  1479. color: rgba(0,0,0,0.85);
  1480. line-height: 56rpx;
  1481. text-align: justify;
  1482. }
  1483. .course-desc {
  1484. margin-top: 20rpx;
  1485. font-family: PingFangSC, PingFang SC;
  1486. font-weight: 400;
  1487. font-size: 32rpx;
  1488. color: rgba(0,0,0,0.65);
  1489. line-height: 44rpx;
  1490. text-align: justify;
  1491. }
  1492. .course-views {
  1493. margin-top: 20rpx;
  1494. font-family: PingFangSC, PingFang SC;
  1495. font-weight: 400;
  1496. font-size: 32rpx;
  1497. color: rgba(0,0,0,0.45);
  1498. line-height: 44rpx;
  1499. text-align: justify;
  1500. }
  1501. .section-head {
  1502. margin-top: 14rpx;
  1503. padding: 18rpx 24rpx 0;
  1504. background: #fff;
  1505. display: flex;
  1506. align-items: center;
  1507. justify-content: space-between;
  1508. }
  1509. .left {
  1510. display: flex;
  1511. align-items: center;
  1512. }
  1513. .dot {
  1514. margin-right: 14rpx;
  1515. width:32rpx;
  1516. height: 32rpx;
  1517. }
  1518. .section-title {
  1519. font-family: PingFangSC, PingFang SC;
  1520. font-weight: 600;
  1521. font-size: 36rpx;
  1522. color: #222222;
  1523. line-height: 50rpx;
  1524. }
  1525. .count {
  1526. font-family: PingFangSC, PingFang SC;
  1527. font-weight: 400;
  1528. font-size: 32rpx;
  1529. color: rgba(0,0,0,0.45);
  1530. display: flex;
  1531. align-items: center;
  1532. }
  1533. .catalog-scroll {
  1534. padding: 24rpx;
  1535. background: #fff;
  1536. white-space: nowrap;
  1537. box-sizing: border-box;
  1538. }
  1539. .catalog-row {
  1540. display: inline-flex;
  1541. gap: 24rpx;
  1542. }
  1543. .catalog-item {
  1544. width: 280rpx;
  1545. min-height: 192rpx;
  1546. background: #FFF0F2;
  1547. border-radius: 20rpx;
  1548. background: #f2f3f6;
  1549. padding:24rpx;
  1550. box-sizing: border-box;
  1551. position: relative;
  1552. }
  1553. .catalog-item.active {
  1554. background: #ffeef1;
  1555. border-color: #ffd7de;
  1556. }
  1557. .catalog-top {
  1558. display: flex;
  1559. align-items: center;
  1560. justify-content: space-between;
  1561. }
  1562. .catalog-index-wrap {
  1563. display: flex;
  1564. align-items: center;
  1565. }
  1566. .catalog-index {
  1567. font-family: PingFangSC, PingFang SC;
  1568. font-weight: 600;
  1569. font-size: 32rpx;
  1570. color: #FF233C;
  1571. line-height: 44rpx;
  1572. }
  1573. .catalog-active-dot {
  1574. width: 32rpx;
  1575. height: 32rpx;
  1576. margin-left: 10rpx;
  1577. border-radius: 50%;
  1578. position: relative;
  1579. }
  1580. // .catalog-active-dot::after {
  1581. // content: "";
  1582. // position: absolute;
  1583. // left: 5rpx;
  1584. // top: 5rpx;
  1585. // width: 8rpx;
  1586. // height: 8rpx;
  1587. // border-radius: 50%;
  1588. // background: #fff;
  1589. // }
  1590. .free-tag {
  1591. position: absolute;
  1592. right: 0;
  1593. top:0;
  1594. padding:2rpx 10rpx;
  1595. background: #ff2b49;
  1596. border-radius: 0rpx 20rpx 0rpx 20rpx;
  1597. font-family: PingFangSC, PingFang SC;
  1598. font-weight: 400;
  1599. font-size: 28rpx;
  1600. color: #FFFFFF;
  1601. line-height: 40rpx;
  1602. }
  1603. .catalog-name {
  1604. margin-top: 12rpx;
  1605. font-family: PingFangSC, PingFang SC;
  1606. font-weight: 400;
  1607. font-size: 32rpx;
  1608. color: rgba(0,0,0,0.65);
  1609. line-height: 44rpx;
  1610. white-space: normal;
  1611. word-break: break-all;
  1612. overflow: hidden;
  1613. text-overflow: ellipsis;
  1614. display: -webkit-box;
  1615. -webkit-line-clamp: 2;
  1616. -webkit-box-orient: vertical;
  1617. }
  1618. .catalog-name.active {
  1619. color: #FF233C;
  1620. }
  1621. .comment-wrap {
  1622. margin-top: 20rpx;
  1623. background: #fff;
  1624. padding: 24rpx;
  1625. }
  1626. .comment-title {
  1627. font-family: PingFangSC, PingFang SC;
  1628. font-weight: 600;
  1629. font-size: 36rpx;
  1630. color: #222222;
  1631. line-height: 50rpx;
  1632. margin-bottom: 24rpx;
  1633. }
  1634. .comment-item {
  1635. display: flex;
  1636. padding-bottom: 24rpx;
  1637. }
  1638. .comment-empty {
  1639. padding: 30rpx 0;
  1640. text-align: center;
  1641. font-size: 30rpx;
  1642. color: #999;
  1643. }
  1644. .comment-load-status {
  1645. padding: 20rpx 0 8rpx;
  1646. text-align: center;
  1647. font-size: 28rpx;
  1648. color: #999;
  1649. }
  1650. .avatar {
  1651. width: 90rpx;
  1652. height: 90rpx;
  1653. border-radius: 50%;
  1654. margin-right: 12rpx;
  1655. }
  1656. .comment-main {
  1657. flex: 1;
  1658. }
  1659. .name {
  1660. font-family: PingFangSC, PingFang SC;
  1661. font-weight: 600;
  1662. font-size: 32rpx;
  1663. color: #222222;
  1664. line-height: 44rpx;
  1665. }
  1666. .self-only-tag {
  1667. font-size: 26rpx;
  1668. color: #ff3b57;
  1669. margin-left: 8rpx;
  1670. font-weight: 400;
  1671. }
  1672. .time {
  1673. font-family: PingFangSC, PingFang SC;
  1674. font-weight: 400;
  1675. font-size: 28rpx;
  1676. color: rgba(0,0,0,0.45);
  1677. line-height: 40rpx;
  1678. margin-top: 12rpx;
  1679. }
  1680. .text {
  1681. font-family: PingFangSC, PingFang SC;
  1682. font-weight: 400;
  1683. font-size: 32rpx;
  1684. color: #222222;
  1685. line-height: 40rpx;
  1686. margin-top: 12rpx;
  1687. }
  1688. .bottom-space {
  1689. height: 40rpx;
  1690. }
  1691. .answer-entry {
  1692. position: fixed;
  1693. right: 34rpx;
  1694. bottom: 320rpx;
  1695. z-index: 28;
  1696. display: flex;
  1697. flex-direction: column;
  1698. align-items: center;
  1699. }
  1700. .gift-icon {
  1701. width: 210rpx;
  1702. height: 90rpx;
  1703. margin-bottom: -10rpx;
  1704. }
  1705. .answer-tip {
  1706. width: 210rpx;
  1707. // height: 188rpx;
  1708. background: linear-gradient( 180deg, #FFF9DC 0%, #FFDC97 100%);
  1709. border-radius: 20rpx;
  1710. //border: 2rpx solid transparent;
  1711. //border-image: linear-gradient(180deg, rgba(255, 228, 105, 1), rgba(255, 178, 30, 1)) 2 2;
  1712. font-family: PingFangSC, PingFang SC;
  1713. font-weight: 600;
  1714. font-size: 32rpx;
  1715. color: #FF2E3F;
  1716. line-height: 44rpx;
  1717. padding: 20rpx 0;
  1718. display: flex;
  1719. flex-direction: column;
  1720. align-items: center;
  1721. text-align: center;
  1722. box-sizing: border-box;
  1723. }
  1724. .answer-tip-line {
  1725. display: block;
  1726. width: 100%;
  1727. word-break: keep-all;
  1728. white-space: nowrap;
  1729. line-height: 44rpx;
  1730. }
  1731. .answer-tip-line-first {
  1732. margin-bottom: 4rpx;
  1733. }
  1734. .answer-tip-single {
  1735. display: block;
  1736. line-height: 44rpx;
  1737. }
  1738. .answer-tip-single2 {
  1739. display:flex;
  1740. align-items: baseline;
  1741. font-family: PingFangSC, PingFang SC;
  1742. font-weight: 400;
  1743. font-size: 28rpx;
  1744. color: #FF2E3F;
  1745. .jifen{
  1746. font-family: PingFangSC, PingFang SC;
  1747. font-weight: 600;
  1748. font-size: 56rpx;
  1749. color: #FF2E3F;
  1750. }
  1751. }
  1752. .answer-tip.done {
  1753. border-color: #f2be3f;
  1754. color: #c53533;
  1755. }
  1756. .answer-btn {
  1757. margin-top: 8rpx;
  1758. width: 150rpx;
  1759. height: 60rpx;
  1760. background: linear-gradient( 135deg, #FF515F 0%, #F72234 100%);
  1761. border-radius: 30rpx;
  1762. font-family: PingFangSC, PingFang SC;
  1763. font-weight: 600;
  1764. font-size: 32rpx;
  1765. color: #FFF2C3;
  1766. line-height: 60rpx;
  1767. text-align: center;
  1768. }
  1769. .bottom-bar {
  1770. position: fixed;
  1771. left: 0;
  1772. right: 0;
  1773. bottom: 0;
  1774. background: #fff;
  1775. // border-top: 1rpx solid #eee;
  1776. display: flex;
  1777. align-items: center;
  1778. padding: 20rpx 24rpx 68rpx;
  1779. box-sizing: border-box;
  1780. }
  1781. .input {
  1782. flex: 1;
  1783. height: 96rpx;
  1784. background: #F5F5F5;
  1785. border-radius: 48rpx;
  1786. padding: 0 30rpx;
  1787. font-family: PingFangSC, PingFang SC;
  1788. font-weight: 400;
  1789. font-size: 32rpx;
  1790. //color: rgba(0,0,0,0.25);
  1791. display: flex;
  1792. align-items: center;
  1793. }
  1794. .send-btn {
  1795. margin-left: 24rpx;
  1796. margin-right: 24rpx;
  1797. width: 160rpx;
  1798. height: 96rpx;
  1799. background: linear-gradient( 135deg, #FF5267 0%, #FF233C 100%);
  1800. border-radius: 48rpx;
  1801. color: #fff;
  1802. font-family: PingFangSC, PingFang SC;
  1803. font-weight: 600;
  1804. font-size: 40rpx;
  1805. color: #FFFFFF;
  1806. display: flex;
  1807. align-items: center;
  1808. justify-content: center;
  1809. }
  1810. .send-btn.disabled {
  1811. background: #ff9baa;
  1812. }
  1813. .comment-input {
  1814. box-sizing: border-box;
  1815. }
  1816. .comment-input-placeholder {
  1817. color: #bbb;
  1818. }
  1819. .share-btn {
  1820. display: flex;
  1821. flex-direction: column;
  1822. align-items: center;
  1823. font-family: PingFangSC, PingFang SC;
  1824. font-weight: 600;
  1825. font-size: 32rpx;
  1826. color: #222222;
  1827. line-height: 44rpx;
  1828. text-align: center;
  1829. image{
  1830. width: 52rpx;
  1831. height: 52rpx;
  1832. }
  1833. }
  1834. .share-icon {
  1835. color: #ff3b57;
  1836. font-size: 36rpx;
  1837. line-height: 1;
  1838. }
  1839. .share-mask {
  1840. position: fixed;
  1841. inset: 0;
  1842. background: rgba(0, 0, 0, 0.45);
  1843. z-index: 120;
  1844. display: flex;
  1845. align-items: flex-end;
  1846. }
  1847. .share-panel {
  1848. width: 100%;
  1849. padding: 20rpx 20rpx 28rpx;
  1850. box-sizing: border-box;
  1851. background: #F4F6F7;
  1852. border-radius: 20rpx 20rpx 0rpx 0rpx;
  1853. }
  1854. .share-card {
  1855. background: #fff;
  1856. border-radius: 12rpx;
  1857. padding: 40rpx;
  1858. overflow: hidden;
  1859. }
  1860. .share-item {
  1861. //height: 106rpx;
  1862. display: flex;
  1863. align-items: center;
  1864. background: #fff;
  1865. position: relative;
  1866. // &:first-child{
  1867. // margin-bottom: 40rpx;
  1868. // }
  1869. .share {
  1870. display: inline-block;
  1871. position: absolute;
  1872. top: 0;
  1873. left: 0;
  1874. width: 100%;
  1875. height: 100%;
  1876. opacity: 0;
  1877. }
  1878. }
  1879. .share-avatar {
  1880. width: 80rpx;
  1881. height: 80rpx;
  1882. border-radius: 50%;
  1883. margin-right: 20rpx;
  1884. }
  1885. .wechat {
  1886. }
  1887. .moments {
  1888. }
  1889. .share-text {
  1890. font-family: PingFangSC, PingFang SC;
  1891. font-weight: 400;
  1892. font-size: 36rpx;
  1893. color: rgba(0,0,0,0.85);
  1894. line-height: 50rpx;
  1895. }
  1896. .cancel-btn {
  1897. margin-top: 20rpx;
  1898. height: 96rpx;
  1899. background: #fff;
  1900. border-radius: 48rpx;
  1901. display: flex;
  1902. align-items: center;
  1903. justify-content: center;
  1904. font-family: PingFangSC, PingFang SC;
  1905. font-weight: 400;
  1906. font-size: 32rpx;
  1907. color: rgba(0,0,0,0.85);
  1908. }
  1909. .answer-mask {
  1910. position: fixed;
  1911. inset: 0;
  1912. background: rgba(0, 0, 0, 0.45);
  1913. display: flex;
  1914. align-items: flex-end;
  1915. z-index: 130;
  1916. }
  1917. .answer-panel {
  1918. width: 100%;
  1919. background: #fff;
  1920. border-radius: 24rpx 24rpx 0 0;
  1921. padding: 20rpx 22rpx 30rpx;
  1922. box-sizing: border-box;
  1923. }
  1924. .answer-head {
  1925. display: flex;
  1926. align-items: center;
  1927. justify-content: space-between;
  1928. .dot{
  1929. width: 32rpx;
  1930. height: 32rpx;
  1931. margin-right: 10rpx;
  1932. }
  1933. }
  1934. .answer-divider {
  1935. margin-top: 26rpx;
  1936. height: 1rpx;
  1937. background: #D8D8D8;
  1938. }
  1939. .question-title {
  1940. margin-top: 18rpx;
  1941. font-size: 46rpx;
  1942. font-weight: 600;
  1943. color: #222;
  1944. line-height: 60rpx;
  1945. }
  1946. .answer-option {
  1947. margin-top: 18rpx;
  1948. background: #f3f4f7;
  1949. border-radius: 16rpx;
  1950. padding: 22rpx 24rpx;
  1951. font-size: 42rpx;
  1952. color: #333;
  1953. line-height: 48rpx;
  1954. }
  1955. .answer-option.active {
  1956. background: #ffedf0;
  1957. color: #ff2b49;
  1958. font-weight: 600;
  1959. }
  1960. .answer-option.disabled {
  1961. color: #4a4a4a;
  1962. }
  1963. .submit-btn {
  1964. margin: 48rpx auto 0;
  1965. width: 690rpx;
  1966. max-width: 100%;
  1967. height: 88rpx;
  1968. border-radius: 44rpx;
  1969. background: #c3c4c8;
  1970. color: #fff;
  1971. font-size: 40rpx;
  1972. display: flex;
  1973. align-items: center;
  1974. justify-content: center;
  1975. }
  1976. .submit-btn.active {
  1977. background: #ff3b57;
  1978. }
  1979. .submit-btn.disabled {
  1980. background: #c3c4c8;
  1981. }
  1982. .answer-result-mask {
  1983. position: fixed;
  1984. inset: 0;
  1985. background: rgba(0, 0, 0, 0.45);
  1986. display: flex;
  1987. align-items: center;
  1988. justify-content: center;
  1989. flex-direction: column;
  1990. z-index: 135;
  1991. }
  1992. .answer-result-panel {
  1993. width: 660rpx;
  1994. background: #fff;
  1995. border-radius: 28rpx;
  1996. padding:40rpx;
  1997. box-sizing: border-box;
  1998. text-align: center;
  1999. display: flex;
  2000. align-items: center;
  2001. flex-direction: column;
  2002. }
  2003. .result-title {
  2004. font-family: PingFangSC, PingFang SC;
  2005. font-weight: 600;
  2006. font-size: 40rpx;
  2007. color: #000000;
  2008. line-height: 56rpx;
  2009. text-align: center;
  2010. }
  2011. .result-subtitle {
  2012. margin-top: 40rpx;
  2013. font-family: PingFangSC, PingFang SC;
  2014. font-weight: 600;
  2015. font-size: 36rpx;
  2016. color: rgba(0,0,0,0.85);
  2017. line-height: 50rpx;
  2018. text-align: center;
  2019. }
  2020. .result-score {
  2021. color: #ff2b49;
  2022. font-size: 56rpx;
  2023. font-weight: 600;
  2024. }
  2025. .result-chance {
  2026. margin-top: 24rpx;
  2027. font-family: PingFangSC, PingFang SC;
  2028. font-weight: 400;
  2029. font-size: 32rpx;
  2030. color: rgba(0,0,0,0.65);
  2031. line-height: 44rpx;
  2032. text-align: center;
  2033. }
  2034. .result-primary-btn {
  2035. margin-top: 40rpx;
  2036. width: 390rpx;
  2037. height: 84rpx;
  2038. background: linear-gradient( 135deg, #FF5267 0%, #FF233C 100%);
  2039. border-radius: 42rpx;
  2040. font-family: PingFangSC, PingFang SC;
  2041. font-weight: 500;
  2042. font-size: 32rpx;
  2043. color: #FFFFFF;
  2044. display: flex;
  2045. align-items: center;
  2046. justify-content: center;
  2047. }
  2048. .result-second-btn {
  2049. margin-top: 40rpx;
  2050. width: 390rpx;
  2051. height: 84rpx;
  2052. border-radius: 42rpx;
  2053. border: 2rpx solid #FF233C;
  2054. font-family: PingFangSC, PingFang SC;
  2055. font-weight: 600;
  2056. font-size: 32rpx;
  2057. color: #FF233C;
  2058. display: flex;
  2059. align-items: center;
  2060. justify-content: center;
  2061. }
  2062. .result-close {
  2063. margin-top: 30rpx;
  2064. width: 60rpx;
  2065. height: 60rpx;
  2066. border-radius: 50%;
  2067. border: 2rpx solid #fff;
  2068. color: #fff;
  2069. font-size: 34rpx;
  2070. display: flex;
  2071. align-items: center;
  2072. justify-content: center;
  2073. }
  2074. .popup-mask {
  2075. position: fixed;
  2076. inset: 0;
  2077. background: rgba(0, 0, 0, 0.45);
  2078. display: flex;
  2079. align-items: flex-end;
  2080. z-index: 99;
  2081. }
  2082. .popup-panel {
  2083. width: 100%;
  2084. height: 66vh;
  2085. background: #fff;
  2086. border-radius: 28rpx 28rpx 0 0;
  2087. padding: 24rpx;
  2088. box-sizing: border-box;
  2089. }
  2090. .popup-divider {
  2091. margin-top: 26rpx;
  2092. height: 1rpx;
  2093. background: #D8D8D8;
  2094. }
  2095. .popup-head {
  2096. display: flex;
  2097. align-items: center;
  2098. justify-content: space-between;
  2099. .dot{
  2100. width: 32rpx;
  2101. height: 32rpx;
  2102. margin-right: 10rpx;
  2103. }
  2104. }
  2105. .close-btn {
  2106. width: 60rpx;
  2107. height: 60rpx;
  2108. border-radius: 50%;
  2109. background: #f3f3f3;
  2110. color: #999;
  2111. display: flex;
  2112. align-items: center;
  2113. justify-content: center;
  2114. font-size: 28rpx;
  2115. image{
  2116. width: 100%;
  2117. height: 100%;
  2118. }
  2119. }
  2120. .popup-scroll {
  2121. height: calc(66vh - 160rpx);
  2122. margin-top: 24rpx;
  2123. }
  2124. .popup-item {
  2125. background: #f5f5f5;
  2126. border-radius: 16rpx;
  2127. padding: 16rpx;
  2128. margin-bottom: 14rpx;
  2129. position: relative;
  2130. }
  2131. .popup-item.active {
  2132. background: #FFF0F2;
  2133. }
  2134. .popup-name {
  2135. margin-top: 8rpx;
  2136. font-family: PingFangSC, PingFang SC;
  2137. font-weight: 400;
  2138. font-size: 32rpx;
  2139. color: rgba(0,0,0,0.65);
  2140. line-height: 44rpx;
  2141. }
  2142. .popup-name.active {
  2143. color: #FF233C;
  2144. }
  2145. </style>