detail.vue 27 KB

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