videoOld.vue 57 KB

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