learning.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975
  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. internetTraffic,
  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(1)
  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(type) {
  881. this.$refs.answerPopup.close()
  882. if (this.errTitle == '恭喜你,回答正确') {
  883. let param = {
  884. ...this.urlOption,
  885. rewardType: Number(this.currentReward),
  886. }
  887. if(type == 1) {
  888. param = {
  889. ...this.urlOption
  890. }
  891. }
  892. sendReward(param).then(res => {
  893. if(res.code == 200) {
  894. if(res.isNew&&res.isNew==1) {
  895. const packageInfo = res.data.packageInfo || ''
  896. if(packageInfo) {
  897. uni.setStorageSync('receive_package',packageInfo);
  898. if(res.mchId) uni.setStorageSync('mchId',res.mchId);
  899. uni.navigateTo({
  900. url: '/pages/course/reward'
  901. })
  902. }
  903. } else {
  904. uni.showToast({
  905. title: res.msg,
  906. icon: 'none'
  907. })
  908. }
  909. }else {
  910. uni.showToast({
  911. title: res.msg,
  912. icon: 'none'
  913. })
  914. }
  915. })
  916. }
  917. },
  918. // 线路
  919. openPop() {
  920. this.$refs.popup.open('bottom')
  921. },
  922. close() {
  923. this.$refs.popup.close()
  924. },
  925. handleLine(index) {
  926. var that=this;
  927. if (this.lineIndex == index && this.videoUrl == this.lineList[index]) {
  928. this.close()
  929. return
  930. } else {
  931. // let div = document.querySelector(".vjs-progress-control");
  932. // if(div) {
  933. // if (this.isFinish == 1 || this.isEnded || this.linkType == 1) {
  934. // div.style.pointerEvents = "auto";
  935. // } else {
  936. // div.style.pointerEvents = "none"; //禁止所有事件
  937. // }
  938. // }
  939. this.lineIndex = index
  940. this.videoUrl = this.lineList[index]
  941. this.tipsOpen = false
  942. this.playDurationSeek = this.playTime || 0
  943. this.player = uni.createVideoContext('video-content-box');
  944. setTimeout(function(){
  945. that.player.seek(that.playDurationSeek)
  946. that.player.play();
  947. },500);
  948. // this.player.src(this.lineList[index])
  949. // this.player.one('loadedmetadata', () => {
  950. // this.player.currentTime(this.playDurationSeek);
  951. // this.player.play();
  952. // });
  953. this.close()
  954. }
  955. },
  956. // 温馨提示
  957. openTipsPop() {
  958. this.$refs.tipsPopup.open()
  959. this.tipsOpen = true
  960. this.pause()
  961. },
  962. closeTipsPop() {
  963. this.$refs.tipsPopup.close()
  964. },
  965. // 客服
  966. getIsAddKf() {
  967. this.qrcode = ''
  968. this.qrcodeMsg = ''
  969. this.isAddKf = 0
  970. // {videoId: this.videoId,qwUserId: this.qwUserId,corpId: this.corpId}
  971. const param = {
  972. ...this.urlOption
  973. }
  974. getIsAddKf(param).then(res => {
  975. if (res.code == 200) {
  976. if (this.urlOption.isRoom == 1 && res.qwExternalId) {
  977. this.urlOption = {
  978. ...this.urlOption,
  979. qwExternalId: res.qwExternalId
  980. }
  981. }
  982. this.isAddKf = 1
  983. this.getH5CourseVideoDetails()
  984. } else if (res.code == 400) {
  985. this.isAddKf = 0
  986. this.qrcode = res.qrcode
  987. this.qrcodeMsg = res.msg
  988. this.$refs.kfPopup.open()
  989. } else if (res.code == 567) {
  990. // 群聊通用链接
  991. this.urlOption = {
  992. ...this.urlOption,
  993. qwExternalId: res.qwExternalId
  994. }
  995. this.isAddKf = 1
  996. this.getH5CourseVideoDetails()
  997. } else if (res.code == 504) {
  998. // 登录
  999. // #ifdef H5
  1000. if (isWechat) { //是否在微信浏览器中打开
  1001. this.loginByMp()
  1002. } else {
  1003. uni.navigateTo({
  1004. url: "/pages/auth/login"
  1005. });
  1006. }
  1007. // #endif
  1008. } else {
  1009. this.isAddKf = 0
  1010. uni.showToast({
  1011. title: res.msg,
  1012. icon: 'none'
  1013. });
  1014. }
  1015. },
  1016. err => {}
  1017. );
  1018. },
  1019. closeKFPop() {
  1020. this.$refs.kfPopup.close()
  1021. },
  1022. loginByMp() {
  1023. if (this.code == null||!this.code) {
  1024. if(this.sortLink) {
  1025. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.sortLink
  1026. } else {
  1027. if(this.urlOption.link) {
  1028. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.urlOption.link
  1029. } else {
  1030. this.isExpire = true
  1031. this.msg = '课程链接地址有误'
  1032. uni.showToast({
  1033. title: '课程链接地址有误',
  1034. icon: 'none'
  1035. });
  1036. }
  1037. }
  1038. return;
  1039. }
  1040. uni.showLoading({
  1041. title: "处理中..."
  1042. });
  1043. let that = this;
  1044. var data = {
  1045. code: this.code
  1046. }
  1047. loginByMp(data).then(res => {
  1048. uni.hideLoading();
  1049. if (res.code == 200) {
  1050. uni.setStorageSync(this.$TOKEN_KEY, res.token);
  1051. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  1052. this.isLogin = this.$isLogin()
  1053. if(this.isAddKf == 1) {
  1054. this.getH5CourseVideoDetails()
  1055. } else {
  1056. this.getIsAddKf()
  1057. }
  1058. } else {
  1059. uni.showToast({
  1060. title: res.msg,
  1061. icon: 'none'
  1062. });
  1063. }
  1064. },
  1065. err => {}
  1066. ).catch(err=>{
  1067. uni.hideLoading();
  1068. });
  1069. },
  1070. getFinishCourseVideo() {
  1071. if (!this.playTime||!this.$isLogin()||this.isAddKf != 1) return
  1072. // {videoId: this.videoId,duration:this.playTime}
  1073. const param = {
  1074. duration: this.playTime,
  1075. ...this.urlOption
  1076. }
  1077. getFinishCourseVideo(param)
  1078. },
  1079. // 每十分钟获得积分
  1080. getIntegralByH5Video() {
  1081. if (!this.$isLogin()||this.isAddKf != 1) return
  1082. const param = {
  1083. duration: this.playTime,
  1084. ...this.urlOption,
  1085. }
  1086. getIntegralByH5Video(param).then(res => {
  1087. if (res.code == 200) {
  1088. uni.showToast({
  1089. title: "积分+10",
  1090. icon: "none"
  1091. })
  1092. }
  1093. })
  1094. },
  1095. progressChange(e) {
  1096. this.bufferRate = Math.ceil(e.detail.buffered)
  1097. },
  1098. // 缓冲
  1099. getInternetTraffic() {
  1100. if (!this.$isLogin()||this.isAddKf != 1) return
  1101. const playVideoTime = Math.ceil(this.playTime / this.duration * 100) // 播放百分比
  1102. if(this.bufferRate == 0 || this.bufferRate < playVideoTime) {
  1103. this.bufferRate = playVideoTime
  1104. }
  1105. if(this.bufferRate == 0 || Number(this.bufferRate.toFixed(2)) == 0) return
  1106. const param = {
  1107. ...this.urlOption,
  1108. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1109. duration: this.playTime,
  1110. bufferRate: Number(this.bufferRate.toFixed(2)),
  1111. }
  1112. if(!param.bufferRate) return
  1113. internetTraffic(param)
  1114. },
  1115. getErrMsg(err,type) {
  1116. let msgerr = {
  1117. errType: type || 'error',
  1118. videoUrl: this.videoUrl,
  1119. lineIndex: this.lineIndex,
  1120. errTime: new Date(),
  1121. ip: this.ip,
  1122. errMsg: err || ''
  1123. }
  1124. getErrMsg({
  1125. msg: JSON.stringify(msgerr)
  1126. })
  1127. },
  1128. getLink() {
  1129. let that = this;
  1130. getRealLink({sortLink:this.sortLink}).then(res=>{
  1131. if(res.code == 200) {
  1132. this.isExpire = false
  1133. this.authDomainName = res.config.authDomainName || ''
  1134. if(this.authDomainName) {
  1135. uni.setStorageSync('authDomainName',this.authDomainName)
  1136. }
  1137. if(this.isLogin) {
  1138. window.location.replace(res.realLink)
  1139. } else{
  1140. const option = res.realLink.split('?course=')[1]
  1141. const urlOption = option ? JSON.parse(option) : {}
  1142. const videoId = urlOption.videoId || ''
  1143. this.getH5CourseByVideo(videoId)
  1144. }
  1145. } else {
  1146. this.isExpire = true
  1147. this.msg = '课程已过期或链接无效'
  1148. uni.showToast({
  1149. title: '课程已过期或链接无效',
  1150. icon: 'none'
  1151. });
  1152. }
  1153. }).catch(err=>{
  1154. this.isExpire = true
  1155. this.msg = '发生错误,请稍后再试'
  1156. uni.showToast({
  1157. title: '发生错误,请稍后再试',
  1158. icon: 'none'
  1159. });
  1160. })
  1161. },
  1162. /**
  1163. * 节流原理:在一定时间内,只能触发一次
  1164. *
  1165. * @param {Function} func 要执行的回调函数
  1166. * @param {Number} wait 延时的时间
  1167. * @param {Boolean} immediate 是否立即执行
  1168. * @return null
  1169. */
  1170. throttle(func, wait = 500, immediate = true) {
  1171. if (immediate) {
  1172. if (!this.flag) {
  1173. this.flag = true
  1174. // 如果是立即执行,则在wait毫秒内开始时执行
  1175. typeof func === 'function' && func()
  1176. this.timer = setTimeout(() => {
  1177. this.flag = false
  1178. }, wait)
  1179. }
  1180. } else if (!this.flag) {
  1181. this.flag = true
  1182. // 如果是非立即执行,则在wait毫秒内的结束处执行
  1183. this.timer = setTimeout(() => {
  1184. this.flag = false
  1185. typeof func === 'function' && func()
  1186. }, wait)
  1187. }
  1188. },
  1189. // 弹幕
  1190. keyboardHeightChange(res) {
  1191. // #ifndef H5
  1192. console.log("this.danmuboxHeight",this.danmuboxHeight)
  1193. this.danmuboxHeight = res.height
  1194. // #endif
  1195. },
  1196. openDanmu(type) {
  1197. this.openDanmuType = type
  1198. this.inputText = ''
  1199. if(type == 1) {
  1200. this.player.exitFullScreen()
  1201. }
  1202. this.$refs.danmuPopup.open()
  1203. },
  1204. changeShowPopup(val) {
  1205. this.focus = val.show
  1206. },
  1207. switchDanmu() {
  1208. this.showDanmu = this.showDanmu == 1 ? 0:1
  1209. if(this.showDanmu == 0&&this.$refs.danmuBox) {
  1210. this.$refs.danmuBox.activeDanmus = []
  1211. this.$refs.danmuBox.initTracks()
  1212. }
  1213. },
  1214. getScrollTop(res) {
  1215. if(this.currentTab == 2) {
  1216. this.scrollTop = res
  1217. } else {
  1218. this.scrollTop = 0
  1219. }
  1220. },
  1221. handleTab(index) {
  1222. this.currentTab = index
  1223. if(this.currentTab==2) {
  1224. if(this.$refs.commentBox) {
  1225. this.$refs.commentBox.msgs = []
  1226. this.$refs.commentBox.pageNum = 1
  1227. this.$refs.commentBox.getComments()
  1228. }
  1229. } else {
  1230. setTimeout(()=>{
  1231. this.scrollTop = 0
  1232. },100)
  1233. }
  1234. },
  1235. handleRefresher() {
  1236. this.triggered = true;
  1237. if (!this.isMore&&this.currentTab==2&&this.openCommentStatus==1) {
  1238. this.$nextTick(()=>{
  1239. this.$refs.commentBox&&this.$refs.commentBox.getComments()
  1240. })
  1241. }
  1242. setTimeout(() => {
  1243. this.triggered = false;
  1244. }, 500);
  1245. },
  1246. getMore(val) {
  1247. this.triggered = false;
  1248. this.isMore = val == 1
  1249. },
  1250. handleChatInput() {
  1251. this.inputText = this.inputText.trim()
  1252. if (this.inputText == "" || this.inputText.trim() == "") {
  1253. uni.showToast({
  1254. title: '请输入评论',
  1255. icon: "none"
  1256. })
  1257. return;
  1258. }
  1259. if(this.openCommentStatus==1) {
  1260. this.$refs.commentBox&&this.$refs.commentBox.handleInput(this.inputText)
  1261. } else if(this.openCommentStatus==2) {
  1262. this.$refs.danmuBox&&this.$refs.danmuBox.handleInput(this.inputText)
  1263. }
  1264. },
  1265. setInputText() {
  1266. this.inputText = ""
  1267. if(this.openCommentStatus==2) {
  1268. this.$refs.danmuPopup.close()
  1269. }
  1270. }
  1271. }
  1272. }
  1273. </script>
  1274. <style scoped>
  1275. .full-width-popup {
  1276. width: 100%;
  1277. }
  1278. </style>
  1279. <style lang="scss" scoped>
  1280. @mixin u-flex($flexD, $alignI, $justifyC) {
  1281. display: flex;
  1282. flex-direction: $flexD;
  1283. align-items: $alignI;
  1284. justify-content: $justifyC;
  1285. }
  1286. .footer-tips {
  1287. margin-top: 14rpx;
  1288. text-align: center;
  1289. font-family: PingFang SC,PingFang SC;
  1290. font-weight: 500;
  1291. font-size: 12px;
  1292. color: #bbb;
  1293. }
  1294. .textOne {
  1295. overflow: hidden;
  1296. white-space: nowrap;
  1297. text-overflow: ellipsis;
  1298. }
  1299. .textTwo {
  1300. overflow: hidden;
  1301. text-overflow: ellipsis;
  1302. display: -webkit-box;
  1303. -webkit-line-clamp: 2;
  1304. -webkit-box-orient: vertical;
  1305. }
  1306. .expirebox {
  1307. height: 100vh;
  1308. @include u-flex(column, center, center);
  1309. font-family: PingFang SC, PingFang SC;
  1310. font-weight: 400;
  1311. font-size: 32rpx;
  1312. color: #757575;
  1313. image {
  1314. width: 428rpx;
  1315. height: 360rpx;
  1316. margin-bottom: 30rpx;
  1317. }
  1318. }
  1319. .reward-list {
  1320. width: 100%;
  1321. margin-top: 20rpx;
  1322. margin-bottom: -40rpx;
  1323. &-group {
  1324. font-family: PingFang SC, PingFang SC;
  1325. font-weight: 400;
  1326. font-size: 14px;
  1327. color: #222222;
  1328. @include u-flex(row, center, center);
  1329. }
  1330. &-option {
  1331. @include u-flex(row, center, flex-start);
  1332. &:first-child {
  1333. margin-right: 40rpx;
  1334. }
  1335. }
  1336. }
  1337. .err {
  1338. color: #f56c6c !important;
  1339. }
  1340. .kfqrcode-box {
  1341. background-color: #fff;
  1342. border-radius: 16rpx;
  1343. max-width: 560rpx;
  1344. padding: 60rpx 40rpx;
  1345. margin-top: -100rpx;
  1346. box-sizing: border-box;
  1347. @include u-flex(column, center, flex-start);
  1348. font-family: PingFang SC, PingFang SC;
  1349. font-weight: 400;
  1350. font-size: 34rpx;
  1351. color: #222;
  1352. position: relative;
  1353. text-align: center;
  1354. .kfqrcode {
  1355. height: 460rpx;
  1356. width: 460rpx;
  1357. }
  1358. }
  1359. .kfqrcode-close {
  1360. width: 64rpx;
  1361. height: 64rpx;
  1362. position: absolute;
  1363. bottom: -100rpx;
  1364. left: 50%;
  1365. transform: translateX(-50%);
  1366. }
  1367. .tipsPopup-mask {
  1368. position: relative;
  1369. width: 560rpx;
  1370. background-color: transparent;
  1371. .red_envelope_top {
  1372. width: 480rpx;
  1373. height: 360rpx;
  1374. margin: 0 auto;
  1375. display: inherit;
  1376. }
  1377. }
  1378. .tipsPopup-btn-box {
  1379. width: 456rpx;
  1380. height: 104rpx;
  1381. padding: 4rpx;
  1382. box-sizing: border-box;
  1383. background: linear-gradient(180deg, rgba(252, 209, 94, 1), rgba(254, 253, 251, 1));
  1384. border-radius: 52rpx;
  1385. }
  1386. .tipsPopup-btn {
  1387. width: 100%;
  1388. height: 100%;
  1389. background: linear-gradient(180deg, #FF9F22 0%, #FA1E05 100%);
  1390. border-radius: 52rpx 52rpx 52rpx 52rpx;
  1391. font-family: PingFang SC, PingFang SC;
  1392. font-weight: 500;
  1393. font-size: 36rpx;
  1394. color: #FFFFFF;
  1395. line-height: 96rpx;
  1396. text-align: center;
  1397. }
  1398. .tipsPopup {
  1399. width: 560rpx;
  1400. padding: 12rpx;
  1401. margin-top: -72rpx;
  1402. box-sizing: border-box;
  1403. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1404. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1405. position: relative;
  1406. &-close {
  1407. width: 64rpx;
  1408. height: 64rpx;
  1409. position: absolute;
  1410. right: 0;
  1411. top: -188rpx;
  1412. }
  1413. &-line {
  1414. padding: 3rpx;
  1415. box-sizing: border-box;
  1416. background: linear-gradient(180deg, rgba(247, 245, 220, 1), rgba(250, 220, 157, 1));
  1417. border-radius: 24rpx;
  1418. }
  1419. &-box {
  1420. padding: 0 40rpx 40rpx 40rpx;
  1421. box-sizing: border-box;
  1422. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1423. border-radius: 24rpx;
  1424. @include u-flex(column, center, flex-start);
  1425. }
  1426. &-head {
  1427. @include u-flex(row, center, center);
  1428. &-title {
  1429. width: 364rpx;
  1430. height: auto;
  1431. margin-top: -22rpx;
  1432. }
  1433. }
  1434. &-content {
  1435. margin: 48rpx 0;
  1436. font-family: PingFang SC, PingFang SC;
  1437. font-weight: 500;
  1438. font-size: 32rpx;
  1439. color: #222222;
  1440. text-align: center;
  1441. &-title {
  1442. margin-bottom: 26rpx;
  1443. font-weight: 600;
  1444. font-size: 40rpx;
  1445. color: #FF5C03;
  1446. }
  1447. }
  1448. }
  1449. .video-controls-box {
  1450. width: 100%;
  1451. height: calc(100% - 44px);
  1452. overflow: hidden;
  1453. position: absolute;
  1454. top: 0;
  1455. left: 0;
  1456. z-index: 2;
  1457. background: rgba(0, 0, 0, 0.2);
  1458. .video-play {
  1459. height: 72rpx;
  1460. width: 72rpx;
  1461. position: absolute;
  1462. top: 50%;
  1463. left: 50%;
  1464. transform: translate(-50%, -50%);
  1465. }
  1466. }
  1467. .video-controls {
  1468. width: 100%;
  1469. height: 80rpx;
  1470. padding: 0 28rpx;
  1471. box-sizing: border-box;
  1472. position: absolute;
  1473. bottom: 0;
  1474. left: 0;
  1475. display: flex;
  1476. align-items: center;
  1477. justify-content: space-between;
  1478. background: linear-gradient(to top, #222 0%, transparent 80%);
  1479. .video-icon {
  1480. height: 44rpx;
  1481. width: 44rpx;
  1482. }
  1483. }
  1484. .errQuesbox {
  1485. width: 100%;
  1486. max-height: 260rpx;
  1487. overflow-y: auto;
  1488. margin-top: 24rpx;
  1489. font-family: PingFang SC, PingFang SC;
  1490. font-weight: 500;
  1491. font-size: 30rpx;
  1492. color: #222222;
  1493. &-item {
  1494. width: 100%;
  1495. height: 128rpx;
  1496. line-height: 128rpx;
  1497. margin-bottom: 24rpx;
  1498. padding: 0 30rpx;
  1499. box-sizing: border-box;
  1500. overflow: hidden;
  1501. background: #fff;
  1502. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1503. position: relative;
  1504. &::after {
  1505. content: "题目";
  1506. min-width: 64rpx;
  1507. height: 36rpx;
  1508. padding: 0 12rpx;
  1509. line-height: 36rpx;
  1510. background: #FF5C03;
  1511. box-sizing: border-box;
  1512. border-radius: 0rpx 0rpx 16rpx 0rpx;
  1513. text-align: center;
  1514. font-family: PingFang SC, PingFang SC;
  1515. font-weight: 500;
  1516. font-size: 20rpx;
  1517. color: #fff;
  1518. position: absolute;
  1519. left: 0;
  1520. top: 0;
  1521. }
  1522. }
  1523. }
  1524. .bg {
  1525. background: #fff !important;
  1526. }
  1527. .answerPopup {
  1528. &-box {
  1529. width: 560rpx;
  1530. background: linear-gradient(180deg, #FFFAF6 0%, #FEECD8 100%);
  1531. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1532. background-color: #fff;
  1533. font-weight: 400;
  1534. padding: 32rpx;
  1535. box-sizing: border-box;
  1536. position: relative;
  1537. @include u-flex(column, center, flex-start);
  1538. font-family: PingFang SC, PingFang SC;
  1539. font-weight: 400;
  1540. .tipimg {
  1541. width: 206rpx;
  1542. height: 206rpx;
  1543. margin-bottom: 16rpx;
  1544. }
  1545. }
  1546. &-title {
  1547. font-weight: 600;
  1548. font-size: 36rpx;
  1549. color: #222222;
  1550. }
  1551. &-desc {
  1552. margin-top: 10rpx;
  1553. font-size: 28rpx;
  1554. color: #757575;
  1555. }
  1556. &-btn {
  1557. width: 464rpx;
  1558. height: 84rpx;
  1559. margin-top: 54rpx;
  1560. margin-bottom: 16rpx;
  1561. background: #FF5C03;
  1562. border-radius: 42rpx;
  1563. font-weight: 500;
  1564. font-size: 32rpx;
  1565. color: #FFFFFF;
  1566. text-align: center;
  1567. line-height: 84rpx;
  1568. }
  1569. }
  1570. .popupbox {
  1571. width: 100%;
  1572. background-color: #fff;
  1573. border-radius: 16rpx 16rpx 0 0;
  1574. padding: 24rpx 32rpx;
  1575. position: relative;
  1576. &-head {
  1577. height: 60rpx;
  1578. margin-bottom: 30rpx;
  1579. text-align: center;
  1580. overflow-y: auto;
  1581. color: #414858;
  1582. font-size: 32rpx;
  1583. font-weight: bold;
  1584. position: relative;
  1585. .close-icon {
  1586. position: absolute;
  1587. right: 0;
  1588. top: 0;
  1589. height: 40rpx;
  1590. width: 40rpx;
  1591. }
  1592. }
  1593. &-content {
  1594. height: 20vh;
  1595. overflow-y: auto;
  1596. display: flex;
  1597. align-items: flex-start;
  1598. flex-wrap: wrap;
  1599. gap: 32rpx;
  1600. .line-item {
  1601. display: inline-block;
  1602. min-width: 200rpx;
  1603. min-height: 60rpx;
  1604. padding: 0 20rpx;
  1605. box-sizing: border-box;
  1606. border-radius: 50rpx;
  1607. overflow: hidden;
  1608. background-color: #f7f7f7;
  1609. text-align: center;
  1610. color: #414858;
  1611. font-size: 28rpx;
  1612. line-height: 60rpx;
  1613. }
  1614. .line-active {
  1615. color: #f56c6c !important;
  1616. background-color: #fef0f0 !important;
  1617. }
  1618. }
  1619. }
  1620. .content {
  1621. padding-bottom: calc(var(--window-bottom));
  1622. .video-box {
  1623. width: 100%;
  1624. height: 420rpx;
  1625. overflow: hidden;
  1626. position: relative;
  1627. #myVideo {
  1628. width: 100%;
  1629. height: 100%;
  1630. }
  1631. }
  1632. .video-poster {
  1633. width: 100%;
  1634. height: 420rpx;
  1635. }
  1636. .miantitlebox {
  1637. padding: 30rpx 0;
  1638. border-bottom: 2rpx solid #F5F7FA;
  1639. font-family: PingFang SC, PingFang SC;
  1640. font-weight: 500;
  1641. font-size: 36rpx;
  1642. color: #222222;
  1643. }
  1644. .subtitlebox {
  1645. padding: 30rpx 0;
  1646. border-bottom: 2rpx solid #F5F7FA;
  1647. font-family: PingFang SC, PingFang SC;
  1648. font-weight: 500;
  1649. font-size: 36rpx;
  1650. color: #222222;
  1651. }
  1652. .title-content {
  1653. padding: 0 32rpx;
  1654. background-color: #fff;
  1655. font-size: 28rpx;
  1656. line-height: 1.6;
  1657. .title {
  1658. font-size: 36rpx;
  1659. font-weight: 500;
  1660. color: #414858;
  1661. }
  1662. .time-or-subtitle {
  1663. margin-top: 12rpx;
  1664. color: #666666;
  1665. }
  1666. }
  1667. .video-line {
  1668. min-width: 140rpx;
  1669. max-width: 200rpx;
  1670. height: 60rpx;
  1671. padding: 0 20rpx;
  1672. box-sizing: border-box;
  1673. border-radius: 50rpx 0 0 50rpx;
  1674. overflow: hidden;
  1675. background-color: #fff;
  1676. text-align: center;
  1677. color: #888;
  1678. font-size: 28rpx;
  1679. line-height: 60rpx;
  1680. display: inline-flex;
  1681. align-items: center;
  1682. justify-content: center;
  1683. position: fixed;
  1684. right: 0;
  1685. z-index: 9;
  1686. bottom: calc(var(--window-bottom) + 280rpx);
  1687. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, .12);
  1688. image {
  1689. flex-shrink: 0;
  1690. height: 34rpx;
  1691. width: 34rpx;
  1692. margin-right: 6rpx;
  1693. }
  1694. }
  1695. .footer {
  1696. border-top: 1rpx solid #ededef;
  1697. background: #fff;
  1698. width: 100%;
  1699. position: fixed;
  1700. bottom: 0;
  1701. padding: 18rpx 32rpx;
  1702. padding-bottom: calc(var(--window-bottom) + 18rpx);
  1703. box-sizing: border-box;
  1704. z-index: 9;
  1705. &-btn {
  1706. width: 100%;
  1707. height: 98rpx;
  1708. background: #FF5C03;
  1709. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1710. line-height: 98rpx;
  1711. text-align: center;
  1712. font-family: PingFang SC, PingFang SC;
  1713. font-weight: 600;
  1714. font-size: 32rpx;
  1715. color: #FFFFFF;
  1716. @include u-flex(row, center, center);
  1717. &-img {
  1718. flex-shrink: 0;
  1719. width: 144rpx;
  1720. height: 144rpx;
  1721. margin-right: 8rpx;
  1722. margin-top: -24rpx;
  1723. }
  1724. }
  1725. &-btn-border {
  1726. position: relative;
  1727. &::after {
  1728. content: "";
  1729. background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
  1730. position: absolute;
  1731. top: -2rpx;
  1732. left: 0;
  1733. height: 103rpx;
  1734. width: 100%;
  1735. z-index: -1;
  1736. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1737. box-shadow: 0rpx 8rpx 11rpx 0rpx rgba(255, 92, 3, 0.3);
  1738. overflow: hidden;
  1739. }
  1740. }
  1741. }
  1742. }
  1743. .agreement {
  1744. display: inline-flex;
  1745. margin-top: 16rpx;
  1746. font-size: 24rpx;
  1747. color: #525252;
  1748. align-items: center;
  1749. justify-content: center;
  1750. }
  1751. .logo {
  1752. display: inline-block;
  1753. width: 30px;
  1754. height: auto;
  1755. margin: 20px 0 0 10px;
  1756. pointer-events: none;
  1757. object-fit: cover;
  1758. }
  1759. .logo-full {
  1760. display: inline-block;
  1761. width: 40px;
  1762. height: auto;
  1763. margin: 50px 0 0 30px;
  1764. pointer-events: none;
  1765. object-fit: cover;
  1766. }
  1767. .tabbox {
  1768. @include u-flex(row, center, center);
  1769. border-bottom: 2rpx solid #F5F7FA;
  1770. height: 44px;
  1771. background-color: #fff;
  1772. view {
  1773. flex: 1;
  1774. padding: 20rpx 0;
  1775. margin-right: 40rpx;
  1776. text-align: center;
  1777. }
  1778. &-active {
  1779. position: relative;
  1780. &::after {
  1781. position: absolute;
  1782. bottom: 0;
  1783. left: 50%;
  1784. transform: translateX(-50%);
  1785. content: "";
  1786. width: 3rem;
  1787. border-bottom: 4px solid #FF5C03;
  1788. }
  1789. }
  1790. }
  1791. .chatinput {
  1792. position: fixed;
  1793. left: 32rpx;
  1794. right: 32rpx;
  1795. z-index: 999;
  1796. bottom: calc(var(--window-bottom) + 24rpx);
  1797. height: 96rpx;
  1798. background-color: green;
  1799. background: #FFFFFF;
  1800. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1801. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1802. @include u-flex(row, center, center);
  1803. padding: 0 24rpx;
  1804. box-sizing: border-box;
  1805. .uni-input {
  1806. flex: 1;
  1807. margin-right: 32rpx;
  1808. font-size: 30rpx;
  1809. }
  1810. .send {
  1811. font-family: PingFang SC, PingFang SC;
  1812. font-weight: 400;
  1813. font-size: 28rpx;
  1814. color: #FFFFFF !important;
  1815. flex-shrink: 0;
  1816. padding: 0 20rpx;
  1817. height: 72rpx;
  1818. background: #FF5C03 !important;
  1819. border-radius: 8rpx 8rpx 8rpx 8rpx;
  1820. &::after {
  1821. border: none;
  1822. }
  1823. }
  1824. }
  1825. .danmu-line {
  1826. bottom: calc(var(--window-bottom) + 370rpx) !important;
  1827. word-break: keep-all;
  1828. .set_image {
  1829. height: 40rpx;
  1830. width: 40rpx;
  1831. }
  1832. }
  1833. .video-danmu-btnbox {
  1834. width: 50px;
  1835. height: 50px;
  1836. border-radius: 50%;
  1837. overflow: hidden;
  1838. position: absolute;
  1839. right: 10px;
  1840. bottom: calc(50% - 50px);
  1841. transform: translateY(-50%);
  1842. padding: 8px;
  1843. box-sizing: border-box;
  1844. }
  1845. .video-danmu-image {
  1846. width: 100%;
  1847. height: 100%;
  1848. }
  1849. .danmuPopup-input {
  1850. flex: 1;
  1851. height: 35px;
  1852. border-radius: 35px;
  1853. border: 1rpx solid #eee;
  1854. padding: 0 24rpx;
  1855. }
  1856. .danmuPopup {
  1857. background-color: #fff;
  1858. padding-bottom: calc(var(--window-bottom) + 10px);
  1859. &-head {
  1860. width: 100%;
  1861. padding: 10px;
  1862. box-sizing: border-box;
  1863. overflow: hidden;
  1864. @include u-flex(row,center,flex-start);
  1865. .danmu-icon {
  1866. height: 24px;
  1867. width: 24px;
  1868. margin-right: 12px;
  1869. }
  1870. }
  1871. &-send {
  1872. flex-shrink: 0;
  1873. height: 35px;
  1874. display: flex;
  1875. align-items: center;
  1876. justify-content: center;
  1877. padding: 5px 15px;
  1878. box-sizing: border-box;
  1879. background: #FF5C03 !important;
  1880. border-radius: 22px;
  1881. font-family: PingFang SC, PingFang SC;
  1882. font-weight: 500;
  1883. font-size: 15px;
  1884. color: #fff !important;
  1885. margin-left: 12px;
  1886. &::after {
  1887. border: none;
  1888. }
  1889. }
  1890. &-con {
  1891. background-color: #F5F7FA;
  1892. padding: 24px 12px 48px 12px;
  1893. font-family: PingFang SC, PingFang SC;
  1894. font-weight: 400;
  1895. font-size: 14px;
  1896. color: #757575;
  1897. }
  1898. }
  1899. .answerTip {
  1900. position: fixed;
  1901. right: 0;
  1902. z-index: 9;
  1903. bottom: calc(var(--window-bottom) + 380rpx);
  1904. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1905. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1906. background-color: #ff5c03;
  1907. color: #fff;
  1908. border-radius: 50%;
  1909. height: 100rpx;
  1910. width: 100rpx;
  1911. font-size: 30rpx;
  1912. text-align: center;
  1913. padding: 10rpx;
  1914. @include u-flex(row, center, center);
  1915. }
  1916. </style>