video.vue 50 KB

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