detail.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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. if (res.data.has_examine) {
  300. that.loadExamine();
  301. }
  302. uni.setNavigationBarTitle({
  303. title: res.data.name
  304. });
  305. } else {
  306. that.loadingType = 3;
  307. // that.loadingText = err.data.msg || '加载失败';
  308. }
  309. });
  310. // getCourseDetail(this.courseId).then(([err, res]) => {
  311. // console.log('getCourseDetail', err, res);
  312. // if (!err) {
  313. // if (!this.hasLoad) {
  314. // if (res.auth_state == 3) {
  315. // this.showContent = 'chapter';
  316. // }
  317. // }
  318. // this.hasLoad = true;
  319. // this.loadingType = -1;
  320. // this.state = res;
  321. // if (res.has_examine) {
  322. // this.loadExamine();
  323. // }
  324. // uni.setNavigationBarTitle({
  325. // title: res.name
  326. // });
  327. // } else {
  328. // this.loadingType = 3;
  329. // this.loadingText = err.data.msg || '加载失败';
  330. // }
  331. // });
  332. },
  333. loadExamine() {
  334. this.$api.getCourseExamine({}, function (res) {
  335. console.log('getCourseExamine', res);
  336. that.examineList = res.data;
  337. });
  338. // getCourseExamine(this.courseId).then(([err, res]) => {
  339. // console.log('getCourseExamine', err, res);
  340. // if (!err) {
  341. // this.examineList = res;
  342. // }
  343. // });
  344. },
  345. onContentSwitch(type) {
  346. this.showContent = type;
  347. },
  348. onPreviewPhoto(index) {
  349. let photos = [];
  350. for (let i = 0; i < this.state.photo_list.length; i++) {
  351. photos.push(this.state.photo_list[i].url);
  352. }
  353. uni.previewImage({
  354. current: index,
  355. urls: photos
  356. });
  357. },
  358. onPlay(chapterIndex, contentIndex) {
  359. console.log('onPlay', chapterIndex, contentIndex);
  360. // if (!this.checkLogin()) {
  361. // return;
  362. // }
  363. console.log(this.state.chapter_list, 444);
  364. const content = this.state.chapter_list[chapterIndex].content_list[contentIndex];
  365. if (!content.trial_duration && !content.trial_view) {
  366. if (this.state.auth_state != 3) {
  367. this.$logic.showToast('还未开通');
  368. return;
  369. }
  370. }
  371. if (this.chapterIndex == chapterIndex && this.contentIndex == contentIndex) {
  372. if (content.type === 'rich') {
  373. uni.navigateTo({
  374. url: '/pages/course/rich?cid=' + content.id
  375. });
  376. }
  377. return;
  378. }
  379. if (this.$store.getters.isLock('wantToPlay')) {
  380. return;
  381. }
  382. this.$store.commit('lock', 'wantToPlay');
  383. setTimeout(() => {
  384. this.$store.commit('unlock', 'wantToPlay');
  385. }, 1000);
  386. this.chapterIndex = chapterIndex;
  387. this.contentIndex = contentIndex;
  388. if (this.$refs.audioPlayer) {
  389. this.$refs.audioPlayer.stop();
  390. }
  391. if (this.videoContext) {
  392. this.videoContext.stop();
  393. }
  394. this.playData = {
  395. type: 'loading'
  396. };
  397. if (content.type === 'rich') {
  398. this.playData = null;
  399. uni.navigateTo({
  400. url: '/pages/course/rich?cid=' + content.id
  401. });
  402. return;
  403. }
  404. this.$api.getContentDetail({}, function (res) {
  405. console.log(777, res);
  406. if (res.code == 1) {
  407. that.playData = res.data;
  408. that.playState.diffTime = res.data.server_time - getTimestamp();
  409. if (this.playData.type === 'video') {
  410. this.videoContext = uni.createVideoContext('videoPlayer');
  411. // setTimeout(() => {
  412. // this.videoContext.play()
  413. // }, 500)
  414. } else if (this.playData.type === 'audio') {
  415. console.log('audio load');
  416. // setTimeout(() => {
  417. // if (this.$refs.audioPlayer) {
  418. // this.$refs.audioPlayer.play()
  419. // }
  420. // }, 500)
  421. }
  422. }
  423. });
  424. // getContentDetail(content.id).then(([err, res]) => {
  425. // console.log('getContentDetail', err, res);
  426. // if (!err) {
  427. // this.playData = res;
  428. // this.playState.diffTime = res.server_time - getTimestamp();
  429. // if (this.playData.type === 'video') {
  430. // this.videoContext = uni.createVideoContext('videoPlayer');
  431. // // setTimeout(() => {
  432. // // this.videoContext.play()
  433. // // }, 500)
  434. // } else if (this.playData.type === 'audio') {
  435. // console.log('audio load');
  436. // // setTimeout(() => {
  437. // // if (this.$refs.audioPlayer) {
  438. // // this.$refs.audioPlayer.play()
  439. // // }
  440. // // }, 500)
  441. // }
  442. // }
  443. // });
  444. },
  445. watchPlayState() {
  446. console.log('watchPlayState', this.playState);
  447. this.playState.playTime = 0;
  448. this.playState.intervalTimer = setInterval(() => {
  449. // console.log('playTime', this.playState.playTime)
  450. if (this.playState.isPlaying) {
  451. this.playState.playTime++;
  452. } else {
  453. if (this.playState.playTime > 0) {
  454. console.log('upload playState end');
  455. this.uploadPlayState();
  456. }
  457. }
  458. if (this.playState.playTime >= 5) {
  459. console.log('upload playState ing');
  460. this.uploadPlayState();
  461. }
  462. }, 1000);
  463. },
  464. uploadPlayState() {
  465. console.log('uploadPlayState', this.playState);
  466. if (this.playData.id && !this.playData.trial_duration) {
  467. const syncTime = getTimestamp() + this.playState.diffTime;
  468. syncPlayState(this.courseId, this.playData.id, this.playState.currentTime, 0, this.playState.playTime, syncTime).then(([err, res]) => {
  469. console.log('syncPlayState', err, res);
  470. if (!err) {
  471. if (++this.playState.syncTimes % 5 == 0) {
  472. // 每5次同步刷新当前数据
  473. this.loadDetail();
  474. }
  475. }
  476. });
  477. }
  478. this.playState.playTime = 0;
  479. },
  480. onVideoPlay(e) {
  481. console.log('onVideoPlay', e);
  482. this.playState.isPlaying = 1;
  483. },
  484. onVideoPause(e) {
  485. console.log('onVideoPause', e);
  486. this.playState.isPlaying = 0;
  487. },
  488. onVideoEnded(e) {
  489. console.log('onVideoEnded', e);
  490. this.playState.isPlaying = 0;
  491. },
  492. onVideoTimeupdate(e) {
  493. console.log('onVideoTimeupdate', e);
  494. if (this.playData.trial_duration) {
  495. if (e.detail.currentTime >= this.playData.trial_duration) {
  496. console.log('this.videoContext', this.videoContext);
  497. // this.videoContext.stop()
  498. this.videoContext.pause();
  499. this.videoContext.seek(0);
  500. this.$logic.showToast('试播结束');
  501. }
  502. } else {
  503. this.playState.currentTime = e.detail.currentTime;
  504. }
  505. },
  506. onAudioPlay(e) {
  507. console.log('onAudioPlay', e);
  508. this.playState.isPlaying = 1;
  509. },
  510. onAudioPause(e) {
  511. console.log('onAudioPause', e);
  512. this.playState.isPlaying = 0;
  513. },
  514. onAudioEnded(e) {
  515. console.log('onAudioEnded', e);
  516. this.playState.isPlaying = 0;
  517. },
  518. onAudioTimeupdate(e) {
  519. // console.log('onAudioTimeupdate', e)
  520. if (this.playData.trial_duration) {
  521. if (e.currentTime >= this.playData.trial_duration) {
  522. setTimeout(() => {
  523. this.$refs.audioPlayer.stop();
  524. }, 200);
  525. this.$logic.showToast('试播结束');
  526. }
  527. } else {
  528. this.playState.currentTime = e.currentTime;
  529. }
  530. },
  531. onTeacherDetail() {
  532. uni.navigateTo({
  533. url: '/pages/teacher/detail?id=' + this.state.teacher_data.id
  534. });
  535. },
  536. onJumpHome() {
  537. uni.switchTab({
  538. url: '/pages/home/index'
  539. });
  540. },
  541. onHandleLike() {
  542. if (!this.checkLogin()) {
  543. return;
  544. }
  545. var action = this.state.is_like ? 'no' : 'yes';
  546. handleLike(this.courseId, action).then(([err, res]) => {
  547. console.log('handleLike', err, res);
  548. if (!err) {
  549. if (action === 'yes') {
  550. this.state.is_like = 1;
  551. this.state.count_like++;
  552. } else {
  553. this.state.is_like = 0;
  554. this.state.count_like--;
  555. }
  556. this.$logic.showToast('操作成功');
  557. }
  558. });
  559. },
  560. onCloseCart() {
  561. this.showCart = false;
  562. },
  563. // 加入购物车
  564. onAddCart() {
  565. // if (!this.checkLogin()) {
  566. // return;
  567. // }
  568. this.$api.addCart({ id: this.courseId }, function (res) {
  569. console.log('加入购物车', res);
  570. if (res.code == 1) {
  571. this.$store.commit('addCartItem', {
  572. goods_id: that.courseId,
  573. goods_type: 'course',
  574. goods_name: that.state.name,
  575. goods_cover: that.state.cover_url,
  576. goods_price: that.state.price
  577. });
  578. that.showCart = true;
  579. setTimeout(() => {
  580. that.showCart = false;
  581. }, 5000);
  582. }
  583. });
  584. // addCart('course', this.courseId).then(([err, res]) => {
  585. // console.log('addCart', err, res);
  586. // if (!err) {
  587. // this.$store.commit('addCartItem', {
  588. // goods_id: this.courseId,
  589. // goods_type: 'course',
  590. // goods_name: this.state.name,
  591. // goods_cover: this.state.cover_url,
  592. // goods_price: this.state.price
  593. // });
  594. // this.showCart = true;
  595. // setTimeout(() => {
  596. // this.showCart = false;
  597. // }, 5000);
  598. // }
  599. // });
  600. },
  601. onPreviewOrder() {
  602. // if (!this.checkLogin()) {
  603. // return;
  604. // }
  605. let goodsData = [
  606. {
  607. goods_type: 'course',
  608. goods_id: this.courseId
  609. }
  610. ];
  611. uni.navigateTo({
  612. url: '/pages/order/preview?goods_data=' + JSON.stringify(goodsData)
  613. });
  614. },
  615. onStartLearn() {
  616. if (!this.checkLogin()) {
  617. return;
  618. }
  619. this.$api.startLearn({}, function (res) {
  620. console.log('333', res);
  621. });
  622. // startLearn(this.courseId).then(([err, res]) => {
  623. // console.log('startLearn', err, res);
  624. // if (!err) {
  625. // this.$logic.showToast('开通成功,可以开始学习了');
  626. // this.loadDetail();
  627. // }
  628. // });
  629. }
  630. }
  631. };
  632. </script>
  633. <style>
  634. page {
  635. padding-bottom: env(safe-area-inset-bottom);
  636. background: $pq-bg-color;
  637. }
  638. /* 隐藏header */
  639. uni-page-head {
  640. display: block;
  641. }
  642. .wrap {
  643. padding-bottom: 150upx;
  644. }
  645. .b-photos {
  646. position: relative;
  647. width: 750upx;
  648. height: 500upx;
  649. }
  650. .b-photos swiper {
  651. height: 100%;
  652. }
  653. .b-photos .swiper-item {
  654. display: flex;
  655. justify-content: center;
  656. align-content: center;
  657. height: 320upx;
  658. overflow: hidden;
  659. }
  660. .b-photos .swiper-item image {
  661. width: 100%;
  662. height: 100%;
  663. }
  664. .b-photos .image-wrapper {
  665. width: 100%;
  666. height: 100%;
  667. }
  668. .b-player {
  669. width: 100%;
  670. height: 500upx;
  671. }
  672. .b-player.f-loading {
  673. display: flex;
  674. align-items: center;
  675. justify-content: center;
  676. }
  677. .b-player.f-loading .s-cont {
  678. font-size: 28upx;
  679. color: #666;
  680. }
  681. .b-player.f-video video {
  682. width: 100%;
  683. height: 500upx;
  684. }
  685. .b-slide {
  686. display: flex;
  687. align-items: center;
  688. justify-content: center;
  689. background: #fff;
  690. border-bottom: 2upx solid #eee;
  691. }
  692. .b-slide .b-item {
  693. flex: 1;
  694. height: 80upx;
  695. line-height: 80upx;
  696. font-size: 28upx;
  697. text-align: center;
  698. }
  699. .b-slide .b-item.f-active {
  700. height: 76upx;
  701. line-height: 80upx;
  702. font-weight: bold;
  703. border-bottom: 4upx solid #da5650;
  704. }
  705. .info {
  706. padding: 30upx;
  707. background: #fff;
  708. }
  709. .info .b-title {
  710. font-size: 30upx;
  711. color: #333;
  712. }
  713. .info .b-main {
  714. margin-top: 20upx;
  715. display: flex;
  716. align-items: center;
  717. justify-content: space-between;
  718. }
  719. .info .b-main .b-price {
  720. display: flex;
  721. align-items: center;
  722. }
  723. .info .b-main .b-price .s-payment {
  724. margin-right: 20upx;
  725. font-size: 36upx;
  726. font-weight: bold;
  727. color: #dd524d;
  728. }
  729. .info .b-main .b-price .s-payment.f-small {
  730. font-size: 28upx;
  731. }
  732. .info .b-main .b-price .s-vip-price {
  733. margin-right: 20upx;
  734. font-size: 26upx;
  735. color: #f0ad4e;
  736. }
  737. .info .b-main .b-price .s-vip-free {
  738. margin-right: 20upx;
  739. padding: 6upx 10upx;
  740. font-size: 24upx;
  741. color: #555;
  742. background: #f0ad4e;
  743. border-radius: 5upx;
  744. }
  745. .info .b-main .b-opt {
  746. display: flex;
  747. align-items: center;
  748. }
  749. .info .b-main .b-opt .s-btn {
  750. margin-left: 20upx;
  751. font-size: 50upx;
  752. }
  753. .info .b-main .b-opt .s-btn.f-like .f-yes.iconfont {
  754. color: #da5650;
  755. }
  756. .info .b-main .b-opt .iconfont {
  757. font-size: 40upx;
  758. color: #999;
  759. }
  760. .info .b-info {
  761. margin-top: 20upx;
  762. display: flex;
  763. align-items: center;
  764. justify-content: space-between;
  765. }
  766. .info .b-info .s-worth {
  767. color: #999;
  768. font-size: 24upx;
  769. }
  770. .info .b-info .s-count {
  771. color: #999;
  772. font-size: 24upx;
  773. display: flex;
  774. align-items: center;
  775. }
  776. .info .b-info .s-count .s-gain {
  777. margin-left: 40upx;
  778. }
  779. .teacher {
  780. margin-top: 30upx;
  781. padding: 30upx;
  782. background: #fff;
  783. display: flex;
  784. flex-direction: column;
  785. }
  786. .teacher .b-title {
  787. font-size: 28upx;
  788. font-weight: bold;
  789. }
  790. .teacher .b-teacher {
  791. margin-top: 20upx;
  792. display: flex;
  793. align-items: center;
  794. justify-content: space-between;
  795. }
  796. .teacher .b-teacher .b-avatar {
  797. width: 100upx;
  798. height: 100upx;
  799. }
  800. .teacher .b-teacher .b-avatar image {
  801. width: 100upx;
  802. height: 100upx;
  803. }
  804. .teacher .b-teacher .b-main {
  805. margin-left: 20upx;
  806. flex: 1;
  807. display: flex;
  808. flex-direction: column;
  809. }
  810. .teacher .b-teacher .b-main .s-name {
  811. font-size: 26upx;
  812. color: #333;
  813. }
  814. .teacher .b-teacher .b-main .s-info {
  815. margin-top: 20upx;
  816. font-size: 24upx;
  817. color: #666;
  818. }
  819. .teacher .b-teacher .b-more {
  820. display: flex;
  821. align-items: center;
  822. justify-content: center;
  823. }
  824. .teacher .b-teacher .b-more .iconfont {
  825. font-size: 40upx;
  826. color: #999;
  827. }
  828. .content {
  829. margin-top: 30upx;
  830. }
  831. .content .b-title {
  832. display: flex;
  833. align-items: center;
  834. justify-content: center;
  835. }
  836. .content .b-title .iconfont {
  837. color: #ccc;
  838. }
  839. .xiant {
  840. width: 60rpx;
  841. height: 3rpx;
  842. background-color: #dddedd;
  843. }
  844. .content .b-title .s-tit {
  845. margin: 0 20upx;
  846. font-size: 24upx;
  847. color: #666;
  848. }
  849. .content .b-rich {
  850. margin-top: 30upx;
  851. padding: 30upx 0;
  852. background: #fff;
  853. font-size: 28upx;
  854. }
  855. .content-list {
  856. padding: 30upx;
  857. background: #fff;
  858. }
  859. .content-list .chapter-item {
  860. margin-bottom: 30upx;
  861. }
  862. .content-list .chapter-item .chapter-info {
  863. height: 80upx;
  864. display: flex;
  865. align-items: center;
  866. justify-content: space-between;
  867. }
  868. .content-list .chapter-item .chapter-info .b-name {
  869. font-weight: bold;
  870. }
  871. .content-list .chapter-item .chapter-info .b-more {
  872. font-weight: 32upx;
  873. color: #666;
  874. }
  875. .content-list .chapter-item .chapter-content .content-item {
  876. height: 100upx;
  877. display: flex;
  878. align-items: center;
  879. justify-content: space-between;
  880. border-bottom: 2upx solid #eee;
  881. }
  882. .content-list .chapter-item .chapter-content .content-item.f-active {
  883. font-weight: bold;
  884. }
  885. .content-list .chapter-item .chapter-content .content-item .b-main {
  886. display: flex;
  887. align-items: center;
  888. }
  889. .content-list .chapter-item .chapter-content .content-item .b-main .s-name {
  890. font-size: 28upx;
  891. color: #666;
  892. max-width: 500upx;
  893. display: inline-block;
  894. }
  895. .content-list .chapter-item .chapter-content .content-item .b-main .s-time {
  896. margin-left: 20upx;
  897. font-size: 26upx;
  898. color: #666;
  899. }
  900. .content-list .chapter-item .chapter-content .content-item .b-play {
  901. display: flex;
  902. align-items: center;
  903. }
  904. .content-list .chapter-item .chapter-content .content-item .b-play .s-percent {
  905. margin-right: 20upx;
  906. font-size: 26upx;
  907. color: #666;
  908. }
  909. .content-list .chapter-item .chapter-content .content-item .b-play .s-state {
  910. margin-right: 20upx;
  911. font-size: 26upx;
  912. color: #da5650;
  913. }
  914. .content-list .chapter-item .chapter-content .content-item .b-play .s-play .iconfont {
  915. font-size: 60upx;
  916. color: #333;
  917. }
  918. .navbar {
  919. padding: 10upx 0;
  920. position: fixed;
  921. left: 0;
  922. bottom: 0;
  923. width: 100%;
  924. height: 100upx;
  925. background: #fff;
  926. border-top: 1upx solid #f6f6f6;
  927. display: flex;
  928. align-items: center;
  929. justify-content: space-between;
  930. }
  931. .navbar .b-main {
  932. margin-left: 30upx;
  933. flex: 1;
  934. display: flex;
  935. align-items: center;
  936. }
  937. .navbar .b-main .b-amount {
  938. flex: 1;
  939. display: flex;
  940. align-items: center;
  941. justify-content: center;
  942. }
  943. .navbar .b-main .b-amount .s-tit {
  944. margin-right: 10upx;
  945. font-size: 28upx;
  946. color: #333;
  947. }
  948. .navbar .b-main .b-amount .s-num {
  949. font-size: 40upx;
  950. color: #da5650;
  951. }
  952. .navbar .b-main .b-amount .s-num.f-small {
  953. font-size: 32upx;
  954. }
  955. .navbar .b-main .b-amount .s-vip-price {
  956. margin-left: 20upx;
  957. font-size: 28upx;
  958. font-weight: bold;
  959. color: #f0ad4e;
  960. }
  961. .navbar .b-main .b-amount .s-vip-free {
  962. margin-left: 20upx;
  963. padding: 6upx 10upx;
  964. font-size: 24upx;
  965. color: #555;
  966. background: #f0ad4e;
  967. border-radius: 5upx;
  968. }
  969. .navbar .b-action {
  970. margin-right: 30upx;
  971. width: 450upx;
  972. display: flex;
  973. align-items: center;
  974. }
  975. .navbar .b-action .b-btn {
  976. height: 80upx;
  977. line-height: 80upx;
  978. font-size: 28upx;
  979. color: #fff;
  980. text-align: center;
  981. letter-spacing: 2upx;
  982. }
  983. .navbar .b-action .f-cart {
  984. flex: 1;
  985. background: #ec9c4e;
  986. font-size: 26upx;
  987. border-radius: 40upx 0 0 40upx;
  988. }
  989. .navbar .b-action .f-cart.f-disable {
  990. background: rgba(218, 86, 80, 0.8);
  991. }
  992. .navbar .b-action .f-order {
  993. flex: 1;
  994. background: #da5650;
  995. font-size: 26upx;
  996. border-radius: 0 40upx 40upx 0;
  997. }
  998. .navbar .b-action .f-order.f-disable {
  999. background: rgba(218, 86, 80, 0.8);
  1000. }
  1001. .navbar .b-action .f-learn {
  1002. flex: 1;
  1003. letter-spacing: 4upx;
  1004. background: #da5650;
  1005. border-radius: 40upx;
  1006. }
  1007. .navbar .b-action .f-mute {
  1008. flex: 1;
  1009. color: #666;
  1010. font-size: 26upx;
  1011. background: #eee;
  1012. border-radius: 40upx;
  1013. }
  1014. </style>