learningNew.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970
  1. <template>
  2. <view>
  3. <view class="expirebox" v-if="isExpire">
  4. <image src="/static/images/expire.png" mode="aspectFill"></image>
  5. {{msg}}
  6. </view>
  7. <view class="content" v-show="!isExpire">
  8. <view class="video-box">
  9. <image v-if="!isLogin || isAddKf!=1" class="video-poster" :src="courseInfo.imgUrl" mode="aspectFill">
  10. </image>
  11. <video
  12. @timeupdate="onTimeUpdate"
  13. @progress="progressChange"
  14. @error="videoErrorCallback"
  15. @play="getPlay"
  16. @pause="getPause"
  17. @ended="getEnded"
  18. @waiting="getWaiting"
  19. @fullscreenchange="fullscreenchange"
  20. :title="courseInfo.title"
  21. style="width: 100%;height: 420rpx;"
  22. :poster="poster"
  23. id="video-content-box"
  24. controls
  25. :auto-pause-if-open-native="true"
  26. :auto-pause-if-navigate="true"
  27. :enable-progress-gesture="false"
  28. :show-progress="true"
  29. :picture-in-picture-mode="[]"
  30. :show-background-playback-button="false"
  31. :src="videoUrl">
  32. <!-- logo -->
  33. <commentBox
  34. v-if="openCommentStatus==2"
  35. ref="danmuBox"
  36. :height="height"
  37. :urlOption="urlOption"
  38. :time="playTime"
  39. :showDanmu="showDanmu"
  40. :viewCommentNum="viewCommentNum"
  41. :openCommentStatus="openCommentStatus"
  42. @setInputText="setInputText"
  43. @getScrollTop="getScrollTop"
  44. @getMore="getMore"></commentBox>
  45. <cover-view class="video-danmu-btnbox" :style="{display: openCommentStatus==2&&isfull&&crtShow&&isLogin&&isAddKf==1 ? 'block':'none'}">
  46. <cover-image class="video-danmu-image"
  47. src="https://cos.his.cdwjyyh.com/fs/20250418/beaf9df1a6204b8babc3e28d9b563c62.png"
  48. @click="openDanmu(1)"></cover-image>
  49. </cover-view>
  50. <cover-image v-if="courseLogo" :class="isfull?'logo-full':'logo'" :src="courseLogo" mode="widthFix"></cover-image>
  51. <cover-view class="video-controls-box" v-if="isLogin&&isAddKf==1&&isPause">
  52. <cover-image class="video-play" src="@/static/images/video_icon.png" @click="clickVideo()"></cover-image>
  53. </cover-view>
  54. </video>
  55. </view>
  56. <view class="title-content" id="title-contentnav" v-show="openCommentStatus!=1">
  57. <!-- 答题时展示小节课程名,其他展示课程名 -->
  58. <!-- 小节课程名 -->
  59. <view class="subtitlebox" v-if="isLogin&&isAddKf==1">
  60. {{courseInfo.title}}
  61. </view>
  62. <!-- 课程名字 -->
  63. <view class="miantitlebox" v-else>
  64. {{courseInfo.courseName}}
  65. </view>
  66. </view>
  67. <view class="tabbox" v-if="openCommentStatus==1">
  68. <view :class="currentTab == nav.id ? 'tabbox-active':''" v-for="nav in navList" :key="nav.id" @click="handleTab(nav.id)">{{nav.name}}</view>
  69. </view>
  70. <scroll-view
  71. class="scroll-view"
  72. :style="{height: height}"
  73. :scroll-top="scrollTop"
  74. :scroll-y="true"
  75. :refresher-enabled="currentTab == 2"
  76. :refresher-triggered="triggered"
  77. @refresherrefresh="handleRefresher">
  78. <template v-if="openCommentStatus==1">
  79. <view v-show="currentTab==0">
  80. <descInfoNav ref="descInfoNav" :isLogin="isLogin" :isAddKf="isAddKf" :courseInfo="courseInfo"></descInfoNav>
  81. </view>
  82. <view v-show="currentTab==2">
  83. <commentBox
  84. ref="commentBox"
  85. :height="height"
  86. :urlOption="urlOption"
  87. :time="playTime"
  88. :flagTime="flagTime"
  89. :showDanmu="showDanmu"
  90. :viewCommentNum="viewCommentNum"
  91. :openCommentStatus="openCommentStatus"
  92. @setInputText="setInputText"
  93. @getScrollTop="getScrollTop"
  94. @getMore="getMore"></commentBox>
  95. </view>
  96. </template>
  97. <view v-show="currentTab==1">
  98. <template v-if="openCommentStatus!=1">
  99. <!-- 介绍 -->
  100. <descInfo ref="descInfo" :isLogin="isLogin" :isAddKf="isAddKf" :courseInfo="courseInfo"></descInfo>
  101. </template>
  102. <!-- 问题 -->
  103. <template v-if="isLogin&&isAddKf==1">
  104. <ques ref="ques" :quesList="quesList" :openCommentStatus="openCommentStatus" @handleAnswer="handleAnswer"></ques>
  105. </template>
  106. </view>
  107. </scroll-view>
  108. <!-- 线路 -->
  109. <view class="video-line" @click="openPop" v-if="isLogin&&isAddKf==1">
  110. <image src="/static/images/changePlayer-icon.png"></image>
  111. <text>线路{{lineIndex + 1 | numberToChinese}}</text>
  112. </view>
  113. <!-- 线路弹窗 -->
  114. <uni-popup ref="popup" type="bottom" class="full-width-popup">
  115. <view class="popupbox">
  116. <view class="popupbox-head">
  117. <text>线路选择</text>
  118. <image class="close-icon" src="/static/images/tc_close_icon.png" mode="aspectFill" @click="close">
  119. </image>
  120. </view>
  121. <view class="popupbox-content">
  122. <view :class="lineIndex == index ? 'line-item line-active': 'line-item'"
  123. v-for="(it,index) in lineList" :key="index" @click="handleLine(index)">
  124. 线路{{index + 1 | numberToChinese}}</view>
  125. </view>
  126. </view>
  127. </uni-popup>
  128. <!-- 温馨提示弹窗 -->
  129. <uni-popup ref="tipsPopup" type="center" :is-mask-click="false">
  130. <view class="tipsPopup-mask">
  131. <image class="red_envelope_top" src="/static/images/red_envelope_img.png" mode="aspectFill"></image>
  132. <view class="tipsPopup">
  133. <image class="tipsPopup-close" src="/static/images/course_close_white_icon.png" mode="aspectFill"
  134. @click="closeTipsPop"></image>
  135. <view class="tipsPopup-line">
  136. <view class="tipsPopup-box">
  137. <view class="tipsPopup-head">
  138. <image class="tipsPopup-head-title" src="/static/images/tips_title_img.png"
  139. mode="widthFix"></image>
  140. </view>
  141. <view class="tipsPopup-content">
  142. <view class="tipsPopup-content-title">亲爱的用户,</view>
  143. <view>您已经观看课程一半的时间了,请注意休息并保持专注。</view>
  144. </view>
  145. <view class="tipsPopup-btn-box">
  146. <view class="tipsPopup-btn" @click="closeTipsPop">继续观看领奖励</view>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </uni-popup>
  153. <!-- 发送弹幕 -->
  154. <view class="video-line danmu-line" @click="openDanmu(0)" v-if="isLogin&&isAddKf==1&&openCommentStatus==2">
  155. <image class="set_image" src="https://cos.his.cdwjyyh.com/fs/20250418/5e508642737a44169061382566043ac9.png" mode="aspectFill"></image>
  156. <text>发弹幕</text>
  157. </view>
  158. <!-- 发送弹幕弹窗 -->
  159. <uni-popup ref="danmuPopup" type="bottom" style="z-index: 999;" @change="changeShowPopup">
  160. <view class="danmuPopup" :style="{marginLeft:isfull ? statusBarHeight+'px': 0,marginBottom: danmuboxHeight+'px'}">
  161. <view class="danmuPopup-head border-line">
  162. <image class="danmu-icon" :src="showDanmu==0?'/static/images/danmu-off.png':'/static/images/danmu-on.png'" mode="heightFix" @click="switchDanmu()"></image>
  163. <input
  164. class="danmuPopup-input"
  165. placeholder="发个弹幕吧~"
  166. border="surround"
  167. shape="circle"
  168. :focus="focus"
  169. :adjustPosition="false"
  170. :autoBlur="true"
  171. maxlength="140"
  172. clearable
  173. v-model.trim="inputText"></input>
  174. <button class="danmuPopup-send" @click="handleChatInput">发送</button>
  175. </view>
  176. </view>
  177. </uni-popup>
  178. <!-- 答题弹窗 -->
  179. <uni-popup ref="answerPopup" type="center" :show="answerPopup">
  180. <view :class="errTitle == '恭喜你,回答正确' ? 'answerPopup-box bg':'answerPopup-box'">
  181. <!-- 正确 -->
  182. <image class="tipimg" v-if="errTitle == '恭喜你,回答正确'" src="/static/images/course_answer_img.png"
  183. mode="aspectFill"></image>
  184. <!-- 错误 -->
  185. <image class="tipimg" v-else src="/static/images/course_answer_incorrectly_img.png" mode="aspectFill">
  186. </image>
  187. <view class="answerPopup-title">{{errTitle}}</view>
  188. <view class="answerPopup-desc" v-html="errDesc"></view>
  189. <!-- 选择奖励 -->
  190. <view class="reward-list" v-if="errTitle == '恭喜你,回答正确'">
  191. <radio-group class="reward-list-group" @change="rewardChange">
  192. <label class="reward-list-option" v-for="(item, index) in rewardType" :key="item.value">
  193. <radio :value="item.value+ ''" :checked="item.value == currentReward"
  194. activeBorderColor="#FF5C03" activeBackgroundColor="#FF5C03"
  195. style="transform:scale(0.7)" />
  196. <view :style="{color: item.value == currentReward ? '#FF5C03':''}">{{item.name}}</view>
  197. </label>
  198. </radio-group>
  199. </view>
  200. <!-- 错误题目 -->
  201. <view class="errQuesbox" v-if="errQues&&errQues.length>0">
  202. <view class="errQuesbox-item textOne" v-for="(it,index) in errQues" :key="index">{{it.title}}</view>
  203. </view>
  204. <view class="answerPopup-btn" v-if="errTitle == '恭喜你,回答正确'" @click="closeAnswerPopup">领取</view>
  205. <view class="tipsPopup-btn-box" v-else
  206. :style="{marginTop: errQues&&errQues.length>0 ? '40rpx':'54rpx'}">
  207. <view class="tipsPopup-btn" @click="closeAnswerPopup">{{remain > 0 ? '重新答题': '确认'}}</view>
  208. </view>
  209. </view>
  210. </uni-popup>
  211. <!-- 客服二维码弹窗 -->
  212. <uni-popup ref="kfPopup" type="center" :mask-click="false">
  213. <view class="kfqrcode-box">
  214. <image class="kfqrcode" :src="qrcode" show-menu-by-longpress="true"></image>
  215. <view v-show="qrcodeMsg" style="margin-top: 30rpx;" v-html="qrcodeMsg"></view>
  216. <image class="kfqrcode-close" src="/static/images/course_close_white_icon.png" mode="aspectFill"
  217. @click="closeKFPop"></image>
  218. </view>
  219. </uni-popup>
  220. <!-- 可以答题提示 -->
  221. <view class="answerTip" v-if="currentTab!=1&&openCommentStatus==1&&showAnswerTip" @click="handleTab(1)">
  222. 可以答题啦
  223. </view>
  224. <!-- footer -->
  225. <view class="footer" v-if="currentTab!=2&&(videoId||sortLink)">
  226. <view class="footer-btn" v-if="!isLogin || isAddKf !=1" @click="submit">
  227. <text>立即学习</text>
  228. </view>
  229. <view v-if="currentTab==1&&isLogin&&isAddKf==1&&quesList&&quesList.length>0" class="footer-btn footer-btn-border" @click="submit">
  230. <!-- <image class="footer-btn-img" v-show="isLogin&&isAddKf==1" src="@/static/images/red_envelope_btnimg.png"
  231. mode="aspectFill"></image> -->
  232. <text>提交答案领取奖励</text>
  233. </view>
  234. <view @click="checked=!checked" class="agreement" v-if="!isLogin">
  235. <radio value="r1" :checked="checked" color="#ff5c03" activeBorderColor="#ff5c03"
  236. style="transform:scale(0.6);" />
  237. <view>阅读并同意<text style="color: #ff5c03;" @click.stop="goWeb(0)">《用户协议》</text>和<text
  238. style="color: #ff5c03;" @click.stop="goWeb(1)">《隐私协议》</text></view>
  239. </view>
  240. <view class="footer-tips" v-if="isLogin">重庆云联融智提供技术支持</view>
  241. </view>
  242. <view v-show="currentTab==2">
  243. <view class="chatinput">
  244. <input class="uni-input" v-model.trim="inputText" maxlength="140" placeholder="发消息···" confirm-type="send" @confirm="handleChatInput" />
  245. <button class="send" @click="handleChatInput">发送</button>
  246. </view>
  247. </view>
  248. </view>
  249. </view>
  250. </template>
  251. <script>
  252. import ques from "@/components/ques.vue"
  253. import descInfo from "@/components/descInfo.vue"
  254. import descInfoNav from "@/components/descInfoNav.vue"
  255. import commentBox from "@/components/commentBox.vue"
  256. import { generateRandomString } from "@/utils/common.js"
  257. import dayjs from 'dayjs';
  258. import {
  259. getErrMsg,
  260. getH5CourseByVideoId,
  261. getH5CourseVideoDetails,
  262. courseAnswer,
  263. getFinishCourseVideo,
  264. getIsAddKf,
  265. getInternetTraffic,
  266. getIntegralByH5Video,
  267. sendReward,
  268. loginByMp,
  269. getRealLink
  270. } from "@/api/course.js"
  271. const isWechat = () => {
  272. return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  273. }
  274. export default {
  275. components: {
  276. descInfoNav,
  277. descInfo,
  278. commentBox,
  279. ques,
  280. },
  281. data() {
  282. return {
  283. // 1 红包 2 积分
  284. rewardType: [{
  285. name: '红包奖励',
  286. value: 1
  287. }, {
  288. name: '积分奖励',
  289. value: 2
  290. }],
  291. currentReward: 1,
  292. player: null,
  293. loading: true,
  294. progress: 0,
  295. code: null,
  296. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  297. scrollTop: 0,
  298. height: '0px',
  299. isLogin: false,
  300. videoUrl: "",
  301. videoId: "",
  302. //现在的时长
  303. playTime: 0,
  304. //总时长
  305. duration: 0,
  306. playDuration: 0,
  307. // 用于续播
  308. playDurationSeek: 0,
  309. // 温馨提醒时间节点,
  310. tipsTime: 0,
  311. tipsOpen: false,
  312. config: {},
  313. courseInfo: {},
  314. quesList: [],
  315. lineList: [],
  316. // 错题
  317. errQues: [],
  318. // 答题机会
  319. remain: 0,
  320. errTitle: "",
  321. errDesc: "",
  322. showPlay: true,
  323. showControls: false,
  324. playStatus: "",
  325. isAddKf: 0,
  326. lineIndex: 0,
  327. textHeight: 0, //文本高度
  328. qwUserId: "",
  329. qrcode: "",
  330. corpId: "",
  331. qrcodeMsg: "",
  332. urlOption: {},
  333. bufferRate: 0, // 缓冲时间
  334. uuId: "",
  335. isEnded: false,
  336. // 是否允许拖动进度条
  337. linkType: 0,
  338. ip: null,
  339. checked: true,
  340. isFinish: 0, // 是否完课
  341. interval: null,
  342. intervalIntegral: null, // 积分定时
  343. // 错误请求次数
  344. errorCount: 0,
  345. answerPopup: false,
  346. sortLink:"",
  347. // 课程是否过期
  348. isExpire: false,
  349. menuButtonLeft: 281,
  350. menuButtonH: 45,
  351. timer: null,
  352. flag: false,
  353. poster:"",
  354. msg:"",
  355. authDomainName: "",
  356. // 是否暂停
  357. isPause: true,
  358. courseLogo: '',
  359. isfull: false,
  360. navList:[{
  361. id: 0,
  362. name: '介绍'
  363. },{
  364. id: 1,
  365. name: '答题'
  366. },{
  367. id: 2,
  368. name: '评论'
  369. }],
  370. currentTab: 1,
  371. triggered: false,
  372. // 没有更多
  373. isMore: false,
  374. inputText:"",
  375. // 获取最多历史评论条数
  376. viewCommentNum: 200,
  377. // 1-开启评论;2-开启弹幕;3-关闭
  378. openCommentStatus: 3,
  379. flagTime:0,
  380. showDanmu: 1,
  381. focus: false,
  382. openDanmuType: 0,
  383. danmuboxHeight: 0,
  384. crtShow: true,
  385. showAnswerTip: false,
  386. }
  387. },
  388. filters: {
  389. numberToChinese(number) {
  390. if (number) {
  391. const chineseNumber = ['一', '二', '三', '四', '五', '六', '七', '八', '九'];
  392. return chineseNumber[number - 1];
  393. } else {
  394. return ''
  395. }
  396. },
  397. },
  398. computed: {
  399. isAnswer() {
  400. return (item, name) => {
  401. if (item.type == 1) {
  402. return item.answer == name
  403. } else if (item.type == 2) {
  404. const array = item.answer.split(',')
  405. return array.some(i => i == name)
  406. } else {
  407. return false
  408. }
  409. }
  410. }
  411. },
  412. onLoad(option) {
  413. this.sortLink = option.s || ''
  414. this.code = option.code
  415. this.urlOption = option.course ? JSON.parse(option.course) : {}
  416. this.videoId = this.urlOption.videoId || ''
  417. console.log("this.videoId====",this.videoId)
  418. this.qwUserId = this.urlOption.qwUserId || ''
  419. this.corpId = this.urlOption.corpId || ''
  420. this.linkType = this.urlOption.linkType || 0
  421. if (this.videoId) {
  422. this.getH5CourseByVideo()
  423. }
  424. // #ifndef H5
  425. uni.onKeyboardHeightChange(this.keyboardHeightChange);
  426. // #endif
  427. },
  428. onShow() {
  429. this.isLogin = this.$isLogin()
  430. this.tipsOpen = false
  431. this.uuId = generateRandomString(16)
  432. if(this.videoId) {
  433. if (this.$isLogin()) {
  434. if(this.isAddKf == 1) {
  435. this.getH5CourseVideoDetails()
  436. } else {
  437. this.getIsAddKf()
  438. }
  439. } else {
  440. this.loginByMp()
  441. }
  442. } else {
  443. if(this.sortLink){
  444. this.getLink()
  445. return
  446. }
  447. uni.showToast({
  448. title: 'sortLink is not found',
  449. icon: 'none'
  450. });
  451. }
  452. },
  453. mounted() {
  454. this.getIP()
  455. this.getHeight()
  456. },
  457. onHide() {
  458. if (this.player) {
  459. this.player.pause()
  460. }
  461. this.getFinishCourseVideo()
  462. this.getInternetTraffic()
  463. if (this.interval != null) {
  464. clearInterval(this.interval)
  465. this.interval = null
  466. }
  467. },
  468. onUnload() {
  469. console.log("==onUnload===")
  470. this.getFinishCourseVideo()
  471. this.getInternetTraffic()
  472. if (this.interval != null) {
  473. clearInterval(this.interval)
  474. this.interval = null
  475. }
  476. this.clearIntegral()
  477. // #ifndef H5
  478. uni.offKeyboardHeightChange(this.keyboardHeightChange);
  479. // #endif
  480. },
  481. beforeDestroy() {
  482. this.player = uni.createVideoContext('video-content-box');
  483. if (this.player) {
  484. this.player.stop()
  485. this.player = null
  486. }
  487. if (this.interval != null) {
  488. clearInterval(this.interval)
  489. this.interval = null
  490. }
  491. this.clearIntegral()
  492. // #ifndef H5
  493. uni.offKeyboardHeightChange(this.keyboardHeightChange);
  494. // #endif
  495. },
  496. methods: {
  497. fullscreenchange(e) {
  498. this.isfull = e.detail.fullScreen
  499. if(this.isfull) {
  500. this.$refs.danmuBox&&this.$refs.danmuBox.initTracks()
  501. }
  502. },
  503. clickVideo() {
  504. if (this.player) {
  505. this.player.play()
  506. }
  507. },
  508. //播放时间更新事件方法
  509. onTimeUpdate(e){
  510. let currentTime = Math.round(e.detail.currentTime)
  511. if (this.playDurationSeek > 0) {
  512. this.playTime = this.playDurationSeek
  513. this.throttle(() => this.changeTime(this), 1000, false)
  514. } else {
  515. if (this.linkType != 1 && (currentTime - this.playTime > 3 || currentTime - this.playTime < -3)&&this.isFinish!=1) {
  516. uni.showToast({
  517. title: '不能快进哦',
  518. icon: 'none',
  519. });
  520. currentTime = this.playTime
  521. this.player.seek(this.playTime);
  522. }
  523. this.playTime = currentTime
  524. }
  525. if(this.isEnded||this.playTime >= this.duration - 60) {
  526. this.showAnswerTip = true
  527. } else {
  528. this.showAnswerTip = false
  529. }
  530. if (Math.floor(e.detail.currentTime) != this.flagTime &&this.openCommentStatus == 2) {
  531. this.flagTime = Math.floor(e.detail.currentTime)
  532. this.$refs.danmuBox&&this.$refs.danmuBox.checkDanmu(this.flagTime)
  533. }
  534. },
  535. changeTime(that,e) {
  536. that.playDurationSeek = 0
  537. },
  538. videoErrorCallback(e) {
  539. if(this.$isLogin()&&this.isAddKf==1) {
  540. this.clearIntegral()
  541. this.errorCount++
  542. if (this.errorCount > 3) return
  543. console.log(e)
  544. this.getErrMsg(e.target.errMsg)
  545. this.getH5CourseVideoDetails('error')
  546. }
  547. },
  548. // 当开始/继续播放时触发play事件
  549. getPlay() {
  550. this.isPause = false
  551. this.errorCount = 0
  552. // this.judgeDuration()
  553. },
  554. getPause() {
  555. this.isPause = true
  556. this.clearIntegral()
  557. },
  558. getEnded() {
  559. this.clearIntegral()
  560. this.isEnded = true
  561. this.showAnswerTip = true
  562. this.getFinishCourseVideo()
  563. },
  564. getWaiting() {
  565. this.getErrMsg('','waiting')
  566. },
  567. controlstoggle(event) {
  568. this.crtShow = event.detail.show
  569. },
  570. getIP() {
  571. uni.request({
  572. url: 'https://ipinfo.io/json', //仅为示例,并非真实接口地址。
  573. method: 'GET',
  574. success: (res) => {
  575. this.ip = res.data.ip
  576. }
  577. });
  578. },
  579. goWeb(tyep) {
  580. const path = uni.getStorageSync('requestPath',path);
  581. const url = tyep == 0 ? path + "/web/userAgreement" : path + "/web/privacyPolicy"
  582. window.open(url)
  583. },
  584. getHeight() {
  585. setTimeout(()=>{
  586. const query = uni.createSelectorQuery().in(this);
  587. query
  588. .select("#title-contentnav")
  589. .boundingClientRect((data) => {
  590. if(data) {
  591. this.height =
  592. `calc(100vh - ${data.height}px - 420rpx - ${this.statusBarHeight}px - 44px - 88rpx)`
  593. }
  594. })
  595. .exec();
  596. },200)
  597. },
  598. numberToLetter(num) {
  599. // 将数字转换为字母的 ASCII 码
  600. let letterCode = num + 65;
  601. // 将 ASCII 码转换为大写字母
  602. let letter = String.fromCharCode(letterCode);
  603. return letter;
  604. },
  605. updateTime() {
  606. var that = this;
  607. if (this.interval != null) {
  608. clearInterval(this.interval)
  609. }
  610. this.interval = setInterval(function() {
  611. that.getFinishCourseVideo()
  612. that.getInternetTraffic()
  613. }, 60000);
  614. },
  615. judgeDuration() {
  616. var that = this;
  617. if (this.intervalIntegral != null) {
  618. clearInterval(this.intervalIntegral)
  619. this.intervalIntegral = null
  620. }
  621. // 观看10分钟获得积分
  622. this.intervalIntegral = setInterval(function() {
  623. that.getIntegralByH5Video()
  624. }, 600000);
  625. },
  626. clearIntegral() {
  627. if (this.intervalIntegral != null) {
  628. clearInterval(this.intervalIntegral)
  629. this.intervalIntegral = null
  630. }
  631. },
  632. getH5CourseByVideo(videoId) {
  633. this.loading = true
  634. getH5CourseByVideoId({
  635. videoId: this.videoId || videoId
  636. }).then(res => {
  637. this.loading = false
  638. if (res.code == 200) {
  639. this.courseInfo = res.data
  640. uni.setNavigationBarTitle({
  641. title: this.courseInfo && this.courseInfo.title ? this.courseInfo.title : ''
  642. });
  643. }
  644. this.getHeight()
  645. this.$nextTick(()=>{
  646. this.$refs.descInfo&&this.$refs.descInfo.getDescHeight()
  647. this.$refs.descInfoNav&&this.$refs.descInfoNav.getDescHeight()
  648. })
  649. },
  650. rej => {
  651. this.loading = false
  652. }
  653. ).catch(() => {
  654. this.loading = false
  655. })
  656. },
  657. getH5CourseVideoDetails(type) {
  658. const param = {
  659. ...this.urlOption
  660. }
  661. getH5CourseVideoDetails(param).then(res => {
  662. if (res.code == 200) {
  663. this.config = res.config || {}
  664. this.isFinish = res.isFinish || 0
  665. this.duration = res.course && res.course.duration ? res.course.duration : 0
  666. this.playDuration = res.playDuration || 0
  667. this.playDurationSeek = res.playDuration || 0
  668. this.tipsTime = res.tipsTime || 0
  669. let lineList = []
  670. if (res.course && res.course.lineOne) {
  671. lineList.push(res.course.lineOne)
  672. }
  673. if (res.course && res.course.lineTwo) {
  674. lineList.push(res.course.lineTwo)
  675. }
  676. if (res.course && res.course.lineThree) {
  677. lineList.push(res.course.lineThree)
  678. }
  679. this.lineList = lineList
  680. this.courseLogo = res.config&&res.config.courseLogo
  681. this.viewCommentNum = res.config&&res.config.viewCommentNum || 200
  682. if(this.openCommentStatus == 3) {
  683. this.$refs.commentBox&&this.$refs.commentBox.closeWSocket()
  684. this.$refs.danmuBox&&this.$refs.danmuBox.closeWSocket()
  685. }
  686. const status = res.config&&res.config.openCommentStatus || 3
  687. if(status != this.openCommentStatus) {
  688. this.openCommentStatus = status
  689. }
  690. if(this.openCommentStatus==1) {
  691. this.currentTab = 0
  692. } else {
  693. this.currentTab = 1
  694. }
  695. if (!this.player || type == 'error') {
  696. this.lineIndex = this.config.defaultLine
  697. this.videoUrl = lineList[this.lineIndex]
  698. this.poster= res.course && res.course.imgUrl ? res.course.imgUrl : ''
  699. this.playTime = this.playDuration >= this.duration ? 0 : this.playDuration
  700. setTimeout(()=>{
  701. this.player = uni.createVideoContext('video-content-box');
  702. this.player.seek(this.playTime)
  703. this.player.play();
  704. },500);
  705. } else {
  706. this.playTime = this.playTime > this.playDuration ? this.playTime : this.playDuration >= this.duration ? 0 : this.playDuration
  707. this.player.seek(this.playTime)
  708. this.player.play();
  709. }
  710. this.updateTime();
  711. this.quesList = res.questions && res.questions.length > 0 ? res.questions : [],
  712. this.quesList = this.quesList.map(item => ({
  713. ...item,
  714. questionOption: JSON.parse(item.question),
  715. answer: ''
  716. }))
  717. }
  718. this.getHeight()
  719. this.$nextTick(()=>{
  720. this.$refs.descInfo&&this.$refs.descInfo.getDescHeight()
  721. this.$refs.descInfoNav&&this.$refs.descInfoNav.getDescHeight()
  722. })
  723. },
  724. rej => {}
  725. )
  726. },
  727. handleAnswer(val) {
  728. let {item, option} = val
  729. let time = this.playTime
  730. if(this.isEnded) {
  731. time = this.duration
  732. } else {
  733. if(time < this.playDuration&&this.isFinish!=1) {
  734. // 没完课且小于续播的时间
  735. time = this.playDuration
  736. }
  737. }
  738. if(Number(this.duration || 0) == 0 || time < this.duration - 60) {
  739. uni.showToast({
  740. title: "请先观看完整课程再答题哦~",
  741. icon: "none"
  742. })
  743. return
  744. }
  745. if (item.type == 1) {
  746. // 单选option
  747. item.answer = option.name
  748. } else if (item.type == 2) {
  749. // 多选
  750. let answer = item.answer ? item.answer.split(',') : []
  751. if (answer.indexOf(option.name) === -1) {
  752. answer.push(option.name)
  753. item.answer = answer.join(',')
  754. } else {
  755. answer.splice(answer.indexOf(option.name), 1)
  756. item.answer = answer.join(',')
  757. }
  758. }
  759. },
  760. submit() {
  761. // 登录
  762. if (this.$isLogin()) {
  763. if (this.isAddKf == 1) {
  764. // 答题
  765. // 您已提交过答案,请领取红包
  766. this.courseAnswer()
  767. } else {
  768. // 添加客服
  769. if (this.videoId && this.qwUserId) {
  770. this.getIsAddKf()
  771. } else {
  772. uni.showToast({
  773. title: '请添加客服',
  774. icon: 'none'
  775. })
  776. }
  777. }
  778. } else {
  779. // 登录
  780. if (!this.checked) {
  781. uni.showToast({
  782. title: "请先勾选阅读并同意《用户协议》和《隐私协议》",
  783. icon: "none"
  784. })
  785. return
  786. }
  787. // #ifdef H5
  788. if (isWechat) { //是否在微信浏览器中打开
  789. this.loginByMp()
  790. } else {
  791. uni.showToast({
  792. title: '请在微信浏览器中打开',
  793. icon: 'error'
  794. })
  795. }
  796. // #endif
  797. }
  798. },
  799. // 答题
  800. courseAnswer() {
  801. let time = this.playTime
  802. if (this.isEnded) {
  803. time = this.duration
  804. } else {
  805. if (time < this.playDuration && this.isFinish != 1) {
  806. // 没完课且小于续播的时间
  807. time = this.playDuration
  808. }
  809. }
  810. if (Number(this.duration || 0) == 0 || time < this.duration - 60) {
  811. uni.showToast({
  812. title: "请先观看完整课程再答题哦~",
  813. icon: "none"
  814. })
  815. return
  816. }
  817. if (this.quesList.some(item => !item.answer)) {
  818. uni.showToast({
  819. title: "请确认是否答完所有题目",
  820. icon: "none"
  821. })
  822. return
  823. }
  824. const questions = this.quesList.map(obj => {
  825. const {
  826. questionOption,
  827. ...rest
  828. } = obj;
  829. return rest;
  830. });
  831. const param = {
  832. ...this.urlOption,
  833. questions: questions,
  834. videoId: this.videoId,
  835. duration: this.playTime
  836. }
  837. this.errTitle = ""
  838. this.errDesc = ""
  839. this.errQues = []
  840. courseAnswer(param).then(res => {
  841. if (res.code == 200) {
  842. if (res.incorrectQuestions) {
  843. // 答题失败
  844. if (res.incorrectQuestions.length > 0) {
  845. this.errQues = res.incorrectQuestions
  846. }
  847. this.remain = res.remain || 0
  848. if (res.remain > 0) {
  849. this.errTitle = "很遗憾答错了"
  850. this.errDesc = `<span style="color:#FF5C03">还有${res.remain}次机会,继续加油</span>`
  851. this.$refs.answerPopup.open("center")
  852. }
  853. } else {
  854. // 答题成功
  855. this.errTitle = "恭喜你,回答正确"
  856. this.errDesc = `您有一份奖励待领取哦~`
  857. this.$refs.answerPopup.open("center")
  858. // this.closeAnswerPopup()
  859. }
  860. } else {
  861. if (res.msg == "该课题到达答错次数限制") {
  862. this.errTitle = "答题次数超过限制"
  863. this.errDesc = "以后的课程要认真学习哦"
  864. this.$refs.answerPopup.open("center")
  865. } else {
  866. uni.showToast({
  867. title: res.msg,
  868. icon: "none"
  869. })
  870. }
  871. }
  872. },
  873. rej => {}
  874. )
  875. },
  876. // 选择
  877. rewardChange(e) {
  878. this.currentReward = e.detail.value
  879. },
  880. closeAnswerPopup() {
  881. this.$refs.answerPopup.close()
  882. if (this.errTitle == '恭喜你,回答正确') {
  883. const param = {
  884. ...this.urlOption,
  885. rewardType: Number(this.currentReward),
  886. }
  887. sendReward(param).then(res => {
  888. if(res.code == 200) {
  889. if(res.isNew&&res.isNew==1) {
  890. const packageInfo = res.data.packageInfo || ''
  891. if(packageInfo) {
  892. uni.setStorageSync('receive_package',packageInfo);
  893. if(res.mchId) uni.setStorageSync('mchId',res.mchId);
  894. uni.navigateTo({
  895. url: '/pages/course/reward'
  896. })
  897. }
  898. } else {
  899. uni.showToast({
  900. title: res.msg,
  901. icon: 'none'
  902. })
  903. }
  904. }else {
  905. uni.showToast({
  906. title: res.msg,
  907. icon: 'none'
  908. })
  909. }
  910. })
  911. }
  912. },
  913. // 线路
  914. openPop() {
  915. this.$refs.popup.open('bottom')
  916. },
  917. close() {
  918. this.$refs.popup.close()
  919. },
  920. handleLine(index) {
  921. var that=this;
  922. if (this.lineIndex == index && this.videoUrl == this.lineList[index]) {
  923. this.close()
  924. return
  925. } else {
  926. // let div = document.querySelector(".vjs-progress-control");
  927. // if(div) {
  928. // if (this.isFinish == 1 || this.isEnded || this.linkType == 1) {
  929. // div.style.pointerEvents = "auto";
  930. // } else {
  931. // div.style.pointerEvents = "none"; //禁止所有事件
  932. // }
  933. // }
  934. this.lineIndex = index
  935. this.videoUrl = this.lineList[index]
  936. this.tipsOpen = false
  937. this.playDurationSeek = this.playTime || 0
  938. this.player = uni.createVideoContext('video-content-box');
  939. setTimeout(function(){
  940. that.player.seek(that.playDurationSeek)
  941. that.player.play();
  942. },500);
  943. // this.player.src(this.lineList[index])
  944. // this.player.one('loadedmetadata', () => {
  945. // this.player.currentTime(this.playDurationSeek);
  946. // this.player.play();
  947. // });
  948. this.close()
  949. }
  950. },
  951. // 温馨提示
  952. openTipsPop() {
  953. this.$refs.tipsPopup.open()
  954. this.tipsOpen = true
  955. this.pause()
  956. },
  957. closeTipsPop() {
  958. this.$refs.tipsPopup.close()
  959. },
  960. // 客服
  961. getIsAddKf() {
  962. this.qrcode = ''
  963. this.qrcodeMsg = ''
  964. this.isAddKf = 0
  965. // {videoId: this.videoId,qwUserId: this.qwUserId,corpId: this.corpId}
  966. const param = {
  967. ...this.urlOption
  968. }
  969. getIsAddKf(param).then(res => {
  970. if (res.code == 200) {
  971. if (this.urlOption.isRoom == 1 && res.qwExternalId) {
  972. this.urlOption = {
  973. ...this.urlOption,
  974. qwExternalId: res.qwExternalId
  975. }
  976. }
  977. this.isAddKf = 1
  978. this.getH5CourseVideoDetails()
  979. } else if (res.code == 400) {
  980. this.isAddKf = 0
  981. this.qrcode = res.qrcode
  982. this.qrcodeMsg = res.msg
  983. this.$refs.kfPopup.open()
  984. } else if (res.code == 567) {
  985. // 群聊通用链接
  986. this.urlOption = {
  987. ...this.urlOption,
  988. qwExternalId: res.qwExternalId
  989. }
  990. this.isAddKf = 1
  991. this.getH5CourseVideoDetails()
  992. } else if (res.code == 504) {
  993. // 登录
  994. // #ifdef H5
  995. if (isWechat) { //是否在微信浏览器中打开
  996. this.loginByMp()
  997. } else {
  998. uni.navigateTo({
  999. url: "/pages/auth/login"
  1000. });
  1001. }
  1002. // #endif
  1003. } else {
  1004. this.isAddKf = 0
  1005. uni.showToast({
  1006. title: res.msg,
  1007. icon: 'none'
  1008. });
  1009. }
  1010. },
  1011. err => {}
  1012. );
  1013. },
  1014. closeKFPop() {
  1015. this.$refs.kfPopup.close()
  1016. },
  1017. loginByMp() {
  1018. if (this.code == null||!this.code) {
  1019. if(this.sortLink) {
  1020. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.sortLink
  1021. } else {
  1022. if(this.urlOption.link) {
  1023. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.urlOption.link
  1024. } else {
  1025. this.isExpire = true
  1026. this.msg = '课程链接地址有误'
  1027. uni.showToast({
  1028. title: '课程链接地址有误',
  1029. icon: 'none'
  1030. });
  1031. }
  1032. }
  1033. return;
  1034. }
  1035. uni.showLoading({
  1036. title: "处理中..."
  1037. });
  1038. let that = this;
  1039. var data = {
  1040. code: this.code
  1041. }
  1042. loginByMp(data).then(res => {
  1043. uni.hideLoading();
  1044. if (res.code == 200) {
  1045. uni.setStorageSync(this.$TOKEN_KEY, res.token);
  1046. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  1047. this.isLogin = this.$isLogin()
  1048. if(this.isAddKf == 1) {
  1049. this.getH5CourseVideoDetails()
  1050. } else {
  1051. this.getIsAddKf()
  1052. }
  1053. } else {
  1054. uni.showToast({
  1055. title: res.msg,
  1056. icon: 'none'
  1057. });
  1058. }
  1059. },
  1060. err => {}
  1061. ).catch(err=>{
  1062. uni.hideLoading();
  1063. });
  1064. },
  1065. getFinishCourseVideo() {
  1066. if (!this.playTime||!this.$isLogin()||this.isAddKf != 1) return
  1067. // {videoId: this.videoId,duration:this.playTime}
  1068. const param = {
  1069. duration: this.playTime,
  1070. ...this.urlOption
  1071. }
  1072. getFinishCourseVideo(param)
  1073. },
  1074. // 每十分钟获得积分
  1075. getIntegralByH5Video() {
  1076. if (!this.$isLogin()||this.isAddKf != 1) return
  1077. const param = {
  1078. duration: this.playTime,
  1079. ...this.urlOption,
  1080. }
  1081. getIntegralByH5Video(param).then(res => {
  1082. if (res.code == 200) {
  1083. uni.showToast({
  1084. title: "积分+10",
  1085. icon: "none"
  1086. })
  1087. }
  1088. })
  1089. },
  1090. progressChange(e) {
  1091. this.bufferRate = Math.ceil(e.detail.buffered)
  1092. },
  1093. // 缓冲
  1094. getInternetTraffic() {
  1095. if (!this.$isLogin()||this.isAddKf != 1) return
  1096. const playVideoTime = Math.ceil(this.playTime / this.duration * 100) // 播放百分比
  1097. if(this.bufferRate == 0 || this.bufferRate < playVideoTime) {
  1098. this.bufferRate = playVideoTime
  1099. }
  1100. if(this.bufferRate == 0 || Number(this.bufferRate.toFixed(2)) == 0) return
  1101. const param = {
  1102. ...this.urlOption,
  1103. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1104. duration: this.playTime,
  1105. bufferRate: Number(this.bufferRate.toFixed(2)),
  1106. }
  1107. if(!param.bufferRate) return
  1108. getInternetTraffic(param)
  1109. },
  1110. getErrMsg(err,type) {
  1111. let msgerr = {
  1112. errType: type || 'error',
  1113. videoUrl: this.videoUrl,
  1114. lineIndex: this.lineIndex,
  1115. errTime: new Date(),
  1116. ip: this.ip,
  1117. errMsg: err || ''
  1118. }
  1119. getErrMsg({
  1120. msg: JSON.stringify(msgerr)
  1121. })
  1122. },
  1123. getLink() {
  1124. let that = this;
  1125. getRealLink({sortLink:this.sortLink}).then(res=>{
  1126. if(res.code == 200) {
  1127. this.isExpire = false
  1128. this.authDomainName = res.config.authDomainName || ''
  1129. if(this.authDomainName) {
  1130. uni.setStorageSync('authDomainName',this.authDomainName)
  1131. }
  1132. if(this.isLogin) {
  1133. window.location.replace(res.realLink)
  1134. } else{
  1135. const option = res.realLink.split('?course=')[1]
  1136. const urlOption = option ? JSON.parse(option) : {}
  1137. const videoId = urlOption.videoId || ''
  1138. this.getH5CourseByVideo(videoId)
  1139. }
  1140. } else {
  1141. this.isExpire = true
  1142. this.msg = '课程已过期或链接无效'
  1143. uni.showToast({
  1144. title: '课程已过期或链接无效',
  1145. icon: 'none'
  1146. });
  1147. }
  1148. }).catch(err=>{
  1149. this.isExpire = true
  1150. this.msg = '发生错误,请稍后再试'
  1151. uni.showToast({
  1152. title: '发生错误,请稍后再试',
  1153. icon: 'none'
  1154. });
  1155. })
  1156. },
  1157. /**
  1158. * 节流原理:在一定时间内,只能触发一次
  1159. *
  1160. * @param {Function} func 要执行的回调函数
  1161. * @param {Number} wait 延时的时间
  1162. * @param {Boolean} immediate 是否立即执行
  1163. * @return null
  1164. */
  1165. throttle(func, wait = 500, immediate = true) {
  1166. if (immediate) {
  1167. if (!this.flag) {
  1168. this.flag = true
  1169. // 如果是立即执行,则在wait毫秒内开始时执行
  1170. typeof func === 'function' && func()
  1171. this.timer = setTimeout(() => {
  1172. this.flag = false
  1173. }, wait)
  1174. }
  1175. } else if (!this.flag) {
  1176. this.flag = true
  1177. // 如果是非立即执行,则在wait毫秒内的结束处执行
  1178. this.timer = setTimeout(() => {
  1179. this.flag = false
  1180. typeof func === 'function' && func()
  1181. }, wait)
  1182. }
  1183. },
  1184. // 弹幕
  1185. keyboardHeightChange(res) {
  1186. // #ifndef H5
  1187. console.log("this.danmuboxHeight",this.danmuboxHeight)
  1188. this.danmuboxHeight = res.height
  1189. // #endif
  1190. },
  1191. openDanmu(type) {
  1192. this.openDanmuType = type
  1193. this.inputText = ''
  1194. if(type == 1) {
  1195. this.player.exitFullScreen()
  1196. }
  1197. this.$refs.danmuPopup.open()
  1198. },
  1199. changeShowPopup(val) {
  1200. this.focus = val.show
  1201. },
  1202. switchDanmu() {
  1203. this.showDanmu = this.showDanmu == 1 ? 0:1
  1204. if(this.showDanmu == 0&&this.$refs.danmuBox) {
  1205. this.$refs.danmuBox.activeDanmus = []
  1206. this.$refs.danmuBox.initTracks()
  1207. }
  1208. },
  1209. getScrollTop(res) {
  1210. if(this.currentTab == 2) {
  1211. this.scrollTop = res
  1212. } else {
  1213. this.scrollTop = 0
  1214. }
  1215. },
  1216. handleTab(index) {
  1217. this.currentTab = index
  1218. if(this.currentTab==2) {
  1219. if(this.$refs.commentBox) {
  1220. this.$refs.commentBox.msgs = []
  1221. this.$refs.commentBox.pageNum = 1
  1222. this.$refs.commentBox.getComments()
  1223. }
  1224. } else {
  1225. setTimeout(()=>{
  1226. this.scrollTop = 0
  1227. },100)
  1228. }
  1229. },
  1230. handleRefresher() {
  1231. this.triggered = true;
  1232. if (!this.isMore&&this.currentTab==2&&this.openCommentStatus==1) {
  1233. this.$nextTick(()=>{
  1234. this.$refs.commentBox&&this.$refs.commentBox.getComments()
  1235. })
  1236. }
  1237. setTimeout(() => {
  1238. this.triggered = false;
  1239. }, 500);
  1240. },
  1241. getMore(val) {
  1242. this.triggered = false;
  1243. this.isMore = val == 1
  1244. },
  1245. handleChatInput() {
  1246. this.inputText = this.inputText.trim()
  1247. if (this.inputText == "" || this.inputText.trim() == "") {
  1248. uni.showToast({
  1249. title: '请输入评论',
  1250. icon: "none"
  1251. })
  1252. return;
  1253. }
  1254. if(this.openCommentStatus==1) {
  1255. this.$refs.commentBox&&this.$refs.commentBox.handleInput(this.inputText)
  1256. } else if(this.openCommentStatus==2) {
  1257. this.$refs.danmuBox&&this.$refs.danmuBox.handleInput(this.inputText)
  1258. }
  1259. },
  1260. setInputText() {
  1261. this.inputText = ""
  1262. if(this.openCommentStatus==2) {
  1263. this.$refs.danmuPopup.close()
  1264. }
  1265. }
  1266. }
  1267. }
  1268. </script>
  1269. <style scoped>
  1270. .full-width-popup {
  1271. width: 100%;
  1272. }
  1273. </style>
  1274. <style lang="scss" scoped>
  1275. @mixin u-flex($flexD, $alignI, $justifyC) {
  1276. display: flex;
  1277. flex-direction: $flexD;
  1278. align-items: $alignI;
  1279. justify-content: $justifyC;
  1280. }
  1281. .footer-tips {
  1282. margin-top: 14rpx;
  1283. text-align: center;
  1284. font-family: PingFang SC,PingFang SC;
  1285. font-weight: 500;
  1286. font-size: 12px;
  1287. color: #bbb;
  1288. }
  1289. .textOne {
  1290. overflow: hidden;
  1291. white-space: nowrap;
  1292. text-overflow: ellipsis;
  1293. }
  1294. .textTwo {
  1295. overflow: hidden;
  1296. text-overflow: ellipsis;
  1297. display: -webkit-box;
  1298. -webkit-line-clamp: 2;
  1299. -webkit-box-orient: vertical;
  1300. }
  1301. .expirebox {
  1302. height: 100vh;
  1303. @include u-flex(column, center, center);
  1304. font-family: PingFang SC, PingFang SC;
  1305. font-weight: 400;
  1306. font-size: 32rpx;
  1307. color: #757575;
  1308. image {
  1309. width: 428rpx;
  1310. height: 360rpx;
  1311. margin-bottom: 30rpx;
  1312. }
  1313. }
  1314. .reward-list {
  1315. width: 100%;
  1316. margin-top: 20rpx;
  1317. margin-bottom: -40rpx;
  1318. &-group {
  1319. font-family: PingFang SC, PingFang SC;
  1320. font-weight: 400;
  1321. font-size: 14px;
  1322. color: #222222;
  1323. @include u-flex(row, center, center);
  1324. }
  1325. &-option {
  1326. @include u-flex(row, center, flex-start);
  1327. &:first-child {
  1328. margin-right: 40rpx;
  1329. }
  1330. }
  1331. }
  1332. .err {
  1333. color: #f56c6c !important;
  1334. }
  1335. .kfqrcode-box {
  1336. background-color: #fff;
  1337. border-radius: 16rpx;
  1338. max-width: 560rpx;
  1339. padding: 60rpx 40rpx;
  1340. margin-top: -100rpx;
  1341. box-sizing: border-box;
  1342. @include u-flex(column, center, flex-start);
  1343. font-family: PingFang SC, PingFang SC;
  1344. font-weight: 400;
  1345. font-size: 34rpx;
  1346. color: #222;
  1347. position: relative;
  1348. text-align: center;
  1349. .kfqrcode {
  1350. height: 460rpx;
  1351. width: 460rpx;
  1352. }
  1353. }
  1354. .kfqrcode-close {
  1355. width: 64rpx;
  1356. height: 64rpx;
  1357. position: absolute;
  1358. bottom: -100rpx;
  1359. left: 50%;
  1360. transform: translateX(-50%);
  1361. }
  1362. .tipsPopup-mask {
  1363. position: relative;
  1364. width: 560rpx;
  1365. background-color: transparent;
  1366. .red_envelope_top {
  1367. width: 480rpx;
  1368. height: 360rpx;
  1369. margin: 0 auto;
  1370. display: inherit;
  1371. }
  1372. }
  1373. .tipsPopup-btn-box {
  1374. width: 456rpx;
  1375. height: 104rpx;
  1376. padding: 4rpx;
  1377. box-sizing: border-box;
  1378. background: linear-gradient(180deg, rgba(252, 209, 94, 1), rgba(254, 253, 251, 1));
  1379. border-radius: 52rpx;
  1380. }
  1381. .tipsPopup-btn {
  1382. width: 100%;
  1383. height: 100%;
  1384. background: linear-gradient(180deg, #FF9F22 0%, #FA1E05 100%);
  1385. border-radius: 52rpx 52rpx 52rpx 52rpx;
  1386. font-family: PingFang SC, PingFang SC;
  1387. font-weight: 500;
  1388. font-size: 36rpx;
  1389. color: #FFFFFF;
  1390. line-height: 96rpx;
  1391. text-align: center;
  1392. }
  1393. .tipsPopup {
  1394. width: 560rpx;
  1395. padding: 12rpx;
  1396. margin-top: -72rpx;
  1397. box-sizing: border-box;
  1398. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1399. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1400. position: relative;
  1401. &-close {
  1402. width: 64rpx;
  1403. height: 64rpx;
  1404. position: absolute;
  1405. right: 0;
  1406. top: -188rpx;
  1407. }
  1408. &-line {
  1409. padding: 3rpx;
  1410. box-sizing: border-box;
  1411. background: linear-gradient(180deg, rgba(247, 245, 220, 1), rgba(250, 220, 157, 1));
  1412. border-radius: 24rpx;
  1413. }
  1414. &-box {
  1415. padding: 0 40rpx 40rpx 40rpx;
  1416. box-sizing: border-box;
  1417. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1418. border-radius: 24rpx;
  1419. @include u-flex(column, center, flex-start);
  1420. }
  1421. &-head {
  1422. @include u-flex(row, center, center);
  1423. &-title {
  1424. width: 364rpx;
  1425. height: auto;
  1426. margin-top: -22rpx;
  1427. }
  1428. }
  1429. &-content {
  1430. margin: 48rpx 0;
  1431. font-family: PingFang SC, PingFang SC;
  1432. font-weight: 500;
  1433. font-size: 32rpx;
  1434. color: #222222;
  1435. text-align: center;
  1436. &-title {
  1437. margin-bottom: 26rpx;
  1438. font-weight: 600;
  1439. font-size: 40rpx;
  1440. color: #FF5C03;
  1441. }
  1442. }
  1443. }
  1444. .video-controls-box {
  1445. width: 100%;
  1446. height: 420rpx;
  1447. overflow: hidden;
  1448. position: absolute;
  1449. bottom: 0;
  1450. left: 0;
  1451. z-index: 2;
  1452. background: rgba(0, 0, 0, 0.2);
  1453. .video-play {
  1454. height: 72rpx;
  1455. width: 72rpx;
  1456. position: absolute;
  1457. top: 50%;
  1458. left: 50%;
  1459. transform: translate(-50%, -50%);
  1460. }
  1461. }
  1462. .video-controls {
  1463. width: 100%;
  1464. height: 80rpx;
  1465. padding: 0 28rpx;
  1466. box-sizing: border-box;
  1467. position: absolute;
  1468. bottom: 0;
  1469. left: 0;
  1470. display: flex;
  1471. align-items: center;
  1472. justify-content: space-between;
  1473. background: linear-gradient(to top, #222 0%, transparent 80%);
  1474. .video-icon {
  1475. height: 44rpx;
  1476. width: 44rpx;
  1477. }
  1478. }
  1479. .errQuesbox {
  1480. width: 100%;
  1481. max-height: 260rpx;
  1482. overflow-y: auto;
  1483. margin-top: 24rpx;
  1484. font-family: PingFang SC, PingFang SC;
  1485. font-weight: 500;
  1486. font-size: 30rpx;
  1487. color: #222222;
  1488. &-item {
  1489. width: 100%;
  1490. height: 128rpx;
  1491. line-height: 128rpx;
  1492. margin-bottom: 24rpx;
  1493. padding: 0 30rpx;
  1494. box-sizing: border-box;
  1495. overflow: hidden;
  1496. background: #fff;
  1497. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1498. position: relative;
  1499. &::after {
  1500. content: "题目";
  1501. min-width: 64rpx;
  1502. height: 36rpx;
  1503. padding: 0 12rpx;
  1504. line-height: 36rpx;
  1505. background: #FF5C03;
  1506. box-sizing: border-box;
  1507. border-radius: 0rpx 0rpx 16rpx 0rpx;
  1508. text-align: center;
  1509. font-family: PingFang SC, PingFang SC;
  1510. font-weight: 500;
  1511. font-size: 20rpx;
  1512. color: #fff;
  1513. position: absolute;
  1514. left: 0;
  1515. top: 0;
  1516. }
  1517. }
  1518. }
  1519. .bg {
  1520. background: #fff !important;
  1521. }
  1522. .answerPopup {
  1523. &-box {
  1524. width: 560rpx;
  1525. background: linear-gradient(180deg, #FFFAF6 0%, #FEECD8 100%);
  1526. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1527. background-color: #fff;
  1528. font-weight: 400;
  1529. padding: 32rpx;
  1530. box-sizing: border-box;
  1531. position: relative;
  1532. @include u-flex(column, center, flex-start);
  1533. font-family: PingFang SC, PingFang SC;
  1534. font-weight: 400;
  1535. .tipimg {
  1536. width: 206rpx;
  1537. height: 206rpx;
  1538. margin-bottom: 16rpx;
  1539. }
  1540. }
  1541. &-title {
  1542. font-weight: 600;
  1543. font-size: 36rpx;
  1544. color: #222222;
  1545. }
  1546. &-desc {
  1547. margin-top: 10rpx;
  1548. font-size: 28rpx;
  1549. color: #757575;
  1550. }
  1551. &-btn {
  1552. width: 464rpx;
  1553. height: 84rpx;
  1554. margin-top: 54rpx;
  1555. margin-bottom: 16rpx;
  1556. background: #FF5C03;
  1557. border-radius: 42rpx;
  1558. font-weight: 500;
  1559. font-size: 32rpx;
  1560. color: #FFFFFF;
  1561. text-align: center;
  1562. line-height: 84rpx;
  1563. }
  1564. }
  1565. .popupbox {
  1566. width: 100%;
  1567. background-color: #fff;
  1568. border-radius: 16rpx 16rpx 0 0;
  1569. padding: 24rpx 32rpx;
  1570. position: relative;
  1571. &-head {
  1572. height: 60rpx;
  1573. margin-bottom: 30rpx;
  1574. text-align: center;
  1575. overflow-y: auto;
  1576. color: #414858;
  1577. font-size: 32rpx;
  1578. font-weight: bold;
  1579. position: relative;
  1580. .close-icon {
  1581. position: absolute;
  1582. right: 0;
  1583. top: 0;
  1584. height: 40rpx;
  1585. width: 40rpx;
  1586. }
  1587. }
  1588. &-content {
  1589. height: 20vh;
  1590. overflow-y: auto;
  1591. display: flex;
  1592. align-items: flex-start;
  1593. flex-wrap: wrap;
  1594. gap: 32rpx;
  1595. .line-item {
  1596. display: inline-block;
  1597. min-width: 200rpx;
  1598. min-height: 60rpx;
  1599. padding: 0 20rpx;
  1600. box-sizing: border-box;
  1601. border-radius: 50rpx;
  1602. overflow: hidden;
  1603. background-color: #f7f7f7;
  1604. text-align: center;
  1605. color: #414858;
  1606. font-size: 28rpx;
  1607. line-height: 60rpx;
  1608. }
  1609. .line-active {
  1610. color: #f56c6c !important;
  1611. background-color: #fef0f0 !important;
  1612. }
  1613. }
  1614. }
  1615. .content {
  1616. padding-bottom: calc(var(--window-bottom));
  1617. .video-box {
  1618. width: 100%;
  1619. height: 420rpx;
  1620. overflow: hidden;
  1621. position: relative;
  1622. #myVideo {
  1623. width: 100%;
  1624. height: 100%;
  1625. }
  1626. }
  1627. .video-poster {
  1628. width: 100%;
  1629. height: 420rpx;
  1630. }
  1631. .miantitlebox {
  1632. padding: 30rpx 0;
  1633. border-bottom: 2rpx solid #F5F7FA;
  1634. font-family: PingFang SC, PingFang SC;
  1635. font-weight: 500;
  1636. font-size: 36rpx;
  1637. color: #222222;
  1638. }
  1639. .subtitlebox {
  1640. padding: 30rpx 0;
  1641. border-bottom: 2rpx solid #F5F7FA;
  1642. font-family: PingFang SC, PingFang SC;
  1643. font-weight: 500;
  1644. font-size: 36rpx;
  1645. color: #222222;
  1646. }
  1647. .title-content {
  1648. padding: 0 32rpx;
  1649. background-color: #fff;
  1650. font-size: 28rpx;
  1651. line-height: 1.6;
  1652. .title {
  1653. font-size: 36rpx;
  1654. font-weight: 500;
  1655. color: #414858;
  1656. }
  1657. .time-or-subtitle {
  1658. margin-top: 12rpx;
  1659. color: #666666;
  1660. }
  1661. }
  1662. .video-line {
  1663. min-width: 140rpx;
  1664. max-width: 200rpx;
  1665. height: 60rpx;
  1666. padding: 0 20rpx;
  1667. box-sizing: border-box;
  1668. border-radius: 50rpx 0 0 50rpx;
  1669. overflow: hidden;
  1670. background-color: #fff;
  1671. text-align: center;
  1672. color: #888;
  1673. font-size: 28rpx;
  1674. line-height: 60rpx;
  1675. display: inline-flex;
  1676. align-items: center;
  1677. justify-content: center;
  1678. position: fixed;
  1679. right: 0;
  1680. z-index: 9;
  1681. bottom: calc(var(--window-bottom) + 280rpx);
  1682. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, .12);
  1683. image {
  1684. flex-shrink: 0;
  1685. height: 34rpx;
  1686. width: 34rpx;
  1687. margin-right: 6rpx;
  1688. }
  1689. }
  1690. .footer {
  1691. border-top: 1rpx solid #ededef;
  1692. background: #fff;
  1693. width: 100%;
  1694. position: fixed;
  1695. bottom: 0;
  1696. padding: 18rpx 32rpx;
  1697. padding-bottom: calc(var(--window-bottom) + 18rpx);
  1698. box-sizing: border-box;
  1699. z-index: 9;
  1700. &-btn {
  1701. width: 100%;
  1702. height: 98rpx;
  1703. background: #FF5C03;
  1704. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1705. line-height: 98rpx;
  1706. text-align: center;
  1707. font-family: PingFang SC, PingFang SC;
  1708. font-weight: 600;
  1709. font-size: 32rpx;
  1710. color: #FFFFFF;
  1711. @include u-flex(row, center, center);
  1712. &-img {
  1713. flex-shrink: 0;
  1714. width: 144rpx;
  1715. height: 144rpx;
  1716. margin-right: 8rpx;
  1717. margin-top: -24rpx;
  1718. }
  1719. }
  1720. &-btn-border {
  1721. position: relative;
  1722. &::after {
  1723. content: "";
  1724. background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
  1725. position: absolute;
  1726. top: -2rpx;
  1727. left: 0;
  1728. height: 103rpx;
  1729. width: 100%;
  1730. z-index: -1;
  1731. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1732. box-shadow: 0rpx 8rpx 11rpx 0rpx rgba(255, 92, 3, 0.3);
  1733. overflow: hidden;
  1734. }
  1735. }
  1736. }
  1737. }
  1738. .agreement {
  1739. display: inline-flex;
  1740. margin-top: 16rpx;
  1741. font-size: 24rpx;
  1742. color: #525252;
  1743. align-items: center;
  1744. justify-content: center;
  1745. }
  1746. .logo {
  1747. display: inline-block;
  1748. width: 30px;
  1749. height: auto;
  1750. margin: 20px 0 0 10px;
  1751. pointer-events: none;
  1752. object-fit: cover;
  1753. }
  1754. .logo-full {
  1755. display: inline-block;
  1756. width: 40px;
  1757. height: auto;
  1758. margin: 50px 0 0 30px;
  1759. pointer-events: none;
  1760. object-fit: cover;
  1761. }
  1762. .tabbox {
  1763. @include u-flex(row, center, center);
  1764. border-bottom: 2rpx solid #F5F7FA;
  1765. height: 44px;
  1766. background-color: #fff;
  1767. view {
  1768. flex: 1;
  1769. padding: 20rpx 0;
  1770. margin-right: 40rpx;
  1771. text-align: center;
  1772. }
  1773. &-active {
  1774. position: relative;
  1775. &::after {
  1776. position: absolute;
  1777. bottom: 0;
  1778. left: 50%;
  1779. transform: translateX(-50%);
  1780. content: "";
  1781. width: 3rem;
  1782. border-bottom: 4px solid #FF5C03;
  1783. }
  1784. }
  1785. }
  1786. .chatinput {
  1787. position: fixed;
  1788. left: 32rpx;
  1789. right: 32rpx;
  1790. z-index: 999;
  1791. bottom: calc(var(--window-bottom) + 24rpx);
  1792. height: 96rpx;
  1793. background-color: green;
  1794. background: #FFFFFF;
  1795. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1796. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1797. @include u-flex(row, center, center);
  1798. padding: 0 24rpx;
  1799. box-sizing: border-box;
  1800. .uni-input {
  1801. flex: 1;
  1802. margin-right: 32rpx;
  1803. font-size: 30rpx;
  1804. }
  1805. .send {
  1806. font-family: PingFang SC, PingFang SC;
  1807. font-weight: 400;
  1808. font-size: 28rpx;
  1809. color: #FFFFFF !important;
  1810. flex-shrink: 0;
  1811. padding: 0 20rpx;
  1812. height: 72rpx;
  1813. background: #FF5C03 !important;
  1814. border-radius: 8rpx 8rpx 8rpx 8rpx;
  1815. &::after {
  1816. border: none;
  1817. }
  1818. }
  1819. }
  1820. .danmu-line {
  1821. bottom: calc(var(--window-bottom) + 370rpx) !important;
  1822. word-break: keep-all;
  1823. .set_image {
  1824. height: 40rpx;
  1825. width: 40rpx;
  1826. }
  1827. }
  1828. .video-danmu-btnbox {
  1829. width: 50px;
  1830. height: 50px;
  1831. border-radius: 50%;
  1832. overflow: hidden;
  1833. position: absolute;
  1834. right: 10px;
  1835. bottom: calc(50% - 50px);
  1836. transform: translateY(-50%);
  1837. padding: 8px;
  1838. box-sizing: border-box;
  1839. }
  1840. .video-danmu-image {
  1841. width: 100%;
  1842. height: 100%;
  1843. }
  1844. .danmuPopup-input {
  1845. flex: 1;
  1846. height: 35px;
  1847. border-radius: 35px;
  1848. border: 1rpx solid #eee;
  1849. padding: 0 24rpx;
  1850. }
  1851. .danmuPopup {
  1852. background-color: #fff;
  1853. padding-bottom: calc(var(--window-bottom) + 10px);
  1854. &-head {
  1855. width: 100%;
  1856. padding: 10px;
  1857. box-sizing: border-box;
  1858. overflow: hidden;
  1859. @include u-flex(row,center,flex-start);
  1860. .danmu-icon {
  1861. height: 24px;
  1862. width: 24px;
  1863. margin-right: 12px;
  1864. }
  1865. }
  1866. &-send {
  1867. flex-shrink: 0;
  1868. height: 35px;
  1869. display: flex;
  1870. align-items: center;
  1871. justify-content: center;
  1872. padding: 5px 15px;
  1873. box-sizing: border-box;
  1874. background: #FF5C03 !important;
  1875. border-radius: 22px;
  1876. font-family: PingFang SC, PingFang SC;
  1877. font-weight: 500;
  1878. font-size: 15px;
  1879. color: #fff !important;
  1880. margin-left: 12px;
  1881. &::after {
  1882. border: none;
  1883. }
  1884. }
  1885. &-con {
  1886. background-color: #F5F7FA;
  1887. padding: 24px 12px 48px 12px;
  1888. font-family: PingFang SC, PingFang SC;
  1889. font-weight: 400;
  1890. font-size: 14px;
  1891. color: #757575;
  1892. }
  1893. }
  1894. .answerTip {
  1895. position: fixed;
  1896. right: 0;
  1897. z-index: 9;
  1898. bottom: calc(var(--window-bottom) + 380rpx);
  1899. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1900. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1901. background-color: #ff5c03;
  1902. color: #fff;
  1903. border-radius: 50%;
  1904. height: 100rpx;
  1905. width: 100rpx;
  1906. font-size: 30rpx;
  1907. text-align: center;
  1908. padding: 10rpx;
  1909. @include u-flex(row, center, center);
  1910. }
  1911. </style>