video.vue 49 KB

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