courseSearch.vue 13 KB

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