videoOld.vue 57 KB

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