learningNew.vue 51 KB

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