video.vue 56 KB

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