course.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航 Tab -->
  4. <view class="top-nav">
  5. <view class="nav-tabs">
  6. <view
  7. class="nav-item"
  8. :class="{ active: tabIndex === 0 }"
  9. @click="tabIndex = 0"
  10. >
  11. <text>精品课程</text>
  12. <view v-if="tabIndex === 0" class="nav-indicator"></view>
  13. </view>
  14. <view
  15. class="nav-item"
  16. :class="{ active: tabIndex === 1 }"
  17. @click="tabIndex = 1"
  18. >
  19. <text>最近学习</text>
  20. <view v-if="tabIndex === 1" class="nav-indicator"></view>
  21. </view>
  22. </view>
  23. <view class="nav-actions">
  24. <text class="action-icon">⋯</text>
  25. <text class="action-icon">⊙</text>
  26. </view>
  27. </view>
  28. <!-- 精品课程 内容 -->
  29. <scroll-view v-show="tabIndex === 0" scroll-y class="scroll-wrap" :show-scrollbar="false">
  30. <!-- 分类标签区 -->
  31. <view class="category-wrap">
  32. <view class="category-tags" :class="{ collapsed: !categoryExpand }">
  33. <view
  34. v-for="(cat, idx) in categories"
  35. :key="idx"
  36. class="tag-item"
  37. :class="{ active: categoryIndex === idx }"
  38. @click="categoryIndex = idx"
  39. >
  40. <text>{{ cat }}</text>
  41. </view>
  42. </view>
  43. <view class="expand-btn" @click="categoryExpand = !categoryExpand">
  44. <text>{{ categoryExpand ? '收起' : '展开' }}</text>
  45. <text class="arrow">{{ categoryExpand ? '▲' : '▼' }}</text>
  46. </view>
  47. </view>
  48. <!-- 课程网格 -->
  49. <view class="course-grid">
  50. <view
  51. v-for="(course, idx) in courseList"
  52. :key="idx"
  53. class="course-card"
  54. @click="onCourseClick(course)"
  55. >
  56. <view class="card-cover">
  57. <image :src="course.cover || 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png'" mode="aspectFill" class="cover-img"></image>
  58. </view>
  59. <text class="card-title">{{ course.title }}</text>
  60. <view class="card-footer">
  61. <text class="card-views"> {{ course.views }}</text>
  62. <view class="btn-watch" @click.stop="onCourseClick(course)">立即观看</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="bottom-placeholder"></view>
  67. </scroll-view>
  68. <!-- 最近学习 内容 -->
  69. <scroll-view v-show="tabIndex === 1" scroll-y class="scroll-wrap" :show-scrollbar="false">
  70. <!-- 有学习记录:按日期分组列表 -->
  71. <template v-if="recentList.length > 0">
  72. <view v-for="(group, gIdx) in recentList" :key="gIdx" class="recent-group">
  73. <view class="group-date">
  74. <text class="date-icon"></text>
  75. <text class="date-text">{{ group.date }}</text>
  76. </view>
  77. <view
  78. v-for="(item, i) in group.list"
  79. :key="i"
  80. class="recent-card"
  81. @click="onCourseClick(item)"
  82. >
  83. <view class="recent-thumb">
  84. <image :src="item.cover || 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png'" mode="aspectFill" class="thumb-img"></image>
  85. </view>
  86. <view class="recent-info">
  87. <text class="recent-title">{{ item.title }}</text>
  88. <text class="recent-progress">已学: {{ item.progress }}%</text>
  89. <view class="btn-watch" @click.stop="onCourseClick(item)">立即观看</view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <!-- 无学习记录:空态 + 为您精选 -->
  95. <template v-else>
  96. <view class="empty-state">
  97. <view class="empty-icon"></view>
  98. <text class="empty-text">暂无学习内容</text>
  99. </view>
  100. <view class="recommend-section">
  101. <text class="recommend-title">为您精选</text>
  102. <view class="course-grid">
  103. <view
  104. v-for="(course, idx) in recommendList"
  105. :key="idx"
  106. class="course-card"
  107. @click="onCourseClick(course)"
  108. >
  109. <view class="card-cover">
  110. <image :src="course.cover || 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png'" mode="aspectFill" class="cover-img"></image>
  111. </view>
  112. <text class="card-title">{{ course.title }}</text>
  113. <view class="card-footer">
  114. <text class="card-views"> {{ course.views }}</text>
  115. <view class="btn-watch" @click.stop="onCourseClick(course)">立即观看</view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <view class="bottom-placeholder"></view>
  122. </scroll-view>
  123. </view>
  124. </template>
  125. <script>
  126. export default {
  127. data() {
  128. return {
  129. tabIndex: 0,
  130. categoryExpand: true,
  131. categoryIndex: 0,
  132. categories: ['全部', '歌唱艺术', '太极养生', '防骗指南', '手机摄影', '棋牌益智', '用药指导', '膳食营养', '慢病管理'],
  133. courseList: [
  134. { title: '刘金的《0基础金曲演唱速练课》', views: '9239', cover: '' },
  135. { title: '邹方斌讲《毛笔书法修心课》', views: '10.8w', cover: '' },
  136. { title: '张斌《元气八段锦》系列课', views: '2.5w', cover: '' },
  137. { title: '翔哥精讲摄影课—手机微距拍摄技巧...', views: '100w+', cover: '' },
  138. { title: '道家智慧 入门21讲', views: '1.2w', cover: '' },
  139. { title: '入门进阶必修 瑜伽呼吸全精讲', views: '3.6w', cover: '' }
  140. ],
  141. recentList: [
  142. {
  143. date: '2026-02-08',
  144. list: [
  145. { title: '歌唱家刘金的《0基础金曲演唱速练课》', progress: 87, cover: '' },
  146. { title: '资深编辑邹方斌讲《毛笔书法修心课》', progress: 56, cover: '' }
  147. ]
  148. },
  149. {
  150. date: '2026-02-01',
  151. list: [
  152. { title: '张斌《元气八段锦》系列课', progress: 56, cover: '' }
  153. ]
  154. }
  155. ],
  156. recommendList: [
  157. { title: '刘金的《0基础金曲演唱速练课》', views: '9239', cover: '' },
  158. { title: '邹方斌讲《毛笔书法修心课》', views: '10.8w', cover: '' },
  159. { title: '张斌《元气八段锦》系列课', views: '2.5w', cover: '' },
  160. { title: '翔哥精讲摄影课-手机微距拍摄技巧...', views: '100w+', cover: '' }
  161. ]
  162. }
  163. },
  164. onLoad() {
  165. // 若无最近学习,可置空 recentList 显示空态
  166. // this.recentList = [];
  167. },
  168. methods: {
  169. onCourseClick(course) {
  170. uni.showToast({ title: course.title || '立即观看', icon: 'none' })
  171. // uni.navigateTo({ url: '/pages_course/videovip?id=' + (course.id || '') })
  172. }
  173. }
  174. }
  175. </script>
  176. <style scoped>
  177. .container {
  178. min-height: 100vh;
  179. background: #fff;
  180. display: flex;
  181. flex-direction: column;
  182. }
  183. /* 顶部 Tab */
  184. .top-nav {
  185. display: flex;
  186. align-items: center;
  187. justify-content: space-between;
  188. padding: 24rpx 24rpx 20rpx;
  189. background: #fff;
  190. border-bottom: 1rpx solid #f0f0f0;
  191. }
  192. .nav-tabs {
  193. display: flex;
  194. align-items: center;
  195. gap: 48rpx;
  196. }
  197. .nav-item {
  198. position: relative;
  199. padding: 8rpx 0;
  200. }
  201. .nav-item text {
  202. font-size: 32rpx;
  203. color: #999;
  204. }
  205. .nav-item.active text {
  206. color: #333;
  207. font-weight: bold;
  208. }
  209. .nav-indicator {
  210. position: absolute;
  211. left: 50%;
  212. bottom: 0;
  213. transform: translateX(-50%);
  214. width: 40rpx;
  215. height: 6rpx;
  216. background: #e54d42;
  217. border-radius: 3rpx;
  218. }
  219. .nav-actions {
  220. display: flex;
  221. align-items: center;
  222. gap: 24rpx;
  223. }
  224. .action-icon {
  225. font-size: 36rpx;
  226. color: #666;
  227. }
  228. /* 滚动区 */
  229. .scroll-wrap {
  230. flex: 1;
  231. height: 0;
  232. }
  233. /* 分类标签 */
  234. .category-wrap {
  235. padding: 20rpx 24rpx;
  236. background: #fff;
  237. }
  238. .category-tags {
  239. display: flex;
  240. flex-wrap: wrap;
  241. gap: 16rpx 16rpx;
  242. }
  243. .category-tags.collapsed {
  244. max-height: 88rpx;
  245. overflow: hidden;
  246. }
  247. .tag-item {
  248. padding: 14rpx 28rpx;
  249. border-radius: 36rpx;
  250. background: #f0f0f0;
  251. }
  252. .tag-item text {
  253. font-size: 26rpx;
  254. color: #333;
  255. }
  256. .tag-item.active {
  257. background: #e54d42;
  258. }
  259. .tag-item.active text {
  260. color: #fff;
  261. }
  262. .expand-btn {
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. margin-top: 20rpx;
  267. padding: 12rpx 0;
  268. }
  269. .expand-btn text {
  270. font-size: 26rpx;
  271. color: #e54d42;
  272. }
  273. .expand-btn .arrow {
  274. margin-left: 6rpx;
  275. font-size: 22rpx;
  276. }
  277. /* 课程网格 */
  278. .course-grid {
  279. display: flex;
  280. flex-wrap: wrap;
  281. padding: 20rpx 24rpx;
  282. gap: 24rpx 20rpx;
  283. }
  284. .course-card {
  285. width: calc(50% - 10rpx);
  286. background: #fff;
  287. border-radius: 16rpx;
  288. overflow: hidden;
  289. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.06);
  290. }
  291. .card-cover {
  292. width: 100%;
  293. height: 220rpx;
  294. background: #f0f0f0;
  295. }
  296. .cover-img {
  297. width: 100%;
  298. height: 100%;
  299. }
  300. .card-title {
  301. display: block;
  302. padding: 16rpx 16rpx 8rpx;
  303. font-size: 26rpx;
  304. color: #333;
  305. line-height: 1.4;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. display: -webkit-box;
  309. -webkit-line-clamp: 2;
  310. -webkit-box-orient: vertical;
  311. }
  312. .card-footer {
  313. display: flex;
  314. align-items: center;
  315. justify-content: space-between;
  316. padding: 0 16rpx 16rpx;
  317. }
  318. .card-views {
  319. font-size: 24rpx;
  320. color: #999;
  321. }
  322. .btn-watch {
  323. padding: 10rpx 24rpx;
  324. background: #e54d42;
  325. border-radius: 32rpx;
  326. font-size: 24rpx;
  327. color: #fff;
  328. }
  329. /* 最近学习 - 按日期分组 */
  330. .recent-group {
  331. padding: 24rpx 24rpx 0;
  332. }
  333. .group-date {
  334. display: flex;
  335. align-items: center;
  336. margin-bottom: 20rpx;
  337. }
  338. .date-icon {
  339. font-size: 28rpx;
  340. margin-right: 8rpx;
  341. }
  342. .date-text {
  343. font-size: 28rpx;
  344. color: #333;
  345. font-weight: 500;
  346. }
  347. .recent-card {
  348. display: flex;
  349. background: #f8f8f8;
  350. border-radius: 16rpx;
  351. overflow: hidden;
  352. margin-bottom: 20rpx;
  353. }
  354. .recent-thumb {
  355. width: 220rpx;
  356. height: 160rpx;
  357. flex-shrink: 0;
  358. background: #e8e8e8;
  359. }
  360. .thumb-img {
  361. width: 100%;
  362. height: 100%;
  363. }
  364. .recent-info {
  365. flex: 1;
  366. padding: 20rpx 24rpx;
  367. display: flex;
  368. flex-direction: column;
  369. justify-content: space-between;
  370. min-width: 0;
  371. }
  372. .recent-title {
  373. font-size: 28rpx;
  374. color: #333;
  375. line-height: 1.4;
  376. overflow: hidden;
  377. text-overflow: ellipsis;
  378. display: -webkit-box;
  379. -webkit-line-clamp: 2;
  380. -webkit-box-orient: vertical;
  381. margin-bottom: 8rpx;
  382. }
  383. .recent-progress {
  384. font-size: 24rpx;
  385. color: #666;
  386. margin-bottom: 12rpx;
  387. }
  388. /* 空态 */
  389. .empty-state {
  390. display: flex;
  391. flex-direction: column;
  392. align-items: center;
  393. justify-content: center;
  394. padding: 80rpx 0 48rpx;
  395. background: linear-gradient(180deg, #fff5f5 0%, #fff 100%);
  396. }
  397. .empty-icon {
  398. font-size: 120rpx;
  399. margin-bottom: 24rpx;
  400. opacity: 0.9;
  401. }
  402. .empty-text {
  403. font-size: 28rpx;
  404. color: #999;
  405. }
  406. /* 为您精选 */
  407. .recommend-section {
  408. padding: 0 24rpx 32rpx;
  409. }
  410. .recommend-title {
  411. display: block;
  412. font-size: 32rpx;
  413. font-weight: bold;
  414. color: #333;
  415. margin-bottom: 24rpx;
  416. }
  417. .bottom-placeholder {
  418. height: 120rpx;
  419. }
  420. </style>