curriculum.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <video class="course-video" :src="url" @play="Onplay" controls="" x5-playsinline="" playsinline="" webkit-playsinline="" poster="" x-webkit-airplay="allow" preload="auto"></video>
  5. </view>
  6. <view class="list-box">
  7. <view class="title">{{list.title}}</view>
  8. <view class="play_count">已播放{{list.play_count}}次</view>
  9. </view>
  10. <view class="navbar">
  11. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  12. </view>
  13. <!-- 详情 -->
  14. <view class="course-details" v-if="tabCurrentIndex == 0">
  15. <view class="details-intro">
  16. <rich-text class="detail-centent" :nodes="list.content"></rich-text>
  17. </view>
  18. </view>
  19. <!-- 课程目录 -->
  20. <view class="course-catalogue" v-if="tabCurrentIndex == 1">
  21. <view class="course-menu flex_item" v-for="(ls, index) in courseList" :key="index" @click="ToCourseDetail(ls)">
  22. <image :src="ls.image"></image>
  23. <view class="menu-info">
  24. <view class="title">{{ls.title}}</view>
  25. <view class="tip"><text>直播回放</text></view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { task_info,course,GetTask,PlayNum } from '@/api/course.js';
  33. export default {
  34. data() {
  35. return {
  36. id:'',//课程详情id
  37. specialId:'',//专题id
  38. list:'',//详情数据
  39. url:'',
  40. tabCurrentIndex:0,
  41. navList: [
  42. {
  43. state: 0,
  44. text: '详情',
  45. },
  46. {
  47. state: 1,
  48. text: '课程目录',
  49. }
  50. ],
  51. courseList: [],
  52. play:false,
  53. };
  54. },
  55. onLoad(option) {
  56. this.id = option.id;//课程详情id
  57. this.specialId = option.specialId;//专题id
  58. this.loadData();
  59. this.course();
  60. },
  61. methods: {
  62. //加载专题详情
  63. loadData() {
  64. let obj = this;
  65. task_info({
  66. id:obj.id,
  67. specialId:obj.specialId
  68. })
  69. .then(data => {
  70. obj.list = data.data.taskInfo;
  71. obj.url = obj.list.link;
  72. })
  73. .catch(e => {
  74. if(e.message == '您未购买课程'){
  75. uni.showModal({
  76. title: '提示',
  77. content: '您未购买课程?是否购买该专题',
  78. success: function (res) {
  79. if (res.confirm) {
  80. uni.navigateTo({
  81. url:"/pages/course/detail?id="+obj.specialId
  82. })
  83. } else if (res.cancel) {
  84. uni.navigateTo({
  85. url:"/pages/course/detail?id="+obj.specialId
  86. })
  87. }
  88. }
  89. });
  90. }
  91. });
  92. },
  93. //课程目录列表
  94. course(){
  95. let obj = this;
  96. course({
  97. special_id:obj.specialId,
  98. limit:10,
  99. page:1,
  100. })
  101. .then(data => {
  102. this.courseList = data.data.list;
  103. })
  104. .catch(e => {
  105. console.log(e.message);
  106. });
  107. },
  108. //监听播放按钮
  109. Onplay(){
  110. let obj = this;
  111. if(obj.play == false){
  112. obj.play = true;
  113. obj.isPlay();
  114. }else{
  115. console.log("不是第一次播放")
  116. }
  117. },
  118. //判断视频是否可播放
  119. isPlay(){
  120. let obj = this;
  121. GetTask({
  122. task_id:obj.id,
  123. })
  124. .then(data => {
  125. obj.PlayNum();
  126. })
  127. .catch(e => {
  128. console.log(e.message);
  129. });
  130. },
  131. //播放数量加1
  132. PlayNum(){
  133. let obj = this;
  134. PlayNum({
  135. task_id:obj.id,
  136. })
  137. .then(data => {
  138. obj.loadData();
  139. })
  140. .catch(e => {
  141. console.log(e.message);
  142. });
  143. },
  144. // 课程详情
  145. ToCourseDetail(ls){
  146. // console.log(ls)
  147. let obj = this;
  148. // if(ls.is_pay == 1){
  149. // if(obj.isPay == false){
  150. // this.$api.msg('清先购买该课程!');
  151. // }else{
  152. // uni.navigateTo({
  153. // url:'/pages/course/curriculum?id='+ls.id+'&specialId='+obj.specialId
  154. // });
  155. // }
  156. // this.$api.msg('清先购买该课程!');
  157. // }else{
  158. // uni.navigateTo({
  159. // url:'/pages/course/curriculum?id='+ls.id+'&specialId='+obj.specialId
  160. // });
  161. // }
  162. uni.navigateTo({
  163. url:'/pages/course/curriculum?id='+ls.id+'&specialId='+obj.specialId
  164. });
  165. },
  166. //顶部tab点击
  167. tabClick(index) {
  168. this.tabCurrentIndex = index;
  169. },
  170. }
  171. };
  172. </script>
  173. <style lang="scss">
  174. .container {
  175. }
  176. //视频
  177. .top {
  178. width: 100%;
  179. height: 500rpx;
  180. .course-video {
  181. width: 100%;
  182. height: 100%;
  183. }
  184. }
  185. .list-box{
  186. background-color: #FFFFFF;
  187. padding: 25rpx 25rpx;
  188. font-size: 36rpx;
  189. color: #333333;
  190. margin-bottom: 20rpx;
  191. .play_count{
  192. color: #999999;
  193. font-size: 24rpx;
  194. padding-top: 20rpx;
  195. }
  196. }
  197. .navbar {
  198. display: flex;
  199. height: 40px;
  200. padding: 0 5px;
  201. background: #fff;
  202. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  203. position: relative;
  204. z-index: 10;
  205. .nav-item {
  206. flex: 1;
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. height: 100%;
  211. font-size: 30rpx;
  212. color: $font-color-dark;
  213. position: relative;
  214. &.current {
  215. color: $base-color;
  216. }
  217. }
  218. }
  219. // 详情
  220. .course-details {
  221. padding: 20rpx;
  222. .details-content {
  223. background: #ffffff;
  224. border-radius: 10rpx;
  225. text-align: center;
  226. .details-title {
  227. padding: 30rpx 0;
  228. border-bottom: 1px solid #f0f0f0;
  229. font-size: $font-base;
  230. font-weight: bold;
  231. color: rgba(51, 51, 51, 1);
  232. }
  233. .details-num {
  234. display: flex;
  235. padding: 30rpx 0;
  236. font-size: $font-sm + 2rpx;
  237. font-weight: bold;
  238. color: rgba(102, 102, 102, 1);
  239. text {
  240. flex: 1;
  241. }
  242. .interval {
  243. width: 2px;
  244. background-color: #eeeeee;
  245. }
  246. }
  247. }
  248. .details-intro {
  249. padding: 40rpx 20rpx;
  250. background: #ffffff;
  251. border-radius: 10rpx;
  252. margin-top: 20rpx;
  253. .intro-title {
  254. width: 100%;
  255. font-size: 36rpx;
  256. font-weight: bold;
  257. color: $font-color;
  258. text-align: center;
  259. margin-bottom: 40rpx;
  260. }
  261. .intro-text {
  262. color: #5dcafa;
  263. font-size: $font-base;
  264. line-height: 40rpx;
  265. }
  266. .intro-img {
  267. width: 100%;
  268. height: 400rpx;
  269. margin-top: 40rpx;
  270. .img {
  271. width: 100%;
  272. height: 100%;
  273. }
  274. }
  275. }
  276. }
  277. // 课程目录
  278. .course-catalogue {
  279. padding: 20rpx;
  280. .no-data{
  281. width: 100%;
  282. text-align: center;
  283. font-size: 26rpx;
  284. }
  285. .course-menu {
  286. background: #ffffff;
  287. border-bottom: 1px solid #f0f0f0;
  288. padding: 20rpx;
  289. display: flex;
  290. align-items: center;
  291. font-size: 24rpx;
  292. image{
  293. width: 250rpx;
  294. height: 135rpx;
  295. border-radius: 15rpx;
  296. }
  297. .menu-info{
  298. padding-left: 25rpx;
  299. color: #333333;
  300. .title{
  301. font-size: 28rpx;
  302. }
  303. .tip{
  304. margin: 15rpx 0rpx;
  305. text{
  306. padding: 5rpx 10rpx;
  307. background-color:rgba(43,121,245,0.18);
  308. color: #6786FB;
  309. }
  310. }
  311. .price{
  312. color: #E73932;
  313. }
  314. .red{
  315. color:#6786FB !important;
  316. }
  317. .free{
  318. background:rgba(253,248,234,1);
  319. border-radius:19px;
  320. color:rgba(241,174,39,1);
  321. padding: 2rpx 10rpx;
  322. }
  323. }
  324. }
  325. }
  326. </style>