detail.vue 32 KB

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