detail.vue 31 KB

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