detail.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444
  1. <template>
  2. <view>
  3. <nav-bar title="课程详情"></nav-bar>
  4. <view class="videoBox">
  5. <!-- <view > -->
  6. <view class="video_box" v-if="!startStatus">
  7. <image
  8. :src="$method.splitImgHost(detail.coverUrl)"
  9. style="width: 100%; height: 450rpx"
  10. ></image>
  11. <image
  12. v-if="false"
  13. class="video_play"
  14. src="/static/play.png"
  15. @click="startVideo"
  16. ></image>
  17. </view>
  18. <view v-else class="video_box" style="width: 100%; height: 450rpx">
  19. <polyv-player
  20. id="playerVideo"
  21. playerId="playerVideo"
  22. height="450rpx"
  23. :vid="vid"
  24. :showSettingBtn="true"
  25. :enablePlayGesture="true"
  26. :playbackRate="playbackRate"
  27. :isAllowSeek="isAllowSeek"
  28. :autoplay="autoplay"
  29. :startTime="startTime"
  30. @statechange="onStateChange"
  31. ></polyv-player>
  32. </view>
  33. <view class="cou_title">
  34. <view class="title_name">
  35. <!-- <view class="yearTag" v-if="detail.year">{{detail.year}}</view> -->
  36. <view class="titleTag">{{ detail.goodsName }}</view>
  37. </view>
  38. <view
  39. style="
  40. display: flex;
  41. justify-content: space-between;
  42. margin-top: 13rpx;
  43. "
  44. >
  45. <view class="prices">
  46. <!-- <text v-if="detail.standPrice" class="price_word">¥ {{ detail.standPrice }}</text>
  47. <text v-else class="price_word free">免费</text> -->
  48. <view
  49. class="price_word"
  50. v-if="
  51. !detail.specTemplateId || (!detail.maxPrice && !detail.minPrice)
  52. "
  53. >
  54. {{ detail.standPrice === 0 ? "免费" : `¥${detail.standPrice}` }}
  55. </view>
  56. <!-- 范围价格 -->
  57. <view v-else class="price_word">
  58. <view>{{ detail.minPrice }}</view>
  59. <template v-if="detail.minPrice != detail.maxPrice">
  60. <text>-</text>
  61. <view>{{ detail.maxPrice }}</view>
  62. </template>
  63. </view>
  64. <text v-if="detail.linePrice" class="sale"> ¥ </text>
  65. <text v-if="detail.linePrice" class="price_line">
  66. {{ detail.linePrice }}</text
  67. >
  68. </view>
  69. <view class="noteTag">
  70. <text class="blackFont"
  71. >{{ courseList.length }} 课程 {{ detail.classHours || "-" }}</text
  72. >
  73. 学时
  74. </view>
  75. </view>
  76. </view>
  77. <!-- </view> -->
  78. </view>
  79. <view class="contents">
  80. <!-- <u-line color="#D6D6DB" /> -->
  81. <!-- <view style="height: 80rpx;">
  82. <view><u-tabs :list="list" :item-width="itemWidth()" font-size="30" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  83. </view> -->
  84. <view class="tabs">
  85. <view
  86. v-for="(item, index) in list"
  87. :key="index"
  88. class="tab_item"
  89. :class="[
  90. list.length == 2 ? 'twoBtn' : list.length == 3 ? 'threeBtn' : '',
  91. { nactive: current == index },
  92. ]"
  93. @click="change(index)"
  94. >{{ item.name }}</view
  95. >
  96. </view>
  97. <view
  98. style="padding: 20rpx; padding-bottom: 100rpx; position: relative"
  99. v-show="current == 0"
  100. >
  101. <view class="content">
  102. <view
  103. v-html="detail.mobileDetailHtml"
  104. style="width: 100%; overflow: hidden"
  105. ></view>
  106. </view>
  107. </view>
  108. <view
  109. style="padding: 20rpx; padding-bottom: 100rpx; position: relative"
  110. v-show="current == 1"
  111. >
  112. <!-- <view v-for="(item, index) in courseItem.courseList" :key="index" > -->
  113. <!-- 视频课 -->
  114. <template v-if="goodsType == 1">
  115. <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
  116. <view v-for="(item, index) in courseItem.courseList" :key="index">
  117. <view class="courseItemBox" v-if="item.show && item.show == 1">
  118. <view class="courseItem" @click="openCourse(item)">
  119. <view class="courseName">{{ item.courseName }}</view>
  120. <view>
  121. <image
  122. src="/static/icon/up.png"
  123. class="icon_up"
  124. v-if="item.down"
  125. ></image>
  126. <image
  127. src="/static/icon/down.png"
  128. class="icon_up"
  129. v-if="!item.down"
  130. ></image>
  131. </view>
  132. </view>
  133. <view
  134. v-if="courseItem.teaList && courseItem.teaList.length > 0"
  135. class="teacher_names"
  136. >
  137. <view
  138. v-for="(tea, tindex) in courseItem.teaList"
  139. :key="tindex"
  140. class="names"
  141. :class="[States[gTindex] == tindex ? 'nactive' : '']"
  142. @click.stop="switchTeacher(tea, tindex, gTindex)"
  143. >
  144. <view>{{ tea.aliasName }}</view>
  145. </view>
  146. </view>
  147. <view v-show="!item.down">
  148. <view v-for="(itemM, indexM) in item.menuList" :key="indexM">
  149. <courseModule
  150. :courseId="itemM.courseId"
  151. :needOpen="
  152. isFirstEnter &&
  153. menuIndex[0] === index &&
  154. menuIndex[1] === indexM
  155. ? true
  156. : false
  157. "
  158. v-if="itemM.type == 1"
  159. :menuItem="itemM"
  160. ></courseModule>
  161. <courseChapter
  162. :courseId="itemM.courseId"
  163. :needOpen="
  164. isFirstEnter &&
  165. menuIndex[0] === index &&
  166. menuIndex[1] === indexM
  167. ? true
  168. : false
  169. "
  170. v-if="itemM.type == 2"
  171. :isBuy="false"
  172. :menuItem="itemM"
  173. ></courseChapter>
  174. <courseSection
  175. :courseId="itemM.courseId"
  176. v-if="itemM.type == 3"
  177. :isBuy="false"
  178. :menuItem="itemM"
  179. ></courseSection>
  180. <u-line></u-line>
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. </template>
  187. <!-- 直播课 -->
  188. <template v-else>
  189. <view v-for="(item, index) in courseList" :key="index">
  190. <view class="courseItemBox">
  191. <view class="courseItem" @click="openCourse(item)">
  192. <view class="courseName">{{ item.courseName }}</view>
  193. <view>
  194. <image
  195. src="/static/icon/up.png"
  196. class="icon_up"
  197. v-if="item.down"
  198. ></image>
  199. <image
  200. src="/static/icon/down.png"
  201. class="icon_up"
  202. v-if="!item.down"
  203. ></image>
  204. </view>
  205. </view>
  206. <view v-show="!item.down">
  207. <view v-for="(itemM, indexM) in item.menuList" :key="indexM">
  208. <courseModule
  209. :courseId="itemM.courseId"
  210. :needOpen="
  211. isFirstEnter &&
  212. menuIndex[0] === index &&
  213. menuIndex[1] === indexM
  214. ? true
  215. : false
  216. "
  217. v-if="itemM.type == 1"
  218. :menuItem="itemM"
  219. ></courseModule>
  220. <courseChapter
  221. :courseId="itemM.courseId"
  222. :needOpen="
  223. isFirstEnter &&
  224. menuIndex[0] === index &&
  225. menuIndex[1] === indexM
  226. ? true
  227. : false
  228. "
  229. v-if="itemM.type == 2"
  230. :isBuy="false"
  231. :menuItem="itemM"
  232. ></courseChapter>
  233. <courseSection
  234. :courseId="itemM.courseId"
  235. v-if="itemM.type == 3"
  236. :isBuy="false"
  237. :menuItem="itemM"
  238. ></courseSection>
  239. <u-line></u-line>
  240. </view>
  241. </view>
  242. </view>
  243. </view>
  244. </template>
  245. </view>
  246. <view
  247. style="padding: 20rpx; padding-bottom: 100rpx; position: relative"
  248. v-show="current == 2"
  249. >
  250. <!-- <view > -->
  251. <view v-for="(item, index) in freeMenuList" :key="index">
  252. <view class="courseItemBox">
  253. <view class="courseItem">
  254. <view class="courseName">{{ item.freeExamName }}</view>
  255. </view>
  256. </view>
  257. </view>
  258. <!-- </view> -->
  259. </view>
  260. </view>
  261. <view class="bottomBox" v-if="!hideBuyState">
  262. <view class="icons">
  263. <view class="icon_item ones">
  264. <image src="/static/index/share.png" class="share"></image>
  265. <button type="default" open-type="share" class="bt_share"></button>
  266. <view class="share_w">分享</view>
  267. </view>
  268. <view class="icon_item">
  269. <image
  270. src="/static/index/shopcar.png"
  271. class="shopcar"
  272. @click="toShopcar()"
  273. ></image>
  274. <view class="share_w">购物车</view>
  275. </view>
  276. </view>
  277. <view style="display: flex; color: #ffffff; align-items: center">
  278. <view class="btn1" @click="addCart()">加购物车</view>
  279. <view class="btn2" @click="buy()">立即购买 </view>
  280. </view>
  281. </view>
  282. <!-- 已购买过课程的弹窗 -->
  283. <u-popup v-model="bugCourseModel" mode="center" border-radius="40">
  284. <view class="had_bugCourse">
  285. <image src="/pages3/static/imgs/hadBug.png" class="share"></image>
  286. <view class="tips">
  287. <view class="warns">温馨提示</view>
  288. <view class="words">您<text>已购买过</text>该商品课程</view>
  289. <view class="words">可立即前往学习</view>
  290. </view>
  291. <view class="tip_botton">
  292. <view class="cancel_btn" @click="changeKown()">知道了</view>
  293. <view class="confirm_btn" @click="toStudy()">去学习</view>
  294. </view>
  295. </view>
  296. </u-popup>
  297. <!-- 选择规格弹窗 -->
  298. <u-popup v-model="toggleSkuShow" mode="bottom" border-radius="40">
  299. <view class="popup_box">
  300. <view class="check_head">
  301. <view class="headers">
  302. <view class="grade">选择规格</view>
  303. <u-icon
  304. name="close"
  305. color="#9C9C9C"
  306. size="40"
  307. @click="closePop()"
  308. ></u-icon>
  309. </view>
  310. </view>
  311. <view class="check_con">
  312. <scroll-view scroll-y="true" style="height: 600rpx">
  313. <view
  314. v-for="(item, index) in specList"
  315. :key="index"
  316. class="check_items"
  317. >
  318. <view class="grades">{{ item.name }}</view>
  319. <view
  320. class="grade_names"
  321. v-if="index == 0 && specList.length > 1"
  322. >
  323. <view
  324. class="course_items"
  325. v-for="(child, c_index) in item.specAttrList"
  326. :key="c_index"
  327. :class="{ nactive: selectGoodIndex == c_index }"
  328. @click="selectGoodType(c_index)"
  329. >
  330. {{ child.name }}
  331. </view>
  332. </view>
  333. <view v-if="index == 1 || specList.length == 1" class="check_box">
  334. <u-checkbox-group>
  335. <view
  336. class="check_box_item"
  337. :class="spec.check ? 'selected' : ''"
  338. v-for="spec in item.specAttrList"
  339. :key="spec.specAttributeId"
  340. >
  341. <u-checkbox
  342. @change="checkboxChange"
  343. v-model="spec.check"
  344. :name="spec.specAttributeId"
  345. >
  346. <view class="price_box">
  347. <view class="check_box_item_titme">{{
  348. spec.name
  349. }}</view>
  350. <view class="price">¥{{ spec.standPrice }}</view>
  351. </view>
  352. </u-checkbox>
  353. </view>
  354. </u-checkbox-group>
  355. </view>
  356. </view>
  357. </scroll-view>
  358. </view>
  359. <view class="confirm_btns">
  360. <view class="allprice">
  361. <view>
  362. 总价:<text>¥</text><text>{{ allPrice }}</text>
  363. </view>
  364. <text>已选择{{ goodsIds.length }}个商品</text>
  365. </view>
  366. <view class="btns">
  367. <view v-if="!goodsIds.length" class="right_now r_disable">{{
  368. isCarOrBuy == 2 ? "立即购买" : "加入购物车"
  369. }}</view>
  370. <view v-else class="right_now" @click="rightNowBuy()"
  371. >{{ isCarOrBuy == 2 ? "立即购买" : "加入购物车" }}
  372. </view>
  373. </view>
  374. </view>
  375. </view>
  376. </u-popup>
  377. </view>
  378. </template>
  379. <script>
  380. import courseModule from "@/components/course/courseModule.vue";
  381. import courseChapter from "@/components/course/courseChapter.vue";
  382. import courseSection from "@/components/course/courseSection.vue";
  383. import { mapGetters, mapMutations } from "vuex";
  384. export default {
  385. components: {
  386. courseModule,
  387. courseChapter,
  388. courseSection,
  389. },
  390. data() {
  391. return {
  392. id: 0,
  393. list: [],
  394. menuIndex: [],
  395. current: 0,
  396. detail: {},
  397. courseList: [],
  398. menuList: [],
  399. freeMenuList: [],
  400. startStatus: false,
  401. playbackRate: [1.0],
  402. isAllowSeek: "no",
  403. vid: "",
  404. autoplay: true,
  405. listenConfigList: [],
  406. listenSecond: 0,
  407. isFirstEnter: true, //是否首次进入
  408. timer: null,
  409. businessData: {},
  410. startTime: 0,
  411. bugCourseModel: false, // 弹窗
  412. hadBuyCourse: {}, // 已购买课程信息
  413. goodsTeacher: [],
  414. teaIndex: 0,
  415. States: { 0: 0 },
  416. goodsType: 1, // 1视频2题库 3补考 4前培 6直播
  417. toggleSkuShow: false,
  418. skuItem: {},
  419. isCarOrBuy: 1, // 1加入购物车 2立即购买
  420. specList: [], // 规格列表
  421. checkedAttrs: [],
  422. selectGoodIndex: 0,
  423. specAttrPriceList: [],
  424. };
  425. },
  426. computed: {
  427. ...mapGetters([
  428. "userInfo",
  429. "goodsAuditionConfigIdList",
  430. "playSectionId",
  431. "hideBuyState",
  432. ]),
  433. allPrice() {
  434. if (!this.specList.length) return 0;
  435. let allPrice = this.specList.slice(-1)[0].specAttrList.reduce((a, b) => {
  436. if (b.check) {
  437. return a + b.standPrice;
  438. }
  439. return a;
  440. }, 0);
  441. return this.toFixed(allPrice);
  442. },
  443. goodsIds() {
  444. if (!this.specList.length) return [];
  445. return this.specList
  446. .slice(-1)[0]
  447. .specAttrList.filter((e) => e.check)
  448. .map((e) => e.goodsId);
  449. },
  450. isSingleChoice() {
  451. if (!this.specAttrPriceList.length) {
  452. return false;
  453. }
  454. return this.specAttrPriceList[0].specialGoods;
  455. },
  456. },
  457. onLoad(option) {
  458. if (option.scene) {
  459. // scene 生成二维码扫码进来的
  460. let optObj = {};
  461. let arrs = decodeURIComponent(option.scene).split("&");
  462. for (let i = 0; i < arrs.length; i++) {
  463. optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
  464. }
  465. // console.log('optObj:', optObj);
  466. this.id = optObj.id;
  467. this.goodsType = optObj.goodsType;
  468. console.log("optObj.sc:", optObj.sc);
  469. uni.setStorageSync("newUser_sc", optObj.sc);
  470. } else {
  471. // 小程序正常跳转的
  472. // this.id => goodsId
  473. this.id = option.id;
  474. this.goodsType = option.goodsType;
  475. }
  476. this.getDetail();
  477. this.goodsCourseList();
  478. this.appCommonGoodsCourseModuleFreeExamList();
  479. this.getIsBuy(); // 判断是否已经购买过该课程
  480. wx.showShareMenu({
  481. withShareTicket: true,
  482. menus: ["shareAppMessage", "shareTimeline"],
  483. });
  484. },
  485. onUnload(option) {
  486. this.$store.commit("setPlaySectionId", { playSectionId: 0 });
  487. //移除所有的事件监听器
  488. uni.$off();
  489. },
  490. // 分享到朋友圈
  491. onShareTimeline() {
  492. return {
  493. title: this.detail.goodsName,
  494. query: "id=" + this.id,
  495. imageUrl: this.$method.splitImgHost(this.detail.coverUrl),
  496. };
  497. },
  498. // 分享给朋友
  499. onShareAppMessage() {
  500. return {
  501. title: this.detail.goodsName,
  502. path:
  503. `/pages3/course/detail?id=` + this.id + "&goodsType=" + this.goodsType,
  504. imageUrl: this.$method.splitImgHost(this.detail.coverUrl),
  505. };
  506. },
  507. mounted() {
  508. let self = this;
  509. uni.$on("getSection", (item) => {
  510. //播放试听
  511. self.listenSecond = 0;
  512. for (var itemChild of self.listenConfigList) {
  513. if (
  514. self.playSectionId == (itemChild.sectionId || itemChild.menuId) &&
  515. item.courseId == itemChild.courseId
  516. ) {
  517. if (itemChild.auditionMinute > 0) {
  518. // self.listenSecond = itemChild.auditionMinute *60 //试听秒数
  519. self.listenSecond = itemChild.auditionMinute; //试听秒数 auditionMinute调整为秒单位
  520. }
  521. }
  522. }
  523. if (self.listenSecond > 0) {
  524. if (self.timer) {
  525. clearInterval(self.timer);
  526. }
  527. if (self.vid) {
  528. //切换视频
  529. var polyvPlayerContext = self.selectComponent("#playerVideo");
  530. polyvPlayerContext.changeVid(item.recordingUrl);
  531. } else {
  532. self.vid = item.recordingUrl;
  533. }
  534. self.startStatus = true;
  535. self.startTime = 0;
  536. } else {
  537. self.$u.toast("试听配置错误");
  538. }
  539. });
  540. this.updateChapterOpen(true);
  541. },
  542. methods: {
  543. ...mapMutations(["updateChapterOpen"]),
  544. itemWidth() {
  545. return 100 / this.list.length + "%";
  546. },
  547. appCommonGoodsCourseModuleFreeExamList() {
  548. // url: '/app/common/goods/course/moduleFreeExamList/'+data,
  549. this.$api.appCommonGoodsCourseModuleFreeExamList(this.id).then((res) => {
  550. if (res.data.data.length) {
  551. this.freeMenuList = res.data.data;
  552. this.list = [
  553. {
  554. name: "课程介绍",
  555. },
  556. {
  557. name: "课程目录",
  558. },
  559. {
  560. name: "赠送",
  561. },
  562. ];
  563. } else {
  564. this.list = [
  565. {
  566. name: "课程介绍",
  567. },
  568. {
  569. name: "课程目录",
  570. },
  571. ];
  572. }
  573. console.log(this.list);
  574. });
  575. },
  576. selectGoodType(index) {
  577. if (index == this.selectGoodIndex) {
  578. return;
  579. }
  580. this.selectGoodIndex = index;
  581. this.changeData();
  582. },
  583. select(val) {
  584. val.check = !val.check;
  585. console.log(val, 6666);
  586. },
  587. checkboxChange(val) {
  588. if (!this.isSingleChoice) return;
  589. this.specList.slice(-1)[0].specAttrList.forEach((ele) => {
  590. if (val.name != ele.specAttributeId) {
  591. ele.check = false;
  592. }
  593. });
  594. },
  595. courseBusiness() {
  596. // url: '/app/common/course/business/'+data,
  597. this.$api.courseBusiness(this.detail.businessId).then((res) => {
  598. this.businessData = res.data.data;
  599. });
  600. },
  601. toFixed(number) {
  602. if (number > 0) {
  603. return number.toFixed(2);
  604. } else {
  605. return "0.00";
  606. }
  607. },
  608. onStateChange(newstate, oldstate) {
  609. if (newstate.detail.newstate == "playing") {
  610. //开始播放
  611. if (this.timer) {
  612. clearInterval(this.timer);
  613. }
  614. this.timer = setInterval(this.timeEvent, 1500); //定时器
  615. }
  616. },
  617. closePlay() {
  618. this.$store.commit("setPlaySectionId", { playSectionId: 0 });
  619. this.vid = "";
  620. this.startStatus = false;
  621. },
  622. timeEvent() {
  623. let self = this;
  624. var polyvPlayerContext = this.selectComponent("#playerVideo");
  625. if (polyvPlayerContext != null) {
  626. let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
  627. if (PlayCurrentTime >= this.listenSecond) {
  628. polyvPlayerContext.stop();
  629. polyvPlayerContext.exitFullScreen();
  630. clearInterval(this.timer);
  631. this.timer = null;
  632. uni.showModal({
  633. title: "提示",
  634. content: "试听结束,购买课程可学习全部",
  635. showCancel: false,
  636. success: function (resst) {
  637. self.closePlay();
  638. },
  639. });
  640. }
  641. }
  642. },
  643. openCourse(item) {
  644. item.down = !item.down;
  645. if (!item.down && item.menuList.length == 0) {
  646. this.getMenuList(item);
  647. }
  648. },
  649. addShopCart(goodsIds) {
  650. if (!Array.isArray(goodsIds)) {
  651. goodsIds = [goodsIds];
  652. }
  653. this.$api.addCart({ goodsIds: goodsIds }).then((res) => {
  654. if (res.data.code == 200) {
  655. uni.setStorageSync("updateCart", 1); //提醒刷新购物车
  656. uni.showToast({
  657. title: "添加成功",
  658. });
  659. } else {
  660. this.$u.toast(res.data.msg);
  661. }
  662. });
  663. },
  664. goodsCourseList() {
  665. // url: '/app/common/goods/course/list/'+ data,
  666. this.$api.goodsCourseList(this.id).then((res) => {
  667. if (res.data.code == 200) {
  668. for (let i = 0; i < res.data.rows.length; i++) {
  669. let item = res.data.rows[i];
  670. item.down = true;
  671. item.menuList = [];
  672. }
  673. this.courseList = res.data.rows;
  674. this.getFirstCourse();
  675. // 不同
  676. if (this.goodsType == 1) {
  677. this.getCourseTeacher(res.data.rows);
  678. }
  679. }
  680. });
  681. },
  682. /**
  683. * 获取第一个有模块或者章的课程
  684. */
  685. async getFirstCourse() {
  686. for (let i = 0; i < this.courseList.length; i++) {
  687. let menuIndexOrFalse = await this.getCourseMenus(this.courseList[i]);
  688. if (menuIndexOrFalse !== false) {
  689. this.menuIndex = [i, menuIndexOrFalse];
  690. this.openCourse(this.courseList[i]);
  691. break;
  692. }
  693. }
  694. },
  695. getCourseMenus(item) {
  696. return new Promise((resolve) => {
  697. // url: '/app/common/course/menuList',
  698. this.$api.menuList({ courseId: item.courseId }).then((res) => {
  699. if (res.data.code == 200) {
  700. for (let i = 0; i < res.data.rows.length; i++) {
  701. if (res.data.rows[i].type == 1 || res.data.rows[i].type == 2) {
  702. resolve(i);
  703. break;
  704. }
  705. }
  706. }
  707. });
  708. });
  709. },
  710. getCourseTeacher(rows) {
  711. //获取商品双师资模板
  712. this.$api
  713. .getGoodsCourseTeacher({
  714. goodsId: this.id,
  715. })
  716. .then((res1) => {
  717. // console.log(res1,'res1');
  718. if (res1.data.data && res1.data.data.length > 0) {
  719. //课程老师模板
  720. let teacherTel = res1.data.data;
  721. //商品课程
  722. let courses = rows;
  723. teacherTel.forEach((tea) => {
  724. let dataList = [];
  725. let teacherList = [];
  726. courses.forEach((item) => {
  727. let data = tea.courseList.filter(
  728. (x) => x.courseId == item.courseId
  729. );
  730. if (data && data.length > 0) {
  731. dataList.push(item);
  732. teacherList = tea.courseList;
  733. }
  734. });
  735. let result = {
  736. teaList: teacherList,
  737. courseList: dataList,
  738. };
  739. this.goodsTeacher.push(result);
  740. });
  741. if (this.goodsTeacher && this.goodsTeacher.length > 0) {
  742. let courseIds = [];
  743. this.goodsTeacher.forEach((item) => {
  744. item.courseList.forEach((course) => {
  745. courseIds.push(course.courseId);
  746. });
  747. });
  748. if (courseIds.length > 0) {
  749. courses.forEach((item) => {
  750. if (!courseIds.includes(item.courseId)) {
  751. let data = {
  752. teaList: [],
  753. courseList: [],
  754. };
  755. data.courseList.push(item);
  756. this.goodsTeacher.push(data);
  757. }
  758. });
  759. }
  760. this.goodsTeacher.forEach((item) => {
  761. if (item.courseList && item.courseList.length > 0) {
  762. item.courseList[0].show = 1;
  763. }
  764. });
  765. }
  766. } else {
  767. //没有双师资模板
  768. rows.forEach((item) => {
  769. item.show = 1;
  770. let data = {
  771. teaList: [],
  772. courseList: [],
  773. };
  774. data.courseList.push(item);
  775. this.goodsTeacher.push(data);
  776. });
  777. }
  778. });
  779. console.log(this.goodsTeacher, "this.goodsTeacher");
  780. },
  781. //切换老师
  782. switchTeacher(data, tindex, gTindex) {
  783. // console.log(data,'data');
  784. this.States[gTindex] = tindex;
  785. this.teaIndex = tindex;
  786. this.goodsTeacher.forEach((item, index) => {
  787. if (item.teaList && item.teaList.length > 0) {
  788. let list = item.teaList.filter((x) => x.courseId == data.courseId);
  789. if (list && list.length > 0) {
  790. item.courseList.forEach((course, courseIndex) => {
  791. if (course.courseId == data.courseId) {
  792. this.$set(
  793. this.goodsTeacher[index].courseList[courseIndex],
  794. "show",
  795. 1
  796. );
  797. } else {
  798. this.$set(
  799. this.goodsTeacher[index].courseList[courseIndex],
  800. "show",
  801. 0
  802. );
  803. }
  804. });
  805. }
  806. }
  807. });
  808. console.log("切换后的this.goodsTeacher, ", this.goodsTeacher);
  809. },
  810. getMenuList(item) {
  811. let self = this;
  812. this.$api.menuList({ courseId: item.courseId }).then((res) => {
  813. if (res.data.code == 200) {
  814. for (let i = 0; i < res.data.rows.length; i++) {
  815. let item = res.data.rows[i];
  816. item.down = true;
  817. item.id = item.menuId;
  818. item.name = item.menuName;
  819. if (item.type == 3) {
  820. //判断是否试听
  821. item.tryListen = false;
  822. if (self.goodsAuditionConfigIdList.indexOf(item.id) !== -1) {
  823. item.tryListen = true;
  824. }
  825. }
  826. }
  827. item.menuList = res.data.rows;
  828. }
  829. });
  830. },
  831. // 获取课程详情
  832. getDetail() {
  833. let self = this;
  834. let sectionIdList = [];
  835. // /app/common/goods/+data
  836. this.$api.commonGoodsDetail(this.id).then((res) => {
  837. if (res.data.code == 200) {
  838. if (res.data.data) {
  839. if (res.data.data.mobileDetailHtml) {
  840. res.data.data.mobileDetailHtml =
  841. res.data.data.mobileDetailHtml.replace(
  842. /<img/gi,
  843. '<img style="max-width:100%;"'
  844. );
  845. }
  846. self.detail = res.data.data;
  847. this.courseBusiness();
  848. if (self.detail.goodsAuditionConfig) {
  849. self.listenConfigList = JSON.parse(
  850. self.detail.goodsAuditionConfig
  851. );
  852. for (var itemChild of self.listenConfigList) {
  853. sectionIdList.push(itemChild.sectionId); //存储试听节ID
  854. }
  855. self.$store.commit("setGoodsAuditionConfigIdList", {
  856. goodsAuditionConfigIdList: sectionIdList,
  857. });
  858. }
  859. }
  860. }
  861. });
  862. },
  863. buy() {
  864. if (this.$method.isGoLogin()) {
  865. return;
  866. }
  867. // 判断有没有规格选择
  868. if (this.detail.specTemplateId) {
  869. this.isCarOrBuy = 2;
  870. this.getSpecDetail();
  871. return;
  872. }
  873. this.$navTo.togo("/pages2/order/confirm_list?id=" + this.id);
  874. },
  875. addCart() {
  876. if (this.$method.isGoLogin()) {
  877. return;
  878. }
  879. // 判断有没有规格选择
  880. if (this.detail.specTemplateId) {
  881. this.isCarOrBuy = 1;
  882. this.getSpecDetail();
  883. return;
  884. }
  885. this.addShopCart(this.id);
  886. },
  887. getSpecDetail() {
  888. // || 35
  889. this.checkedAttrs = [];
  890. this.$http({
  891. url: `/app/common/spec/${this.detail.specTemplateId}`,
  892. method: "get",
  893. noToken: true,
  894. }).then((res) => {
  895. let data = res.data.data;
  896. console.log(data, "data");
  897. if (data) {
  898. this.toggleSkuShow = true;
  899. this.specAttrPriceList = data.specAttrPriceList;
  900. this.specList = this.changeData(data.specList || []);
  901. } else {
  902. if (this.isCarOrBuy == 1) {
  903. // 加入购物车
  904. this.addShopCart(this.id);
  905. } else {
  906. this.$navTo.togo("/pages2/order/confirm_list?id=" + this.id);
  907. }
  908. this.closePop();
  909. }
  910. });
  911. },
  912. changeData(data = this.specList) {
  913. let len = data.length;
  914. if (!len) return [];
  915. data[len - 1].specAttrList.forEach((e, i) => {
  916. e.check = e.check || false;
  917. let id = e.specAttributeId;
  918. if (len > 1) {
  919. id =
  920. data[0].specAttrList[this.selectGoodIndex].specAttributeId +
  921. "," +
  922. id;
  923. }
  924. let item = this.specAttrPriceList.find((e) => e.specAttrIds == id);
  925. if (item) {
  926. e.standPrice = item.standPrice;
  927. e.goodsId = item.goodsId;
  928. }
  929. });
  930. // data.forEach((item, index) => {
  931. // if (index == len - 1) {
  932. // item.specAttrList.forEach((e, i) => {
  933. // e.check = false
  934. // })
  935. // }
  936. // })
  937. return data;
  938. },
  939. change(index) {
  940. this.current = index;
  941. },
  942. toShopcar() {
  943. uni.navigateTo({
  944. url: "/pages4/shopping/shoppingCart",
  945. });
  946. },
  947. getIsBuy() {
  948. this.$http({
  949. url: "/order/buyGoodsNotExpired",
  950. method: "get",
  951. data: { goodsId: this.id },
  952. }).then((res) => {
  953. if (res.data.code == 200) {
  954. if (res.data.data) {
  955. // 有data返回是已经购买过的课程
  956. this.hadBuyCourse = res.data.data;
  957. this.bugCourseModel = true;
  958. }
  959. }
  960. });
  961. },
  962. changeKown() {
  963. this.bugCourseModel = false;
  964. },
  965. async toStudy() {
  966. let item = this.hadBuyCourse;
  967. if (item.goodsType == 6) {
  968. // 进入直播课
  969. this.toLive(item);
  970. return;
  971. }
  972. // /course/goodsRebuildStatus查询用户商品重修状态
  973. let rebuildStatus = await this.courseGoodsRebuildStatus(
  974. item.goodsId,
  975. item.gradeId
  976. );
  977. if (rebuildStatus == 0) {
  978. this.$navTo.togo("/pages2/learn/details", {
  979. gradeId: item.gradeId,
  980. goodsId: item.goodsId,
  981. orderGoodsId: item.orderGoodsId,
  982. });
  983. return;
  984. }
  985. // /lock/lockStatus
  986. this.$api
  987. .lockLockStatus({
  988. action: "jxjy",
  989. uuid: this.$method.getUuid(),
  990. })
  991. .then((res) => {
  992. if (res.data.code == 200) {
  993. //有其他端在操作,不能学习
  994. uni.showToast({
  995. icon: "none",
  996. title: res.data.msg,
  997. mask: true,
  998. duration: 3000,
  999. });
  1000. } else if (res.data.code == 500) {
  1001. //可以学习
  1002. this.$http({
  1003. url: "/course/courseList",
  1004. method: "get",
  1005. data: {
  1006. pageNum: 1,
  1007. pageSize: 1,
  1008. goodsId: item.goodsId,
  1009. gradeId: item.gradeId,
  1010. orderGoodsId: item.orderGoodsId,
  1011. },
  1012. }).then((res) => {
  1013. if (res.data.code == 200) {
  1014. if (res.data.total > 1) {
  1015. // this.$navTo.togo(`/pages2/wd/course?id=${item.goodsId}&gid=${item.gradeId}&orderGoodsId=${item.orderGoodsId}`);
  1016. uni.navigateTo({
  1017. url: `/pages3/polyv/detail?id=''&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`,
  1018. });
  1019. } else if (res.data.total == 1) {
  1020. uni.navigateTo({
  1021. url: `/pages3/polyv/detail?id=${res.data.rows[0].courseId}&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`,
  1022. });
  1023. } else {
  1024. uni.showToast({
  1025. icon: "none",
  1026. title: "暂无可观看的视频课程",
  1027. });
  1028. }
  1029. }
  1030. });
  1031. }
  1032. });
  1033. },
  1034. toLive(item) {
  1035. this.$api
  1036. .courseCourseList({
  1037. pageNum: 1,
  1038. pageSize: 1,
  1039. goodsId: item.goodsId,
  1040. gradeId: 0,
  1041. orderGoodsId: item.orderGoodsId,
  1042. })
  1043. .then((res) => {
  1044. if (res.data.code == 200) {
  1045. if (res.data.total > 1) {
  1046. // uni.navigateTo({
  1047. // url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
  1048. // })
  1049. uni.navigateTo({
  1050. url:
  1051. "/pages3/live/detail?orderGoodsId=" +
  1052. item.orderGoodsId +
  1053. "&goodsId=" +
  1054. item.goodsId +
  1055. '&gradeId=0&courseId=""',
  1056. });
  1057. } else if (res.data.total == 1) {
  1058. uni.navigateTo({
  1059. url:
  1060. "/pages3/live/detail?orderGoodsId=" +
  1061. item.orderGoodsId +
  1062. "&goodsId=" +
  1063. item.goodsId +
  1064. "&gradeId=0&courseId=" +
  1065. res.data.rows[0].courseId,
  1066. });
  1067. } else {
  1068. uni.showToast({
  1069. icon: "none",
  1070. title: "暂无可观看的直播课程",
  1071. });
  1072. }
  1073. }
  1074. });
  1075. },
  1076. /**
  1077. * @param {Object} goodsId 商品id
  1078. * 查询商品重修状态
  1079. */
  1080. courseGoodsRebuildStatus(goodsId, gradeId) {
  1081. return new Promise((resolve) => {
  1082. this.$http({
  1083. url: "/course/goodsRebuildStatus",
  1084. method: "get",
  1085. data: {
  1086. goodsId: goodsId,
  1087. gradeId: gradeId,
  1088. },
  1089. // noLoading: true,
  1090. // compleLoading: true, // 请求成功是否还要继续显示加载中
  1091. }).then((res) => {
  1092. resolve(res.data.data);
  1093. });
  1094. });
  1095. },
  1096. closePop() {
  1097. this.toggleSkuShow = false;
  1098. this.skuItem = {};
  1099. },
  1100. // 获取规格属性值对应的商品信息
  1101. getGoodsInfos(specAttrIds) {
  1102. this.$http({
  1103. url: "/app/common/attr/goods",
  1104. method: "get",
  1105. data: {
  1106. specTemplateId: this.detail.specTemplateId,
  1107. specAttrIds: specAttrIds.join(","),
  1108. },
  1109. noToken: true,
  1110. }).then((res) => {
  1111. if (res.data.code == 200) {
  1112. this.skuItem = res.data.data || {};
  1113. } else {
  1114. this.skuItem = {};
  1115. this.$u.toast("商品已下架, 请重新选择");
  1116. }
  1117. });
  1118. },
  1119. rightNowBuy() {
  1120. let goodsIds = [...new Set(this.goodsIds)];
  1121. this.$api.checkGoodsStatus({ goodsIds }).then((res) => {
  1122. if (res.data.code == 500) {
  1123. return this.$u.toast(res.data.msg);
  1124. }
  1125. if (this.isCarOrBuy == 1) {
  1126. // 加入购物车
  1127. this.addShopCart(goodsIds);
  1128. } else {
  1129. if (this.isSingleChoice) {
  1130. this.$navTo.togo("/pages2/order/confirm_list?id=" + goodsIds);
  1131. } else {
  1132. let data = [];
  1133. goodsIds.forEach((id) => {
  1134. data.push(this.specAttrPriceList.find((e) => e.goodsId == id));
  1135. });
  1136. this.$store.commit("setShoppingCartList", {
  1137. shoppingCartList: data,
  1138. });
  1139. this.$navTo.togo("/pages2/order/confirm_pay");
  1140. }
  1141. }
  1142. this.closePop();
  1143. });
  1144. },
  1145. },
  1146. };
  1147. </script>
  1148. <style >
  1149. page {
  1150. background-color: #f2f2f2;
  1151. }
  1152. </style>
  1153. <style lang="scss" scope>
  1154. @import "./index.scss";
  1155. .video_t2 {
  1156. font-size: 24rpx;
  1157. font-family: PingFang SC;
  1158. font-weight: 500;
  1159. color: #666666;
  1160. }
  1161. .video_t1 {
  1162. height: 80rpx;
  1163. color: #333333;
  1164. line-height: 80rpx;
  1165. font-size: 30rpx;
  1166. font-family: PingFang SC;
  1167. font-weight: bold;
  1168. color: #333333;
  1169. overflow: hidden;
  1170. text-overflow: ellipsis;
  1171. white-space: nowrap;
  1172. }
  1173. .video_t1_t {
  1174. display: flex;
  1175. flex-direction: column;
  1176. height: 80rpx;
  1177. color: #333333;
  1178. text-align: center;
  1179. align-items: center;
  1180. border-left: solid 1px #d6d6db;
  1181. }
  1182. .video_play {
  1183. position: absolute;
  1184. width: 95rpx;
  1185. height: 95rpx;
  1186. top: 0;
  1187. left: 0;
  1188. right: 0;
  1189. bottom: 0;
  1190. margin: auto;
  1191. }
  1192. .video_box {
  1193. position: relative;
  1194. }
  1195. .contents {
  1196. width: 100%;
  1197. height: 100%;
  1198. background-color: #ffffff;
  1199. margin-top: 16rpx;
  1200. overflow: hidden;
  1201. }
  1202. .cou_title {
  1203. padding: 24rpx 32rpx 40rpx 32rpx;
  1204. display: flex;
  1205. flex-direction: column;
  1206. justify-content: space-around;
  1207. }
  1208. .prices {
  1209. .price_word {
  1210. display: flex;
  1211. font-size: 44rpx;
  1212. font-weight: 800;
  1213. color: #fc3f3f;
  1214. margin-bottom: 8rpx;
  1215. view::before {
  1216. content: "¥";
  1217. font-size: 26rpx;
  1218. font-weight: bold;
  1219. }
  1220. }
  1221. .sale {
  1222. color: #999999;
  1223. font-size: 28rpx;
  1224. margin-left: 8rpx;
  1225. }
  1226. .price_line {
  1227. color: #999999;
  1228. font-size: 28rpx;
  1229. text-decoration: line-through;
  1230. font-weight: 400;
  1231. }
  1232. .free {
  1233. font-size: 32rpx;
  1234. }
  1235. }
  1236. // tab
  1237. .tabs {
  1238. // width: 100%;
  1239. height: 78rpx;
  1240. display: flex;
  1241. align-items: center;
  1242. justify-content: space-between;
  1243. background-color: #f2f7ff;
  1244. border-radius: 38rpx;
  1245. margin: 24rpx;
  1246. padding: 0rpx 5rpx;
  1247. .tab_item {
  1248. width: 345rpx;
  1249. height: 65rpx;
  1250. line-height: 65rpx;
  1251. font-size: 28rpx;
  1252. font-weight: bold;
  1253. border-radius: 32rpx;
  1254. text-align: center;
  1255. color: #333;
  1256. &.nactive {
  1257. color: #fff;
  1258. background-color: #3577e8;
  1259. }
  1260. &.twoBtn {
  1261. width: 50%;
  1262. }
  1263. &.threeBtn {
  1264. width: 33%;
  1265. }
  1266. }
  1267. // /deep/ .u-tabs {
  1268. // background:none!important;
  1269. // }
  1270. }
  1271. .courseName {
  1272. white-space: nowrap;
  1273. overflow: hidden;
  1274. text-overflow: ellipsis;
  1275. }
  1276. .videoBox {
  1277. background-color: #ffffff;
  1278. width: 100%;
  1279. /* height: 680rpx; */
  1280. z-index: 999;
  1281. }
  1282. .icon_up {
  1283. width: 32rpx;
  1284. height: 32rpx;
  1285. }
  1286. .courseItemBox {
  1287. background: #ffffff;
  1288. border-radius: 16rpx;
  1289. padding: 0 10rpx;
  1290. margin-bottom: 20rpx;
  1291. }
  1292. .courseItem {
  1293. height: 80rpx;
  1294. color: #333333;
  1295. font-size: 32rpx;
  1296. line-height: 80rpx;
  1297. font-weight: bold;
  1298. display: flex;
  1299. justify-content: space-between;
  1300. }
  1301. .content {
  1302. background-color: #ffffff;
  1303. width: 100%;
  1304. }
  1305. .btn2 {
  1306. width: 187rpx;
  1307. height: 79rpx;
  1308. line-height: 79rpx;
  1309. background: #fc3f3f;
  1310. border-radius: 40rpx;
  1311. text-align: center;
  1312. font-size: 24rpx;
  1313. }
  1314. .btn1 {
  1315. width: 187rpx;
  1316. height: 79rpx;
  1317. line-height: 79rpx;
  1318. background: #ffb102;
  1319. border-radius: 40rpx;
  1320. text-align: center;
  1321. margin-right: 11rpx;
  1322. font-size: 24rpx;
  1323. }
  1324. .wk_icon {
  1325. width: 24rpx;
  1326. height: 24rpx;
  1327. margin-right: 12rpx;
  1328. }
  1329. .noteTag,
  1330. .blackFont {
  1331. font-size: 26rpx;
  1332. font-family: PingFang SC;
  1333. font-weight: 400;
  1334. color: #999999;
  1335. align-items: center;
  1336. margin: 0 4rpx;
  1337. line-height: 60rpx;
  1338. }
  1339. .priceTag {
  1340. /* font-size: 30rpx;
  1341. font-family: PingFang SC;
  1342. font-weight: bold;
  1343. color: #FF2D55; */
  1344. width: 60rpx;
  1345. height: 40rpx;
  1346. line-height: 40rpx;
  1347. text-align: center;
  1348. border: 1rpx solid #333;
  1349. }
  1350. .titleTag {
  1351. font-size: 32rpx;
  1352. font-weight: bold;
  1353. color: #333333;
  1354. // margin-left: 8rpx;
  1355. }
  1356. .yearTag {
  1357. width: 80rpx;
  1358. height: 32rpx;
  1359. background: #ebf5ff;
  1360. border: 2rpx solid #007aff;
  1361. border-radius: 16rpx;
  1362. font-size: 24rpx;
  1363. color: #007aff;
  1364. text-align: center;
  1365. line-height: 32rpx;
  1366. }
  1367. .itemBox {
  1368. background: #ffffff;
  1369. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1370. border-radius: 24rpx;
  1371. width: 100%;
  1372. padding: 20rpx;
  1373. margin-bottom: 20rpx;
  1374. }
  1375. // 老师名字样式
  1376. .teacher_names {
  1377. display: flex;
  1378. padding-bottom: 15rpx;
  1379. border-bottom: 2rpx solid #f0f0f0;
  1380. .names {
  1381. padding: 6rpx 12rpx;
  1382. font-size: 26rpx;
  1383. color: #969696;
  1384. background: #f8f8f8;
  1385. border-radius: 8rpx;
  1386. margin-right: 10rpx;
  1387. &.nactive {
  1388. color: #3f8dfd;
  1389. background: #f2f7ff;
  1390. }
  1391. }
  1392. }
  1393. </style>