videoOld.vue 57 KB

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