detail.vue 40 KB

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