detail.vue 31 KB

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