detail.vue 32 KB

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