detail.vue 31 KB

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