detail.vue 32 KB

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