detail.vue 31 KB

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