detail.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <view class="wrap">
  3. <u-navbar :autoBack="true" title="课程详情" bgColor="rgba(255,255,255,255)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
  4. <!-- <view class="main" v-if="hasLoad"> 暂时取消隐藏看效果-->
  5. <view class="main">
  6. <view class="b-top" v-if="playData">
  7. <view class="b-player f-loading" v-if="playData.type === 'loading'">
  8. <view class="s-cont">加载中</view>
  9. </view>
  10. <view class="b-player f-video" v-else-if="playData.type === 'video'">
  11. <video
  12. id="videoPlayer"
  13. :src="videoData.src"
  14. :poster="videoData.poster"
  15. :autoplay="true"
  16. :duration="videoData.duration"
  17. :initial-time="videoData.currentTime"
  18. :title="playData.name"
  19. @play="onVideoPlay"
  20. @pause="onVideoPause"
  21. @ended="onVideoEnded"
  22. @timeupdate="onVideoTimeupdate"
  23. ></video>
  24. </view>
  25. <view class="b-player f-video" v-else-if="playData.type === 'audio'">
  26. <audio-player
  27. ref="audioPlayer"
  28. :chapterName="chapterName"
  29. :audioData="audioData"
  30. @play="onAudioPlay"
  31. @pause="onAudioPause"
  32. @ended="onAudioEnded"
  33. @timeupdate="onAudioTimeupdate"
  34. ></audio-player>
  35. </view>
  36. </view>
  37. <view class="b-top" v-else>
  38. <view class="b-photos">
  39. <swiper indicator-dots circular="true" duration="400">
  40. <swiper-item class="swiper-item" v-for="(item, index) in state.photo_list" :key="index">
  41. <view class="image-wrapper" @click="onPreviewPhoto(index)">
  42. <image :src="item.url" mode="aspectFill"></image>
  43. </view>
  44. </swiper-item>
  45. </swiper>
  46. </view>
  47. </view>
  48. <view class="b-slide">
  49. <view class="b-item" :class="{ 'f-active': showContent === 'detail' }" @click="onContentSwitch('detail')">介绍</view>
  50. <view class="b-item" :class="{ 'f-active': showContent === 'chapter' }" @click="onContentSwitch('chapter')">目录</view>
  51. <view class="b-item" :class="{ 'f-active': showContent === 'examine' }" @click="onContentSwitch('examine')" v-if="state.has_examine">考核</view>
  52. </view>
  53. <!-- 课程目录 -->
  54. <view class="content-list" v-show="showContent === 'chapter'">
  55. <view class="chapter-item" v-for="(chapter, index) in state.chapter_list" :key="index">
  56. <view class="chapter-info">
  57. <view class="b-name">第{{ index + 1 }}章 {{ chapter.name }}</view>
  58. <!-- <view class="b-more">
  59. <view class="iconfont icon-fold"></view>
  60. </view> -->
  61. </view>
  62. <view class="chapter-content">
  63. <view
  64. class="content-item"
  65. v-for="(sContent, sIndex) in state.chapter_list[index].content_list"
  66. :key="sIndex"
  67. :class="{ 'f-active': chapterIndex == index && contentIndex == sIndex }"
  68. >
  69. <view class="b-main">
  70. <view class="s-name too-long">{{ index + 1 }}-{{ sIndex + 1 }} {{ sContent.name }}</view>
  71. <view class="s-time" v-if="sContent.duration > 0">{{ sContent.duration_text }}</view>
  72. </view>
  73. <view class="b-play" @click="onPlay(index, sIndex)">
  74. <view class="s-state" v-if="goonPlay(sContent.id)">继续</view>
  75. <view class="s-state" v-else-if="sContent.trial_view">试读</view>
  76. <view class="s-state" v-else-if="sContent.trial_duration">试播{{ sContent.trial_duration }}秒</view>
  77. <view class="s-percent" v-if="sContent.learn_percent > 0">{{ sContent.learn_percent }}%</view>
  78. <view class="s-play" v-if="sContent.type === 'video'">
  79. <view class="iconfont icon-video" v-show="!(chapterIndex == index && contentIndex == sIndex)"></view>
  80. <view class="iconfont icon-video-ing" v-show="chapterIndex == index && contentIndex == sIndex"></view>
  81. </view>
  82. <view class="s-play" v-else-if="sContent.type === 'audio'">
  83. <view class="iconfont icon-audio" v-show="!(chapterIndex == index && contentIndex == sIndex)"></view>
  84. <view class="iconfont icon-audio-ing" v-show="chapterIndex == index && contentIndex == sIndex"></view>
  85. </view>
  86. <view class="s-play" v-else-if="sContent.type === 'rich'">
  87. <view class="iconfont icon-rich"></view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 课程目录 -->
  94. </view>
  95. <!-- 课程介绍 -->
  96. <view class="course-detail" v-show="showContent === 'detail'">
  97. <view class="info">
  98. <view class="b-title">{{ state.name }}</view>
  99. <view class="b-main">
  100. <view class="b-price">
  101. <view class="s-payment" :class="{ 'f-small': textCost }">{{ goodsPrice(state.price) }}</view>
  102. <!-- <view class="s-vip-price" v-if="state.card_price > 0 && !iphonePlatform">会员价 ¥{{ state.card_price }}</view>
  103. <view class="s-vip-free" v-if="state.vip_free">会员免费</view> -->
  104. </view>
  105. <view class="b-opt">
  106. <view class="s-btn f-like" @click="onHandleLike()">
  107. <view class="f-yes iconfont icon-like-yes" v-if="state.is_like"></view>
  108. <view class="f-no iconfont icon-like-no" v-else></view>
  109. </view>
  110. <button class="s-btn f-shar open-data-btn" open-type="share">
  111. <view class="iconfont icon-share"></view>
  112. </button>
  113. <!-- <view class="s-btn f-share">
  114. <view class="iconfont icon-share"></view>
  115. </view> -->
  116. </view>
  117. </view>
  118. <view class="b-info">
  119. <view class="s-worth">{{ state.category_name }}</view>
  120. <view class="s-count">
  121. <view class="s-left">{{ state.count_user }}人学习</view>
  122. <view class="s-gain">{{ state.count_like }}人收藏</view>
  123. </view>
  124. </view>
  125. </view>
  126. <!-- <view class="teacher" v-if="state.teacher_data"> 暂时取消隐藏看效果-->
  127. <view class="teacher">
  128. <view class="b-title">课程讲师</view>
  129. <view class="b-teacher" @click="onTeacherDetail">
  130. <view class="b-avatar">
  131. <image :src="state.teacher_data.avatar_url" mode=""></image>
  132. </view>
  133. <view class="b-main">
  134. <view class="s-name">{{ state.teacher_data.name }}</view>
  135. <view class="s-info">{{ state.teacher_data.intro }}</view>
  136. </view>
  137. <!-- <view class="b-more">
  138. <view class="iconfont icon-more"></view>
  139. </view> -->
  140. </view>
  141. </view>
  142. <view class="content">
  143. <view class="b-title">
  144. <view class="xiant"></view>
  145. <view class="s-tit">课程详情</view>
  146. <view class="xiant"></view>
  147. </view>
  148. <view class="b-rich">
  149. <rich-text :nodes="state.content"></rich-text>
  150. </view>
  151. </view>
  152. </view>
  153. <!-- 课程介绍end -->
  154. <!-- 考核 -->
  155. <view class="course-examine" v-show="showContent === 'examine'">
  156. <view class="examine-list" v-if="examineList.length > 0">
  157. <examine-item v-for="(item, index) in examineList" :key="index" :item="item"></examine-item>
  158. </view>
  159. </view>
  160. <view class="navbar" v-if="state.auth_state != 3">
  161. <view class="b-main">
  162. <view class="b-amount">
  163. <view class="s-num" :class="{ 'f-small': textCost }">{{ goodsPrice(state.price) }}</view>
  164. </view>
  165. </view>
  166. <view class="b-action" v-if="state.auth_state == 0">
  167. <view class="b-btn f-mute" v-if="iphonePlatform">根据相关规定,iOS不支持购买</view>
  168. <template v-else>
  169. <view class="b-btn f-cart" @click="onAddCart()">加入购物车</view>
  170. <view class="b-btn f-order" @click="onPreviewOrder()">立即购买</view>
  171. </template>
  172. </view>
  173. <view class="b-action" v-else-if="state.auth_state == 1">
  174. <view class="b-btn f-learn" @click="onStartLearn()">开始学习</view>
  175. </view>
  176. <view class="b-action" v-else-if="state.auth_state == 2">
  177. <view class="b-btn f-learn" @click="onStartLearn()">VIP免费</view>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 加载中 -->
  182. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  183. <!-- 快捷购物车 -->
  184. <quick-cart :show="showCart" @close="onCloseCart()"></quick-cart>
  185. <!-- 首页 -->
  186. <app-home></app-home>
  187. </view>
  188. </template>
  189. <script>
  190. // import { startLearn, syncPlayState, handleLike, getCourseDetail, getCourseExamine, getContentDetail } from '@/service/api/course.js';
  191. // import { addCart } from '@/service/api/order.js';
  192. // import { getTimestamp } from '@/common/util.js';
  193. import mixinsGoods from '@/mixins/goods.js';
  194. import mixinsCommon from '@/mixins/common.js';
  195. let that;
  196. export default {
  197. mixins: [mixinsCommon, mixinsGoods],
  198. data() {
  199. return {
  200. state: null,
  201. examineList: [],
  202. chapterIndex: -1,
  203. contentIndex: -1,
  204. showContent: 'detail',
  205. showCart: false,
  206. hasLoad: false,
  207. loadingType: 1,
  208. loadingText: '',
  209. playData: null,
  210. playState: {
  211. intervalTimer: 0,
  212. diffTime: 0,
  213. syncTimes: 0,
  214. isPlaying: 0,
  215. currentTime: 0,
  216. playTime: 0
  217. }
  218. };
  219. },
  220. onLoad(options) {
  221. that = this;
  222. this.courseId = options.cid;
  223. this.loadDetail();
  224. if (!this.playState.intervalTimer) {
  225. // this.watchPlayState();
  226. }
  227. },
  228. onUnload() {
  229. console.log('onUnload', this.playState.intervalTimer);
  230. if (this.playState.intervalTimer > 0) {
  231. console.log('clear intervalTimer');
  232. clearInterval(this.playState.intervalTimer);
  233. this.playState.intervalTimer = 0;
  234. }
  235. if (this.$refs.audioPlayer) {
  236. console.log('stop audioPlayer');
  237. this.$refs.audioPlayer.stop();
  238. }
  239. if (this.videoContext) {
  240. console.log('stop videoPlayer');
  241. this.videoContext.stop();
  242. }
  243. },
  244. computed: {
  245. // videoData() {
  246. // return {
  247. // poster: this.playData.data.poster,
  248. // src: this.playData.data.src,
  249. // duration: this.playData.data.duration,
  250. // currentTime: this.playData.trial_duration > 0 ? 0 : this.playData.learn_data.current_time
  251. // };
  252. // },
  253. // audioData() {
  254. // return {
  255. // id: this.playData.id,
  256. // name: this.playData.name,
  257. // src: this.playData.data.src,
  258. // duration: this.playData.data.duration,
  259. // currentTime: this.playData.trial_duration > 0 ? 0 : this.playData.learn_data.current_time
  260. // };
  261. // },
  262. // chapterName() {
  263. // return this.state.chapter_list[this.chapterIndex].name;
  264. // },
  265. goonPlay() {
  266. return (contentId) => {
  267. return this.state.recent_data && contentId == this.state.recent_data.content_id;
  268. };
  269. },
  270. orderPayment() {
  271. return this.state.card_auth && this.state.card_price ? this.state.card_price : this.state.price;
  272. }
  273. },
  274. onShareAppMessage(res) {
  275. // console.log('onShareAppMessage', res);
  276. // if (res.from === 'button') {
  277. // // 来自页面内分享按钮
  278. // console.log(res.target);
  279. // }
  280. // return {
  281. // title: this.state.name,
  282. // path: '/pages/course/detail?cid=' + this.courseId,
  283. // imageUrl: this.state.photo_list[0]['url']
  284. // };
  285. },
  286. methods: {
  287. loadDetail() {
  288. this.$api.getCourseDetail({ id: this.courseId }, function (res) {
  289. console.log(res, 55555);
  290. if (res.code == 1) {
  291. if (!that.hasLoad) {
  292. if (res.data.auth_state == 3) {
  293. that.showContent = 'chapter';
  294. }
  295. }
  296. that.hasLoad = true;
  297. that.loadingType = -1;
  298. that.state = res.data;
  299. console.log(that.state, 88888888888);
  300. if (res.data.has_examine) {
  301. that.loadExamine();
  302. }
  303. uni.setNavigationBarTitle({
  304. title: res.data.name
  305. });
  306. } else {
  307. that.loadingType = 3;
  308. // that.loadingText = err.data.msg || '加载失败';
  309. }
  310. });
  311. // getCourseDetail(this.courseId).then(([err, res]) => {
  312. // console.log('getCourseDetail', err, res);
  313. // if (!err) {
  314. // if (!this.hasLoad) {
  315. // if (res.auth_state == 3) {
  316. // this.showContent = 'chapter';
  317. // }
  318. // }
  319. // this.hasLoad = true;
  320. // this.loadingType = -1;
  321. // this.state = res;
  322. // if (res.has_examine) {
  323. // this.loadExamine();
  324. // }
  325. // uni.setNavigationBarTitle({
  326. // title: res.name
  327. // });
  328. // } else {
  329. // this.loadingType = 3;
  330. // this.loadingText = err.data.msg || '加载失败';
  331. // }
  332. // });
  333. },
  334. loadExamine() {
  335. this.$api.getCourseExamine({}, function (res) {
  336. console.log('getCourseExamine', res);
  337. that.examineList = res.data;
  338. });
  339. // getCourseExamine(this.courseId).then(([err, res]) => {
  340. // console.log('getCourseExamine', err, res);
  341. // if (!err) {
  342. // this.examineList = res;
  343. // }
  344. // });
  345. },
  346. onContentSwitch(type) {
  347. this.showContent = type;
  348. },
  349. onPreviewPhoto(index) {
  350. let photos = [];
  351. for (let i = 0; i < this.state.photo_list.length; i++) {
  352. photos.push(this.state.photo_list[i].url);
  353. }
  354. uni.previewImage({
  355. current: index,
  356. urls: photos
  357. });
  358. },
  359. onPlay(chapterIndex, contentIndex) {
  360. console.log('onPlay', chapterIndex, contentIndex);
  361. // if (!this.checkLogin()) {
  362. // return;
  363. // }
  364. // console.log(that.state.chapter_list, 444);
  365. const content = this.state.chapter_list[chapterIndex].content_list[contentIndex];
  366. if (!content.trial_duration && !content.trial_view) {
  367. if (this.state.auth_state != 3) {
  368. this.$logic.showToast('还未开通');
  369. return;
  370. }
  371. }
  372. if (this.chapterIndex == chapterIndex && this.contentIndex == contentIndex) {
  373. if (content.type === 'rich') {
  374. uni.navigateTo({
  375. url: '/pages/course/rich?cid=' + content.id
  376. });
  377. }
  378. return;
  379. }
  380. if (this.$store.getters.isLock('wantToPlay')) {
  381. return;
  382. }
  383. this.$store.commit('lock', 'wantToPlay');
  384. setTimeout(() => {
  385. this.$store.commit('unlock', 'wantToPlay');
  386. }, 1000);
  387. this.chapterIndex = chapterIndex;
  388. this.contentIndex = contentIndex;
  389. if (this.$refs.audioPlayer) {
  390. this.$refs.audioPlayer.stop();
  391. }
  392. if (this.videoContext) {
  393. this.videoContext.stop();
  394. }
  395. this.playData = {
  396. type: 'loading'
  397. };
  398. if (content.type === 'rich') {
  399. this.playData = null;
  400. uni.navigateTo({
  401. url: '/pages/course/rich?cid=' + content.id
  402. });
  403. return;
  404. }
  405. this.$api.getContentDetail({}, function (res) {
  406. console.log(777, res);
  407. if (res.code == 1) {
  408. that.playData = res.data;
  409. that.playState.diffTime = res.data.server_time - getTimestamp();
  410. if (this.playData.type === 'video') {
  411. this.videoContext = uni.createVideoContext('videoPlayer');
  412. // setTimeout(() => {
  413. // this.videoContext.play()
  414. // }, 500)
  415. } else if (this.playData.type === 'audio') {
  416. console.log('audio load');
  417. // setTimeout(() => {
  418. // if (this.$refs.audioPlayer) {
  419. // this.$refs.audioPlayer.play()
  420. // }
  421. // }, 500)
  422. }
  423. }
  424. });
  425. // getContentDetail(content.id).then(([err, res]) => {
  426. // console.log('getContentDetail', err, res);
  427. // if (!err) {
  428. // this.playData = res;
  429. // this.playState.diffTime = res.server_time - getTimestamp();
  430. // if (this.playData.type === 'video') {
  431. // this.videoContext = uni.createVideoContext('videoPlayer');
  432. // // setTimeout(() => {
  433. // // this.videoContext.play()
  434. // // }, 500)
  435. // } else if (this.playData.type === 'audio') {
  436. // console.log('audio load');
  437. // // setTimeout(() => {
  438. // // if (this.$refs.audioPlayer) {
  439. // // this.$refs.audioPlayer.play()
  440. // // }
  441. // // }, 500)
  442. // }
  443. // }
  444. // });
  445. },
  446. watchPlayState() {
  447. console.log('watchPlayState', this.playState);
  448. this.playState.playTime = 0;
  449. this.playState.intervalTimer = setInterval(() => {
  450. // console.log('playTime', this.playState.playTime)
  451. if (this.playState.isPlaying) {
  452. this.playState.playTime++;
  453. } else {
  454. if (this.playState.playTime > 0) {
  455. console.log('upload playState end');
  456. this.uploadPlayState();
  457. }
  458. }
  459. if (this.playState.playTime >= 5) {
  460. console.log('upload playState ing');
  461. this.uploadPlayState();
  462. }
  463. }, 1000);
  464. },
  465. uploadPlayState() {
  466. console.log('uploadPlayState', this.playState);
  467. if (this.playData.id && !this.playData.trial_duration) {
  468. const syncTime = getTimestamp() + this.playState.diffTime;
  469. syncPlayState(this.courseId, this.playData.id, this.playState.currentTime, 0, this.playState.playTime, syncTime).then(([err, res]) => {
  470. console.log('syncPlayState', err, res);
  471. if (!err) {
  472. if (++this.playState.syncTimes % 5 == 0) {
  473. // 每5次同步刷新当前数据
  474. this.loadDetail();
  475. }
  476. }
  477. });
  478. }
  479. this.playState.playTime = 0;
  480. },
  481. onVideoPlay(e) {
  482. console.log('onVideoPlay', e);
  483. this.playState.isPlaying = 1;
  484. },
  485. onVideoPause(e) {
  486. console.log('onVideoPause', e);
  487. this.playState.isPlaying = 0;
  488. },
  489. onVideoEnded(e) {
  490. console.log('onVideoEnded', e);
  491. this.playState.isPlaying = 0;
  492. },
  493. onVideoTimeupdate(e) {
  494. console.log('onVideoTimeupdate', e);
  495. if (this.playData.trial_duration) {
  496. if (e.detail.currentTime >= this.playData.trial_duration) {
  497. console.log('this.videoContext', this.videoContext);
  498. // this.videoContext.stop()
  499. this.videoContext.pause();
  500. this.videoContext.seek(0);
  501. this.$logic.showToast('试播结束');
  502. }
  503. } else {
  504. this.playState.currentTime = e.detail.currentTime;
  505. }
  506. },
  507. onAudioPlay(e) {
  508. console.log('onAudioPlay', e);
  509. this.playState.isPlaying = 1;
  510. },
  511. onAudioPause(e) {
  512. console.log('onAudioPause', e);
  513. this.playState.isPlaying = 0;
  514. },
  515. onAudioEnded(e) {
  516. console.log('onAudioEnded', e);
  517. this.playState.isPlaying = 0;
  518. },
  519. onAudioTimeupdate(e) {
  520. // console.log('onAudioTimeupdate', e)
  521. if (this.playData.trial_duration) {
  522. if (e.currentTime >= this.playData.trial_duration) {
  523. setTimeout(() => {
  524. this.$refs.audioPlayer.stop();
  525. }, 200);
  526. this.$logic.showToast('试播结束');
  527. }
  528. } else {
  529. this.playState.currentTime = e.currentTime;
  530. }
  531. },
  532. onTeacherDetail() {
  533. uni.navigateTo({
  534. url: '/pages/teacher/detail?id=' + this.state.teacher_data.id
  535. });
  536. },
  537. onJumpHome() {
  538. uni.switchTab({
  539. url: '/pages/home/index'
  540. });
  541. },
  542. onHandleLike() {
  543. if (!this.checkLogin()) {
  544. return;
  545. }
  546. var action = this.state.is_like ? 'no' : 'yes';
  547. handleLike(this.courseId, action).then(([err, res]) => {
  548. console.log('handleLike', err, res);
  549. if (!err) {
  550. if (action === 'yes') {
  551. this.state.is_like = 1;
  552. this.state.count_like++;
  553. } else {
  554. this.state.is_like = 0;
  555. this.state.count_like--;
  556. }
  557. this.$logic.showToast('操作成功');
  558. }
  559. });
  560. },
  561. onCloseCart() {
  562. this.showCart = false;
  563. },
  564. // 加入购物车
  565. onAddCart() {
  566. // if (!this.checkLogin()) {
  567. // return;
  568. // }
  569. this.$api.addCart({ id: this.courseId }, function (res) {
  570. console.log('加入购物车', res);
  571. if (res.code == 1) {
  572. this.$store.commit('addCartItem', {
  573. goods_id: that.courseId,
  574. goods_type: 'course',
  575. goods_name: that.state.name,
  576. goods_cover: that.state.cover_url,
  577. goods_price: that.state.price
  578. });
  579. that.showCart = true;
  580. setTimeout(() => {
  581. that.showCart = false;
  582. }, 5000);
  583. }
  584. });
  585. // addCart('course', this.courseId).then(([err, res]) => {
  586. // console.log('addCart', err, res);
  587. // if (!err) {
  588. // this.$store.commit('addCartItem', {
  589. // goods_id: this.courseId,
  590. // goods_type: 'course',
  591. // goods_name: this.state.name,
  592. // goods_cover: this.state.cover_url,
  593. // goods_price: this.state.price
  594. // });
  595. // this.showCart = true;
  596. // setTimeout(() => {
  597. // this.showCart = false;
  598. // }, 5000);
  599. // }
  600. // });
  601. },
  602. onPreviewOrder() {
  603. // if (!this.checkLogin()) {
  604. // return;
  605. // }
  606. let goodsData = [
  607. {
  608. goods_type: 'course',
  609. goods_id: this.courseId
  610. }
  611. ];
  612. uni.navigateTo({
  613. url: '/pages/order/preview?goods_data=' + JSON.stringify(goodsData)
  614. });
  615. },
  616. onStartLearn() {
  617. if (!this.checkLogin()) {
  618. return;
  619. }
  620. this.$api.startLearn({}, function (res) {
  621. console.log('333', res);
  622. });
  623. // startLearn(this.courseId).then(([err, res]) => {
  624. // console.log('startLearn', err, res);
  625. // if (!err) {
  626. // this.$logic.showToast('开通成功,可以开始学习了');
  627. // this.loadDetail();
  628. // }
  629. // });
  630. }
  631. }
  632. };
  633. </script>
  634. <style>
  635. page {
  636. padding-bottom: env(safe-area-inset-bottom);
  637. background: $pq-bg-color;
  638. }
  639. /* 隐藏header */
  640. uni-page-head {
  641. display: block;
  642. }
  643. .wrap {
  644. padding-bottom: 150upx;
  645. }
  646. .b-photos {
  647. position: relative;
  648. width: 750upx;
  649. height: 500upx;
  650. }
  651. .b-photos swiper {
  652. height: 100%;
  653. }
  654. .b-photos .swiper-item {
  655. display: flex;
  656. justify-content: center;
  657. align-content: center;
  658. height: 320upx;
  659. overflow: hidden;
  660. }
  661. .b-photos .swiper-item image {
  662. width: 100%;
  663. height: 100%;
  664. }
  665. .b-photos .image-wrapper {
  666. width: 100%;
  667. height: 100%;
  668. }
  669. .b-player {
  670. width: 100%;
  671. height: 500upx;
  672. }
  673. .b-player.f-loading {
  674. display: flex;
  675. align-items: center;
  676. justify-content: center;
  677. }
  678. .b-player.f-loading .s-cont {
  679. font-size: 28upx;
  680. color: #666;
  681. }
  682. .b-player.f-video video {
  683. width: 100%;
  684. height: 500upx;
  685. }
  686. .b-slide {
  687. display: flex;
  688. align-items: center;
  689. justify-content: center;
  690. background: #fff;
  691. border-bottom: 2upx solid #eee;
  692. }
  693. .b-slide .b-item {
  694. flex: 1;
  695. height: 80upx;
  696. line-height: 80upx;
  697. font-size: 28upx;
  698. text-align: center;
  699. }
  700. .b-slide .b-item.f-active {
  701. height: 76upx;
  702. line-height: 80upx;
  703. font-weight: bold;
  704. border-bottom: 4upx solid #da5650;
  705. }
  706. .info {
  707. padding: 30upx;
  708. background: #fff;
  709. }
  710. .info .b-title {
  711. font-size: 30upx;
  712. color: #333;
  713. }
  714. .info .b-main {
  715. margin-top: 20upx;
  716. display: flex;
  717. align-items: center;
  718. justify-content: space-between;
  719. }
  720. .info .b-main .b-price {
  721. display: flex;
  722. align-items: center;
  723. }
  724. .info .b-main .b-price .s-payment {
  725. margin-right: 20upx;
  726. font-size: 36upx;
  727. font-weight: bold;
  728. color: #dd524d;
  729. }
  730. .info .b-main .b-price .s-payment.f-small {
  731. font-size: 28upx;
  732. }
  733. .info .b-main .b-price .s-vip-price {
  734. margin-right: 20upx;
  735. font-size: 26upx;
  736. color: #f0ad4e;
  737. }
  738. .info .b-main .b-price .s-vip-free {
  739. margin-right: 20upx;
  740. padding: 6upx 10upx;
  741. font-size: 24upx;
  742. color: #555;
  743. background: #f0ad4e;
  744. border-radius: 5upx;
  745. }
  746. .info .b-main .b-opt {
  747. display: flex;
  748. align-items: center;
  749. }
  750. .info .b-main .b-opt .s-btn {
  751. margin-left: 20upx;
  752. font-size: 50upx;
  753. }
  754. .info .b-main .b-opt .s-btn.f-like .f-yes.iconfont {
  755. color: #da5650;
  756. }
  757. .info .b-main .b-opt .iconfont {
  758. font-size: 40upx;
  759. color: #999;
  760. }
  761. .info .b-info {
  762. margin-top: 20upx;
  763. display: flex;
  764. align-items: center;
  765. justify-content: space-between;
  766. }
  767. .info .b-info .s-worth {
  768. color: #999;
  769. font-size: 24upx;
  770. }
  771. .info .b-info .s-count {
  772. color: #999;
  773. font-size: 24upx;
  774. display: flex;
  775. align-items: center;
  776. }
  777. .info .b-info .s-count .s-gain {
  778. margin-left: 40upx;
  779. }
  780. .teacher {
  781. margin-top: 30upx;
  782. padding: 30upx;
  783. background: #fff;
  784. display: flex;
  785. flex-direction: column;
  786. }
  787. .teacher .b-title {
  788. font-size: 28upx;
  789. font-weight: bold;
  790. }
  791. .teacher .b-teacher {
  792. margin-top: 20upx;
  793. display: flex;
  794. align-items: center;
  795. justify-content: space-between;
  796. }
  797. .teacher .b-teacher .b-avatar {
  798. width: 100upx;
  799. height: 100upx;
  800. }
  801. .teacher .b-teacher .b-avatar image {
  802. width: 100upx;
  803. height: 100upx;
  804. }
  805. .teacher .b-teacher .b-main {
  806. margin-left: 20upx;
  807. flex: 1;
  808. display: flex;
  809. flex-direction: column;
  810. }
  811. .teacher .b-teacher .b-main .s-name {
  812. font-size: 26upx;
  813. color: #333;
  814. }
  815. .teacher .b-teacher .b-main .s-info {
  816. margin-top: 20upx;
  817. font-size: 24upx;
  818. color: #666;
  819. }
  820. .teacher .b-teacher .b-more {
  821. display: flex;
  822. align-items: center;
  823. justify-content: center;
  824. }
  825. .teacher .b-teacher .b-more .iconfont {
  826. font-size: 40upx;
  827. color: #999;
  828. }
  829. .content {
  830. margin-top: 30upx;
  831. }
  832. .content .b-title {
  833. display: flex;
  834. align-items: center;
  835. justify-content: center;
  836. }
  837. .content .b-title .iconfont {
  838. color: #ccc;
  839. }
  840. .xiant {
  841. width: 60rpx;
  842. height: 3rpx;
  843. background-color: #dddedd;
  844. }
  845. .content .b-title .s-tit {
  846. margin: 0 20upx;
  847. font-size: 24upx;
  848. color: #666;
  849. }
  850. .content .b-rich {
  851. margin-top: 30upx;
  852. padding: 30upx 0;
  853. background: #fff;
  854. font-size: 28upx;
  855. }
  856. .content-list {
  857. padding: 30upx;
  858. background: #fff;
  859. }
  860. .content-list .chapter-item {
  861. margin-bottom: 30upx;
  862. }
  863. .content-list .chapter-item .chapter-info {
  864. height: 80upx;
  865. display: flex;
  866. align-items: center;
  867. justify-content: space-between;
  868. }
  869. .content-list .chapter-item .chapter-info .b-name {
  870. font-weight: bold;
  871. }
  872. .content-list .chapter-item .chapter-info .b-more {
  873. font-weight: 32upx;
  874. color: #666;
  875. }
  876. .content-list .chapter-item .chapter-content .content-item {
  877. height: 100upx;
  878. display: flex;
  879. align-items: center;
  880. justify-content: space-between;
  881. border-bottom: 2upx solid #eee;
  882. }
  883. .content-list .chapter-item .chapter-content .content-item.f-active {
  884. font-weight: bold;
  885. }
  886. .content-list .chapter-item .chapter-content .content-item .b-main {
  887. display: flex;
  888. align-items: center;
  889. }
  890. .content-list .chapter-item .chapter-content .content-item .b-main .s-name {
  891. font-size: 28upx;
  892. color: #666;
  893. max-width: 500upx;
  894. display: inline-block;
  895. }
  896. .content-list .chapter-item .chapter-content .content-item .b-main .s-time {
  897. margin-left: 20upx;
  898. font-size: 26upx;
  899. color: #666;
  900. }
  901. .content-list .chapter-item .chapter-content .content-item .b-play {
  902. display: flex;
  903. align-items: center;
  904. }
  905. .content-list .chapter-item .chapter-content .content-item .b-play .s-percent {
  906. margin-right: 20upx;
  907. font-size: 26upx;
  908. color: #666;
  909. }
  910. .content-list .chapter-item .chapter-content .content-item .b-play .s-state {
  911. margin-right: 20upx;
  912. font-size: 26upx;
  913. color: #da5650;
  914. }
  915. .content-list .chapter-item .chapter-content .content-item .b-play .s-play .iconfont {
  916. font-size: 60upx;
  917. color: #333;
  918. }
  919. .navbar {
  920. padding: 10upx 0;
  921. position: fixed;
  922. left: 0;
  923. bottom: 0;
  924. width: 100%;
  925. height: 100upx;
  926. background: #fff;
  927. border-top: 1upx solid #f6f6f6;
  928. display: flex;
  929. align-items: center;
  930. justify-content: space-between;
  931. }
  932. .navbar .b-main {
  933. margin-left: 30upx;
  934. flex: 1;
  935. display: flex;
  936. align-items: center;
  937. }
  938. .navbar .b-main .b-amount {
  939. flex: 1;
  940. display: flex;
  941. align-items: center;
  942. justify-content: center;
  943. }
  944. .navbar .b-main .b-amount .s-tit {
  945. margin-right: 10upx;
  946. font-size: 28upx;
  947. color: #333;
  948. }
  949. .navbar .b-main .b-amount .s-num {
  950. font-size: 40upx;
  951. color: #da5650;
  952. }
  953. .navbar .b-main .b-amount .s-num.f-small {
  954. font-size: 32upx;
  955. }
  956. .navbar .b-main .b-amount .s-vip-price {
  957. margin-left: 20upx;
  958. font-size: 28upx;
  959. font-weight: bold;
  960. color: #f0ad4e;
  961. }
  962. .navbar .b-main .b-amount .s-vip-free {
  963. margin-left: 20upx;
  964. padding: 6upx 10upx;
  965. font-size: 24upx;
  966. color: #555;
  967. background: #f0ad4e;
  968. border-radius: 5upx;
  969. }
  970. .navbar .b-action {
  971. margin-right: 30upx;
  972. width: 450upx;
  973. display: flex;
  974. align-items: center;
  975. }
  976. .navbar .b-action .b-btn {
  977. height: 80upx;
  978. line-height: 80upx;
  979. font-size: 28upx;
  980. color: #fff;
  981. text-align: center;
  982. letter-spacing: 2upx;
  983. }
  984. .navbar .b-action .f-cart {
  985. flex: 1;
  986. background: #ec9c4e;
  987. font-size: 26upx;
  988. border-radius: 40upx 0 0 40upx;
  989. }
  990. .navbar .b-action .f-cart.f-disable {
  991. background: rgba(218, 86, 80, 0.8);
  992. }
  993. .navbar .b-action .f-order {
  994. flex: 1;
  995. background: #da5650;
  996. font-size: 26upx;
  997. border-radius: 0 40upx 40upx 0;
  998. }
  999. .navbar .b-action .f-order.f-disable {
  1000. background: rgba(218, 86, 80, 0.8);
  1001. }
  1002. .navbar .b-action .f-learn {
  1003. flex: 1;
  1004. letter-spacing: 4upx;
  1005. background: #da5650;
  1006. border-radius: 40upx;
  1007. }
  1008. .navbar .b-action .f-mute {
  1009. flex: 1;
  1010. color: #666;
  1011. font-size: 26upx;
  1012. background: #eee;
  1013. border-radius: 40upx;
  1014. }
  1015. </style>