videoOld.vue 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199
  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="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. ...this.urlOption,
  1007. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1008. duration: this.playTime,
  1009. bufferRate: Number(this.bufferRate.toFixed(2)),
  1010. }
  1011. if(!param.bufferRate) return
  1012. getInternetTraffic(param)
  1013. },
  1014. getErrMsg(err,type) {
  1015. let msgerr = {
  1016. errType: type || 'error',
  1017. videoUrl: this.videoUrl,
  1018. lineIndex: this.lineIndex,
  1019. errTime: new Date(),
  1020. ip: this.ip,
  1021. errMsg: err || ''
  1022. }
  1023. getErrMsg({
  1024. msg: JSON.stringify(msgerr)
  1025. })
  1026. },
  1027. goLogin() {
  1028. this.$getProvider().then(provider=>{
  1029. console.log('当前的环境商',provider)
  1030. if (!provider) {
  1031. reject()
  1032. }
  1033. uni.login({
  1034. provider: provider,
  1035. success: async loginRes => {
  1036. console.log(loginRes)
  1037. uni.getUserInfo({
  1038. provider: provider,
  1039. success: (infoRes)=> {
  1040. uni.showToast({
  1041. title: '处理中...',
  1042. icon: 'loading'
  1043. });
  1044. loginByMp({code: loginRes.code,encryptedData:infoRes.encryptedData,iv:infoRes.iv}).then(res=>{
  1045. uni.hideLoading();
  1046. if (res.code == 200) {
  1047. uni.setStorageSync('AppTokenmini_RTCourse', res.token);
  1048. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  1049. this.user = res.user
  1050. this.isLogin = true
  1051. this.getIsAddKf()
  1052. } else {
  1053. uni.showToast({
  1054. title: res.msg,
  1055. icon: 'none'
  1056. });
  1057. }
  1058. }).catch(err=>{
  1059. uni.hideLoading();
  1060. uni.showToast({
  1061. icon:'none',
  1062. title: "登录失败,请重新登录",
  1063. });
  1064. });
  1065. }
  1066. });
  1067. }
  1068. })
  1069. }).catch(err => {})
  1070. },
  1071. getLink() {
  1072. let that = this;
  1073. getRealLink({sortLink:this.sortLink}).then(res=>{
  1074. if(res.code == 200) {
  1075. this.isExpire = false
  1076. // 如果响应中包含真实链接,则跳转到真实链接
  1077. // window.location.href = res.realLink +"&sortLink="+this.sortLink+"&code="+this.code+"&time="+new Date().getTime()
  1078. if (this.isLogin && this.isAddKf == 1&&this.isCheckRealUrl) {
  1079. this.getH5CourseVideoDetails()
  1080. }
  1081. if (this.videoId &&(this.isAddKf != 1 || !this.isCheckRealUrl)) {
  1082. this.$isLoginCourse().then(
  1083. isLogin => {
  1084. this.isLogin = isLogin
  1085. if(isLogin){
  1086. this.getIsAddKf()
  1087. } else {
  1088. this.goLogin()
  1089. }
  1090. },
  1091. rej => {}
  1092. );
  1093. }
  1094. } else {
  1095. this.isExpire = true
  1096. uni.showToast({
  1097. title: '课程已过期或链接无效',
  1098. icon: 'none'
  1099. });
  1100. }
  1101. }).catch(err=>{
  1102. this.isExpire = true
  1103. uni.showToast({
  1104. title: '发生错误,请稍后再试',
  1105. icon: 'none'
  1106. });
  1107. })
  1108. },
  1109. /**
  1110. * 节流原理:在一定时间内,只能触发一次
  1111. *
  1112. * @param {Function} func 要执行的回调函数
  1113. * @param {Number} wait 延时的时间
  1114. * @param {Boolean} immediate 是否立即执行
  1115. * @return null
  1116. */
  1117. throttle(func, wait = 500, immediate = true) {
  1118. if (immediate) {
  1119. if (!this.flag) {
  1120. this.flag = true
  1121. // 如果是立即执行,则在wait毫秒内开始时执行
  1122. typeof func === 'function' && func()
  1123. this.timer = setTimeout(() => {
  1124. this.flag = false
  1125. }, wait)
  1126. }
  1127. } else if (!this.flag) {
  1128. this.flag = true
  1129. // 如果是非立即执行,则在wait毫秒内的结束处执行
  1130. this.timer = setTimeout(() => {
  1131. this.flag = false
  1132. typeof func === 'function' && func()
  1133. }, wait)
  1134. }
  1135. },
  1136. // 弹幕
  1137. openDanmu(type) {
  1138. this.openDanmuType = type
  1139. this.danmuIput= ''
  1140. if(type == 1) {
  1141. this.player.exitFullScreen()
  1142. }
  1143. this.$refs.danmuPopup.open()
  1144. },
  1145. changeShowPopup(val) {
  1146. this.focus = val.show
  1147. },
  1148. // 发送弹幕
  1149. sendDanmu() {
  1150. if(this.danmuIput=='') {
  1151. uni.showToast({
  1152. title: '弹幕不能为空',
  1153. icon: 'none'
  1154. })
  1155. return;
  1156. }
  1157. this.sendMsg()
  1158. },
  1159. // 弹幕列表
  1160. getDanmuList(){
  1161. getDanmuList(this.videoId).then(res=>{
  1162. if(res.code == 200&&res.data&&res.data.length>0) {
  1163. this.danmuList = res.data.map(item=>({
  1164. id: item.id,
  1165. text: item.content,
  1166. time: item.timePoint ? Number(item.timePoint) : this.playTime,
  1167. color: "#FFFFFF",
  1168. mode: item.mode|| "scroll",
  1169. top: null,
  1170. style: {
  1171. color: item.isColor==1 ? item.color || this.danmuItemStyle.color : this.danmuItemStyle.color,//是否彩色1是0否
  1172. fontSize: item.fontSize || this.danmuItemStyle.fontSize,
  1173. padding: this.danmuItemStyle.padding,
  1174. border:this.user.userId ==item.userId ? item.color ? `solid 1px ${item.color}`: this.danmuItemStyle.border : 'none',
  1175. borderRadius: this.user.userId==item.userId ? this.danmuItemStyle.borderRadius : 0,
  1176. backgroundColor: this.user.userId==item.userId ? this.danmuItemStyle.backgroundColor : 'transparent'
  1177. },
  1178. }))
  1179. } else {
  1180. this.danmuList = []
  1181. }
  1182. })
  1183. },
  1184. //创建一个socket连接
  1185. initSocket() {
  1186. let userId = this.user.userId;
  1187. let that = this;
  1188. this.socket = uni.connectSocket({
  1189. url: getApp().globalData.danmuWSUrl + "/ws/barrage/" + this.videoId,
  1190. multiple: true,
  1191. header: {
  1192. 'token': uni.getStorageSync('AppTokenmini_RTCourse')
  1193. },
  1194. success: res => {
  1195. console.log('WebSocket连接已打开1!');
  1196. that.isSocketOpen = true
  1197. that.reOpenSocket = false
  1198. // 保持心跳
  1199. if(that.pingpangTimes) {
  1200. clearInterval(that.pingpangTimes)
  1201. that.pingpangTimes= null
  1202. }
  1203. that.pingpangTimes=setInterval(()=>{
  1204. let data={cmd:"heartbeat",userId: userId};
  1205. that.socket.send({
  1206. data: JSON.stringify(data),
  1207. success: () => {
  1208. // console.log('WebSocket发送心条数据!');
  1209. },
  1210. fail: () => {
  1211. that.isSocketOpen=false
  1212. }
  1213. });
  1214. },15000)
  1215. },
  1216. error: res => {
  1217. console.log(res)
  1218. },
  1219. })
  1220. this.socket.onMessage((res) => {
  1221. // console.log("收到消息parse",JSON.parse(res.data))
  1222. const redata = JSON.parse(res.data);
  1223. if(redata.cmd=="heartbeat"){
  1224. //心跳
  1225. // console.log("heartbeat")
  1226. }else if(redata.cmd=="danmu"){
  1227. that.isSend=true;
  1228. that.addMsg(1,redata);
  1229. }
  1230. })
  1231. //监听socket打开
  1232. this.socket.onOpen(() => {
  1233. console.log('WebSocket连接已打开2!');
  1234. that.isSocketOpen = true
  1235. that.reOpenSocket = false
  1236. that.isSend = true;
  1237. })
  1238. //监听socket关闭
  1239. this.socket.onClose(() => {
  1240. that.isSocketOpen = false
  1241. that.socket = null
  1242. console.log('WebSocket连接已关闭!',that.reOpenSocket);
  1243. if(that.pingpangTimes) {
  1244. clearInterval(that.pingpangTimes)
  1245. that.pingpangTimes= null
  1246. }
  1247. if(that.reOpenSocket) {
  1248. //重启
  1249. that.initSocket()
  1250. }
  1251. })
  1252. //监听socket错误
  1253. this.socket.onError((err) => {
  1254. console.log("socket err:",err)
  1255. that.isSocketOpen = false
  1256. that.reOpenSocket = false
  1257. that.socket = null
  1258. if(that.pingpangTimes) {
  1259. clearInterval(that.pingpangTimes)
  1260. that.pingpangTimes= null
  1261. }
  1262. })
  1263. },
  1264. sendMsg() {
  1265. if (!this.isSend) {
  1266. return;
  1267. }
  1268. if (this.isSocketOpen) {
  1269. var data = {
  1270. cmd: 'danmu',
  1271. userId: this.user.userId,
  1272. videoId: this.videoId,
  1273. content: this.danmuIput,
  1274. timePoint: this.playTime, // 弹幕对应视频时间节点()秒
  1275. platform: 'uniapp', //发送平台,app传值“app”,小程序传值“uniapp”
  1276. fontSize: '16px',
  1277. mode: "scroll",
  1278. color: "#ffffff",
  1279. };
  1280. this.socket.send({
  1281. data: JSON.stringify(data),
  1282. success: () => {
  1283. console.log("发送成功")
  1284. this.$refs.danmuPopup.close()
  1285. this.isSend = false;
  1286. },
  1287. fail: () => {
  1288. uni.showToast({
  1289. title: '发送失败',
  1290. icon: 'none'
  1291. })
  1292. }
  1293. });
  1294. }
  1295. },
  1296. // 收到消息
  1297. addMsg(type, content) {
  1298. if (!this.player) {
  1299. this.player = uni.createVideoContext('video-content-box');
  1300. }
  1301. // this.player.sendDanmu({
  1302. // text: content.content,
  1303. // color: "#FF0000",
  1304. // time: this.playTime + 1
  1305. // })
  1306. const id = content.userId +'_' + new Date().getTime()
  1307. const mystyle = {
  1308. color: content.color || this.danmuItemStyle.color,
  1309. fontSize: content.fontSize || this.danmuItemStyle.fontSize,
  1310. border: content.color ? `solid 1px ${content.color}`: this.danmuItemStyle.border,
  1311. borderRadius: this.danmuItemStyle.borderRadius,
  1312. padding: this.danmuItemStyle.padding,
  1313. backgroundColor: this.danmuItemStyle.backgroundColor
  1314. }
  1315. const otherstyle = {
  1316. color: content.color || this.danmuItemStyle.color,
  1317. fontSize: content.fontSize || this.danmuItemStyle.fontSize,
  1318. padding: this.danmuItemStyle.padding,
  1319. }
  1320. const mode = content.mode || "scroll"
  1321. const obj = {
  1322. id: content.id || id,
  1323. userId: content.userId,
  1324. text: content.content,
  1325. time: this.flagTime + 1,
  1326. color: content.color || this.danmuItemStyle.color,
  1327. style: this.user.userId == content.userId ? mystyle : otherstyle,
  1328. top: null
  1329. }
  1330. console
  1331. if(this.showDanmu == 0) return
  1332. this.danmuList.push(obj)
  1333. },
  1334. initTracks() {
  1335. this.tracks = []
  1336. const trackHeight = 22; // 每行高度
  1337. const trackCount = 3
  1338. for (let i = 0; i < trackCount; i++) {
  1339. this.tracks.push({
  1340. top: i * trackHeight+10,
  1341. isFree: true
  1342. });
  1343. }
  1344. },
  1345. // 获取字体高度
  1346. getTextWidth(content) {
  1347. if (!this.ctx) {
  1348. this.ctx = uni.createCanvasContext('myCanvas')
  1349. }
  1350. const metrics = this.ctx.measureText(content)
  1351. return Math.ceil(metrics.width)
  1352. },
  1353. // 分配轨道
  1354. getFreeTrack(item) {
  1355. const width = this.getTextWidth(item.content)
  1356. const passWidth = width + uni.getSystemInfoSync().screenWidth
  1357. const duration = 8
  1358. for (let i = 0; i < this.tracks.length; i++) {
  1359. if (this.tracks[i].isFree) {
  1360. this.tracks[i].isFree = false;
  1361. // 等本条通过右边界的时间
  1362. let passtime = Math.ceil(duration * 1000 / passWidth * width)
  1363. passtime = passtime + 1000
  1364. // console.log("passtime==", passtime)
  1365. setTimeout(() => {
  1366. this.tracks[i].isFree = true;
  1367. }, passtime); // 5秒后释放轨道
  1368. return this.tracks[i].top;
  1369. }
  1370. }
  1371. // 无可用轨道
  1372. if (item.userId == this.user.userId) {
  1373. let trackHeight = this.tracks[this.tracks.length - 1].top
  1374. return Math.random() * trackHeight + 16 // 自己发的弹幕随机高度; // 无可用轨道
  1375. } else {
  1376. // console.log("无可用轨道")
  1377. return 'abandon'
  1378. }
  1379. },
  1380. // 检测并激活弹幕
  1381. checkDanmu() {
  1382. if(this.showDanmu == 0) return
  1383. // 筛选当前时间应出现的弹幕
  1384. const newDanmus = this.danmuList.filter((item) => Math.abs(item.time - this.flagTime) < 1)
  1385. // 分配轨道高度
  1386. newDanmus.forEach((item) => {
  1387. // 滚动弹幕随机高度
  1388. if(!item.top) {
  1389. item.top = this.getFreeTrack(item)
  1390. }
  1391. })
  1392. // 过滤没有分配到空闲轨道弹幕
  1393. const aliveNewDanmus = newDanmus.filter((item) => item.top != 'abandon')
  1394. // 添加到活跃列表
  1395. this.activeDanmus = [...this.activeDanmus, ...aliveNewDanmus]
  1396. },
  1397. animationend(moveItem, i) {
  1398. // 移除动画结束的弹幕(性能优化)
  1399. this.activeDanmus = this.activeDanmus.filter((item) => item.id != moveItem.id)
  1400. },
  1401. switchDanmu() {
  1402. this.showDanmu = this.showDanmu == 1 ? 0:1
  1403. if(this.showDanmu == 0) {
  1404. this.activeDanmus = []
  1405. this.initTracks()
  1406. }
  1407. },
  1408. }
  1409. }
  1410. </script>
  1411. <style scoped>
  1412. .full-width-popup {
  1413. width: 100%;
  1414. }
  1415. </style>
  1416. <style lang="scss" scoped>
  1417. @mixin u-flex($flexD, $alignI, $justifyC) {
  1418. display: flex;
  1419. flex-direction: $flexD;
  1420. align-items: $alignI;
  1421. justify-content: $justifyC;
  1422. }
  1423. .footer-tips {
  1424. margin-top: 14rpx;
  1425. text-align: center;
  1426. font-family: PingFang SC,PingFang SC;
  1427. font-weight: 500;
  1428. font-size: 12px;
  1429. color: #bbb;
  1430. }
  1431. .textOne {
  1432. overflow: hidden;
  1433. white-space: nowrap;
  1434. text-overflow: ellipsis;
  1435. }
  1436. .textTwo {
  1437. overflow: hidden;
  1438. text-overflow: ellipsis;
  1439. display: -webkit-box;
  1440. -webkit-line-clamp: 2;
  1441. -webkit-box-orient: vertical;
  1442. }
  1443. .header-nav {
  1444. height: 88rpx;
  1445. @include u-flex(row, center, flex-start);
  1446. overflow: hidden;
  1447. background-color: #fff;
  1448. box-sizing: border-box;
  1449. .header-title {
  1450. text-align: center;
  1451. overflow: hidden;
  1452. white-space: nowrap;
  1453. text-overflow: ellipsis;
  1454. padding: 0 10rpx 0 100rpx;
  1455. font-family: PingFang SC,PingFang SC;
  1456. font-weight: 500;
  1457. font-size: 15px;
  1458. color: #000;
  1459. box-sizing: border-box;
  1460. }
  1461. }
  1462. .reward-list {
  1463. width: 100%;
  1464. margin-top: 20rpx;
  1465. margin-bottom: -40rpx;
  1466. &-group {
  1467. font-family: PingFang SC, PingFang SC;
  1468. font-weight: 400;
  1469. font-size: 14px;
  1470. color: #222222;
  1471. @include u-flex(row, center, center);
  1472. }
  1473. &-option {
  1474. @include u-flex(row, center, flex-start);
  1475. &:first-child {
  1476. margin-right: 40rpx;
  1477. }
  1478. }
  1479. }
  1480. .err {
  1481. color: #f56c6c !important;
  1482. }
  1483. .kfqrcode-box {
  1484. background-color: #fff;
  1485. border-radius: 16rpx;
  1486. max-width: 560rpx;
  1487. padding: 60rpx 40rpx;
  1488. margin-top: -100rpx;
  1489. box-sizing: border-box;
  1490. @include u-flex(column, center, flex-start);
  1491. font-family: PingFang SC, PingFang SC;
  1492. font-weight: 400;
  1493. font-size: 34rpx;
  1494. color: #222;
  1495. position: relative;
  1496. text-align: center;
  1497. .kfqrcode {
  1498. height: 460rpx;
  1499. width: 460rpx;
  1500. }
  1501. }
  1502. .kfqrcode-close {
  1503. width: 64rpx;
  1504. height: 64rpx;
  1505. position: absolute;
  1506. bottom: -100rpx;
  1507. left: 50%;
  1508. transform: translateX(-50%);
  1509. }
  1510. .tipsPopup-mask {
  1511. position: relative;
  1512. width: 560rpx;
  1513. background-color: transparent;
  1514. .red_envelope_top {
  1515. width: 480rpx;
  1516. height: 360rpx;
  1517. margin: 0 auto;
  1518. display: inherit;
  1519. }
  1520. }
  1521. .tipsPopup-btn-box {
  1522. width: 456rpx;
  1523. height: 104rpx;
  1524. padding: 4rpx;
  1525. box-sizing: border-box;
  1526. background: linear-gradient(180deg, rgba(252, 209, 94, 1), rgba(254, 253, 251, 1));
  1527. border-radius: 52rpx;
  1528. }
  1529. .tipsPopup-btn {
  1530. width: 100%;
  1531. height: 100%;
  1532. background: linear-gradient(180deg, #FF9F22 0%, #FA1E05 100%);
  1533. border-radius: 52rpx 52rpx 52rpx 52rpx;
  1534. font-family: PingFang SC, PingFang SC;
  1535. font-weight: 500;
  1536. font-size: 36rpx;
  1537. color: #FFFFFF;
  1538. line-height: 96rpx;
  1539. text-align: center;
  1540. }
  1541. .tipsPopup {
  1542. width: 560rpx;
  1543. padding: 12rpx;
  1544. margin-top: -72rpx;
  1545. box-sizing: border-box;
  1546. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1547. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1548. position: relative;
  1549. &-close {
  1550. width: 64rpx;
  1551. height: 64rpx;
  1552. position: absolute;
  1553. right: 0;
  1554. top: -188rpx;
  1555. }
  1556. &-line {
  1557. padding: 3rpx;
  1558. box-sizing: border-box;
  1559. background: linear-gradient(180deg, rgba(247, 245, 220, 1), rgba(250, 220, 157, 1));
  1560. border-radius: 24rpx;
  1561. }
  1562. &-box {
  1563. padding: 0 40rpx 40rpx 40rpx;
  1564. box-sizing: border-box;
  1565. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1566. border-radius: 24rpx;
  1567. @include u-flex(column, center, flex-start);
  1568. }
  1569. &-head {
  1570. @include u-flex(row, center, center);
  1571. &-title {
  1572. width: 364rpx;
  1573. height: auto;
  1574. margin-top: -22rpx;
  1575. }
  1576. }
  1577. &-content {
  1578. margin: 48rpx 0;
  1579. font-family: PingFang SC, PingFang SC;
  1580. font-weight: 500;
  1581. font-size: 32rpx;
  1582. color: #222222;
  1583. text-align: center;
  1584. &-title {
  1585. margin-bottom: 26rpx;
  1586. font-weight: 600;
  1587. font-size: 40rpx;
  1588. color: #FF5C03;
  1589. }
  1590. }
  1591. }
  1592. .video-controls-box {
  1593. width: 100%;
  1594. height: 420rpx;
  1595. overflow: hidden;
  1596. position: absolute;
  1597. bottom: 0;
  1598. left: 0;
  1599. z-index: 2;
  1600. background: rgba(0, 0, 0, 0.2);
  1601. .video-play {
  1602. height: 72rpx;
  1603. width: 72rpx;
  1604. position: absolute;
  1605. top: 50%;
  1606. left: 50%;
  1607. transform: translate(-50%, -50%);
  1608. }
  1609. }
  1610. .video-controls {
  1611. width: 100%;
  1612. height: 80rpx;
  1613. padding: 0 28rpx;
  1614. box-sizing: border-box;
  1615. position: absolute;
  1616. bottom: 0;
  1617. left: 0;
  1618. display: flex;
  1619. align-items: center;
  1620. justify-content: space-between;
  1621. background: linear-gradient(to top, #222 0%, transparent 80%);
  1622. .video-icon {
  1623. height: 44rpx;
  1624. width: 44rpx;
  1625. }
  1626. }
  1627. .errQuesbox {
  1628. width: 100%;
  1629. max-height: 260rpx;
  1630. overflow-y: auto;
  1631. margin-top: 24rpx;
  1632. font-family: PingFang SC, PingFang SC;
  1633. font-weight: 500;
  1634. font-size: 30rpx;
  1635. color: #222222;
  1636. &-item {
  1637. width: 100%;
  1638. height: 128rpx;
  1639. line-height: 128rpx;
  1640. margin-bottom: 24rpx;
  1641. padding: 0 30rpx;
  1642. box-sizing: border-box;
  1643. overflow: hidden;
  1644. background: #fff;
  1645. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1646. position: relative;
  1647. &::after {
  1648. content: "题目";
  1649. min-width: 64rpx;
  1650. height: 36rpx;
  1651. padding: 0 12rpx;
  1652. line-height: 36rpx;
  1653. background: #FF5C03;
  1654. box-sizing: border-box;
  1655. border-radius: 0rpx 0rpx 16rpx 0rpx;
  1656. text-align: center;
  1657. font-family: PingFang SC, PingFang SC;
  1658. font-weight: 500;
  1659. font-size: 20rpx;
  1660. color: #fff;
  1661. position: absolute;
  1662. left: 0;
  1663. top: 0;
  1664. }
  1665. }
  1666. }
  1667. .bg {
  1668. background: #fff !important;
  1669. }
  1670. .answerPopup {
  1671. &-box {
  1672. width: 560rpx;
  1673. background: linear-gradient(180deg, #FFFAF6 0%, #FEECD8 100%);
  1674. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1675. background-color: #fff;
  1676. font-weight: 400;
  1677. padding: 32rpx;
  1678. box-sizing: border-box;
  1679. position: relative;
  1680. @include u-flex(column, center, flex-start);
  1681. font-family: PingFang SC, PingFang SC;
  1682. font-weight: 400;
  1683. .tipimg {
  1684. width: 206rpx;
  1685. height: 206rpx;
  1686. margin-bottom: 16rpx;
  1687. }
  1688. }
  1689. &-title {
  1690. font-weight: 600;
  1691. font-size: 36rpx;
  1692. color: #222222;
  1693. }
  1694. &-desc {
  1695. margin-top: 10rpx;
  1696. font-size: 28rpx;
  1697. color: #757575;
  1698. }
  1699. &-btn {
  1700. width: 464rpx;
  1701. height: 84rpx;
  1702. margin-top: 54rpx;
  1703. margin-bottom: 16rpx;
  1704. background: #FF5C03;
  1705. border-radius: 42rpx;
  1706. font-weight: 500;
  1707. font-size: 32rpx;
  1708. color: #FFFFFF;
  1709. text-align: center;
  1710. line-height: 84rpx;
  1711. }
  1712. }
  1713. .popupbox {
  1714. width: 100%;
  1715. background-color: #fff;
  1716. border-radius: 16rpx 16rpx 0 0;
  1717. padding: 24rpx 32rpx;
  1718. position: relative;
  1719. &-head {
  1720. height: 60rpx;
  1721. margin-bottom: 30rpx;
  1722. text-align: center;
  1723. overflow-y: auto;
  1724. color: #414858;
  1725. font-size: 32rpx;
  1726. font-weight: bold;
  1727. position: relative;
  1728. .close-icon {
  1729. position: absolute;
  1730. right: 0;
  1731. top: 0;
  1732. height: 40rpx;
  1733. width: 40rpx;
  1734. }
  1735. }
  1736. &-content {
  1737. height: 20vh;
  1738. overflow-y: auto;
  1739. display: flex;
  1740. align-items: flex-start;
  1741. flex-wrap: wrap;
  1742. gap: 32rpx;
  1743. .line-item {
  1744. display: inline-block;
  1745. min-width: 200rpx;
  1746. min-height: 60rpx;
  1747. padding: 0 20rpx;
  1748. box-sizing: border-box;
  1749. border-radius: 50rpx;
  1750. overflow: hidden;
  1751. background-color: #f7f7f7;
  1752. text-align: center;
  1753. color: #414858;
  1754. font-size: 28rpx;
  1755. line-height: 60rpx;
  1756. }
  1757. .line-active {
  1758. color: #f56c6c !important;
  1759. background-color: #fef0f0 !important;
  1760. }
  1761. }
  1762. }
  1763. .content {
  1764. padding-bottom: calc(var(--window-bottom) + 164rpx);
  1765. .video-box {
  1766. width: 100%;
  1767. height: 420rpx;
  1768. overflow: hidden;
  1769. position: relative;
  1770. #myVideo {
  1771. width: 100%;
  1772. height: 100%;
  1773. }
  1774. }
  1775. .video-poster {
  1776. width: 100%;
  1777. height: 420rpx;
  1778. }
  1779. .miantitlebox {
  1780. padding: 30rpx 0;
  1781. border-bottom: 2rpx solid #F5F7FA;
  1782. font-family: PingFang SC, PingFang SC;
  1783. font-weight: 500;
  1784. font-size: 36rpx;
  1785. color: #222222;
  1786. }
  1787. .subtitlebox {
  1788. padding: 30rpx 0;
  1789. border-bottom: 2rpx solid #F5F7FA;
  1790. font-family: PingFang SC, PingFang SC;
  1791. font-weight: 500;
  1792. font-size: 36rpx;
  1793. color: #222222;
  1794. }
  1795. .title-content {
  1796. padding: 0 32rpx;
  1797. background-color: #fff;
  1798. font-size: 28rpx;
  1799. line-height: 1.6;
  1800. .title {
  1801. font-size: 36rpx;
  1802. font-weight: 500;
  1803. color: #414858;
  1804. }
  1805. .time-or-subtitle {
  1806. margin-top: 12rpx;
  1807. color: #666666;
  1808. }
  1809. }
  1810. .descbox {
  1811. padding: 36rpx 32rpx;
  1812. margin-bottom: 20rpx;
  1813. background-color: #fff;
  1814. font-family: PingFang SC, PingFang SC;
  1815. font-weight: 400;
  1816. font-size: 28rpx;
  1817. color: #222222;
  1818. line-height: 42rpx;
  1819. word-break: break-word;
  1820. &-title {
  1821. margin-bottom: 24rpx;
  1822. font-weight: 500;
  1823. font-size: 32rpx;
  1824. }
  1825. &-info {
  1826. margin-bottom: 24rpx;
  1827. @include u-flex(row, center, space-between);
  1828. font-size: 26rpx;
  1829. color: #757575;
  1830. &-l {
  1831. flex: 1;
  1832. @include u-flex(row, center, flex-start);
  1833. }
  1834. &-time {
  1835. margin-left: 18rpx;
  1836. padding-left: 18rpx;
  1837. position: relative;
  1838. &::after {
  1839. content: "";
  1840. width: 4rpx;
  1841. height: 4rpx;
  1842. background: #999999;
  1843. border-radius: 50%;
  1844. position: absolute;
  1845. left: 0;
  1846. top: 50%;
  1847. transform: translateY(-50%);
  1848. }
  1849. }
  1850. &-r {
  1851. background: transparent;
  1852. }
  1853. }
  1854. &-desc {
  1855. overflow: hidden;
  1856. position: relative;
  1857. }
  1858. }
  1859. .expand {
  1860. flex-shrink: 0;
  1861. @include u-flex(row, center, flex-end);
  1862. color: #FF5C03;
  1863. font-weight: 400;
  1864. font-size: 24rpx;
  1865. image {
  1866. width: 32rpx;
  1867. height: 32rpx;
  1868. }
  1869. }
  1870. .expand-ab {
  1871. position: absolute;
  1872. top: 0;
  1873. right: 0;
  1874. box-shadow: -50rpx 0 20rpx 8rpx #FFFFFF;
  1875. background-color: #fff;
  1876. }
  1877. .ques-content {
  1878. background-color: #fff;
  1879. padding: 40rpx 32rpx;
  1880. box-sizing: border-box;
  1881. font-family: PingFang SC, PingFang SC;
  1882. font-weight: 400;
  1883. font-size: 28rpx;
  1884. color: #222222;
  1885. }
  1886. .ques-content-tit {
  1887. font-family: PingFang SC, PingFang SC;
  1888. font-weight: 600;
  1889. font-size: 36rpx;
  1890. color: #222222;
  1891. }
  1892. .ques-title {
  1893. margin: 48rpx 0 34rpx 0;
  1894. font-weight: 500;
  1895. font-size: 32rpx;
  1896. white-space: normal;
  1897. }
  1898. .ques-type {
  1899. flex-shrink: 0;
  1900. min-width: 72rpx;
  1901. min-height: 40rpx;
  1902. padding: 0 12rpx;
  1903. margin: 0 12rpx;
  1904. box-sizing: border-box;
  1905. background: #FF5C03;
  1906. border-radius: 8rpx 8rpx 8rpx 8rpx;
  1907. line-height: 40rpx;
  1908. text-align: center;
  1909. font-family: PingFang SC, PingFang SC;
  1910. font-weight: 400;
  1911. font-size: 24rpx;
  1912. color: #FFFFFF;
  1913. display: inline-block;
  1914. }
  1915. .ques-option {
  1916. min-height: 88rpx;
  1917. padding: 24rpx 32rpx;
  1918. box-sizing: border-box;
  1919. margin-bottom: 24rpx;
  1920. background: #F5F7FA;
  1921. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1922. display: flex;
  1923. align-items: center;
  1924. &-active {
  1925. color: #FF5C03 !important;
  1926. background: #FCF0E7 !important;
  1927. }
  1928. }
  1929. .video-line {
  1930. min-width: 140rpx;
  1931. max-width: 200rpx;
  1932. height: 60rpx;
  1933. padding: 0 20rpx;
  1934. box-sizing: border-box;
  1935. border-radius: 50rpx 0 0 50rpx;
  1936. overflow: hidden;
  1937. background-color: #fff;
  1938. text-align: center;
  1939. color: #888;
  1940. font-size: 28rpx;
  1941. line-height: 60rpx;
  1942. display: inline-flex;
  1943. align-items: center;
  1944. justify-content: center;
  1945. position: fixed;
  1946. right: 0;
  1947. z-index: 9;
  1948. bottom: calc(var(--window-bottom) + 280rpx);
  1949. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, .12);
  1950. image {
  1951. flex-shrink: 0;
  1952. height: 34rpx;
  1953. width: 34rpx;
  1954. margin-right: 6rpx;
  1955. }
  1956. }
  1957. .danmu-line {
  1958. bottom: calc(var(--window-bottom) + 370rpx);
  1959. word-break: keep-all;
  1960. .set_image {
  1961. height: 40rpx;
  1962. width: 40rpx;
  1963. }
  1964. }
  1965. .footer {
  1966. border-top: 1rpx solid #ededef;
  1967. background: #fff;
  1968. width: 100%;
  1969. position: fixed;
  1970. bottom: 0;
  1971. padding: 32rpx;
  1972. padding-bottom: calc(var(--window-bottom) + 14rpx);
  1973. box-sizing: border-box;
  1974. z-index: 9;
  1975. &-btn {
  1976. width: 100%;
  1977. height: 98rpx;
  1978. background: #FF5C03;
  1979. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1980. line-height: 98rpx;
  1981. text-align: center;
  1982. font-family: PingFang SC, PingFang SC;
  1983. font-weight: 600;
  1984. font-size: 32rpx;
  1985. color: #FFFFFF;
  1986. @include u-flex(row, center, center);
  1987. &-img {
  1988. flex-shrink: 0;
  1989. width: 144rpx;
  1990. height: 144rpx;
  1991. margin-right: 8rpx;
  1992. margin-top: -24rpx;
  1993. }
  1994. }
  1995. &-btn-border {
  1996. position: relative;
  1997. &::after {
  1998. content: "";
  1999. background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
  2000. position: absolute;
  2001. top: -2rpx;
  2002. left: 0;
  2003. height: 103rpx;
  2004. width: 100%;
  2005. z-index: -1;
  2006. border-radius: 49rpx 49rpx 49rpx 49rpx;
  2007. box-shadow: 0rpx 8rpx 11rpx 0rpx rgba(255, 92, 3, 0.3);
  2008. overflow: hidden;
  2009. }
  2010. }
  2011. }
  2012. }
  2013. .agreement {
  2014. display: inline-flex;
  2015. margin-top: 16rpx;
  2016. font-size: 24rpx;
  2017. color: #525252;
  2018. align-items: center;
  2019. justify-content: center;
  2020. }
  2021. .video-danmu-btnbox {
  2022. width: 50px;
  2023. height: 50px;
  2024. border-radius: 50%;
  2025. overflow: hidden;
  2026. position: absolute;
  2027. right: 10px;
  2028. bottom: calc(50% - 50px);
  2029. transform: translateY(-50%);
  2030. padding: 8px;
  2031. box-sizing: border-box;
  2032. }
  2033. .video-danmu-image {
  2034. width: 100%;
  2035. height: 100%;
  2036. }
  2037. .danmuPopup {
  2038. background-color: #fff;
  2039. padding-bottom: calc(var(--window-bottom) + 10px);
  2040. &-head {
  2041. width: 100%;
  2042. padding: 10px;
  2043. box-sizing: border-box;
  2044. overflow: hidden;
  2045. @include u-flex(row,center,flex-start);
  2046. .danmu-icon {
  2047. height: 24px;
  2048. width: 24px;
  2049. margin-right: 12px;
  2050. }
  2051. }
  2052. &-input {
  2053. flex: 1;
  2054. height: 35px;
  2055. }
  2056. &-send {
  2057. flex-shrink: 0;
  2058. height: 35px;
  2059. display: flex;
  2060. align-items: center;
  2061. justify-content: center;
  2062. padding: 5px 15px;
  2063. box-sizing: border-box;
  2064. background: #FF5C03 !important;
  2065. border-radius: 22px;
  2066. font-family: PingFang SC, PingFang SC;
  2067. font-weight: 500;
  2068. font-size: 15px;
  2069. color: #fff !important;
  2070. margin-left: 12px;
  2071. &::after {
  2072. border: none;
  2073. }
  2074. }
  2075. &-con {
  2076. background-color: #F5F7FA;
  2077. padding: 24px 12px 48px 12px;
  2078. font-family: PingFang SC, PingFang SC;
  2079. font-weight: 400;
  2080. font-size: 14px;
  2081. color: #757575;
  2082. }
  2083. }
  2084. .danmu-item {
  2085. position: absolute;
  2086. top: 0;
  2087. white-space: nowrap;
  2088. font-size: 16px;
  2089. height: 20px;
  2090. display: inline-flex;
  2091. box-sizing: border-box;
  2092. align-items: center;
  2093. }
  2094. .danmuMove {
  2095. // animation: mymove 8s linear forwards;
  2096. // animation-duration: 8s;
  2097. animation-timing-function: linear;
  2098. animation-delay: 0s;
  2099. animation-iteration-count: 1;
  2100. animation-direction: normal;
  2101. animation-fill-mode: forwards;
  2102. animation-play-state: running;
  2103. animation-name: mymove;
  2104. will-change: transform;
  2105. }
  2106. @keyframes mymove {
  2107. from {
  2108. transform: translateX(100vw);
  2109. }
  2110. to {
  2111. transform: translateX(-100%);
  2112. }
  2113. }
  2114. .danmu-icon{
  2115. height: 24px;
  2116. width: 24px;
  2117. margin-right: 12px;
  2118. }
  2119. </style>