video.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __defProps = Object.defineProperties;
  4. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  5. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  6. var __hasOwnProp = Object.prototype.hasOwnProperty;
  7. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  8. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  9. var __spreadValues = (a, b) => {
  10. for (var prop in b || (b = {}))
  11. if (__hasOwnProp.call(b, prop))
  12. __defNormalProp(a, prop, b[prop]);
  13. if (__getOwnPropSymbols)
  14. for (var prop of __getOwnPropSymbols(b)) {
  15. if (__propIsEnum.call(b, prop))
  16. __defNormalProp(a, prop, b[prop]);
  17. }
  18. return a;
  19. };
  20. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  21. var __objRest = (source, exclude) => {
  22. var target = {};
  23. for (var prop in source)
  24. if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
  25. target[prop] = source[prop];
  26. if (source != null && __getOwnPropSymbols)
  27. for (var prop of __getOwnPropSymbols(source)) {
  28. if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
  29. target[prop] = source[prop];
  30. }
  31. return target;
  32. };
  33. var common_vendor = require("../common/vendor.js");
  34. var utils_common = require("../utils/common.js");
  35. var api_course = require("../api/course.js");
  36. require("../api/user.js");
  37. require("../common/request.js");
  38. const _sfc_main = {
  39. data() {
  40. return {
  41. baseUrl: common_vendor.index.getStorageSync("requestPath"),
  42. rewardType: [{
  43. name: "\u7EA2\u5305\u5956\u52B1",
  44. value: 1
  45. }, {
  46. name: "\u79EF\u5206\u5956\u52B1",
  47. value: 2
  48. }],
  49. currentReward: 1,
  50. player: null,
  51. loading: true,
  52. progress: 0,
  53. code: null,
  54. statusBarHeight: common_vendor.index.getSystemInfoSync().statusBarHeight,
  55. scrollTop: 0,
  56. height: "0px",
  57. isLogin: true,
  58. videoUrl: "",
  59. videoId: "",
  60. playTime: 0,
  61. duration: 0,
  62. playDuration: 0,
  63. playDurationSeek: 0,
  64. tipsTime: 0,
  65. tipsOpen: false,
  66. config: {},
  67. courseInfo: {},
  68. quesList: [],
  69. lineList: [],
  70. errQues: [],
  71. remain: 0,
  72. errTitle: "",
  73. errDesc: "",
  74. showPlay: true,
  75. showControls: false,
  76. playStatus: "",
  77. isFullscreen: false,
  78. isAddKf: 0,
  79. lineIndex: 0,
  80. isExpand: true,
  81. textHeight: 0,
  82. qwUserId: "",
  83. qrcode: "",
  84. corpId: "",
  85. qrcodeMsg: "",
  86. urlOption: {},
  87. bufferRate: 0,
  88. uuId: "",
  89. isEnded: false,
  90. linkType: 0,
  91. ip: null,
  92. checked: true,
  93. isFinish: 0,
  94. interval: null,
  95. intervalIntegral: null,
  96. options: {
  97. sources: [{
  98. src: ""
  99. }],
  100. poster: "",
  101. live: false,
  102. controls: true,
  103. autoplay: false,
  104. licenseUrl: "https://license.vod2.myqcloud.com/license/v2/1323137866_1/v_cube.license",
  105. LicenseKey: "bcc5bd9a14b798b48c52ff005a21d926",
  106. controlBar: {
  107. volumePanel: false,
  108. playbackRateMenuButton: false,
  109. QualitySwitcherMenuButton: false
  110. },
  111. plugins: {
  112. ContextMenu: {
  113. statistic: false
  114. }
  115. }
  116. },
  117. errorCount: 0,
  118. answerPopup: false,
  119. sortLink: "",
  120. isExpire: true,
  121. menuButtonLeft: 281,
  122. menuButtonH: 45,
  123. timer: null,
  124. flag: false
  125. };
  126. },
  127. filters: {
  128. numberToChinese(number) {
  129. if (number) {
  130. const chineseNumber = ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D"];
  131. return chineseNumber[number - 1];
  132. } else {
  133. return "";
  134. }
  135. }
  136. },
  137. computed: {
  138. isAnswer() {
  139. return (item, name) => {
  140. if (item.type == 1) {
  141. return item.answer == name;
  142. } else if (item.type == 2) {
  143. const array = item.answer.split(",");
  144. return array.some((i) => i == name);
  145. } else {
  146. return false;
  147. }
  148. };
  149. }
  150. },
  151. onLoad(option) {
  152. this.code = option.code;
  153. this.urlOption = option.course ? JSON.parse(option.course) : {};
  154. this.videoId = this.urlOption.videoId;
  155. this.qwUserId = this.urlOption.qwUserId || "";
  156. this.corpId = this.urlOption.corpId || "";
  157. this.linkType = this.urlOption.linkType || 0;
  158. this.sortLink = this.urlOption.link || "";
  159. this.getMenuButton();
  160. },
  161. onShow() {
  162. this.tipsOpen = false;
  163. this.isExpand = true;
  164. this.uuId = utils_common.generateRandomString(16);
  165. if (this.videoId) {
  166. this.getH5CourseByVideo();
  167. }
  168. if (this.sortLink) {
  169. this.getLink();
  170. } else {
  171. common_vendor.index.showToast({
  172. title: "sortLink is not found",
  173. icon: "none"
  174. });
  175. }
  176. },
  177. mounted() {
  178. this.getIP();
  179. this.getHeight();
  180. },
  181. onHide() {
  182. if (this.player) {
  183. this.player.pause();
  184. }
  185. },
  186. onUnload() {
  187. if (this.interval != null) {
  188. clearInterval(this.interval);
  189. this.interval = null;
  190. }
  191. this.clearIntegral();
  192. },
  193. beforeDestroy() {
  194. this.player = common_vendor.index.createVideoContext("video-content-box");
  195. if (this.player) {
  196. this.player.stop();
  197. this.player = null;
  198. }
  199. if (this.interval != null) {
  200. clearInterval(this.interval);
  201. this.interval = null;
  202. }
  203. this.clearIntegral();
  204. },
  205. methods: {
  206. getMenuButton() {
  207. const menuButtonInfo = common_vendor.index.getMenuButtonBoundingClientRect();
  208. this.menuButtonLeft = menuButtonInfo.left;
  209. this.menuButtonH = menuButtonInfo.height;
  210. },
  211. onTimeUpdate(e) {
  212. let currentTime = Math.round(e.detail.currentTime);
  213. if (this.playDurationSeek > 0) {
  214. this.playTime = this.playDurationSeek;
  215. this.throttle(() => this.changeTime(this), 1e3, false);
  216. } else {
  217. if (this.linkType != 1 && (currentTime - this.playTime > 3 || currentTime - this.playTime < -3) && this.isFinish != 1) {
  218. common_vendor.index.showToast({
  219. title: "\u4E0D\u80FD\u5FEB\u8FDB\u54E6",
  220. icon: "none"
  221. });
  222. currentTime = this.playTime;
  223. this.player.seek(this.playTime);
  224. }
  225. this.playTime = currentTime;
  226. }
  227. },
  228. changeTime(that, e) {
  229. that.playDurationSeek = 0;
  230. },
  231. videoErrorCallback(e) {
  232. this.clearIntegral();
  233. this.errorCount++;
  234. if (this.errorCount > 3)
  235. return;
  236. console.log(e);
  237. this.getErrMsg(e.target.errMsg);
  238. this.getH5CourseVideoDetails("error");
  239. },
  240. getPlay() {
  241. this.errorCount = 0;
  242. this.judgeDuration();
  243. },
  244. getPause() {
  245. this.clearIntegral();
  246. },
  247. getEnded() {
  248. this.clearIntegral();
  249. this.isEnded = true;
  250. this.getFinishCourseVideo();
  251. },
  252. getIP() {
  253. common_vendor.index.request({
  254. url: "https://ipinfo.io/json",
  255. method: "GET",
  256. success: (res) => {
  257. this.ip = res.data.ip;
  258. }
  259. });
  260. },
  261. getHeight() {
  262. this.$nextTick(() => {
  263. const query = common_vendor.index.createSelectorQuery().in(this);
  264. query.select("#title-content").boundingClientRect((data) => {
  265. this.height = `calc(100vh - ${data.height}px - 420rpx - ${this.statusBarHeight}px - 164rpx - 88rpx)`;
  266. }).exec();
  267. });
  268. },
  269. getDescHeight() {
  270. this.$nextTick(() => {
  271. const query = common_vendor.index.createSelectorQuery().in(this);
  272. query.select("#descbox-desc").boundingClientRect((data) => {
  273. this.textHeight = data.height;
  274. }).exec();
  275. });
  276. },
  277. numberToLetter(num) {
  278. let letterCode = num + 65;
  279. let letter = String.fromCharCode(letterCode);
  280. return letter;
  281. },
  282. updateTime() {
  283. var that = this;
  284. if (this.interval != null) {
  285. clearInterval(this.interval);
  286. }
  287. this.interval = setInterval(function() {
  288. that.getFinishCourseVideo();
  289. that.getInternetTraffic();
  290. }, 6e4);
  291. },
  292. judgeDuration() {
  293. var that = this;
  294. if (this.intervalIntegral != null) {
  295. clearInterval(this.intervalIntegral);
  296. this.intervalIntegral = null;
  297. }
  298. this.intervalIntegral = setInterval(function() {
  299. that.getIntegralByH5Video();
  300. }, 6e5);
  301. },
  302. clearIntegral() {
  303. if (this.intervalIntegral != null) {
  304. clearInterval(this.intervalIntegral);
  305. this.intervalIntegral = null;
  306. }
  307. },
  308. handleExpand() {
  309. this.isExpand = !this.isExpand;
  310. },
  311. getH5CourseByVideo() {
  312. this.loading = true;
  313. api_course.getH5CourseByVideoId({
  314. videoId: this.videoId
  315. }).then((res) => {
  316. this.loading = false;
  317. if (res.code == 200) {
  318. this.courseInfo = res.data;
  319. common_vendor.index.setNavigationBarTitle({
  320. title: this.courseInfo && this.courseInfo.title ? this.courseInfo.title : ""
  321. });
  322. }
  323. this.getHeight();
  324. this.getDescHeight();
  325. }, (rej) => {
  326. this.loading = false;
  327. }).catch(() => {
  328. this.loading = false;
  329. });
  330. },
  331. getH5CourseVideoDetails(type) {
  332. api_course.getH5CourseVideoDetails(this.urlOption).then((res) => {
  333. if (res.code == 200) {
  334. this.config = res.config || {};
  335. this.isFinish = res.isFinish || 0;
  336. this.duration = res.course && res.course.duration ? res.course.duration : 0;
  337. this.playDuration = res.playDuration || 0;
  338. this.playDurationSeek = res.playDuration || 0;
  339. this.tipsTime = res.tipsTime || 0;
  340. let lineList = [];
  341. if (res.course && res.course.lineOne) {
  342. lineList.push(res.course.lineOne);
  343. }
  344. if (res.course && res.course.lineTwo) {
  345. lineList.push(res.course.lineTwo);
  346. }
  347. if (res.course && res.course.lineThree) {
  348. lineList.push(res.course.lineThree);
  349. }
  350. this.lineList = lineList;
  351. if (!this.player || type == "error") {
  352. this.lineIndex = this.config.defaultLine;
  353. this.videoUrl = lineList[this.lineIndex];
  354. this.poster = res.course && res.course.imgUrl ? res.course.imgUrl : "";
  355. this.playTime = this.playDuration >= this.duration ? 0 : this.playDuration;
  356. setTimeout(() => {
  357. this.player = common_vendor.index.createVideoContext("video-content-box");
  358. this.player.seek(this.playTime);
  359. this.player.play();
  360. }, 500);
  361. } else {
  362. this.playTime = this.playTime > this.playDuration ? this.playTime : this.playDuration >= this.duration ? 0 : this.playDuration;
  363. this.player.seek(this.playTime);
  364. this.player.play();
  365. }
  366. this.updateTime();
  367. this.quesList = res.questions && res.questions.length > 0 ? res.questions : [], this.quesList = this.quesList.map((item) => __spreadProps(__spreadValues({}, item), {
  368. questionOption: JSON.parse(item.question),
  369. answer: ""
  370. }));
  371. }
  372. this.getHeight();
  373. this.getDescHeight();
  374. }, (rej) => {
  375. });
  376. },
  377. handleAnswer(item, option, idx) {
  378. let time = this.playTime;
  379. if (this.isEnded) {
  380. time = this.duration;
  381. } else {
  382. if (time < this.playDuration && this.isFinish != 1) {
  383. time = this.playDuration;
  384. }
  385. }
  386. if (Number(this.duration || 0) == 0 || time < this.duration - 60) {
  387. common_vendor.index.showToast({
  388. title: "\u8BF7\u5148\u89C2\u770B\u5B8C\u6574\u8BFE\u7A0B\u518D\u7B54\u9898\u54E6\uFF5E",
  389. icon: "none"
  390. });
  391. return;
  392. }
  393. if (item.type == 1) {
  394. item.answer = option.name;
  395. } else if (item.type == 2) {
  396. let answer = item.answer ? item.answer.split(",") : [];
  397. if (answer.indexOf(option.name) === -1) {
  398. answer.push(option.name);
  399. item.answer = answer.join(",");
  400. } else {
  401. answer.splice(answer.indexOf(option.name), 1);
  402. item.answer = answer.join(",");
  403. }
  404. }
  405. },
  406. submit() {
  407. if (this.isExpire) {
  408. common_vendor.index.showToast({
  409. title: "\u8BFE\u7A0B\u5DF2\u8FC7\u671F\u6216\u94FE\u63A5\u65E0\u6548",
  410. icon: "none"
  411. });
  412. return;
  413. }
  414. this.$isLoginCourse().then((res) => {
  415. if (res) {
  416. if (this.isAddKf == 1) {
  417. this.courseAnswer();
  418. } else {
  419. if (this.videoId && this.qwUserId) {
  420. this.getIsAddKf();
  421. } else {
  422. common_vendor.index.showToast({
  423. title: "\u8BF7\u6DFB\u52A0\u5BA2\u670D",
  424. icon: "none"
  425. });
  426. }
  427. }
  428. } else {
  429. this.goLogin();
  430. }
  431. }, (rej) => {
  432. });
  433. },
  434. courseAnswer() {
  435. let time = this.playTime;
  436. if (this.isEnded) {
  437. time = this.duration;
  438. } else {
  439. if (time < this.playDuration && this.isFinish != 1) {
  440. time = this.playDuration;
  441. }
  442. }
  443. if (Number(this.duration || 0) == 0 || time < this.duration - 60) {
  444. common_vendor.index.showToast({
  445. title: "\u8BF7\u5148\u89C2\u770B\u5B8C\u6574\u8BFE\u7A0B\u518D\u7B54\u9898\u54E6\uFF5E",
  446. icon: "none"
  447. });
  448. return;
  449. }
  450. if (this.quesList.some((item) => !item.answer)) {
  451. common_vendor.index.showToast({
  452. title: "\u8BF7\u786E\u8BA4\u662F\u5426\u7B54\u5B8C\u6240\u6709\u9898\u76EE",
  453. icon: "none"
  454. });
  455. return;
  456. }
  457. const questions = this.quesList.map((obj) => {
  458. const _a = obj, {
  459. questionOption
  460. } = _a, rest = __objRest(_a, [
  461. "questionOption"
  462. ]);
  463. return rest;
  464. });
  465. const param = __spreadProps(__spreadValues({}, this.urlOption), {
  466. questions,
  467. videoId: this.videoId,
  468. duration: this.playTime
  469. });
  470. this.errTitle = "";
  471. this.errDesc = "";
  472. this.errQues = [];
  473. api_course.courseAnswer(param).then((res) => {
  474. if (res.code == 200) {
  475. if (res.incorrectQuestions) {
  476. if (res.incorrectQuestions.length > 0) {
  477. this.errQues = res.incorrectQuestions;
  478. }
  479. this.remain = res.remain || 0;
  480. if (res.remain > 0) {
  481. this.errTitle = "\u5F88\u9057\u61BE\u7B54\u9519\u4E86";
  482. this.errDesc = `<span style="color:#FF5C03">\u8FD8\u6709${res.remain}\u6B21\u673A\u4F1A\uFF0C\u7EE7\u7EED\u52A0\u6CB9</span>`;
  483. this.$refs.answerPopup.open("center");
  484. }
  485. } else {
  486. this.errTitle = "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E";
  487. this.errDesc = `\u8BF7\u9009\u62E9\u5956\u52B1`;
  488. this.$refs.answerPopup.open("center");
  489. }
  490. } else {
  491. if (res.msg == "\u8BE5\u8BFE\u9898\u5230\u8FBE\u7B54\u9519\u6B21\u6570\u9650\u5236") {
  492. this.errTitle = "\u7B54\u9898\u6B21\u6570\u8D85\u8FC7\u9650\u5236";
  493. this.errDesc = "\u4EE5\u540E\u7684\u8BFE\u7A0B\u8981\u8BA4\u771F\u5B66\u4E60\u54E6";
  494. this.$refs.answerPopup.open("center");
  495. } else {
  496. common_vendor.index.showToast({
  497. title: res.msg,
  498. icon: "none"
  499. });
  500. }
  501. }
  502. }, (rej) => {
  503. });
  504. },
  505. rewardChange(e) {
  506. this.currentReward = e.detail.value;
  507. },
  508. closeAnswerPopup() {
  509. this.$refs.answerPopup.close();
  510. if (this.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E") {
  511. const param = __spreadProps(__spreadValues({}, this.urlOption), {
  512. rewardType: Number(this.currentReward),
  513. source: 2
  514. });
  515. api_course.sendReward(param).then((res) => {
  516. common_vendor.index.showToast({
  517. title: res.msg,
  518. icon: "none"
  519. });
  520. });
  521. }
  522. },
  523. openPop() {
  524. this.$refs.popup.open("bottom");
  525. },
  526. close() {
  527. this.$refs.popup.close();
  528. },
  529. handleLine(index) {
  530. var that = this;
  531. if (this.lineIndex == index && this.videoUrl == this.lineList[index]) {
  532. this.close();
  533. return;
  534. } else {
  535. this.lineIndex = index;
  536. this.videoUrl = this.lineList[index];
  537. this.tipsOpen = false;
  538. this.playDurationSeek = this.playTime || 0;
  539. this.player = common_vendor.index.createVideoContext("video-content-box");
  540. setTimeout(function() {
  541. that.player.seek(that.playDurationSeek);
  542. that.player.play();
  543. }, 500);
  544. this.close();
  545. }
  546. },
  547. openTipsPop() {
  548. this.$refs.tipsPopup.open();
  549. this.tipsOpen = true;
  550. this.pause();
  551. },
  552. closeTipsPop() {
  553. this.$refs.tipsPopup.close();
  554. },
  555. getIsAddKf() {
  556. this.qrcode = "";
  557. this.qrcodeMsg = "";
  558. this.isAddKf = 0;
  559. api_course.getIsAddKf(this.urlOption).then((res) => {
  560. if (res.code == 200) {
  561. this.isAddKf = 1;
  562. this.getH5CourseVideoDetails();
  563. } else if (res.code == 400) {
  564. this.isAddKf = 0;
  565. this.qrcode = res.qrcode;
  566. this.qrcodeMsg = res.msg;
  567. this.$refs.kfPopup.open();
  568. } else if (res.code == 504)
  569. ;
  570. else {
  571. this.isAddKf = 0;
  572. common_vendor.index.showToast({
  573. title: res.msg,
  574. icon: "none"
  575. });
  576. }
  577. }, (err) => {
  578. });
  579. },
  580. closeKFPop() {
  581. this.$refs.kfPopup.close();
  582. },
  583. getFinishCourseVideo() {
  584. if (!this.playTime)
  585. return;
  586. const param = __spreadValues({
  587. duration: this.playTime
  588. }, this.urlOption);
  589. api_course.getFinishCourseVideo(param);
  590. },
  591. getIntegralByH5Video() {
  592. const param = __spreadValues({
  593. duration: this.playTime
  594. }, this.urlOption);
  595. api_course.getIntegralByH5Video(param).then((res) => {
  596. if (res.code == 200) {
  597. common_vendor.index.showToast({
  598. title: "\u79EF\u5206+10",
  599. icon: "none"
  600. });
  601. }
  602. });
  603. },
  604. progressChange(e) {
  605. this.bufferRate = Math.ceil(e.detail.buffered);
  606. },
  607. getInternetTraffic() {
  608. const playVideoTime = Math.ceil(this.playTime / this.duration * 100);
  609. if (this.bufferRate == 0 || this.bufferRate < playVideoTime) {
  610. this.bufferRate = playVideoTime;
  611. }
  612. if (this.bufferRate == 0 || Number(this.bufferRate.toFixed(2)) == 0)
  613. return;
  614. const param = __spreadValues({
  615. uuId: common_vendor.dayjs().format("YYYYMMDD") + this.uuId,
  616. duration: this.playTime,
  617. bufferRate: Number(this.bufferRate.toFixed(2))
  618. }, this.urlOption);
  619. api_course.getInternetTraffic(param);
  620. },
  621. getErrMsg(err) {
  622. let msgerr = {
  623. videoUrl: this.videoUrl,
  624. lineIndex: this.lineIndex,
  625. errTime: new Date(),
  626. ip: this.ip,
  627. errMsg: err
  628. };
  629. api_course.getErrMsg({
  630. msg: JSON.stringify(msgerr)
  631. });
  632. },
  633. goLogin() {
  634. this.$getProvider().then((provider) => {
  635. console.log("\u5F53\u524D\u7684\u73AF\u5883\u5546", provider);
  636. if (!provider) {
  637. reject();
  638. }
  639. common_vendor.index.login({
  640. provider,
  641. success: async (loginRes) => {
  642. console.log(loginRes);
  643. common_vendor.index.getUserInfo({
  644. provider,
  645. success: (infoRes) => {
  646. common_vendor.index.showToast({
  647. title: "\u5904\u7406\u4E2D...",
  648. icon: "loading"
  649. });
  650. api_course.loginByMp({ code: loginRes.code, encryptedData: infoRes.encryptedData, iv: infoRes.iv }).then((res) => {
  651. common_vendor.index.hideLoading();
  652. if (res.code == 200) {
  653. common_vendor.index.setStorageSync("AppTokenmini_RTCourse", res.token);
  654. common_vendor.index.setStorageSync("userInfo", JSON.stringify(res.user));
  655. this.isLogin = true;
  656. this.getIsAddKf();
  657. } else {
  658. common_vendor.index.showToast({
  659. title: res.msg,
  660. icon: "none"
  661. });
  662. }
  663. }).catch((err) => {
  664. common_vendor.index.hideLoading();
  665. common_vendor.index.showToast({
  666. icon: "none",
  667. title: "\u767B\u5F55\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55"
  668. });
  669. });
  670. }
  671. });
  672. }
  673. });
  674. }).catch((err) => {
  675. });
  676. },
  677. getLink() {
  678. api_course.getRealLink({ sortLink: this.sortLink }).then((res) => {
  679. if (res.code == 200) {
  680. this.isExpire = false;
  681. if (this.isLogin && this.isAddKf == 1) {
  682. this.getH5CourseVideoDetails();
  683. }
  684. if (this.videoId && this.isAddKf != 1) {
  685. this.$isLoginCourse().then((isLogin) => {
  686. this.isLogin = isLogin;
  687. if (isLogin) {
  688. this.getIsAddKf();
  689. } else {
  690. this.goLogin();
  691. }
  692. }, (rej) => {
  693. });
  694. }
  695. } else {
  696. this.isExpire = true;
  697. common_vendor.index.showToast({
  698. title: "\u8BFE\u7A0B\u5DF2\u8FC7\u671F\u6216\u94FE\u63A5\u65E0\u6548",
  699. icon: "none"
  700. });
  701. }
  702. }).catch((err) => {
  703. this.isExpire = true;
  704. common_vendor.index.showToast({
  705. title: "\u53D1\u751F\u9519\u8BEF\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
  706. icon: "none"
  707. });
  708. });
  709. },
  710. throttle(func, wait = 500, immediate = true) {
  711. if (immediate) {
  712. if (!this.flag) {
  713. this.flag = true;
  714. typeof func === "function" && func();
  715. this.timer = setTimeout(() => {
  716. this.flag = false;
  717. }, wait);
  718. }
  719. } else if (!this.flag) {
  720. this.flag = true;
  721. this.timer = setTimeout(() => {
  722. this.flag = false;
  723. typeof func === "function" && func();
  724. }, wait);
  725. }
  726. }
  727. }
  728. };
  729. if (!Array) {
  730. const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  731. _easycom_uni_popup2();
  732. }
  733. const _easycom_uni_popup = () => "../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
  734. if (!Math) {
  735. _easycom_uni_popup();
  736. }
  737. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  738. return common_vendor.e({
  739. a: common_vendor.t($data.courseInfo.title),
  740. b: $data.menuButtonLeft + "px",
  741. c: $data.menuButtonH + "px",
  742. d: $data.menuButtonH + "px",
  743. e: `calc(88rpx + ${$data.statusBarHeight}px)`,
  744. f: $data.statusBarHeight + "px",
  745. g: !$data.isLogin || $data.isAddKf != 1
  746. }, !$data.isLogin || $data.isAddKf != 1 ? {
  747. h: $data.courseInfo.imgUrl
  748. } : {}, {
  749. i: common_vendor.o((...args) => $options.onTimeUpdate && $options.onTimeUpdate(...args)),
  750. j: common_vendor.o((...args) => $options.progressChange && $options.progressChange(...args)),
  751. k: common_vendor.o((...args) => $options.videoErrorCallback && $options.videoErrorCallback(...args)),
  752. l: common_vendor.o((...args) => $options.getPlay && $options.getPlay(...args)),
  753. m: common_vendor.o((...args) => $options.getPause && $options.getPause(...args)),
  754. n: common_vendor.o((...args) => $options.getEnded && $options.getEnded(...args)),
  755. o: $data.courseInfo.title,
  756. p: _ctx.poster,
  757. q: [],
  758. r: $data.videoUrl,
  759. s: $data.isLogin && $data.isAddKf == 1
  760. }, $data.isLogin && $data.isAddKf == 1 ? {
  761. t: common_vendor.t($data.courseInfo.title)
  762. } : {
  763. v: common_vendor.t($data.courseInfo.courseName)
  764. }, {
  765. w: !$data.isLogin || $data.isAddKf != 1
  766. }, !$data.isLogin || $data.isAddKf != 1 ? common_vendor.e({
  767. x: common_vendor.t($data.courseInfo.title),
  768. y: $data.textHeight > 21
  769. }, $data.textHeight > 21 ? {
  770. z: common_vendor.t($data.isExpand ? "\u6536\u8D77\u7B80\u4ECB" : "\u5C55\u5F00\u7B80\u4ECB"),
  771. A: common_vendor.o((...args) => $options.handleExpand && $options.handleExpand(...args)),
  772. B: $data.baseUrl + "/images/course_arrow_up_icon.png",
  773. C: $data.isExpand,
  774. D: $data.baseUrl + "/images/course_arrow_down_icon.png",
  775. E: !$data.isExpand
  776. } : {}) : {}, {
  777. F: common_vendor.t($data.courseInfo.description),
  778. G: $data.isLogin && $data.isAddKf == 1 && $data.textHeight > 21
  779. }, $data.isLogin && $data.isAddKf == 1 && $data.textHeight > 21 ? {
  780. H: common_vendor.t($data.isExpand ? "\u6536\u8D77\u7B80\u4ECB" : "\u5C55\u5F00\u7B80\u4ECB"),
  781. I: common_vendor.o((...args) => $options.handleExpand && $options.handleExpand(...args)),
  782. J: $data.baseUrl + "/images/course_arrow_up_icon.png",
  783. K: $data.isExpand,
  784. L: $data.baseUrl + "/images/course_arrow_down_icon.png",
  785. M: !$data.isExpand,
  786. N: common_vendor.n($data.isExpand ? "expand" : "expand expand-ab")
  787. } : {}, {
  788. O: $data.isExpand ? "auto" : "42rpx",
  789. P: $data.isLogin && $data.isAddKf == 1
  790. }, $data.isLogin && $data.isAddKf == 1 ? {
  791. Q: common_vendor.f($data.quesList, (item, index, i0) => {
  792. return {
  793. a: common_vendor.t(index + 1),
  794. b: common_vendor.t(item.type == 1 ? "\u5355\u9009" : item.type == 2 ? "\u591A\u9009" : ""),
  795. c: item.type == 1 || item.type == 2,
  796. d: common_vendor.t(item.title),
  797. e: common_vendor.f(item.questionOption, (option, idx, i1) => {
  798. return {
  799. a: common_vendor.t($options.numberToLetter(idx)),
  800. b: common_vendor.t(option.name),
  801. c: common_vendor.n($options.isAnswer(item, option.name) ? "ques-option ques-option-active" : "ques-option"),
  802. d: idx,
  803. e: common_vendor.o(($event) => $options.handleAnswer(item, option), idx)
  804. };
  805. }),
  806. f: index
  807. };
  808. })
  809. } : {}, {
  810. R: $data.height,
  811. S: $data.scrollTop,
  812. T: $data.isLogin && $data.isAddKf == 1
  813. }, $data.isLogin && $data.isAddKf == 1 ? {
  814. U: $data.baseUrl + "/images/changePlayer-icon.png",
  815. V: common_vendor.t($data.lineIndex + 1 | _ctx.numberToChinese),
  816. W: common_vendor.o((...args) => $options.openPop && $options.openPop(...args))
  817. } : {}, {
  818. X: $data.baseUrl + "/images/tc_close_icon.png",
  819. Y: common_vendor.o((...args) => $options.close && $options.close(...args)),
  820. Z: common_vendor.f($data.lineList, (it, index, i0) => {
  821. return {
  822. a: common_vendor.t(index + 1 | _ctx.numberToChinese),
  823. b: common_vendor.n($data.lineIndex == index ? "line-item line-active" : "line-item"),
  824. c: index,
  825. d: common_vendor.o(($event) => $options.handleLine(index), index)
  826. };
  827. }),
  828. aa: common_vendor.sr("popup", "468b9330-0"),
  829. ab: common_vendor.p({
  830. type: "bottom"
  831. }),
  832. ac: $data.baseUrl + "/images/red_envelope_img.png",
  833. ad: $data.baseUrl + "/images/course_close_white_icon.png",
  834. ae: common_vendor.o((...args) => $options.closeTipsPop && $options.closeTipsPop(...args)),
  835. af: $data.baseUrl + "/images/tips_title_img.png",
  836. ag: common_vendor.o((...args) => $options.closeTipsPop && $options.closeTipsPop(...args)),
  837. ah: common_vendor.sr("tipsPopup", "468b9330-1"),
  838. ai: common_vendor.p({
  839. type: "center",
  840. ["is-mask-click"]: false
  841. }),
  842. aj: $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E"
  843. }, $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E" ? {
  844. ak: $data.baseUrl + "/images/course_answer_img.png"
  845. } : {
  846. al: $data.baseUrl + "/images/course_answer_incorrectly_img.png"
  847. }, {
  848. am: common_vendor.t($data.errTitle),
  849. an: $data.errDesc,
  850. ao: $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E"
  851. }, $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E" ? {
  852. ap: common_vendor.f($data.rewardType, (item, index, i0) => {
  853. return {
  854. a: item.value + "",
  855. b: item.value == $data.currentReward,
  856. c: common_vendor.t(item.name),
  857. d: item.value == $data.currentReward ? "#FF5C03" : "",
  858. e: item.value
  859. };
  860. }),
  861. aq: common_vendor.o((...args) => $options.rewardChange && $options.rewardChange(...args))
  862. } : {}, {
  863. ar: $data.errQues && $data.errQues.length > 0
  864. }, $data.errQues && $data.errQues.length > 0 ? {
  865. as: common_vendor.f($data.errQues, (it, index, i0) => {
  866. return {
  867. a: common_vendor.t(it.title),
  868. b: index
  869. };
  870. })
  871. } : {}, {
  872. at: $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E"
  873. }, $data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E" ? {
  874. av: common_vendor.o((...args) => $options.closeAnswerPopup && $options.closeAnswerPopup(...args))
  875. } : {
  876. aw: common_vendor.t($data.remain > 0 ? "\u91CD\u65B0\u7B54\u9898" : "\u786E\u8BA4"),
  877. ax: common_vendor.o((...args) => $options.closeAnswerPopup && $options.closeAnswerPopup(...args)),
  878. ay: $data.errQues && $data.errQues.length > 0 ? "40rpx" : "54rpx"
  879. }, {
  880. az: common_vendor.n($data.errTitle == "\u606D\u559C\u4F60\uFF0C\u56DE\u7B54\u6B63\u786E" ? "answerPopup-box bg" : "answerPopup-box"),
  881. aA: common_vendor.sr("answerPopup", "468b9330-2"),
  882. aB: common_vendor.p({
  883. type: "center",
  884. show: $data.answerPopup
  885. }),
  886. aC: $data.qrcode,
  887. aD: $data.qrcodeMsg,
  888. aE: $data.qrcodeMsg,
  889. aF: $data.baseUrl + "/images/course_close_white_icon.png",
  890. aG: common_vendor.o((...args) => $options.closeKFPop && $options.closeKFPop(...args)),
  891. aH: common_vendor.sr("kfPopup", "468b9330-3"),
  892. aI: common_vendor.p({
  893. type: "center",
  894. ["mask-click"]: false
  895. }),
  896. aJ: $data.videoId
  897. }, $data.videoId ? {
  898. aK: $data.isLogin && $data.isAddKf == 1,
  899. aL: $data.baseUrl + "/images/red_envelope_btnimg.png",
  900. aM: common_vendor.t($data.isLogin && $data.isAddKf == 1 ? "\u63D0\u4EA4\u7B54\u6848\u9886\u53D6\u5956\u52B1" : "\u7ACB\u5373\u5B66\u4E60"),
  901. aN: common_vendor.n($data.isLogin && $data.isAddKf == 1 ? "footer-btn footer-btn-border" : "footer-btn"),
  902. aO: common_vendor.o((...args) => $options.submit && $options.submit(...args))
  903. } : {});
  904. }
  905. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-468b9330"], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_course/video.vue"]]);
  906. wx.createPage(MiniProgramPage);