course.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航 Tab -->
  4. <view class="top-nav" :style="{marginTop: statusBarHeight}">
  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 v-if="tabIndex === 0" class="category-wrap">
  24. <view class="category-tags" :class="{ collapsed: !categoryExpand }">
  25. <view
  26. v-for="(cat, idx) in categories"
  27. :key="idx"
  28. class="tag-item"
  29. :class="{ active: categoryIndex === idx }"
  30. @click="categoryIndex = idx"
  31. >
  32. <text>{{ cat }}</text>
  33. </view>
  34. </view>
  35. <view class="expand-btn" @click="categoryExpand = !categoryExpand">
  36. <text>{{ categoryExpand ? '收起' : '展开' }}</text>
  37. <image :class="{ 'rotate-arrow': !categoryExpand }" src="@/static/images/new/expand.png"></image>
  38. <!-- <text class="arrow">{{ categoryExpand ? '▲' : '▼' }}</text> -->
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 精品课程 内容 -->
  43. <scroll-view v-show="tabIndex === 0" scroll-y class="scroll-wrap" :show-scrollbar="false">
  44. <!-- 分类标签区 -->
  45. <!-- 课程网格 -->
  46. <view class="course-grid">
  47. <view
  48. v-for="(course, idx) in courseList"
  49. :key="idx"
  50. class="course-card"
  51. @click="onCourseClick(course)"
  52. >
  53. <view class="card-cover">
  54. <image :src="course.cover || '/static/logo.jpg'" mode="aspectFill" class="cover-img"></image>
  55. </view>
  56. <view class="course-info">
  57. <text class="card-title">{{ course.title }}</text>
  58. <view class="x-end" style="justify-content: space-between;">
  59. <view class="course-meta">
  60. <image src="@/static/images/new/renshu.png"></image>
  61. <text class="meta-count">{{ course.views }}</text>
  62. </view>
  63. <view class="btn-watch" @click.stop="onCourseClick(course)">立即观看</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="bottom-placeholder"></view>
  69. </scroll-view>
  70. <!-- 最近学习 内容 -->
  71. <scroll-view v-show="tabIndex === 1" scroll-y class="scroll-wrap" :show-scrollbar="false">
  72. <!-- 有学习记录:按日期分组列表 -->
  73. <template v-if="recentList.length > 0">
  74. <view v-for="(group, gIdx) in recentList" :key="gIdx" class="recent-group">
  75. <view class="group-date">
  76. <image class="date-icon" src="@/static/images/new/time.png"></image>
  77. <text class="date-text">{{ group.date }}</text>
  78. </view>
  79. <view
  80. v-for="(item, i) in group.list"
  81. :key="i"
  82. class="recent-card"
  83. @click="onCourseClick(item)"
  84. >
  85. <view class="recent-thumb">
  86. <image :src="item.cover || '/static/logo.jpg'" mode="aspectFill" class="thumb-img"></image>
  87. </view>
  88. <view class="recent-info">
  89. <text class="recent-title">{{ item.title }}</text>
  90. <text class="recent-progress">已学: {{ item.progress }}%</text>
  91. <view class="y-end">
  92. <view class="btn-watch" @click.stop="onCourseClick(item)">立即观看</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <!-- 无学习记录:空态 + 为您精选 -->
  99. <template v-else>
  100. <view class="empty-state">
  101. <!-- <view class="empty-icon"></view> -->
  102. <image class="empty-icon" src="@/static/images/new/nodata.png"></image>
  103. <text class="empty-text">暂无学习内容</text>
  104. </view>
  105. <view class="recommend-section">
  106. <text class="recommend-title">为您精选</text>
  107. <view class="course-grid" style="padding: 0;">
  108. <view
  109. v-for="(course, idx) in recommendList"
  110. :key="idx"
  111. class="course-card"
  112. @click="onCourseClick(course)"
  113. >
  114. <view class="card-cover">
  115. <image :src="course.cover || '/static/logo.jpg'" mode="aspectFill" class="cover-img"></image>
  116. </view>
  117. <view class="card-footer">
  118. <text class="card-title">{{ course.title }}</text>
  119. <view class="x-end" style="justify-content: space-between;">
  120. <view class="course-meta">
  121. <image src="@/static/images/new/renshu.png"></image>
  122. <text class="meta-count">{{ course.views }}</text>
  123. </view>
  124. <view class="btn-watch" @click.stop="onCourseClick(course)">立即观看</view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </template>
  131. <view class="bottom-placeholder"></view>
  132. </scroll-view>
  133. </view>
  134. </template>
  135. <script>
  136. export default {
  137. data() {
  138. return {
  139. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  140. tabIndex: 0,
  141. categoryExpand: true,
  142. categoryIndex: 0,
  143. categories: ['全部', '歌唱艺术', '太极养生', '防骗指南', '手机摄影', '棋牌益智', '用药指导', '膳食营养', '慢病管理'],
  144. courseList: [
  145. { title: '刘金的《0基础金曲演唱速练课》', views: '9239', cover: '' },
  146. { title: '邹方斌讲《毛笔书法修心课》', views: '10.8w', cover: '' },
  147. { title: '张斌《元气八段锦》系列课', views: '2.5w', cover: '' },
  148. { title: '翔哥精讲摄影课—手机微距拍摄技巧...', views: '100w+', cover: '' },
  149. { title: '道家智慧 入门21讲', views: '1.2w', cover: '' },
  150. { title: '入门进阶必修 瑜伽呼吸全精讲', views: '3.6w', cover: '' }
  151. ],
  152. recentList: [
  153. {
  154. date: '2026-02-08',
  155. list: [
  156. { title: '歌唱家刘金的《0基础金曲演唱速练课》', progress: 87, cover: '' },
  157. { title: '资深编辑邹方斌讲《毛笔书法修心课》', progress: 56, cover: '' }
  158. ]
  159. },
  160. {
  161. date: '2026-02-01',
  162. list: [
  163. { title: '张斌《元气八段锦》系列课', progress: 56, cover: '' }
  164. ]
  165. }
  166. ],
  167. recommendList: [
  168. { title: '刘金的《0基础金曲演唱速练课》', views: '9239', cover: '' },
  169. { title: '邹方斌讲《毛笔书法修心课》', views: '10.8w', cover: '' },
  170. { title: '张斌《元气八段锦》系列课', views: '2.5w', cover: '' },
  171. { title: '翔哥精讲摄影课-手机微距拍摄技巧...', views: '100w+', cover: '' }
  172. ]
  173. }
  174. },
  175. onLoad() {
  176. // 若无最近学习,可置空 recentList 显示空态
  177. // this.recentList = [];
  178. },
  179. methods: {
  180. onCourseClick(course) {
  181. uni.showToast({ title: course.title || '立即观看', icon: 'none' })
  182. // uni.navigateTo({ url: '/pages_course/videovip?id=' + (course.id || '') })
  183. }
  184. }
  185. }
  186. </script>
  187. <style scoped>
  188. /* 图片箭头旋转类(展开时向上) */
  189. .rotate-arrow {
  190. transform: rotate(180deg);
  191. }
  192. .container {
  193. min-height: 100vh;
  194. background: #F5F5F5;
  195. display: flex;
  196. flex-direction: column;
  197. }
  198. /* 顶部 Tab */
  199. .top-nav {
  200. display: flex;
  201. flex-direction: column;
  202. background: #fff;
  203. /* border-bottom: 1rpx solid #f0f0f0; */
  204. }
  205. .nav-tabs {
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. }
  210. .nav-item {
  211. flex:1;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. position: relative;
  216. padding: 24rpx 0;
  217. }
  218. .nav-item text {
  219. font-family: PingFangSC, PingFang SC;
  220. font-weight: 400;
  221. font-size: 36rpx;
  222. color: #030303;
  223. }
  224. .nav-item.active text {
  225. font-weight: 600;
  226. font-size: 40rpx;
  227. }
  228. .nav-indicator {
  229. position: absolute;
  230. left: 50%;
  231. bottom: 0;
  232. transform: translateX(-50%);
  233. width: 100rpx;
  234. height: 10rpx;
  235. background: linear-gradient( 135deg, #FF5267 0%, #FF233C 100%);
  236. border-radius: 6rpx;
  237. }
  238. .nav-actions {
  239. display: flex;
  240. align-items: center;
  241. gap: 24rpx;
  242. }
  243. .action-icon {
  244. font-size: 36rpx;
  245. color: #666;
  246. }
  247. /* 滚动区 */
  248. .scroll-wrap {
  249. flex: 1;
  250. height: 0;
  251. }
  252. /* 分类标签 */
  253. .category-wrap {
  254. padding:24rpx 0;
  255. border-radius: 0rpx 0rpx 20rpx 20rpx;
  256. background: #fff;
  257. display: flex;
  258. align-items: center;
  259. flex-direction: column;
  260. }
  261. .category-tags {
  262. display: flex;
  263. flex-wrap: wrap;
  264. gap:24rpx;
  265. flex-direction: row;
  266. justify-content: center;
  267. }
  268. .category-tags.collapsed {
  269. max-height: 88rpx;
  270. overflow: hidden;
  271. }
  272. .tag-item {
  273. width: 30%;
  274. padding: 20rpx 0;
  275. text-align: center;
  276. border-radius: 20rpx;
  277. background: #f0f0f0;
  278. }
  279. .tag-item text {
  280. font-family: PingFangSC, PingFang SC;
  281. font-weight: 400;
  282. font-size: 40rpx;
  283. color: rgba(0,0,0,0.85);
  284. }
  285. .tag-item.active {
  286. background: linear-gradient( 135deg, #FF5267 0%, #FF233C 100%);
  287. }
  288. .tag-item.active text {
  289. color: #fff;
  290. }
  291. .expand-btn {
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. margin-top: 20rpx;
  296. width: 166rpx;
  297. height: 64rpx;
  298. border-radius: 32rpx;
  299. border: 2rpx solid #FF233C;
  300. }
  301. .expand-btn text {
  302. font-family: PingFangSC, PingFang SC;
  303. font-weight: 400;
  304. font-size: 32rpx;
  305. color: #FF233C;
  306. }
  307. .expand-btn .arrow {
  308. margin-left: 6rpx;
  309. font-size: 22rpx;
  310. }
  311. .expand-btn image{
  312. margin-left:10rpx ;
  313. width: 32rpx;
  314. height: 32rpx;
  315. }
  316. /* 课程网格 */
  317. .course-grid {
  318. display: flex;
  319. flex-wrap: wrap;
  320. padding:24rpx;
  321. gap: 24rpx 20rpx;
  322. flex-direction: column;
  323. }
  324. .course-card {
  325. display: flex;
  326. background: #fff;
  327. border-radius: 20rpx;
  328. overflow: hidden;
  329. padding: 20rpx;
  330. }
  331. .course-tag {
  332. position: absolute;
  333. left: 0;
  334. bottom: 0;
  335. right: 0;
  336. padding: 8rpx 12rpx;
  337. background: linear-gradient(transparent, rgba(0,0,0,0.6));
  338. font-size: 22rpx;
  339. color: #fff;
  340. }
  341. .course-info {
  342. flex: 1;
  343. padding-left: 24rpx;
  344. /* padding: 20rpx 24rpx; */
  345. display: flex;
  346. flex-direction: column;
  347. justify-content: space-between;
  348. min-width: 0;
  349. }
  350. .course-meta {
  351. display: flex;
  352. align-items: center;
  353. image{
  354. width: 30rpx;
  355. height: 30rpx;
  356. }
  357. }
  358. .meta-icon {
  359. font-size: 24rpx;
  360. margin-right: 6rpx;
  361. color: #999;
  362. }
  363. .meta-count {
  364. margin-left: 10rpx;
  365. font-family: PingFangSC, PingFang SC;
  366. font-weight: 400;
  367. font-size: 32rpx;
  368. color: #666666;
  369. }
  370. .card-cover {
  371. position: relative;
  372. width: 296rpx;
  373. height: 222rpx;
  374. border-radius: 20rpx;
  375. overflow: hidden;
  376. flex-shrink: 0;
  377. }
  378. .cover-img {
  379. width: 100%;
  380. height: 100%;
  381. background: #BB6D6D;
  382. }
  383. .card-title {
  384. font-family: PingFangSC, PingFang SC;
  385. font-weight: 600;
  386. font-size: 36rpx;
  387. color: #222222;
  388. line-height: 50rpx;
  389. text-align: justify;
  390. overflow: hidden;
  391. text-overflow: ellipsis;
  392. display: -webkit-box;
  393. -webkit-line-clamp: 2;
  394. -webkit-box-orient: vertical;
  395. }
  396. .card-footer {
  397. flex: 1;
  398. padding-left: 24rpx;
  399. /* padding: 20rpx 24rpx; */
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: space-between;
  403. min-width: 0;
  404. }
  405. .card-views {
  406. font-family: PingFangSC, PingFang SC;
  407. font-weight: 400;
  408. font-size: 32rpx;
  409. color: #666666;
  410. line-height: 44rpx;
  411. }
  412. .btn-watch {
  413. width: 168rpx;
  414. height: 64rpx;
  415. line-height: 64rpx;
  416. text-align: center;
  417. background: linear-gradient( 135deg, #FF5267 0%, #FF233C 100%);
  418. border-radius: 32rpx;
  419. font-family: PingFangSC, PingFang SC;
  420. font-weight: 600;
  421. font-size: 32rpx;
  422. color: #FFFFFF;
  423. }
  424. /* 最近学习 - 按日期分组 */
  425. .recent-group {
  426. padding: 24rpx 24rpx 0;
  427. }
  428. .group-date {
  429. display: flex;
  430. align-items: center;
  431. margin-bottom: 24rpx;
  432. }
  433. .date-icon {
  434. width: 32rpx;
  435. height: 32rpx;
  436. margin-right: 8rpx;
  437. }
  438. .date-text {
  439. font-family: PingFangSC, PingFang SC;
  440. font-weight: 600;
  441. font-size: 40rpx;
  442. line-height: 56rpx;
  443. color: #222222;
  444. }
  445. .recent-card {
  446. display: flex;
  447. background: #fff;
  448. border-radius: 20rpx;
  449. overflow: hidden;
  450. padding: 20rpx;
  451. margin-bottom: 24rpx;
  452. }
  453. .recent-card:last-child{
  454. margin-bottom: 0;
  455. }
  456. .recent-thumb {
  457. position: relative;
  458. width: 296rpx;
  459. height: 222rpx;
  460. border-radius: 20rpx;
  461. overflow: hidden;
  462. flex-shrink: 0;
  463. }
  464. .thumb-img {
  465. width: 100%;
  466. height: 100%;
  467. background: #BB6D6D;
  468. }
  469. .recent-info {
  470. flex: 1;
  471. padding-left: 24rpx;
  472. /* padding: 20rpx 24rpx; */
  473. display: flex;
  474. flex-direction: column;
  475. justify-content: space-between;
  476. min-width: 0;
  477. }
  478. .recent-title {
  479. font-family: PingFangSC, PingFang SC;
  480. font-weight: 600;
  481. font-size: 36rpx;
  482. color: #222222;
  483. line-height: 50rpx;
  484. text-align: justify;
  485. overflow: hidden;
  486. text-overflow: ellipsis;
  487. display: -webkit-box;
  488. -webkit-line-clamp: 2;
  489. -webkit-box-orient: vertical;
  490. }
  491. .recent-progress {
  492. font-family: PingFangSC, PingFang SC;
  493. font-weight: 400;
  494. font-size: 32rpx;
  495. color: rgba(0,0,0,0.65);
  496. line-height: 44rpx;
  497. }
  498. /* 空态 */
  499. .empty-state {
  500. display: flex;
  501. flex-direction: column;
  502. align-items: center;
  503. justify-content: center;
  504. padding: 80rpx 0 48rpx;
  505. /* background: linear-gradient(180deg, #fff5f5 0%, #fff 100%); */
  506. }
  507. .empty-icon {
  508. width: 310rpx;
  509. height: 260rpx;
  510. margin-bottom: 30rpx;
  511. }
  512. .empty-text {
  513. font-family: PingFangSC, PingFang SC;
  514. font-weight: 400;
  515. font-size: 36rpx;
  516. color: rgba(0,0,0,0.25);
  517. line-height: 50rpx;
  518. }
  519. /* 为您精选 */
  520. .recommend-section {
  521. padding: 0 24rpx 32rpx;
  522. }
  523. .recommend-title {
  524. display: block;
  525. font-family: PingFangSC, PingFang SC;
  526. font-weight: 600;
  527. font-size: 40rpx;
  528. color: #222222;
  529. line-height: 56rpx;
  530. padding-bottom: 24rpx;
  531. }
  532. .bottom-placeholder {
  533. height: 120rpx;
  534. }
  535. </style>