detail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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 :src="$method.splitImgHost(detail.coverUrl)" style="width: 100%;height: 450rpx;"></image>
  8. <image v-if="false" class="video_play" src="/static/play.png" @click="startVideo"></image>
  9. </view>
  10. <view v-else class="video_box" style="width: 100%;height: 450rpx;">
  11. <polyv-player
  12. id="playerVideo"
  13. playerId="playerVideo"
  14. height="450rpx"
  15. :vid="vid"
  16. :showSettingBtn="true"
  17. :enablePlayGesture="true"
  18. :playbackRate="playbackRate"
  19. :isAllowSeek="isAllowSeek"
  20. :autoplay="autoplay"
  21. :startTime="startTime"
  22. @statechange="onStateChange"
  23. ></polyv-player>
  24. </view>
  25. <view class="cou_title">
  26. <view class="title_name">
  27. <!-- <view class="yearTag" v-if="detail.year">{{detail.year}}</view> -->
  28. <view class="titleTag">{{detail.goodsName}}</view>
  29. </view>
  30. <view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
  31. <view class="prices">
  32. <text v-if="detail.standPrice" class="price_word">¥ {{ detail.standPrice }}</text>
  33. <text v-else class="price_word free">免费</text>
  34. <text v-if="detail.linePrice" class="sale"> ¥ </text>
  35. <text v-if="detail.linePrice" class="price_line"> {{detail.linePrice }}</text>
  36. </view>
  37. <view class="noteTag">
  38. 共 <text class="blackFont">{{courseList.length}} 课程 {{detail.classHours || '-'}}</text> 学时
  39. </view>
  40. </view>
  41. </view>
  42. <!-- </view> -->
  43. </view>
  44. <view class="contents">
  45. <!-- <u-line color="#D6D6DB" /> -->
  46. <!-- <view style="height: 80rpx;">
  47. <view><u-tabs :list="list" :item-width="itemWidth()" font-size="30" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  48. </view> -->
  49. <view class="tabs">
  50. <view v-for="(item, index) in list" :key="index" class="tab_item"
  51. :class="[list.length == 2 ? 'twoBtn' : list.length == 3 ? 'threeBtn' : '',{nactive: current == index}]" @click="change(index)">{{ item.name }}</view>
  52. </view>
  53. <view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;" v-show="current==0">
  54. <view class="content">
  55. <view v-html="detail.mobileDetailHtml" style="width: 100%;overflow: hidden;"></view>
  56. </view>
  57. </view>
  58. <view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;" v-show="current==1">
  59. <!-- <view v-for="(item, index) in courseItem.courseList" :key="index" > -->
  60. <!-- 视频课 -->
  61. <template v-if="goodsType == 1">
  62. <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
  63. <view v-for="(item, index) in courseItem.courseList" :key="index">
  64. <view class="courseItemBox" v-if="item.show && item.show == 1">
  65. <view class="courseItem" @click="openCourse(item)">
  66. <view class="courseName">{{item.courseName}}</view>
  67. <view>
  68. <image src="/static/icon/up.png" class="icon_up" v-if="item.down"></image>
  69. <image src="/static/icon/down.png" class="icon_up" v-if="!item.down"></image>
  70. </view>
  71. </view>
  72. <view v-if="courseItem.teaList && courseItem.teaList.length > 0" class='teacher_names'>
  73. <view v-for="(tea, tindex) in courseItem.teaList" :key="tindex" class="names" :class="[States[gTindex] == tindex ? 'nactive' : '']"
  74. @click.stop="switchTeacher(tea, tindex, gTindex)">
  75. <view >{{ tea.aliasName }}</view>
  76. </view>
  77. </view>
  78. <view v-show="!item.down">
  79. <view v-for="(itemM,indexM) in item.menuList" :key="indexM">
  80. <courseModule :courseId="itemM.courseId" :needOpen="(isFirstEnter && menuIndex[0] === index && menuIndex[1] === indexM) ? true : false" v-if="itemM.type==1" :menuItem="itemM"></courseModule>
  81. <courseChapter :courseId="itemM.courseId" :needOpen="(isFirstEnter && menuIndex[0] === index && menuIndex[1] === indexM) ? true : false" v-if="itemM.type==2" :isBuy="false" :menuItem="itemM"></courseChapter>
  82. <courseSection :courseId="itemM.courseId" v-if="itemM.type==3" :isBuy="false" :menuItem="itemM"></courseSection>
  83. <u-line></u-line>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <!-- 直播课 -->
  91. <template v-else>
  92. <view v-for="(item,index) in courseList" :key="index" >
  93. <view class="courseItemBox" >
  94. <view class="courseItem" @click="openCourse(item)">
  95. <view class="courseName">{{item.courseName}}</view>
  96. <view>
  97. <image src="/static/icon/up.png" class="icon_up" v-if="item.down"></image>
  98. <image src="/static/icon/down.png" class="icon_up" v-if="!item.down"></image>
  99. </view>
  100. </view>
  101. <view v-show="!item.down">
  102. <view v-for="(itemM,indexM) in item.menuList" :key="indexM">
  103. <courseModule :courseId="itemM.courseId" :needOpen="(isFirstEnter && menuIndex[0] === index && menuIndex[1] === indexM) ? true : false" v-if="itemM.type==1" :menuItem="itemM"></courseModule>
  104. <courseChapter :courseId="itemM.courseId" :needOpen="(isFirstEnter && menuIndex[0] === index && menuIndex[1] === indexM) ? true : false" v-if="itemM.type==2" :isBuy="false" :menuItem="itemM"></courseChapter>
  105. <courseSection :courseId="itemM.courseId" v-if="itemM.type==3" :isBuy="false" :menuItem="itemM"></courseSection>
  106. <u-line></u-line>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </template>
  112. </view>
  113. <view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;" v-show="current==2">
  114. <!-- <view > -->
  115. <view v-for="(item,index) in freeMenuList" :key="index" >
  116. <view class="courseItemBox" >
  117. <view class="courseItem">
  118. <view class="courseName">{{item.freeExamName}}</view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- </view> -->
  123. </view>
  124. </view>
  125. <view class="bottomBox" v-if="!hideBuyState">
  126. <view class="icons">
  127. <view class="icon_item ones">
  128. <image src="/static/index/share.png" class="share"></image>
  129. <button type="default" open-type="share" class="bt_share"></button>
  130. <view class="share_w">分享</view>
  131. </view>
  132. <view class="icon_item">
  133. <image src="/static/index/shopcar.png" class="shopcar" @click="toShopcar()"></image>
  134. <view class="share_w">购物车</view>
  135. </view>
  136. </view>
  137. <view style="display: flex;color: #FFFFFF;align-items: center;">
  138. <view class="btn1" @click="addCart()">加购物车</view>
  139. <view class="btn2" @click="buy()">立即购买 </view>
  140. </view>
  141. </view>
  142. <!-- 已购买过课程的弹窗 -->
  143. <u-popup v-model="bugCourseModel" mode="center" border-radius="40">
  144. <view class="had_bugCourse">
  145. <image src="/pages3/static/imgs/hadBug.png" class="share"></image>
  146. <view class="tips">
  147. <view class="warns">温馨提示</view>
  148. <view class="words">您<text>已购买过</text>该商品课程</view>
  149. <view class="words">可立即前往学习</view>
  150. </view>
  151. <view class="tip_botton">
  152. <view class="cancel_btn" @click="changeKown()">知道了</view>
  153. <view class="confirm_btn" @click="toStudy()">去学习</view>
  154. </view>
  155. </view>
  156. </u-popup>
  157. <!-- 选择规格弹窗 -->
  158. <u-popup v-model="toggleSkuShow" mode="bottom" border-radius="40">
  159. <view class="popup_box">
  160. <view class="check_head">
  161. <view class="headers">
  162. <view class="grade">选择规格</view>
  163. <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
  164. </view>
  165. </view>
  166. <view class="pop_prices">
  167. <view class="lefts">
  168. <!-- <image :src="$method.splitImgHost(item.coverUrl, true)" class="imgs"></image> -->
  169. <!-- <image src="" class="imgs"></image> -->
  170. </view>
  171. <view class="rights">
  172. <view class="goods_titles">【建筑全科】2022年一建精华 2022年一建精华班</view>
  173. <view class="goods_price">¥154.00</view>
  174. </view>
  175. </view>
  176. <view class="lines"></view>
  177. <view class="check_con">
  178. <view v-for="(item, index) in specList" :key="index" class="check_items">
  179. <view class="grades">{{ item.name }}</view>
  180. <view class="grade_names">
  181. <!-- :class="{nactive: skuIndex == index}" -->
  182. <view class="course_items" v-for="(child, c_index) in item.specAttrList" :key="c_index" @click="selectSku(child, index, c_index)">
  183. {{ child.name }}
  184. </view>
  185. </view>
  186. </view>
  187. </view>
  188. <view class="right_now" @click="rightNowBuy()">确 定</view>
  189. </view>
  190. </u-popup>
  191. </view>
  192. </template>
  193. <script>
  194. import courseModule from '@/components/course/courseModule.vue';
  195. import courseChapter from '@/components/course/courseChapter.vue';
  196. import courseSection from '@/components/course/courseSection.vue';
  197. import { mapGetters,mapMutations } from 'vuex';
  198. export default {
  199. components: {
  200. courseModule,
  201. courseChapter,
  202. courseSection
  203. },
  204. data() {
  205. return {
  206. id:0,
  207. list: [],
  208. menuIndex:[],
  209. current:0,
  210. detail:{},
  211. courseList:[],
  212. menuList:[],
  213. freeMenuList:[],
  214. startStatus:false,
  215. playbackRate: [1.0],
  216. isAllowSeek:'no',
  217. vid:'',
  218. autoplay:true,
  219. listenConfigList:[],
  220. listenSecond:0,
  221. isFirstEnter:true, //是否首次进入
  222. timer:null,
  223. businessData:{},
  224. startTime:0,
  225. bugCourseModel: false, // 弹窗
  226. hadBuyCourse: {}, // 已购买课程信息
  227. goodsTeacher: [],
  228. teaIndex: 0,
  229. States: {0: 0},
  230. goodsType: 1, // 1视频2题库 3补考 4前培 6直播
  231. toggleSkuShow: false,
  232. courseSku: ['基础班', '钻石班', '基础班', '钻石班', '基础班', '钻石班'],
  233. skuItem: {},
  234. skuIndex: -1,
  235. isCarOrBuy: 1, // 1加入购物车 2立即购买
  236. specList: [
  237. {
  238. "specId":62,
  239. "specTemplateId":28,
  240. name:"一建规格-001",
  241. "code":null,
  242. "sort":null,
  243. "status":1,
  244. specAttrList: [
  245. {
  246. "specAttributeId":115,
  247. "specId":62,
  248. name:"一建规格属性0011",
  249. "code":null,
  250. "sort":null,
  251. "status":1
  252. },
  253. {
  254. "specAttributeId":116,
  255. "specId":62,
  256. name:"一建规格属性0012",
  257. "code":null,
  258. "sort":null,
  259. "status":1
  260. }
  261. ]
  262. },
  263. {
  264. "specId":63,
  265. "specTemplateId":28,
  266. name:"一建规格-002",
  267. "code":null,
  268. "sort":null,
  269. "status":1,
  270. specAttrList: [
  271. {
  272. "specAttributeId":117,
  273. "specId":63,
  274. name:"一建规格属性0021",
  275. "code":null,
  276. "sort":null,
  277. "status":1
  278. },
  279. {
  280. "specAttributeId":118,
  281. "specId":63,
  282. name:"一建规格属性0022",
  283. "code":null,
  284. "sort":null,
  285. "status":1
  286. }
  287. ]
  288. }
  289. ], // 规格列表
  290. };
  291. },
  292. computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId','hideBuyState']) },
  293. onLoad(option) {
  294. // this.id => goodsId
  295. this.id = option.id;
  296. this.goodsType = option.goodsType
  297. this.getDetail()
  298. this.goodsCourseList()
  299. this.appCommonGoodsCourseModuleFreeExamList();
  300. this.getIsBuy() // 判断是否已经购买过该课程
  301. wx.showShareMenu({
  302. withShareTicket: true,
  303. menus: ["shareAppMessage", "shareTimeline"]
  304. })
  305. },
  306. onUnload(option) {
  307. this.$store.commit('setPlaySectionId', {playSectionId :0});
  308. //移除所有的事件监听器
  309. uni.$off();
  310. },
  311. // 分享到朋友圈
  312. onShareTimeline() {
  313. return {
  314. title: this.detail.goodsName,
  315. query: 'id=' + this.id,
  316. imageUrl: this.$method.splitImgHost(this.detail.coverUrl)
  317. }
  318. },
  319. // 分享给朋友
  320. onShareAppMessage() {
  321. return {
  322. title: this.detail.goodsName,
  323. path: `/pages3/course/detail?id=` + this.id + '&goodsType=' + this.goodsType,
  324. imageUrl: this.$method.splitImgHost(this.detail.coverUrl)
  325. }
  326. },
  327. mounted() {
  328. let self = this
  329. uni.$on('getSection', item => {
  330. //播放试听
  331. self.listenSecond = 0
  332. for (var itemChild of self.listenConfigList) {
  333. if(self.playSectionId == (itemChild.sectionId || itemChild.menuId) && item.courseId == itemChild.courseId){
  334. if(itemChild.auditionMinute>0){
  335. // self.listenSecond = itemChild.auditionMinute *60 //试听秒数
  336. self.listenSecond = itemChild.auditionMinute //试听秒数 auditionMinute调整为秒单位
  337. }
  338. }
  339. }
  340. if(self.listenSecond>0){
  341. if(self.timer){
  342. clearInterval(self.timer);
  343. }
  344. if(self.vid){
  345. //切换视频
  346. var polyvPlayerContext = self.selectComponent('#playerVideo');
  347. polyvPlayerContext.changeVid(item.recordingUrl)
  348. }else{
  349. self.vid = item.recordingUrl
  350. }
  351. self.startStatus = true
  352. self.startTime = 0
  353. }else{
  354. self.$u.toast('试听配置错误');
  355. }
  356. })
  357. this.updateChapterOpen(true)
  358. },
  359. methods: {
  360. ...mapMutations(['updateChapterOpen']),
  361. itemWidth() {
  362. return (100/this.list.length)+'%'
  363. },
  364. appCommonGoodsCourseModuleFreeExamList() {
  365. // url: '/app/common/goods/course/moduleFreeExamList/'+data,
  366. this.$api.appCommonGoodsCourseModuleFreeExamList(this.id).then(res => {
  367. if(res.data.data.length) {
  368. this.freeMenuList = res.data.data;
  369. this.list = [
  370. {
  371. name: '课程介绍'
  372. },
  373. {
  374. name: '课程目录'
  375. },
  376. {
  377. name: '赠送'
  378. }
  379. ]
  380. } else {
  381. this.list = [
  382. {
  383. name: '课程介绍'
  384. },
  385. {
  386. name: '课程目录'
  387. }
  388. ]
  389. }
  390. console.log(this.list)
  391. })
  392. },
  393. courseBusiness(){
  394. // url: '/app/common/course/business/'+data,
  395. this.$api.courseBusiness(this.detail.businessId).then(res => {
  396. this.businessData = res.data.data;
  397. })
  398. },
  399. toFixed(number) {
  400. if(number > 0) {
  401. return number.toFixed(2)
  402. } else {
  403. return '0.00'
  404. }
  405. },
  406. onStateChange(newstate, oldstate) {
  407. if (newstate.detail.newstate == 'playing') {
  408. //开始播放
  409. if(this.timer){
  410. clearInterval(this.timer);
  411. }
  412. this.timer = setInterval(this.timeEvent, 1500);//定时器
  413. }
  414. },
  415. closePlay(){
  416. this.$store.commit('setPlaySectionId', {playSectionId :0});
  417. this.vid = ""
  418. this.startStatus = false
  419. },
  420. timeEvent() {
  421. let self = this
  422. var polyvPlayerContext = this.selectComponent('#playerVideo');
  423. if (polyvPlayerContext != null) {
  424. let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
  425. if(PlayCurrentTime>=this.listenSecond){
  426. polyvPlayerContext.stop();
  427. polyvPlayerContext.exitFullScreen();
  428. clearInterval(this.timer);
  429. this.timer = null
  430. uni.showModal({
  431. title: '提示',
  432. content: '试听结束,购买课程可学习全部',
  433. showCancel:false,
  434. success: function(resst) {
  435. self.closePlay()
  436. }
  437. });
  438. }
  439. }
  440. },
  441. openCourse(item){
  442. item.down = !item.down
  443. if(!item.down&&item.menuList.length==0){
  444. this.getMenuList(item)
  445. }
  446. },
  447. addShopCart() {
  448. this.$api.addCart({goodsId:this.id}).then(res => {
  449. if(res.data.code==200){
  450. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  451. uni.showToast({
  452. title: '添加成功'
  453. });
  454. }else{
  455. this.$u.toast(res.data.msg);
  456. }
  457. });
  458. },
  459. goodsCourseList() {
  460. // url: '/app/common/goods/course/list/'+ data,
  461. this.$api.goodsCourseList(this.id).then(res => {
  462. if(res.data.code==200){
  463. for(let i=0;i<res.data.rows.length;i++){
  464. let item = res.data.rows[i]
  465. item.down = true
  466. item.menuList = []
  467. }
  468. this.courseList = res.data.rows;
  469. this.getFirstCourse();
  470. // 不同
  471. if (this.goodsType == 1) {
  472. this.getCourseTeacher(res.data.rows)
  473. }
  474. }
  475. });
  476. },
  477. /**
  478. * 获取第一个有模块或者章的课程
  479. */
  480. async getFirstCourse() {
  481. for(let i = 0; i < this.courseList.length; i++) {
  482. let menuIndexOrFalse = await this.getCourseMenus(this.courseList[i]);
  483. if(menuIndexOrFalse !== false) {
  484. this.menuIndex = [i,menuIndexOrFalse]
  485. this.openCourse(this.courseList[i])
  486. break
  487. }
  488. }
  489. },
  490. getCourseMenus(item) {
  491. return new Promise(resolve => {
  492. // url: '/app/common/course/menuList',
  493. this.$api.menuList({courseId:item.courseId}).then(res => {
  494. if(res.data.code==200){
  495. for(let i=0;i<res.data.rows.length;i++){
  496. if(res.data.rows[i].type == 1 || res.data.rows[i].type == 2) {
  497. resolve(i)
  498. break;
  499. }
  500. }
  501. }
  502. });
  503. })
  504. },
  505. getCourseTeacher(rows) {
  506. //获取商品双师资模板
  507. this.$api.getGoodsCourseTeacher({
  508. goodsId: this.id
  509. }).then((res1) => {
  510. // console.log(res1,'res1');
  511. if(res1.data.data && res1.data.data.length > 0){
  512. //课程老师模板
  513. let teacherTel = res1.data.data;
  514. //商品课程
  515. let courses = rows
  516. teacherTel.forEach((tea) => {
  517. let dataList = []
  518. let teacherList = []
  519. courses.forEach((item) => {
  520. let data = tea.courseList.filter(x => x.courseId == item.courseId)
  521. if(data && data.length > 0){
  522. dataList.push(item)
  523. teacherList = tea.courseList
  524. }
  525. })
  526. let result = {
  527. teaList:teacherList,
  528. courseList:dataList
  529. }
  530. this.goodsTeacher.push(result)
  531. })
  532. if(this.goodsTeacher && this.goodsTeacher.length > 0){
  533. let courseIds = []
  534. this.goodsTeacher.forEach((item) => {
  535. item.courseList.forEach((course) => {
  536. courseIds.push(course.courseId)
  537. })
  538. })
  539. if(courseIds.length > 0){
  540. courses.forEach((item) => {
  541. if(!courseIds.includes(item.courseId)){
  542. let data = {
  543. teaList:[],
  544. courseList: []
  545. }
  546. data.courseList.push(item)
  547. this.goodsTeacher.push(data)
  548. }
  549. })
  550. }
  551. this.goodsTeacher.forEach((item) => {
  552. if(item.courseList && item.courseList.length > 0){
  553. item.courseList[0].show = 1
  554. }
  555. })
  556. }
  557. }else{
  558. //没有双师资模板
  559. rows.forEach((item) => {
  560. item.show = 1
  561. let data = {
  562. teaList:[],
  563. courseList: []
  564. }
  565. data.courseList.push(item)
  566. this.goodsTeacher.push(data)
  567. })
  568. }
  569. })
  570. console.log(this.goodsTeacher,'this.goodsTeacher');
  571. },
  572. //切换老师
  573. switchTeacher(data, tindex, gTindex){
  574. // console.log(data,'data');
  575. this.States[gTindex] = tindex
  576. this.teaIndex = tindex
  577. this.goodsTeacher.forEach((item,index) => {
  578. if(item.teaList && item.teaList.length > 0){
  579. let list = item.teaList.filter(x => x.courseId == data.courseId)
  580. if(list && list.length > 0){
  581. item.courseList.forEach((course,courseIndex) => {
  582. if(course.courseId == data.courseId){
  583. this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",1)
  584. }else{
  585. this.$set(this.goodsTeacher[index].courseList[courseIndex],"show",0)
  586. }
  587. })
  588. }
  589. }
  590. })
  591. console.log('切换后的this.goodsTeacher, ', this.goodsTeacher)
  592. },
  593. getMenuList(item) {
  594. let self = this
  595. this.$api.menuList({courseId:item.courseId}).then(res => {
  596. if(res.data.code==200){
  597. for(let i=0;i<res.data.rows.length;i++){
  598. let item = res.data.rows[i]
  599. item.down = true
  600. item.id = item.menuId
  601. item.name = item.menuName
  602. if(item.type==3){
  603. //判断是否试听
  604. item.tryListen = false
  605. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  606. item.tryListen = true
  607. }
  608. }
  609. }
  610. item.menuList = res.data.rows
  611. }
  612. });
  613. },
  614. // 获取课程详情
  615. getDetail() {
  616. let self = this
  617. let sectionIdList = []
  618. // /app/common/goods/+data
  619. this.$api.commonGoodsDetail(this.id).then(res => {
  620. if(res.data.code==200){
  621. if(res.data.data.mobileDetailHtml){
  622. res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi,'<img style="max-width:100%;"')
  623. }
  624. self.detail = res.data.data
  625. this.courseBusiness();
  626. if(self.detail.goodsAuditionConfig){
  627. self.listenConfigList = JSON.parse(self.detail.goodsAuditionConfig)
  628. for (var itemChild of self.listenConfigList) {
  629. sectionIdList.push(itemChild.sectionId)//存储试听节ID
  630. }
  631. self.$store.commit('setGoodsAuditionConfigIdList', {goodsAuditionConfigIdList:sectionIdList});
  632. }
  633. }
  634. });
  635. },
  636. buy(){
  637. if(this.$method.isGoLogin()){
  638. return
  639. }
  640. // 判断有没有规格选择
  641. if (this.detail.specTemplateId) {
  642. this.isCarOrBuy = 2
  643. this.toggleSkuShow = true
  644. return
  645. }
  646. this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
  647. },
  648. addCart(){
  649. // this.getSpecDetail()
  650. this.toggleSkuShow = true
  651. this.specList.forEach((item, index) => {
  652. item.specAttrList.forEach((child) => {
  653. child['check'] = false
  654. })
  655. })
  656. console.log('000', this.specList)
  657. return
  658. if(this.$method.isGoLogin()){
  659. return
  660. }
  661. // 判断有没有规格选择
  662. if (this.detail.specTemplateId) {
  663. this.isCarOrBuy = 1
  664. this.getSpecDetail()
  665. return
  666. }
  667. this.addShopCart()
  668. },
  669. getSpecDetail() {
  670. // ${this.detail.specTemplateId}
  671. // 这里id到时候需要改回来
  672. console.log('1111111111')
  673. this.$http({
  674. url: `/app/common/spec/28`,
  675. method: 'get',
  676. noToken: true
  677. }).then((res) => {
  678. if (res.data.code == 200) {
  679. this.toggleSkuShow = true
  680. let data = res.data.data
  681. if (data) {
  682. this.specList = data && (data.specList || [])
  683. this.specList.forEach((item, index) => {
  684. item.specAttrList.forEach((child) => {
  685. child['check'] = false
  686. })
  687. })
  688. console.log('this.specList', this.specList)
  689. }
  690. } else {
  691. this.$u.toast('暂无数据')
  692. }
  693. })
  694. },
  695. change(index){
  696. this.current = index;
  697. },
  698. toShopcar() {
  699. uni.switchTab({
  700. url: '/pages/shopping/shoppingCart'
  701. })
  702. },
  703. getIsBuy() {
  704. this.$http({
  705. url: '/order/buyGoodsNotExpired',
  706. method: 'get',
  707. data: { goodsId: this.id }
  708. }).then((res) => {
  709. if (res.data.code == 200) {
  710. if (res.data.data) { // 有data返回是已经购买过的课程
  711. this.hadBuyCourse = res.data.data
  712. this.bugCourseModel = true
  713. }
  714. }
  715. })
  716. },
  717. changeKown() {
  718. this.bugCourseModel = false
  719. },
  720. async toStudy() {
  721. let item = this.hadBuyCourse
  722. if (item.goodsType == 6) { // 进入直播课
  723. this.toLive(item)
  724. return
  725. }
  726. // /course/goodsRebuildStatus查询用户商品重修状态
  727. let rebuildStatus = await this.courseGoodsRebuildStatus(item.goodsId, item.gradeId)
  728. if (rebuildStatus == 0) {
  729. this.$navTo.togo('/pages2/learn/details', {
  730. gradeId: item.gradeId,
  731. goodsId: item.goodsId,
  732. orderGoodsId: item.orderGoodsId,
  733. });
  734. return;
  735. }
  736. // /lock/lockStatus
  737. this.$api.lockLockStatus({
  738. action: 'jxjy',
  739. uuid:this.$method.getUuid()
  740. }).then(res => {
  741. if (res.data.code == 200) { //有其他端在操作,不能学习
  742. uni.showToast({
  743. icon: 'none',
  744. title: res.data.msg,
  745. mask: true,
  746. duration: 3000
  747. })
  748. } else if (res.data.code == 500) { //可以学习
  749. this.$http({
  750. url: '/course/courseList',
  751. method: 'get',
  752. data: {
  753. pageNum: 1,
  754. pageSize: 1,
  755. goodsId: item.goodsId,
  756. gradeId: item.gradeId,
  757. orderGoodsId: item.orderGoodsId,
  758. },
  759. })
  760. .then(res => {
  761. if (res.data.code == 200) {
  762. if(res.data.total > 1) {
  763. // this.$navTo.togo(`/pages2/wd/course?id=${item.goodsId}&gid=${item.gradeId}&orderGoodsId=${item.orderGoodsId}`);
  764. uni.navigateTo({
  765. url: `/pages3/polyv/detail?id=''&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`
  766. })
  767. } else if(res.data.total == 1) {
  768. uni.navigateTo({
  769. url: `/pages3/polyv/detail?id=${res.data.rows[0].courseId}&goodsId=${item.goodsId}&orderGoodsId=${item.orderGoodsId}&gradeId=${item.gradeId}`
  770. })
  771. } else {
  772. uni.showToast({
  773. icon:'none',
  774. title:'暂无可观看的视频课程'
  775. })
  776. }
  777. }
  778. })
  779. }
  780. })
  781. },
  782. toLive(item) {
  783. this.$api.courseCourseList({
  784. pageNum: 1,
  785. pageSize: 1,
  786. goodsId: item.goodsId,
  787. gradeId: 0,
  788. orderGoodsId: item.orderGoodsId,
  789. }).then(res => {
  790. if (res.data.code == 200) {
  791. if(res.data.total > 1) {
  792. // uni.navigateTo({
  793. // url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
  794. // })
  795. uni.navigateTo({
  796. url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId=""'
  797. })
  798. } else if(res.data.total == 1) {
  799. uni.navigateTo({
  800. url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId='+ res.data.rows[0].courseId
  801. })
  802. } else {
  803. uni.showToast({
  804. icon:'none',
  805. title:'暂无可观看的直播课程'
  806. })
  807. }
  808. }
  809. })
  810. },
  811. /**
  812. * @param {Object} goodsId 商品id
  813. * 查询商品重修状态
  814. */
  815. courseGoodsRebuildStatus(goodsId, gradeId) {
  816. return new Promise(resolve => {
  817. this.$http({
  818. url: '/course/goodsRebuildStatus',
  819. method: 'get',
  820. data: {
  821. goodsId: goodsId,
  822. gradeId: gradeId
  823. },
  824. // noLoading: true,
  825. // compleLoading: true, // 请求成功是否还要继续显示加载中
  826. })
  827. .then(res => {
  828. resolve(res.data.data)
  829. })
  830. })
  831. },
  832. closePop() {
  833. this.toggleSkuShow = false
  834. },
  835. selectSku(item, index, c_index) {
  836. console.log('defhd', item, index, c_index)
  837. this.$set(this.specList[index].specAttrList[c_index], '')
  838. // this.specList
  839. // this.skuItem = item
  840. // this.skuIndex = index
  841. },
  842. rightNowBuy() {
  843. // if (Object.keys(this.skuItem).length == 0) {
  844. // this.$u.toast('请选择科目')
  845. // return
  846. // }
  847. // if(this.$method.isGoLogin()){
  848. // return
  849. // }
  850. // this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId)
  851. }
  852. }
  853. };
  854. </script>
  855. <style >
  856. page{
  857. background-color: #F2F2F2;
  858. }
  859. </style>
  860. <style lang="scss" scope>
  861. @import './index.scss';
  862. .video_t2 {
  863. font-size: 24rpx;
  864. font-family: PingFang SC;
  865. font-weight: 500;
  866. color: #666666;
  867. }
  868. .video_t1 {
  869. height: 80rpx;
  870. color: #333333;
  871. line-height: 80rpx;
  872. font-size: 30rpx;
  873. font-family: PingFang SC;
  874. font-weight: bold;
  875. color: #333333;
  876. overflow: hidden;
  877. text-overflow:ellipsis;
  878. white-space: nowrap;
  879. }
  880. .video_t1_t {
  881. display: flex;
  882. flex-direction: column;
  883. height: 80rpx;
  884. color: #333333;
  885. text-align: center;
  886. align-items: center;
  887. border-left: solid 1px #d6d6db;
  888. }
  889. .video_play {
  890. position: absolute;
  891. width: 95rpx;
  892. height: 95rpx;
  893. top: 0;
  894. left: 0;
  895. right: 0;
  896. bottom: 0;
  897. margin: auto;
  898. }
  899. .video_box {
  900. position: relative;
  901. }
  902. .contents {
  903. width: 100%;
  904. height: 100%;
  905. background-color: #ffffff;
  906. margin-top: 16rpx;
  907. overflow: hidden;
  908. }
  909. .cou_title {
  910. padding: 24rpx 32rpx 40rpx 32rpx;
  911. display: flex;
  912. flex-direction: column;
  913. justify-content: space-around;
  914. }
  915. .prices {
  916. .price_word {
  917. font-size: 40rpx;
  918. font-weight: 800;
  919. color: #FC3F3F;
  920. }
  921. .sale {
  922. color: #999999;
  923. font-size: 28rpx;
  924. margin-left: 8rpx;
  925. }
  926. .price_line {
  927. color: #999999;
  928. font-size: 28rpx;
  929. text-decoration:line-through;
  930. font-weight: 400;
  931. }
  932. .free {
  933. font-size: 32rpx;
  934. }
  935. }
  936. // tab
  937. .tabs {
  938. // width: 100%;
  939. height: 78rpx;
  940. display: flex;
  941. align-items: center;
  942. justify-content: space-between;
  943. background-color: #F2F7FF;
  944. border-radius: 38rpx;
  945. margin: 24rpx;
  946. padding: 0rpx 5rpx;
  947. .tab_item {
  948. width: 345rpx;
  949. height: 65rpx;
  950. line-height: 65rpx;
  951. font-size: 28rpx;
  952. font-weight: bold;
  953. border-radius: 32rpx;
  954. text-align: center;
  955. color: #333;
  956. &.nactive {
  957. color: #fff;
  958. background-color: #3577E8;
  959. }
  960. &.twoBtn {
  961. width: 50%;
  962. }
  963. &.threeBtn {
  964. width: 33%;
  965. }
  966. }
  967. // /deep/ .u-tabs {
  968. // background:none!important;
  969. // }
  970. }
  971. .courseName{
  972. white-space:nowrap;
  973. overflow:hidden;
  974. text-overflow:ellipsis;
  975. }
  976. .videoBox{
  977. background-color: #FFFFFF;
  978. width: 100%;
  979. /* height: 680rpx; */
  980. z-index: 999;
  981. }
  982. .icon_up{
  983. width: 32rpx;
  984. height: 32rpx;
  985. }
  986. .courseItemBox{
  987. background: #FFFFFF;
  988. border-radius: 16rpx;
  989. padding: 0 10rpx;
  990. margin-bottom: 20rpx;
  991. }
  992. .courseItem{
  993. height: 80rpx;
  994. color: #333333;
  995. font-size: 32rpx;
  996. line-height: 80rpx;
  997. font-weight: bold;
  998. display: flex;
  999. justify-content: space-between;
  1000. }
  1001. .content{
  1002. background-color: #FFFFFF;
  1003. width: 100%;
  1004. }
  1005. .btn2 {
  1006. width: 187rpx;
  1007. height: 79rpx;
  1008. line-height: 79rpx;
  1009. background: #FC3F3F;
  1010. border-radius: 40rpx;
  1011. text-align: center;
  1012. font-size: 24rpx;
  1013. }
  1014. .btn1 {
  1015. width: 187rpx;
  1016. height: 79rpx;
  1017. line-height: 79rpx;
  1018. background: #FFB102;
  1019. border-radius: 40rpx;
  1020. text-align: center;
  1021. margin-right: 11rpx;
  1022. font-size: 24rpx;
  1023. }
  1024. .blackFont{
  1025. margin: 0 4rpx;
  1026. }
  1027. .wk_icon{
  1028. width: 24rpx;
  1029. height: 24rpx;
  1030. margin-right: 12rpx;
  1031. }
  1032. .noteTag, .blackFont {
  1033. font-size: 30rpx;
  1034. font-family: PingFang SC;
  1035. font-weight: 400;
  1036. color: #A7B0B8;
  1037. align-items: center;
  1038. }
  1039. .priceTag{
  1040. /* font-size: 30rpx;
  1041. font-family: PingFang SC;
  1042. font-weight: bold;
  1043. color: #FF2D55; */
  1044. width: 60rpx;
  1045. height: 40rpx;
  1046. line-height: 40rpx;
  1047. text-align: center;
  1048. border: 1rpx solid #333;
  1049. }
  1050. .titleTag{
  1051. font-size: 32rpx;
  1052. font-weight: bold;
  1053. color: #333333;
  1054. // margin-left: 8rpx;
  1055. }
  1056. .yearTag{
  1057. width: 80rpx;
  1058. height: 32rpx;
  1059. background: #EBF5FF;
  1060. border: 2rpx solid #007AFF;
  1061. border-radius: 16rpx;
  1062. font-size: 24rpx;
  1063. color: #007AFF;
  1064. text-align: center;
  1065. line-height: 32rpx;
  1066. }
  1067. .itemBox{
  1068. background: #FFFFFF;
  1069. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1070. border-radius: 24rpx;
  1071. width: 100%;
  1072. padding: 20rpx;
  1073. margin-bottom: 20rpx;
  1074. }
  1075. // 老师名字样式
  1076. .teacher_names {
  1077. display: flex;
  1078. padding-bottom: 15rpx;
  1079. border-bottom: 2rpx solid #F0F0F0;
  1080. .names {
  1081. padding: 6rpx 12rpx;
  1082. font-size: 26rpx;
  1083. color: #969696;
  1084. background: #F8F8F8;
  1085. border-radius: 8rpx;
  1086. margin-right: 10rpx;
  1087. &.nactive {
  1088. color: #3F8DFD;
  1089. background: #F2F7FF;
  1090. }
  1091. }
  1092. }
  1093. </style>