courseDetail.vue 53 KB

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