video.vue 49 KB

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