learningNew.vue 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001
  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.playDurationSeek = res.playDuration || 0
  677. this.tipsTime = res.tipsTime || 0
  678. let lineList = []
  679. if (res.course && res.course.lineOne) {
  680. lineList.push(res.course.lineOne)
  681. }
  682. if (res.course && res.course.lineTwo) {
  683. lineList.push(res.course.lineTwo)
  684. }
  685. if (res.course && res.course.lineThree) {
  686. lineList.push(res.course.lineThree)
  687. }
  688. this.lineList = lineList
  689. this.courseLogo = res.config&&res.config.courseLogo
  690. this.viewCommentNum = res.config&&res.config.viewCommentNum || 200
  691. if(this.openCommentStatus == 3) {
  692. this.$refs.commentBox&&this.$refs.commentBox.closeWSocket()
  693. this.$refs.danmuBox&&this.$refs.danmuBox.closeWSocket()
  694. }
  695. const status = res.config&&res.config.openCommentStatus || 3
  696. if(status != this.openCommentStatus) {
  697. this.openCommentStatus = status
  698. }
  699. if(this.openCommentStatus==1) {
  700. this.currentTab = 0
  701. } else {
  702. this.currentTab = 1
  703. }
  704. if (!this.player || type == 'error') {
  705. this.lineIndex = this.config.defaultLine
  706. this.videoUrl = lineList[this.lineIndex]
  707. this.poster= res.course && res.course.imgUrl ? res.course.imgUrl : ''
  708. this.playTime = this.playDuration >= this.duration ? 0 : this.playDuration
  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.player.seek(this.playTime)
  717. this.player.play();
  718. }
  719. this.updateTime();
  720. this.quesList = res.questions && res.questions.length > 0 ? res.questions : [],
  721. this.quesList = this.quesList.map(item => ({
  722. ...item,
  723. questionOption: JSON.parse(item.question),
  724. answer: ''
  725. }))
  726. }
  727. this.getHeight()
  728. this.$nextTick(()=>{
  729. this.$refs.descInfo&&this.$refs.descInfo.getDescHeight()
  730. this.$refs.descInfoNav&&this.$refs.descInfoNav.getDescHeight()
  731. })
  732. },
  733. rej => {}
  734. )
  735. },
  736. handleAnswer(val) {
  737. let {item, option} = val
  738. let time = this.playTime
  739. if(this.isEnded) {
  740. time = this.duration
  741. } else {
  742. if(time < this.playDuration&&this.isFinish!=1) {
  743. // 没完课且小于续播的时间
  744. time = this.playDuration
  745. }
  746. }
  747. if(Number(this.duration || 0) == 0 || time < this.duration - 60) {
  748. uni.showToast({
  749. title: "请先观看完整课程再答题哦~",
  750. icon: "none"
  751. })
  752. return
  753. }
  754. if (item.type == 1) {
  755. // 单选option
  756. item.answer = option.name
  757. } else if (item.type == 2) {
  758. // 多选
  759. let answer = item.answer ? item.answer.split(',') : []
  760. if (answer.indexOf(option.name) === -1) {
  761. answer.push(option.name)
  762. item.answer = answer.join(',')
  763. } else {
  764. answer.splice(answer.indexOf(option.name), 1)
  765. item.answer = answer.join(',')
  766. }
  767. }
  768. },
  769. submit() {
  770. // 登录
  771. if (this.$isLogin()) {
  772. if (this.isAddKf == 1) {
  773. // 答题
  774. // 您已提交过答案,请领取红包
  775. this.courseAnswer()
  776. } else {
  777. // 添加客服
  778. if (this.videoId && this.qwUserId) {
  779. this.getIsAddKf()
  780. } else {
  781. uni.showToast({
  782. title: '请添加客服',
  783. icon: 'none'
  784. })
  785. }
  786. }
  787. } else {
  788. // 登录
  789. if (!this.checked) {
  790. uni.showToast({
  791. title: "请先勾选阅读并同意《用户协议》和《隐私协议》",
  792. icon: "none"
  793. })
  794. return
  795. }
  796. // #ifdef H5
  797. if (isWechat) { //是否在微信浏览器中打开
  798. this.loginByMp()
  799. } else {
  800. uni.showToast({
  801. title: '请在微信浏览器中打开',
  802. icon: 'error'
  803. })
  804. }
  805. // #endif
  806. }
  807. },
  808. // 答题
  809. courseAnswer() {
  810. let time = this.playTime
  811. if (this.isEnded) {
  812. time = this.duration
  813. } else {
  814. if (time < this.playDuration && this.isFinish != 1) {
  815. // 没完课且小于续播的时间
  816. time = this.playDuration
  817. }
  818. }
  819. if (Number(this.duration || 0) == 0 || time < this.duration - 60) {
  820. uni.showToast({
  821. title: "请先观看完整课程再答题哦~",
  822. icon: "none"
  823. })
  824. return
  825. }
  826. if (this.quesList.some(item => !item.answer)) {
  827. uni.showToast({
  828. title: "请确认是否答完所有题目",
  829. icon: "none"
  830. })
  831. return
  832. }
  833. const questions = this.quesList.map(obj => {
  834. const {
  835. questionOption,
  836. ...rest
  837. } = obj;
  838. return rest;
  839. });
  840. const param = {
  841. ...this.urlOption,
  842. questions: questions,
  843. videoId: this.videoId,
  844. duration: this.playTime
  845. }
  846. this.errTitle = ""
  847. this.errDesc = ""
  848. this.errQues = []
  849. courseAnswer(param).then(res => {
  850. if (res.code == 200) {
  851. if (res.incorrectQuestions) {
  852. // 答题失败
  853. if (res.incorrectQuestions.length > 0) {
  854. this.errQues = res.incorrectQuestions
  855. }
  856. this.remain = res.remain || 0
  857. if (res.remain > 0) {
  858. this.errTitle = "很遗憾答错了"
  859. this.errDesc = `<span style="color:#FF5C03">还有${res.remain}次机会,继续加油</span>`
  860. this.$refs.answerPopup.open("center")
  861. }
  862. } else {
  863. // 答题成功
  864. this.errTitle = "恭喜你,回答正确"
  865. this.errDesc = `您有一份奖励待领取哦~`
  866. // this.$refs.answerPopup.open("center")
  867. this.closeAnswerPopup(1)
  868. }
  869. } else {
  870. if (res.msg == "该课题到达答错次数限制") {
  871. this.errTitle = "答题次数超过限制"
  872. this.errDesc = "以后的课程要认真学习哦"
  873. this.$refs.answerPopup.open("center")
  874. } else {
  875. uni.showToast({
  876. title: res.msg,
  877. icon: "none"
  878. })
  879. }
  880. }
  881. },
  882. rej => {}
  883. )
  884. },
  885. // 选择
  886. rewardChange(e) {
  887. this.currentReward = e.detail.value
  888. },
  889. closeAnswerPopup(type) {
  890. this.$refs.answerPopup.close()
  891. if (this.errTitle == '恭喜你,回答正确') {
  892. let param = {
  893. ...this.urlOption,
  894. rewardType: Number(this.currentReward),
  895. }
  896. if(type == 1) {
  897. param = {
  898. ...this.urlOption
  899. }
  900. }
  901. sendReward(param).then(res => {
  902. if(res.code == 200) {
  903. if(res.isNew&&res.isNew==1) {
  904. // 新商户领红包
  905. const packageInfo = res.data.packageInfo || ''
  906. if(packageInfo) {
  907. uni.setStorageSync('receive_package',packageInfo);
  908. if(res.mchId) uni.setStorageSync('mchId',res.mchId);
  909. uni.navigateTo({
  910. url: '/pages/course/reward'
  911. })
  912. }
  913. } else if(res.rewardType==2) {
  914. // 积分
  915. this.$refs.integralGift.openPop()
  916. } else {
  917. uni.showToast({
  918. title: res.msg,
  919. icon: 'none'
  920. })
  921. }
  922. }else {
  923. uni.showToast({
  924. title: res.msg,
  925. icon: 'none'
  926. })
  927. }
  928. })
  929. }
  930. },
  931. // 线路
  932. openPop() {
  933. this.$refs.popup.open('bottom')
  934. },
  935. close() {
  936. this.$refs.popup.close()
  937. },
  938. handleLine(index) {
  939. var that=this;
  940. if (this.lineIndex == index && this.videoUrl == this.lineList[index]) {
  941. this.close()
  942. return
  943. } else {
  944. // let div = document.querySelector(".vjs-progress-control");
  945. // if(div) {
  946. // if (this.isFinish == 1 || this.isEnded || this.linkType == 1) {
  947. // div.style.pointerEvents = "auto";
  948. // } else {
  949. // div.style.pointerEvents = "none"; //禁止所有事件
  950. // }
  951. // }
  952. this.lineIndex = index
  953. this.videoUrl = this.lineList[index]
  954. this.tipsOpen = false
  955. this.playDurationSeek = this.playTime || 0
  956. this.player = uni.createVideoContext('video-content-box');
  957. setTimeout(function(){
  958. that.player.seek(that.playDurationSeek)
  959. that.player.play();
  960. },500);
  961. // this.player.src(this.lineList[index])
  962. // this.player.one('loadedmetadata', () => {
  963. // this.player.currentTime(this.playDurationSeek);
  964. // this.player.play();
  965. // });
  966. this.close()
  967. }
  968. },
  969. // 温馨提示
  970. openTipsPop() {
  971. this.$refs.tipsPopup.open()
  972. this.tipsOpen = true
  973. this.pause()
  974. },
  975. closeTipsPop() {
  976. this.$refs.tipsPopup.close()
  977. },
  978. // 客服
  979. getIsAddKf() {
  980. this.qrcode = ''
  981. this.qrcodeMsg = ''
  982. this.isAddKf = 0
  983. // {videoId: this.videoId,qwUserId: this.qwUserId,corpId: this.corpId}
  984. const param = {
  985. ...this.urlOption
  986. }
  987. getIsAddKf(param).then(res => {
  988. if (res.code == 200) {
  989. if (this.urlOption.isRoom == 1 && res.qwExternalId) {
  990. this.urlOption = {
  991. ...this.urlOption,
  992. qwExternalId: res.qwExternalId
  993. }
  994. }
  995. this.isAddKf = 1
  996. this.getH5CourseVideoDetails()
  997. } else if (res.code == 400) {
  998. this.isAddKf = 0
  999. this.qrcode = res.qrcode
  1000. this.qrcodeMsg = res.msg
  1001. this.$refs.kfPopup.open()
  1002. } else if (res.code == 567) {
  1003. // 群聊通用链接
  1004. this.urlOption = {
  1005. ...this.urlOption,
  1006. qwExternalId: res.qwExternalId
  1007. }
  1008. this.isAddKf = 1
  1009. this.getH5CourseVideoDetails()
  1010. } else if (res.code == 504) {
  1011. // 登录
  1012. // #ifdef H5
  1013. if (isWechat) { //是否在微信浏览器中打开
  1014. this.loginByMp()
  1015. } else {
  1016. uni.navigateTo({
  1017. url: "/pages/auth/login"
  1018. });
  1019. }
  1020. // #endif
  1021. } else {
  1022. this.isAddKf = 0
  1023. uni.showToast({
  1024. title: res.msg,
  1025. icon: 'none'
  1026. });
  1027. }
  1028. },
  1029. err => {}
  1030. );
  1031. },
  1032. closeKFPop() {
  1033. this.$refs.kfPopup.close()
  1034. },
  1035. loginByMp() {
  1036. if (this.code == null||!this.code) {
  1037. if(this.sortLink) {
  1038. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.sortLink
  1039. } else {
  1040. if(this.urlOption.link) {
  1041. window.location.href = uni.getStorageSync('authDomainName') + '?sortLink='+this.urlOption.link
  1042. } else {
  1043. this.isExpire = true
  1044. this.msg = '课程链接地址有误'
  1045. uni.showToast({
  1046. title: '课程链接地址有误',
  1047. icon: 'none'
  1048. });
  1049. }
  1050. }
  1051. return;
  1052. }
  1053. uni.showLoading({
  1054. title: "处理中..."
  1055. });
  1056. let that = this;
  1057. var data = {
  1058. code: this.code
  1059. }
  1060. loginByMp(data).then(res => {
  1061. uni.hideLoading();
  1062. if (res.code == 200) {
  1063. uni.setStorageSync(this.$TOKEN_KEY, res.token);
  1064. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  1065. this.isLogin = this.$isLogin()
  1066. if(this.isAddKf == 1) {
  1067. this.getH5CourseVideoDetails()
  1068. } else {
  1069. this.getIsAddKf()
  1070. }
  1071. } else {
  1072. uni.showToast({
  1073. title: res.msg,
  1074. icon: 'none'
  1075. });
  1076. }
  1077. },
  1078. err => {}
  1079. ).catch(err=>{
  1080. uni.hideLoading();
  1081. });
  1082. },
  1083. getFinishCourseVideo() {
  1084. if (!this.playTime||!this.$isLogin()||this.isAddKf != 1) return
  1085. // {videoId: this.videoId,duration:this.playTime}
  1086. const param = {
  1087. duration: this.playTime,
  1088. ...this.urlOption
  1089. }
  1090. getFinishCourseVideo(param)
  1091. },
  1092. // 每十分钟获得积分
  1093. getIntegralByH5Video() {
  1094. if (!this.$isLogin()||this.isAddKf != 1) return
  1095. const param = {
  1096. duration: this.playTime,
  1097. ...this.urlOption,
  1098. }
  1099. getIntegralByH5Video(param).then(res => {
  1100. if (res.code == 200) {
  1101. uni.showToast({
  1102. title: "积分+10",
  1103. icon: "none"
  1104. })
  1105. }
  1106. })
  1107. },
  1108. progressChange(e) {
  1109. this.bufferRate = Math.ceil(e.detail.buffered)
  1110. },
  1111. // 缓冲
  1112. getInternetTraffic() {
  1113. if (!this.$isLogin()||this.isAddKf != 1) return
  1114. const playVideoTime = Math.ceil(this.playTime / this.duration * 100) // 播放百分比
  1115. if(this.bufferRate == 0 || this.bufferRate < playVideoTime) {
  1116. this.bufferRate = playVideoTime
  1117. }
  1118. if(this.bufferRate == 0 || Number(this.bufferRate.toFixed(2)) == 0) return
  1119. const param = {
  1120. ...this.urlOption,
  1121. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1122. duration: this.playTime,
  1123. bufferRate: Number(this.bufferRate.toFixed(2)),
  1124. }
  1125. if(!param.bufferRate) return
  1126. internetTraffic(param)
  1127. },
  1128. getErrMsg(err,type) {
  1129. let msgerr = {
  1130. errType: type || 'error',
  1131. videoUrl: this.videoUrl,
  1132. lineIndex: this.lineIndex,
  1133. errTime: new Date(),
  1134. ip: this.ip,
  1135. errMsg: err || ''
  1136. }
  1137. getErrMsg({
  1138. msg: JSON.stringify(msgerr)
  1139. })
  1140. },
  1141. getLink() {
  1142. let that = this;
  1143. getRealLink({sortLink:this.sortLink}).then(res=>{
  1144. if(res.code == 200) {
  1145. this.isExpire = false
  1146. this.authDomainName = res.config.authDomainName || ''
  1147. if(this.authDomainName) {
  1148. uni.setStorageSync('authDomainName',this.authDomainName)
  1149. }
  1150. if(this.isLogin) {
  1151. window.location.replace(res.realLink)
  1152. } else{
  1153. const option = res.realLink.split('?course=')[1]
  1154. const urlOption = option ? JSON.parse(option) : {}
  1155. const videoId = urlOption.videoId || ''
  1156. this.getH5CourseByVideo(videoId)
  1157. }
  1158. } else {
  1159. this.isExpire = true
  1160. this.msg = '课程已过期或链接无效'
  1161. uni.showToast({
  1162. title: '课程已过期或链接无效',
  1163. icon: 'none'
  1164. });
  1165. }
  1166. }).catch(err=>{
  1167. this.isExpire = true
  1168. this.msg = '发生错误,请稍后再试'
  1169. uni.showToast({
  1170. title: '发生错误,请稍后再试',
  1171. icon: 'none'
  1172. });
  1173. })
  1174. },
  1175. /**
  1176. * 节流原理:在一定时间内,只能触发一次
  1177. *
  1178. * @param {Function} func 要执行的回调函数
  1179. * @param {Number} wait 延时的时间
  1180. * @param {Boolean} immediate 是否立即执行
  1181. * @return null
  1182. */
  1183. throttle(func, wait = 500, immediate = true) {
  1184. if (immediate) {
  1185. if (!this.flag) {
  1186. this.flag = true
  1187. // 如果是立即执行,则在wait毫秒内开始时执行
  1188. typeof func === 'function' && func()
  1189. this.timer = setTimeout(() => {
  1190. this.flag = false
  1191. }, wait)
  1192. }
  1193. } else if (!this.flag) {
  1194. this.flag = true
  1195. // 如果是非立即执行,则在wait毫秒内的结束处执行
  1196. this.timer = setTimeout(() => {
  1197. this.flag = false
  1198. typeof func === 'function' && func()
  1199. }, wait)
  1200. }
  1201. },
  1202. // 弹幕
  1203. keyboardHeightChange(res) {
  1204. // #ifndef H5
  1205. console.log("this.danmuboxHeight",this.danmuboxHeight)
  1206. this.danmuboxHeight = res.height
  1207. // #endif
  1208. },
  1209. openDanmu(type) {
  1210. this.openDanmuType = type
  1211. this.inputText = ''
  1212. if(type == 1) {
  1213. this.player.exitFullScreen()
  1214. }
  1215. this.$refs.danmuPopup.open()
  1216. },
  1217. changeShowPopup(val) {
  1218. this.focus = val.show
  1219. },
  1220. switchDanmu() {
  1221. this.showDanmu = this.showDanmu == 1 ? 0:1
  1222. if(this.showDanmu == 0&&this.$refs.danmuBox) {
  1223. this.$refs.danmuBox.activeDanmus = []
  1224. this.$refs.danmuBox.initTracks()
  1225. }
  1226. },
  1227. getScrollTop(res) {
  1228. if(this.currentTab == 2) {
  1229. this.scrollTop = res
  1230. } else {
  1231. this.scrollTop = 0
  1232. }
  1233. },
  1234. handleTab(index) {
  1235. this.currentTab = index
  1236. if(this.currentTab==2) {
  1237. if(this.$refs.commentBox) {
  1238. this.$refs.commentBox.msgs = []
  1239. this.$refs.commentBox.pageNum = 1
  1240. this.$refs.commentBox.getComments()
  1241. }
  1242. } else {
  1243. setTimeout(()=>{
  1244. this.scrollTop = 0
  1245. },100)
  1246. }
  1247. },
  1248. handleRefresher() {
  1249. this.triggered = true;
  1250. if (!this.isMore&&this.currentTab==2&&this.openCommentStatus==1) {
  1251. this.$nextTick(()=>{
  1252. this.$refs.commentBox&&this.$refs.commentBox.getComments()
  1253. })
  1254. }
  1255. setTimeout(() => {
  1256. this.triggered = false;
  1257. }, 500);
  1258. },
  1259. getMore(val) {
  1260. this.triggered = false;
  1261. this.isMore = val == 1
  1262. },
  1263. handleChatInput() {
  1264. this.inputText = this.inputText.trim()
  1265. if (this.inputText == "" || this.inputText.trim() == "") {
  1266. uni.showToast({
  1267. title: '请输入评论',
  1268. icon: "none"
  1269. })
  1270. return;
  1271. }
  1272. if(this.openCommentStatus==1) {
  1273. this.$refs.commentBox&&this.$refs.commentBox.handleInput(this.inputText)
  1274. } else if(this.openCommentStatus==2) {
  1275. this.$refs.danmuBox&&this.$refs.danmuBox.handleInput(this.inputText)
  1276. }
  1277. },
  1278. setInputText() {
  1279. this.inputText = ""
  1280. if(this.openCommentStatus==2) {
  1281. this.$refs.danmuPopup.close()
  1282. }
  1283. },
  1284. initWXConfig() {
  1285. const isWechat = String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  1286. if(isWechat) {
  1287. let url = window.location.href.split('#')[0]
  1288. initJssdk((data)=>{
  1289. console.log("wx-open-launch-weapp 加载成功")
  1290. },url)
  1291. } else {
  1292. // uni.showToast({
  1293. // title: '请在微信浏览器中打开'
  1294. // })
  1295. }
  1296. }
  1297. }
  1298. }
  1299. </script>
  1300. <style scoped>
  1301. .full-width-popup {
  1302. width: 100%;
  1303. }
  1304. </style>
  1305. <style lang="scss" scoped>
  1306. @mixin u-flex($flexD, $alignI, $justifyC) {
  1307. display: flex;
  1308. flex-direction: $flexD;
  1309. align-items: $alignI;
  1310. justify-content: $justifyC;
  1311. }
  1312. .footer-tips {
  1313. margin-top: 14rpx;
  1314. text-align: center;
  1315. font-family: PingFang SC,PingFang SC;
  1316. font-weight: 500;
  1317. font-size: 12px;
  1318. color: #bbb;
  1319. }
  1320. .textOne {
  1321. overflow: hidden;
  1322. white-space: nowrap;
  1323. text-overflow: ellipsis;
  1324. }
  1325. .textTwo {
  1326. overflow: hidden;
  1327. text-overflow: ellipsis;
  1328. display: -webkit-box;
  1329. -webkit-line-clamp: 2;
  1330. -webkit-box-orient: vertical;
  1331. }
  1332. .expirebox {
  1333. height: 100vh;
  1334. @include u-flex(column, center, center);
  1335. font-family: PingFang SC, PingFang SC;
  1336. font-weight: 400;
  1337. font-size: 32rpx;
  1338. color: #757575;
  1339. image {
  1340. width: 428rpx;
  1341. height: 360rpx;
  1342. margin-bottom: 30rpx;
  1343. }
  1344. }
  1345. .reward-list {
  1346. width: 100%;
  1347. margin-top: 20rpx;
  1348. margin-bottom: -40rpx;
  1349. &-group {
  1350. font-family: PingFang SC, PingFang SC;
  1351. font-weight: 400;
  1352. font-size: 14px;
  1353. color: #222222;
  1354. @include u-flex(row, center, center);
  1355. }
  1356. &-option {
  1357. @include u-flex(row, center, flex-start);
  1358. &:first-child {
  1359. margin-right: 40rpx;
  1360. }
  1361. }
  1362. }
  1363. .err {
  1364. color: #f56c6c !important;
  1365. }
  1366. .kfqrcode-box {
  1367. background-color: #fff;
  1368. border-radius: 16rpx;
  1369. max-width: 560rpx;
  1370. padding: 60rpx 40rpx;
  1371. margin-top: -100rpx;
  1372. box-sizing: border-box;
  1373. @include u-flex(column, center, flex-start);
  1374. font-family: PingFang SC, PingFang SC;
  1375. font-weight: 400;
  1376. font-size: 34rpx;
  1377. color: #222;
  1378. position: relative;
  1379. text-align: center;
  1380. .kfqrcode {
  1381. height: 460rpx;
  1382. width: 460rpx;
  1383. }
  1384. }
  1385. .kfqrcode-close {
  1386. width: 64rpx;
  1387. height: 64rpx;
  1388. position: absolute;
  1389. bottom: -100rpx;
  1390. left: 50%;
  1391. transform: translateX(-50%);
  1392. }
  1393. .tipsPopup-mask {
  1394. position: relative;
  1395. width: 560rpx;
  1396. background-color: transparent;
  1397. .red_envelope_top {
  1398. width: 480rpx;
  1399. height: 360rpx;
  1400. margin: 0 auto;
  1401. display: inherit;
  1402. }
  1403. }
  1404. .tipsPopup-btn-box {
  1405. width: 456rpx;
  1406. height: 104rpx;
  1407. padding: 4rpx;
  1408. box-sizing: border-box;
  1409. background: linear-gradient(180deg, rgba(252, 209, 94, 1), rgba(254, 253, 251, 1));
  1410. border-radius: 52rpx;
  1411. }
  1412. .tipsPopup-btn {
  1413. width: 100%;
  1414. height: 100%;
  1415. background: linear-gradient(180deg, #FF9F22 0%, #FA1E05 100%);
  1416. border-radius: 52rpx 52rpx 52rpx 52rpx;
  1417. font-family: PingFang SC, PingFang SC;
  1418. font-weight: 500;
  1419. font-size: 36rpx;
  1420. color: #FFFFFF;
  1421. line-height: 96rpx;
  1422. text-align: center;
  1423. }
  1424. .tipsPopup {
  1425. width: 560rpx;
  1426. padding: 12rpx;
  1427. margin-top: -72rpx;
  1428. box-sizing: border-box;
  1429. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1430. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1431. position: relative;
  1432. &-close {
  1433. width: 64rpx;
  1434. height: 64rpx;
  1435. position: absolute;
  1436. right: 0;
  1437. top: -188rpx;
  1438. }
  1439. &-line {
  1440. padding: 3rpx;
  1441. box-sizing: border-box;
  1442. background: linear-gradient(180deg, rgba(247, 245, 220, 1), rgba(250, 220, 157, 1));
  1443. border-radius: 24rpx;
  1444. }
  1445. &-box {
  1446. padding: 0 40rpx 40rpx 40rpx;
  1447. box-sizing: border-box;
  1448. background: linear-gradient(180deg, #FFFBEF 0%, #FFFFF5 43%, #F5EAC2 100%);
  1449. border-radius: 24rpx;
  1450. @include u-flex(column, center, flex-start);
  1451. }
  1452. &-head {
  1453. @include u-flex(row, center, center);
  1454. &-title {
  1455. width: 364rpx;
  1456. height: auto;
  1457. margin-top: -22rpx;
  1458. }
  1459. }
  1460. &-content {
  1461. margin: 48rpx 0;
  1462. font-family: PingFang SC, PingFang SC;
  1463. font-weight: 500;
  1464. font-size: 32rpx;
  1465. color: #222222;
  1466. text-align: center;
  1467. &-title {
  1468. margin-bottom: 26rpx;
  1469. font-weight: 600;
  1470. font-size: 40rpx;
  1471. color: #FF5C03;
  1472. }
  1473. }
  1474. }
  1475. .video-controls-box {
  1476. width: 100%;
  1477. height: calc(100% - 44px);
  1478. overflow: hidden;
  1479. position: absolute;
  1480. top: 0;
  1481. left: 0;
  1482. z-index: 2;
  1483. // background: rgba(0, 0, 0, 0.2);
  1484. .video-play {
  1485. height: 72rpx;
  1486. width: 72rpx;
  1487. position: absolute;
  1488. top: calc(50% + 22px);
  1489. left: 50%;
  1490. transform: translate(-50%, -50%);
  1491. }
  1492. }
  1493. .video-controls {
  1494. width: 100%;
  1495. height: 80rpx;
  1496. padding: 0 28rpx;
  1497. box-sizing: border-box;
  1498. position: absolute;
  1499. bottom: 0;
  1500. left: 0;
  1501. display: flex;
  1502. align-items: center;
  1503. justify-content: space-between;
  1504. background: linear-gradient(to top, #222 0%, transparent 80%);
  1505. .video-icon {
  1506. height: 44rpx;
  1507. width: 44rpx;
  1508. }
  1509. }
  1510. .errQuesbox {
  1511. width: 100%;
  1512. max-height: 260rpx;
  1513. overflow-y: auto;
  1514. margin-top: 24rpx;
  1515. font-family: PingFang SC, PingFang SC;
  1516. font-weight: 500;
  1517. font-size: 30rpx;
  1518. color: #222222;
  1519. &-item {
  1520. width: 100%;
  1521. height: 128rpx;
  1522. line-height: 128rpx;
  1523. margin-bottom: 24rpx;
  1524. padding: 0 30rpx;
  1525. box-sizing: border-box;
  1526. overflow: hidden;
  1527. background: #fff;
  1528. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1529. position: relative;
  1530. &::after {
  1531. content: "题目";
  1532. min-width: 64rpx;
  1533. height: 36rpx;
  1534. padding: 0 12rpx;
  1535. line-height: 36rpx;
  1536. background: #FF5C03;
  1537. box-sizing: border-box;
  1538. border-radius: 0rpx 0rpx 16rpx 0rpx;
  1539. text-align: center;
  1540. font-family: PingFang SC, PingFang SC;
  1541. font-weight: 500;
  1542. font-size: 20rpx;
  1543. color: #fff;
  1544. position: absolute;
  1545. left: 0;
  1546. top: 0;
  1547. }
  1548. }
  1549. }
  1550. .bg {
  1551. background: #fff !important;
  1552. }
  1553. .answerPopup {
  1554. &-box {
  1555. width: 560rpx;
  1556. background: linear-gradient(180deg, #FFFAF6 0%, #FEECD8 100%);
  1557. border-radius: 32rpx 32rpx 32rpx 32rpx;
  1558. background-color: #fff;
  1559. font-weight: 400;
  1560. padding: 32rpx;
  1561. box-sizing: border-box;
  1562. position: relative;
  1563. @include u-flex(column, center, flex-start);
  1564. font-family: PingFang SC, PingFang SC;
  1565. font-weight: 400;
  1566. .tipimg {
  1567. width: 206rpx;
  1568. height: 206rpx;
  1569. margin-bottom: 16rpx;
  1570. }
  1571. }
  1572. &-title {
  1573. font-weight: 600;
  1574. font-size: 36rpx;
  1575. color: #222222;
  1576. }
  1577. &-desc {
  1578. margin-top: 10rpx;
  1579. font-size: 28rpx;
  1580. color: #757575;
  1581. }
  1582. &-btn {
  1583. width: 464rpx;
  1584. height: 84rpx;
  1585. margin-top: 54rpx;
  1586. margin-bottom: 16rpx;
  1587. background: #FF5C03;
  1588. border-radius: 42rpx;
  1589. font-weight: 500;
  1590. font-size: 32rpx;
  1591. color: #FFFFFF;
  1592. text-align: center;
  1593. line-height: 84rpx;
  1594. }
  1595. }
  1596. .popupbox {
  1597. width: 100%;
  1598. background-color: #fff;
  1599. border-radius: 16rpx 16rpx 0 0;
  1600. padding: 24rpx 32rpx;
  1601. position: relative;
  1602. &-head {
  1603. height: 60rpx;
  1604. margin-bottom: 30rpx;
  1605. text-align: center;
  1606. overflow-y: auto;
  1607. color: #414858;
  1608. font-size: 32rpx;
  1609. font-weight: bold;
  1610. position: relative;
  1611. .close-icon {
  1612. position: absolute;
  1613. right: 0;
  1614. top: 0;
  1615. height: 40rpx;
  1616. width: 40rpx;
  1617. }
  1618. }
  1619. &-content {
  1620. height: 20vh;
  1621. overflow-y: auto;
  1622. display: flex;
  1623. align-items: flex-start;
  1624. flex-wrap: wrap;
  1625. gap: 32rpx;
  1626. .line-item {
  1627. display: inline-block;
  1628. min-width: 200rpx;
  1629. min-height: 60rpx;
  1630. padding: 0 20rpx;
  1631. box-sizing: border-box;
  1632. border-radius: 50rpx;
  1633. overflow: hidden;
  1634. background-color: #f7f7f7;
  1635. text-align: center;
  1636. color: #414858;
  1637. font-size: 28rpx;
  1638. line-height: 60rpx;
  1639. }
  1640. .line-active {
  1641. color: #f56c6c !important;
  1642. background-color: #fef0f0 !important;
  1643. }
  1644. }
  1645. }
  1646. .content {
  1647. padding-bottom: calc(var(--window-bottom));
  1648. .video-box {
  1649. width: 100%;
  1650. height: 420rpx;
  1651. overflow: hidden;
  1652. position: relative;
  1653. #myVideo {
  1654. width: 100%;
  1655. height: 100%;
  1656. }
  1657. }
  1658. .video-poster {
  1659. width: 100%;
  1660. height: 420rpx;
  1661. }
  1662. .miantitlebox {
  1663. padding: 30rpx 0;
  1664. border-bottom: 2rpx solid #F5F7FA;
  1665. font-family: PingFang SC, PingFang SC;
  1666. font-weight: 500;
  1667. font-size: 36rpx;
  1668. color: #222222;
  1669. }
  1670. .subtitlebox {
  1671. padding: 30rpx 0;
  1672. border-bottom: 2rpx solid #F5F7FA;
  1673. font-family: PingFang SC, PingFang SC;
  1674. font-weight: 500;
  1675. font-size: 36rpx;
  1676. color: #222222;
  1677. }
  1678. .title-content {
  1679. padding: 0 32rpx;
  1680. background-color: #fff;
  1681. font-size: 28rpx;
  1682. line-height: 1.6;
  1683. .title {
  1684. font-size: 36rpx;
  1685. font-weight: 500;
  1686. color: #414858;
  1687. }
  1688. .time-or-subtitle {
  1689. margin-top: 12rpx;
  1690. color: #666666;
  1691. }
  1692. }
  1693. .video-line {
  1694. min-width: 140rpx;
  1695. max-width: 200rpx;
  1696. height: 60rpx;
  1697. padding: 0 20rpx;
  1698. box-sizing: border-box;
  1699. border-radius: 50rpx 0 0 50rpx;
  1700. overflow: hidden;
  1701. background-color: #fff;
  1702. text-align: center;
  1703. color: #888;
  1704. font-size: 28rpx;
  1705. line-height: 60rpx;
  1706. display: inline-flex;
  1707. align-items: center;
  1708. justify-content: center;
  1709. position: fixed;
  1710. right: 0;
  1711. z-index: 9;
  1712. bottom: calc(var(--window-bottom) + 280rpx);
  1713. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, .12);
  1714. image {
  1715. flex-shrink: 0;
  1716. height: 34rpx;
  1717. width: 34rpx;
  1718. margin-right: 6rpx;
  1719. }
  1720. }
  1721. .footer {
  1722. border-top: 1rpx solid #ededef;
  1723. background: #fff;
  1724. width: 100%;
  1725. position: fixed;
  1726. bottom: 0;
  1727. padding: 18rpx 32rpx;
  1728. padding-bottom: calc(var(--window-bottom) + 18rpx);
  1729. box-sizing: border-box;
  1730. z-index: 9;
  1731. &-btn {
  1732. width: 100%;
  1733. height: 98rpx;
  1734. background: #FF5C03;
  1735. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1736. line-height: 98rpx;
  1737. text-align: center;
  1738. font-family: PingFang SC, PingFang SC;
  1739. font-weight: 600;
  1740. font-size: 32rpx;
  1741. color: #FFFFFF;
  1742. @include u-flex(row, center, center);
  1743. &-img {
  1744. flex-shrink: 0;
  1745. width: 144rpx;
  1746. height: 144rpx;
  1747. margin-right: 8rpx;
  1748. margin-top: -24rpx;
  1749. }
  1750. }
  1751. &-btn-border {
  1752. position: relative;
  1753. &::after {
  1754. content: "";
  1755. background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
  1756. position: absolute;
  1757. top: -2rpx;
  1758. left: 0;
  1759. height: 103rpx;
  1760. width: 100%;
  1761. z-index: -1;
  1762. border-radius: 49rpx 49rpx 49rpx 49rpx;
  1763. box-shadow: 0rpx 8rpx 11rpx 0rpx rgba(255, 92, 3, 0.3);
  1764. overflow: hidden;
  1765. }
  1766. }
  1767. }
  1768. }
  1769. .agreement {
  1770. display: inline-flex;
  1771. margin-top: 16rpx;
  1772. font-size: 24rpx;
  1773. color: #525252;
  1774. align-items: center;
  1775. justify-content: center;
  1776. }
  1777. .logo {
  1778. display: inline-block;
  1779. width: 30px;
  1780. height: auto;
  1781. margin: 20px 0 0 10px;
  1782. pointer-events: none;
  1783. object-fit: cover;
  1784. }
  1785. .logo-full {
  1786. display: inline-block;
  1787. width: 40px;
  1788. height: auto;
  1789. margin: 50px 0 0 30px;
  1790. pointer-events: none;
  1791. object-fit: cover;
  1792. }
  1793. .tabbox {
  1794. @include u-flex(row, center, center);
  1795. border-bottom: 2rpx solid #F5F7FA;
  1796. height: 44px;
  1797. background-color: #fff;
  1798. view {
  1799. flex: 1;
  1800. padding: 20rpx 0;
  1801. margin-right: 40rpx;
  1802. text-align: center;
  1803. }
  1804. &-active {
  1805. position: relative;
  1806. &::after {
  1807. position: absolute;
  1808. bottom: 0;
  1809. left: 50%;
  1810. transform: translateX(-50%);
  1811. content: "";
  1812. width: 3rem;
  1813. border-bottom: 4px solid #FF5C03;
  1814. }
  1815. }
  1816. }
  1817. .chatinput {
  1818. position: fixed;
  1819. left: 32rpx;
  1820. right: 32rpx;
  1821. z-index: 999;
  1822. bottom: calc(var(--window-bottom) + 24rpx);
  1823. height: 96rpx;
  1824. background-color: green;
  1825. background: #FFFFFF;
  1826. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1827. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1828. @include u-flex(row, center, center);
  1829. padding: 0 24rpx;
  1830. box-sizing: border-box;
  1831. .uni-input {
  1832. flex: 1;
  1833. margin-right: 32rpx;
  1834. font-size: 30rpx;
  1835. }
  1836. .send {
  1837. font-family: PingFang SC, PingFang SC;
  1838. font-weight: 400;
  1839. font-size: 28rpx;
  1840. color: #FFFFFF !important;
  1841. flex-shrink: 0;
  1842. padding: 0 20rpx;
  1843. height: 72rpx;
  1844. background: #FF5C03 !important;
  1845. border-radius: 8rpx 8rpx 8rpx 8rpx;
  1846. &::after {
  1847. border: none;
  1848. }
  1849. }
  1850. }
  1851. .danmu-line {
  1852. bottom: calc(var(--window-bottom) + 370rpx) !important;
  1853. word-break: keep-all;
  1854. .set_image {
  1855. height: 40rpx;
  1856. width: 40rpx;
  1857. }
  1858. }
  1859. .video-danmu-btnbox {
  1860. width: 50px;
  1861. height: 50px;
  1862. border-radius: 50%;
  1863. overflow: hidden;
  1864. position: absolute;
  1865. right: 10px;
  1866. bottom: calc(50% - 50px);
  1867. transform: translateY(-50%);
  1868. padding: 8px;
  1869. box-sizing: border-box;
  1870. }
  1871. .video-danmu-image {
  1872. width: 100%;
  1873. height: 100%;
  1874. }
  1875. .danmuPopup-input {
  1876. flex: 1;
  1877. height: 35px;
  1878. border-radius: 35px;
  1879. border: 1rpx solid #eee;
  1880. padding: 0 24rpx;
  1881. }
  1882. .danmuPopup {
  1883. background-color: #fff;
  1884. padding-bottom: calc(var(--window-bottom) + 10px);
  1885. &-head {
  1886. width: 100%;
  1887. padding: 10px;
  1888. box-sizing: border-box;
  1889. overflow: hidden;
  1890. @include u-flex(row,center,flex-start);
  1891. .danmu-icon {
  1892. height: 24px;
  1893. width: 24px;
  1894. margin-right: 12px;
  1895. }
  1896. }
  1897. &-send {
  1898. flex-shrink: 0;
  1899. height: 35px;
  1900. display: flex;
  1901. align-items: center;
  1902. justify-content: center;
  1903. padding: 5px 15px;
  1904. box-sizing: border-box;
  1905. background: #FF5C03 !important;
  1906. border-radius: 22px;
  1907. font-family: PingFang SC, PingFang SC;
  1908. font-weight: 500;
  1909. font-size: 15px;
  1910. color: #fff !important;
  1911. margin-left: 12px;
  1912. &::after {
  1913. border: none;
  1914. }
  1915. }
  1916. &-con {
  1917. background-color: #F5F7FA;
  1918. padding: 24px 12px 48px 12px;
  1919. font-family: PingFang SC, PingFang SC;
  1920. font-weight: 400;
  1921. font-size: 14px;
  1922. color: #757575;
  1923. }
  1924. }
  1925. .answerTip {
  1926. position: fixed;
  1927. right: 0;
  1928. z-index: 9;
  1929. bottom: calc(var(--window-bottom) + 380rpx);
  1930. box-shadow: 0rpx 8rpx 21rpx 0rpx rgba(0, 0, 0, 0.1);
  1931. border-radius: 24rpx 24rpx 24rpx 24rpx;
  1932. background-color: #ff5c03;
  1933. color: #fff;
  1934. border-radius: 50%;
  1935. height: 90rpx;
  1936. width: 90rpx;
  1937. font-size: 25rpx;
  1938. text-align: center;
  1939. padding: 10rpx;
  1940. @include u-flex(column, center, center);
  1941. }
  1942. </style>