detail.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  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);
  469. uni.setStorageSync("newUser_sc", optObj.sc);
  470. uni.setStorageSync("shareActivityCode", optObj.shareActivityCode)
  471. } else {
  472. // 小程序正常跳转的
  473. // this.id => goodsId
  474. this.id = option.id;
  475. this.goodsType = option.goodsType;
  476. if (option.shareActivityCode) {
  477. uni.setStorageSync("shareActivityCode", option.shareActivityCode)
  478. }
  479. }
  480. this.getDetail();
  481. this.goodsCourseList();
  482. this.appCommonGoodsCourseModuleFreeExamList();
  483. this.getIsBuy(); // 判断是否已经购买过该课程
  484. wx.showShareMenu({
  485. withShareTicket: true,
  486. menus: ["shareAppMessage", "shareTimeline"],
  487. });
  488. },
  489. onUnload(option) {
  490. this.$store.commit("setPlaySectionId", { playSectionId: 0 });
  491. //移除所有的事件监听器
  492. uni.$off();
  493. },
  494. // 分享到朋友圈
  495. onShareTimeline() {
  496. return {
  497. title: this.detail.goodsName,
  498. query: "id=" + this.id,
  499. imageUrl: this.$method.splitImgHost(this.detail.coverUrl),
  500. };
  501. },
  502. // 分享给朋友
  503. onShareAppMessage() {
  504. return {
  505. title: this.detail.goodsName,
  506. path:
  507. `/pages3/course/detail?id=` + this.id + "&goodsType=" + this.goodsType,
  508. imageUrl: this.$method.splitImgHost(this.detail.coverUrl),
  509. };
  510. },
  511. mounted() {
  512. let self = this;
  513. uni.$on("getSection", (item) => {
  514. //播放试听
  515. self.listenSecond = 0;
  516. for (var itemChild of self.listenConfigList) {
  517. if (
  518. self.playSectionId == (itemChild.sectionId || itemChild.menuId) &&
  519. item.courseId == itemChild.courseId
  520. ) {
  521. if (itemChild.auditionMinute > 0) {
  522. // self.listenSecond = itemChild.auditionMinute *60 //试听秒数
  523. self.listenSecond = itemChild.auditionMinute; //试听秒数 auditionMinute调整为秒单位
  524. }
  525. }
  526. }
  527. if (self.listenSecond > 0) {
  528. if (self.timer) {
  529. clearInterval(self.timer);
  530. }
  531. if (self.vid) {
  532. //切换视频
  533. var polyvPlayerContext = self.selectComponent("#playerVideo");
  534. polyvPlayerContext.changeVid(item.recordingUrl);
  535. } else {
  536. self.vid = item.recordingUrl;
  537. }
  538. self.startStatus = true;
  539. self.startTime = 0;
  540. } else {
  541. self.$u.toast("试听配置错误");
  542. }
  543. });
  544. this.updateChapterOpen(true);
  545. },
  546. methods: {
  547. ...mapMutations(["updateChapterOpen"]),
  548. itemWidth() {
  549. return 100 / this.list.length + "%";
  550. },
  551. appCommonGoodsCourseModuleFreeExamList() {
  552. // url: '/app/common/goods/course/moduleFreeExamList/'+data,
  553. this.$api.appCommonGoodsCourseModuleFreeExamList(this.id).then((res) => {
  554. if (res.data.data.length) {
  555. this.freeMenuList = res.data.data;
  556. this.list = [
  557. {
  558. name: "课程介绍",
  559. },
  560. {
  561. name: "课程目录",
  562. },
  563. {
  564. name: "赠送",
  565. },
  566. ];
  567. } else {
  568. this.list = [
  569. {
  570. name: "课程介绍",
  571. },
  572. {
  573. name: "课程目录",
  574. },
  575. ];
  576. }
  577. console.log(this.list);
  578. });
  579. },
  580. selectGoodType(index) {
  581. if (index == this.selectGoodIndex) {
  582. return;
  583. }
  584. this.selectGoodIndex = index;
  585. this.changeData();
  586. },
  587. select(val) {
  588. val.check = !val.check;
  589. console.log(val, 6666);
  590. },
  591. checkboxChange(val) {
  592. if (!this.isSingleChoice) return;
  593. this.specList.slice(-1)[0].specAttrList.forEach((ele) => {
  594. if (val.name != ele.specAttributeId) {
  595. ele.check = false;
  596. }
  597. });
  598. },
  599. courseBusiness() {
  600. // url: '/app/common/course/business/'+data,
  601. this.$api.courseBusiness(this.detail.businessId).then((res) => {
  602. this.businessData = res.data.data;
  603. });
  604. },
  605. toFixed(number) {
  606. if (number > 0) {
  607. return number.toFixed(2);
  608. } else {
  609. return "0.00";
  610. }
  611. },
  612. onStateChange(newstate, oldstate) {
  613. if (newstate.detail.newstate == "playing") {
  614. //开始播放
  615. if (this.timer) {
  616. clearInterval(this.timer);
  617. }
  618. this.timer = setInterval(this.timeEvent, 1500); //定时器
  619. }
  620. },
  621. closePlay() {
  622. this.$store.commit("setPlaySectionId", { playSectionId: 0 });
  623. this.vid = "";
  624. this.startStatus = false;
  625. },
  626. timeEvent() {
  627. let self = this;
  628. var polyvPlayerContext = this.selectComponent("#playerVideo");
  629. if (polyvPlayerContext != null) {
  630. let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
  631. if (PlayCurrentTime >= this.listenSecond) {
  632. polyvPlayerContext.stop();
  633. polyvPlayerContext.exitFullScreen();
  634. clearInterval(this.timer);
  635. this.timer = null;
  636. uni.showModal({
  637. title: "提示",
  638. content: "试听结束,购买课程可学习全部",
  639. showCancel: false,
  640. success: function (resst) {
  641. self.closePlay();
  642. },
  643. });
  644. }
  645. }
  646. },
  647. openCourse(item) {
  648. item.down = !item.down;
  649. if (!item.down && item.menuList.length == 0) {
  650. this.getMenuList(item);
  651. }
  652. },
  653. addShopCart(goodsIds) {
  654. if (!Array.isArray(goodsIds)) {
  655. goodsIds = [goodsIds];
  656. }
  657. this.$api.addCart({ goodsIds: goodsIds }).then((res) => {
  658. if (res.data.code == 200) {
  659. uni.setStorageSync("updateCart", 1); //提醒刷新购物车
  660. uni.showToast({
  661. title: "添加成功",
  662. });
  663. } else {
  664. this.$u.toast(res.data.msg);
  665. }
  666. });
  667. },
  668. goodsCourseList() {
  669. // url: '/app/common/goods/course/list/'+ data,
  670. this.$api.goodsCourseList(this.id).then((res) => {
  671. if (res.data.code == 200) {
  672. for (let i = 0; i < res.data.rows.length; i++) {
  673. let item = res.data.rows[i];
  674. item.down = true;
  675. item.menuList = [];
  676. }
  677. this.courseList = res.data.rows;
  678. this.getFirstCourse();
  679. // 不同
  680. if (this.goodsType == 1) {
  681. this.getCourseTeacher(res.data.rows);
  682. }
  683. }
  684. });
  685. },
  686. /**
  687. * 获取第一个有模块或者章的课程
  688. */
  689. async getFirstCourse() {
  690. for (let i = 0; i < this.courseList.length; i++) {
  691. let menuIndexOrFalse = await this.getCourseMenus(this.courseList[i]);
  692. if (menuIndexOrFalse !== false) {
  693. this.menuIndex = [i, menuIndexOrFalse];
  694. this.openCourse(this.courseList[i]);
  695. break;
  696. }
  697. }
  698. },
  699. getCourseMenus(item) {
  700. return new Promise((resolve) => {
  701. // url: '/app/common/course/menuList',
  702. this.$api.menuList({ courseId: item.courseId }).then((res) => {
  703. if (res.data.code == 200) {
  704. for (let i = 0; i < res.data.rows.length; i++) {
  705. if (res.data.rows[i].type == 1 || res.data.rows[i].type == 2) {
  706. resolve(i);
  707. break;
  708. }
  709. }
  710. }
  711. });
  712. });
  713. },
  714. getCourseTeacher(rows) {
  715. //获取商品双师资模板
  716. this.$api
  717. .getGoodsCourseTeacher({
  718. goodsId: this.id,
  719. })
  720. .then((res1) => {
  721. // console.log(res1,'res1');
  722. if (res1.data.data && res1.data.data.length > 0) {
  723. //课程老师模板
  724. let teacherTel = res1.data.data;
  725. //商品课程
  726. let courses = rows;
  727. teacherTel.forEach((tea) => {
  728. let dataList = [];
  729. let teacherList = [];
  730. courses.forEach((item) => {
  731. let data = tea.courseList.filter(
  732. (x) => x.courseId == item.courseId
  733. );
  734. if (data && data.length > 0) {
  735. dataList.push(item);
  736. teacherList = tea.courseList;
  737. }
  738. });
  739. let result = {
  740. teaList: teacherList,
  741. courseList: dataList,
  742. };
  743. this.goodsTeacher.push(result);
  744. });
  745. if (this.goodsTeacher && this.goodsTeacher.length > 0) {
  746. let courseIds = [];
  747. this.goodsTeacher.forEach((item) => {
  748. item.courseList.forEach((course) => {
  749. courseIds.push(course.courseId);
  750. });
  751. });
  752. if (courseIds.length > 0) {
  753. courses.forEach((item) => {
  754. if (!courseIds.includes(item.courseId)) {
  755. let data = {
  756. teaList: [],
  757. courseList: [],
  758. };
  759. data.courseList.push(item);
  760. this.goodsTeacher.push(data);
  761. }
  762. });
  763. }
  764. this.goodsTeacher.forEach((item) => {
  765. if (item.courseList && item.courseList.length > 0) {
  766. item.courseList[0].show = 1;
  767. }
  768. });
  769. }
  770. } else {
  771. //没有双师资模板
  772. rows.forEach((item) => {
  773. item.show = 1;
  774. let data = {
  775. teaList: [],
  776. courseList: [],
  777. };
  778. data.courseList.push(item);
  779. this.goodsTeacher.push(data);
  780. });
  781. }
  782. });
  783. console.log(this.goodsTeacher, "this.goodsTeacher");
  784. },
  785. //切换老师
  786. switchTeacher(data, tindex, gTindex) {
  787. // console.log(data,'data');
  788. this.States[gTindex] = tindex;
  789. this.teaIndex = tindex;
  790. this.goodsTeacher.forEach((item, index) => {
  791. if (item.teaList && item.teaList.length > 0) {
  792. let list = item.teaList.filter((x) => x.courseId == data.courseId);
  793. if (list && list.length > 0) {
  794. item.courseList.forEach((course, courseIndex) => {
  795. if (course.courseId == data.courseId) {
  796. this.$set(
  797. this.goodsTeacher[index].courseList[courseIndex],
  798. "show",
  799. 1
  800. );
  801. } else {
  802. this.$set(
  803. this.goodsTeacher[index].courseList[courseIndex],
  804. "show",
  805. 0
  806. );
  807. }
  808. });
  809. }
  810. }
  811. });
  812. console.log("切换后的this.goodsTeacher, ", this.goodsTeacher);
  813. },
  814. getMenuList(item) {
  815. let self = this;
  816. this.$api.menuList({ courseId: item.courseId }).then((res) => {
  817. if (res.data.code == 200) {
  818. for (let i = 0; i < res.data.rows.length; i++) {
  819. let item = res.data.rows[i];
  820. item.down = true;
  821. item.id = item.menuId;
  822. item.name = item.menuName;
  823. if (item.type == 3) {
  824. //判断是否试听
  825. item.tryListen = false;
  826. if (self.goodsAuditionConfigIdList.indexOf(item.id) !== -1) {
  827. item.tryListen = true;
  828. }
  829. }
  830. }
  831. item.menuList = res.data.rows;
  832. }
  833. });
  834. },
  835. // 获取课程详情
  836. getDetail() {
  837. let self = this;
  838. let sectionIdList = [];
  839. // /app/common/goods/+data
  840. this.$api.commonGoodsDetail(this.id).then((res) => {
  841. if (res.data.code == 200) {
  842. if (res.data.data) {
  843. if (res.data.data.mobileDetailHtml) {
  844. res.data.data.mobileDetailHtml =
  845. res.data.data.mobileDetailHtml.replace(
  846. /<img/gi,
  847. '<img style="max-width:100%;"'
  848. );
  849. }
  850. self.detail = res.data.data;
  851. this.courseBusiness();
  852. if (self.detail.goodsAuditionConfig) {
  853. self.listenConfigList = JSON.parse(
  854. self.detail.goodsAuditionConfig
  855. );
  856. for (var itemChild of self.listenConfigList) {
  857. sectionIdList.push(itemChild.sectionId); //存储试听节ID
  858. }
  859. self.$store.commit("setGoodsAuditionConfigIdList", {
  860. goodsAuditionConfigIdList: sectionIdList,
  861. });
  862. }
  863. }
  864. }
  865. });
  866. },
  867. buy() {
  868. if (this.$method.isGoLogin()) {
  869. return;
  870. }
  871. // 判断有没有规格选择
  872. if (this.detail.specTemplateId) {
  873. this.isCarOrBuy = 2;
  874. this.getSpecDetail();
  875. return;
  876. }
  877. this.$navTo.togo("/pages2/order/confirm_list?id=" + this.id);
  878. },
  879. addCart() {
  880. if (this.$method.isGoLogin()) {
  881. return;
  882. }
  883. // 判断有没有规格选择
  884. if (this.detail.specTemplateId) {
  885. this.isCarOrBuy = 1;
  886. this.getSpecDetail();
  887. return;
  888. }
  889. this.addShopCart(this.id);
  890. },
  891. getSpecDetail() {
  892. // || 35
  893. this.checkedAttrs = [];
  894. this.$http({
  895. url: `/app/common/spec/${this.detail.specTemplateId}`,
  896. method: "get",
  897. noToken: true,
  898. }).then((res) => {
  899. let data = res.data.data;
  900. console.log(data, "data");
  901. if (data) {
  902. this.toggleSkuShow = true;
  903. this.specAttrPriceList = data.specAttrPriceList;
  904. this.specList = this.changeData(data.specList || []);
  905. } else {
  906. if (this.isCarOrBuy == 1) {
  907. // 加入购物车
  908. this.addShopCart(this.id);
  909. } else {
  910. this.$navTo.togo("/pages2/order/confirm_list?id=" + this.id);
  911. }
  912. this.closePop();
  913. }
  914. });
  915. },
  916. changeData(data = this.specList) {
  917. let len = data.length;
  918. if (!len) return [];
  919. data[len - 1].specAttrList.forEach((e, i) => {
  920. e.check = e.check || false;
  921. let id = e.specAttributeId;
  922. if (len > 1) {
  923. id =
  924. data[0].specAttrList[this.selectGoodIndex].specAttributeId +
  925. "," +
  926. id;
  927. }
  928. let item = this.specAttrPriceList.find((e) => e.specAttrIds == id);
  929. if (item) {
  930. e.standPrice = item.standPrice;
  931. e.goodsId = item.goodsId;
  932. }
  933. });
  934. // data.forEach((item, index) => {
  935. // if (index == len - 1) {
  936. // item.specAttrList.forEach((e, i) => {
  937. // e.check = false
  938. // })
  939. // }
  940. // })
  941. return data;
  942. },
  943. change(index) {
  944. this.current = index;
  945. },
  946. toShopcar() {
  947. uni.navigateTo({
  948. url: "/pages4/shopping/shoppingCart",
  949. });
  950. },
  951. getIsBuy() {
  952. this.$http({
  953. url: "/order/buyGoodsNotExpired",
  954. method: "get",
  955. data: { goodsId: this.id },
  956. }).then((res) => {
  957. if (res.data.code == 200) {
  958. if (res.data.data) {
  959. // 有data返回是已经购买过的课程
  960. this.hadBuyCourse = res.data.data;
  961. this.bugCourseModel = true;
  962. }
  963. }
  964. });
  965. },
  966. changeKown() {
  967. this.bugCourseModel = false;
  968. },
  969. async toStudy() {
  970. let item = this.hadBuyCourse;
  971. if (item.goodsType == 6) {
  972. // 进入直播课
  973. this.toLive(item);
  974. return;
  975. }
  976. // /course/goodsRebuildStatus查询用户商品重修状态
  977. let rebuildStatus = await this.courseGoodsRebuildStatus(
  978. item.goodsId,
  979. item.gradeId
  980. );
  981. if (rebuildStatus == 0) {
  982. this.$navTo.togo("/pages2/learn/details", {
  983. gradeId: item.gradeId,
  984. goodsId: item.goodsId,
  985. orderGoodsId: item.orderGoodsId,
  986. });
  987. return;
  988. }
  989. // /lock/lockStatus
  990. this.$api
  991. .lockLockStatus({
  992. action: "jxjy",
  993. uuid: this.$method.getUuid(),
  994. })
  995. .then((res) => {
  996. if (res.data.code == 200) {
  997. //有其他端在操作,不能学习
  998. uni.showToast({
  999. icon: "none",
  1000. title: res.data.msg,
  1001. mask: true,
  1002. duration: 3000,
  1003. });
  1004. } else if (res.data.code == 500) {
  1005. //可以学习
  1006. this.$http({
  1007. url: "/course/courseList",
  1008. method: "get",
  1009. data: {
  1010. pageNum: 1,
  1011. pageSize: 1,
  1012. goodsId: item.goodsId,
  1013. gradeId: item.gradeId,
  1014. orderGoodsId: item.orderGoodsId,
  1015. },
  1016. }).then((res) => {
  1017. if (res.data.code == 200) {
  1018. if (res.data.total > 1) {
  1019. // this.$navTo.togo(`/pages2/wd/course?id=${item.goodsId}&gid=${item.gradeId}&orderGoodsId=${item.orderGoodsId}`);
  1020. uni.navigateTo({
  1021. url: `/pages3/polyv/detail?id=''&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`,
  1022. });
  1023. } else if (res.data.total == 1) {
  1024. uni.navigateTo({
  1025. url: `/pages3/polyv/detail?id=${res.data.rows[0].courseId}&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`,
  1026. });
  1027. } else {
  1028. uni.showToast({
  1029. icon: "none",
  1030. title: "暂无可观看的视频课程",
  1031. });
  1032. }
  1033. }
  1034. });
  1035. }
  1036. });
  1037. },
  1038. toLive(item) {
  1039. this.$api
  1040. .courseCourseList({
  1041. pageNum: 1,
  1042. pageSize: 1,
  1043. goodsId: item.goodsId,
  1044. gradeId: 0,
  1045. orderGoodsId: item.orderGoodsId,
  1046. })
  1047. .then((res) => {
  1048. if (res.data.code == 200) {
  1049. if (res.data.total > 1) {
  1050. // uni.navigateTo({
  1051. // url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
  1052. // })
  1053. uni.navigateTo({
  1054. url:
  1055. "/pages3/live/detail?orderGoodsId=" +
  1056. item.orderGoodsId +
  1057. "&goodsId=" +
  1058. item.goodsId +
  1059. '&gradeId=0&courseId=""',
  1060. });
  1061. } else if (res.data.total == 1) {
  1062. uni.navigateTo({
  1063. url:
  1064. "/pages3/live/detail?orderGoodsId=" +
  1065. item.orderGoodsId +
  1066. "&goodsId=" +
  1067. item.goodsId +
  1068. "&gradeId=0&courseId=" +
  1069. res.data.rows[0].courseId,
  1070. });
  1071. } else {
  1072. uni.showToast({
  1073. icon: "none",
  1074. title: "暂无可观看的直播课程",
  1075. });
  1076. }
  1077. }
  1078. });
  1079. },
  1080. /**
  1081. * @param {Object} goodsId 商品id
  1082. * 查询商品重修状态
  1083. */
  1084. courseGoodsRebuildStatus(goodsId, gradeId) {
  1085. return new Promise((resolve) => {
  1086. this.$http({
  1087. url: "/course/goodsRebuildStatus",
  1088. method: "get",
  1089. data: {
  1090. goodsId: goodsId,
  1091. gradeId: gradeId,
  1092. },
  1093. // noLoading: true,
  1094. // compleLoading: true, // 请求成功是否还要继续显示加载中
  1095. }).then((res) => {
  1096. resolve(res.data.data);
  1097. });
  1098. });
  1099. },
  1100. closePop() {
  1101. this.toggleSkuShow = false;
  1102. this.skuItem = {};
  1103. },
  1104. // 获取规格属性值对应的商品信息
  1105. getGoodsInfos(specAttrIds) {
  1106. this.$http({
  1107. url: "/app/common/attr/goods",
  1108. method: "get",
  1109. data: {
  1110. specTemplateId: this.detail.specTemplateId,
  1111. specAttrIds: specAttrIds.join(","),
  1112. },
  1113. noToken: true,
  1114. }).then((res) => {
  1115. if (res.data.code == 200) {
  1116. this.skuItem = res.data.data || {};
  1117. } else {
  1118. this.skuItem = {};
  1119. this.$u.toast("商品已下架, 请重新选择");
  1120. }
  1121. });
  1122. },
  1123. rightNowBuy() {
  1124. let goodsIds = [...new Set(this.goodsIds)];
  1125. this.$api.checkGoodsStatus({ goodsIds }).then((res) => {
  1126. if (res.data.code == 500) {
  1127. return this.$u.toast(res.data.msg);
  1128. }
  1129. if (this.isCarOrBuy == 1) {
  1130. // 加入购物车
  1131. this.addShopCart(goodsIds);
  1132. } else {
  1133. if (this.isSingleChoice) {
  1134. this.$navTo.togo("/pages2/order/confirm_list?id=" + goodsIds);
  1135. } else {
  1136. let data = [];
  1137. goodsIds.forEach((id) => {
  1138. data.push(this.specAttrPriceList.find((e) => e.goodsId == id));
  1139. });
  1140. this.$store.commit("setShoppingCartList", {
  1141. shoppingCartList: data,
  1142. });
  1143. this.$navTo.togo("/pages2/order/confirm_pay");
  1144. }
  1145. }
  1146. this.closePop();
  1147. });
  1148. },
  1149. },
  1150. };
  1151. </script>
  1152. <style >
  1153. page {
  1154. background-color: #f2f2f2;
  1155. }
  1156. </style>
  1157. <style lang="scss" scope>
  1158. @import "./index.scss";
  1159. .video_t2 {
  1160. font-size: 24rpx;
  1161. font-family: PingFang SC;
  1162. font-weight: 500;
  1163. color: #666666;
  1164. }
  1165. .video_t1 {
  1166. height: 80rpx;
  1167. color: #333333;
  1168. line-height: 80rpx;
  1169. font-size: 30rpx;
  1170. font-family: PingFang SC;
  1171. font-weight: bold;
  1172. color: #333333;
  1173. overflow: hidden;
  1174. text-overflow: ellipsis;
  1175. white-space: nowrap;
  1176. }
  1177. .video_t1_t {
  1178. display: flex;
  1179. flex-direction: column;
  1180. height: 80rpx;
  1181. color: #333333;
  1182. text-align: center;
  1183. align-items: center;
  1184. border-left: solid 1px #d6d6db;
  1185. }
  1186. .video_play {
  1187. position: absolute;
  1188. width: 95rpx;
  1189. height: 95rpx;
  1190. top: 0;
  1191. left: 0;
  1192. right: 0;
  1193. bottom: 0;
  1194. margin: auto;
  1195. }
  1196. .video_box {
  1197. position: relative;
  1198. }
  1199. .contents {
  1200. width: 100%;
  1201. height: 100%;
  1202. background-color: #ffffff;
  1203. margin-top: 16rpx;
  1204. overflow: hidden;
  1205. }
  1206. .cou_title {
  1207. padding: 24rpx 32rpx 40rpx 32rpx;
  1208. display: flex;
  1209. flex-direction: column;
  1210. justify-content: space-around;
  1211. }
  1212. .prices {
  1213. .price_word {
  1214. display: flex;
  1215. font-size: 44rpx;
  1216. font-weight: 800;
  1217. color: #fc3f3f;
  1218. margin-bottom: 8rpx;
  1219. view::before {
  1220. content: "¥";
  1221. font-size: 26rpx;
  1222. font-weight: bold;
  1223. }
  1224. }
  1225. .sale {
  1226. color: #999999;
  1227. font-size: 28rpx;
  1228. margin-left: 8rpx;
  1229. }
  1230. .price_line {
  1231. color: #999999;
  1232. font-size: 28rpx;
  1233. text-decoration: line-through;
  1234. font-weight: 400;
  1235. }
  1236. .free {
  1237. font-size: 32rpx;
  1238. }
  1239. }
  1240. // tab
  1241. .tabs {
  1242. // width: 100%;
  1243. height: 78rpx;
  1244. display: flex;
  1245. align-items: center;
  1246. justify-content: space-between;
  1247. background-color: #f2f7ff;
  1248. border-radius: 38rpx;
  1249. margin: 24rpx;
  1250. padding: 0rpx 5rpx;
  1251. .tab_item {
  1252. width: 345rpx;
  1253. height: 65rpx;
  1254. line-height: 65rpx;
  1255. font-size: 28rpx;
  1256. font-weight: bold;
  1257. border-radius: 32rpx;
  1258. text-align: center;
  1259. color: #333;
  1260. &.nactive {
  1261. color: #fff;
  1262. background-color: #3577e8;
  1263. }
  1264. &.twoBtn {
  1265. width: 50%;
  1266. }
  1267. &.threeBtn {
  1268. width: 33%;
  1269. }
  1270. }
  1271. // /deep/ .u-tabs {
  1272. // background:none!important;
  1273. // }
  1274. }
  1275. .courseName {
  1276. white-space: nowrap;
  1277. overflow: hidden;
  1278. text-overflow: ellipsis;
  1279. }
  1280. .videoBox {
  1281. background-color: #ffffff;
  1282. width: 100%;
  1283. /* height: 680rpx; */
  1284. z-index: 999;
  1285. }
  1286. .icon_up {
  1287. width: 32rpx;
  1288. height: 32rpx;
  1289. }
  1290. .courseItemBox {
  1291. background: #ffffff;
  1292. border-radius: 16rpx;
  1293. padding: 0 10rpx;
  1294. margin-bottom: 20rpx;
  1295. }
  1296. .courseItem {
  1297. height: 80rpx;
  1298. color: #333333;
  1299. font-size: 32rpx;
  1300. line-height: 80rpx;
  1301. font-weight: bold;
  1302. display: flex;
  1303. justify-content: space-between;
  1304. }
  1305. .content {
  1306. background-color: #ffffff;
  1307. width: 100%;
  1308. }
  1309. .btn2 {
  1310. width: 187rpx;
  1311. height: 79rpx;
  1312. line-height: 79rpx;
  1313. background: #fc3f3f;
  1314. border-radius: 40rpx;
  1315. text-align: center;
  1316. font-size: 24rpx;
  1317. }
  1318. .btn1 {
  1319. width: 187rpx;
  1320. height: 79rpx;
  1321. line-height: 79rpx;
  1322. background: #ffb102;
  1323. border-radius: 40rpx;
  1324. text-align: center;
  1325. margin-right: 11rpx;
  1326. font-size: 24rpx;
  1327. }
  1328. .wk_icon {
  1329. width: 24rpx;
  1330. height: 24rpx;
  1331. margin-right: 12rpx;
  1332. }
  1333. .noteTag,
  1334. .blackFont {
  1335. font-size: 26rpx;
  1336. font-family: PingFang SC;
  1337. font-weight: 400;
  1338. color: #999999;
  1339. align-items: center;
  1340. margin: 0 4rpx;
  1341. line-height: 60rpx;
  1342. }
  1343. .priceTag {
  1344. /* font-size: 30rpx;
  1345. font-family: PingFang SC;
  1346. font-weight: bold;
  1347. color: #FF2D55; */
  1348. width: 60rpx;
  1349. height: 40rpx;
  1350. line-height: 40rpx;
  1351. text-align: center;
  1352. border: 1rpx solid #333;
  1353. }
  1354. .titleTag {
  1355. font-size: 32rpx;
  1356. font-weight: bold;
  1357. color: #333333;
  1358. // margin-left: 8rpx;
  1359. }
  1360. .yearTag {
  1361. width: 80rpx;
  1362. height: 32rpx;
  1363. background: #ebf5ff;
  1364. border: 2rpx solid #007aff;
  1365. border-radius: 16rpx;
  1366. font-size: 24rpx;
  1367. color: #007aff;
  1368. text-align: center;
  1369. line-height: 32rpx;
  1370. }
  1371. .itemBox {
  1372. background: #ffffff;
  1373. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1374. border-radius: 24rpx;
  1375. width: 100%;
  1376. padding: 20rpx;
  1377. margin-bottom: 20rpx;
  1378. }
  1379. // 老师名字样式
  1380. .teacher_names {
  1381. display: flex;
  1382. padding-bottom: 15rpx;
  1383. border-bottom: 2rpx solid #f0f0f0;
  1384. .names {
  1385. padding: 6rpx 12rpx;
  1386. font-size: 26rpx;
  1387. color: #969696;
  1388. background: #f8f8f8;
  1389. border-radius: 8rpx;
  1390. margin-right: 10rpx;
  1391. &.nactive {
  1392. color: #3f8dfd;
  1393. background: #f2f7ff;
  1394. }
  1395. }
  1396. }
  1397. </style>