videoOld.vue 57 KB

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