detail.vue 32 KB

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