detail.vue 27 KB

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