learningNew.vue 50 KB

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