四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

670 lines
16 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="home-container">
  3. <!-- 状态栏安全区域 -->
  4. <uv-status-bar></uv-status-bar>
  5. <!-- 顶部搜索栏 -->
  6. <view class="header">
  7. <view class="search-container" @click="goSearch">
  8. <uv-search
  9. placeholder="请输入要查询的内容"
  10. :show-action="false"
  11. shape="round"
  12. bg-color="#f5f5f5"
  13. color="#666"
  14. height="38"
  15. margin="0 200rpx 0 0"
  16. placeholderColor="#c6c6c6"
  17. ></uv-search>
  18. </view>
  19. </view>
  20. <!-- Tab栏 -->
  21. <view class="tab-container">
  22. <scroll-view show-scrollbar="false" class="tab-scroll" scroll-x="true" >
  23. <view class="tab-list">
  24. <view
  25. v-for="(tab, index) in tabs"
  26. :key="index"
  27. class="tab-item"
  28. :class="{ active: activeTab === index }"
  29. @click="switchTab(index)"
  30. >
  31. {{ tab }}
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. <!-- 轮播图 -->
  37. <view class="swiper-container">
  38. <uv-swiper
  39. :list="bannerList"
  40. keyName="image"
  41. height="121"
  42. radius="12"
  43. indicator
  44. ndicatorInactiveColor="#fff"
  45. :loading="false"
  46. indicatorMode="dot"
  47. indicatorActiveColor="#F95A01"
  48. @click="onBannerClick"
  49. ></uv-swiper>
  50. </view>
  51. <!-- 今日更新 -->
  52. <view class="section">
  53. <view class="section-header">
  54. <text class="section-title">今日更新</text>
  55. <view class="section-more">
  56. <text>更多</text>
  57. <uv-icon name="arrow-right" size="14" color="#888"></uv-icon>
  58. </view>
  59. </view>
  60. <scroll-view show-scrollbar="false" class="content-scroll" scroll-x="true" >
  61. <view class="content-list">
  62. <view
  63. v-for="(item, index) in todayUpdates"
  64. :key="index"
  65. class="content-item"
  66. >
  67. <view class="item-cover">
  68. <image :src="item.cover" mode="aspectFill"></image>
  69. </view>
  70. <view class="item-info">
  71. <text class="item-title">{{ item.title }}</text>
  72. <text class="item-author">{{ item.author }}</text>
  73. <view class="item-duration"><image src="/static/播放图标.png" class="item-icon" /><text>{{ item.duration }}</text></view>
  74. </view>
  75. </view>
  76. </view>
  77. </scroll-view>
  78. </view>
  79. <!-- 推荐书籍 -->
  80. <view class="section">
  81. <view class="section-header">
  82. <text class="section-title">推荐书籍</text>
  83. <view class="section-more">
  84. <text>更多</text>
  85. <uv-icon name="arrow-right" size="14" color="#999"></uv-icon>
  86. </view>
  87. </view>
  88. <scroll-view show-scrollbar="false" class="content-scroll" scroll-x="true" >
  89. <view class="book-list">
  90. <view
  91. v-for="(book, index) in recommendBooks"
  92. :key="index"
  93. class="book-item"
  94. @click="goBook"
  95. >
  96. <view class="book-cover">
  97. <image :src="book.cover" mode="aspectFill"></image>
  98. <!-- <view class="book-duration">
  99. <uv-icon name="time" size="10" color="#fff"></uv-icon>
  100. <text>{{ book.duration }}</text>
  101. </view> -->
  102. <view class="book-overlay">
  103. <view class="book-duration">
  104. <image src="/static/闹钟图标.png" class="book-duration-icon" />
  105. <text class="book-duration-text">{{ book.duration }}</text>
  106. </view>
  107. <view class="book-title">{{ book.title }}</view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. </view>
  114. <!-- 四级精讲短文合集书 -->
  115. <view class="section">
  116. <view class="section-header">
  117. <text class="section-title">四级精讲短文合集书</text>
  118. <view class="section-more">
  119. <text>更多</text>
  120. <uv-icon name="arrow-right" size="14" color="#999"></uv-icon>
  121. </view>
  122. </view>
  123. <view class="book-grid">
  124. <view
  125. v-for="(book, index) in bookGridList"
  126. :key="index"
  127. class="book-grid-item"
  128. >
  129. <view class="book-grid-cover">
  130. <image :src="book.cover" mode="aspectFill"></image>
  131. </view>
  132. <view class="book-grid-info">
  133. <text class="book-grid-title">{{ book.title }}</text>
  134. <view class="book-grid-meta">
  135. <text class="book-grid-grade">{{ book.grade }}/</text>
  136. <image src="/static/播放图标.png" class="book-grid-duration-icon" />
  137. <text class="book-grid-duration">{{ book.duration }}</text>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. <!-- 推荐内容列表 -->
  144. <view class="section">
  145. <view class="recommend-list">
  146. <view
  147. @click="goPlan()"
  148. v-for="(item, index) in recommendList"
  149. :key="index"
  150. class="recommend-item"
  151. >
  152. <image :src="item.image" mode="aspectFill" class="recommend-image"></image>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. </template>
  158. <script>
  159. export default {
  160. data() {
  161. return {
  162. // Tab数据
  163. tabs: ['为你推荐', '精选', '短文', '专栏', '初中', '四六级'],
  164. activeTab: 0,
  165. // 轮播图数据
  166. bannerList: [
  167. ],
  168. // 今日更新数据
  169. todayUpdates: [
  170. {
  171. cover: '/static/默认图片.png',
  172. title: '全脑孩子:12项革命性策略...',
  173. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  174. duration: '03:24'
  175. },
  176. {
  177. cover: '/static/默认图片.png',
  178. title: '全脑孩子:12项革命性策略...',
  179. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  180. duration: '03:24'
  181. },
  182. {
  183. cover: '/static/默认图片.png',
  184. title: '全脑孩子:12项革命性策略...',
  185. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  186. duration: '03:24'
  187. },
  188. {
  189. cover: '/static/默认图片.png',
  190. title: '全脑孩子:12项革命性策略...',
  191. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  192. duration: '03:24'
  193. },
  194. ],
  195. // 推荐书籍数据
  196. recommendBooks: [
  197. {
  198. cover: '/static/默认图片.png',
  199. title: 'The Power of Now 擦拭才:The Power of Now :The Power of Now :',
  200. duration: '03:24'
  201. },
  202. {
  203. cover: '/static/默认图片.png',
  204. title: 'Dealing in Desire 擦擦:The Power of Now :The Power of Now :',
  205. duration: '03:24'
  206. },
  207. {
  208. cover: '/static/默认图片.png',
  209. title: 'A New Earth擦超2 :The Power of Now :The Power of Now :',
  210. duration: '03:24'
  211. }
  212. ],
  213. // 书籍网格数据
  214. bookGridList: [
  215. {
  216. cover: '/static/默认图片.png',
  217. title: '精讲短文',
  218. grade: '四级',
  219. duration: '03:24'
  220. },
  221. {
  222. cover: '/static/默认图片.png',
  223. title: '精讲短文',
  224. grade: '四级',
  225. duration: '03:24'
  226. },
  227. {
  228. cover: '/static/默认图片.png',
  229. title: '精讲短文',
  230. grade: '四级',
  231. duration: '03:24'
  232. },
  233. {
  234. cover: '/static/默认图片.png',
  235. title: '精讲短文',
  236. grade: '四级',
  237. duration: '03:24'
  238. },
  239. {
  240. cover: '/static/默认图片.png',
  241. title: '精讲短文',
  242. grade: '四级',
  243. duration: '03:24'
  244. },
  245. {
  246. cover: '/static/默认图片.png',
  247. title: '精讲短文',
  248. grade: '四级',
  249. duration: '03:24'
  250. }
  251. ],
  252. // 推荐列表数据
  253. recommendList: [
  254. {
  255. image: '/static/默认图片.png'
  256. },
  257. {
  258. image: '/static/默认图片.png'
  259. },
  260. {
  261. image: '/static/默认图片.png'
  262. },
  263. {
  264. image: '/static/默认图片.png'
  265. }
  266. ]
  267. }
  268. },
  269. methods: {
  270. // 切换Tab
  271. switchTab(index) {
  272. this.activeTab = index
  273. },
  274. // 轮播图点击事件
  275. onBannerClick(index) {
  276. console.log('点击轮播图:', index)
  277. // 这里可以添加跳转逻辑
  278. },
  279. // 跳转计划定制
  280. goPlan() {
  281. uni.navigateTo({
  282. url: '/subPages/home/plan'
  283. })
  284. },
  285. goSearch() {
  286. uni.navigateTo({
  287. url: '/subPages/home/search'
  288. })
  289. },
  290. goBook() {
  291. uni.navigateTo({
  292. url: '/subPages/home/directory'
  293. })
  294. },
  295. async getBanner() {
  296. const bannerRes = await this.$api.home.getBanner()
  297. if (bannerRes.code === 200){
  298. this.bannerList = bannerRes.result.map(item => ({
  299. image: item.img,
  300. title: item.title
  301. }))
  302. }
  303. },
  304. },
  305. async onShow() {
  306. await this.getBanner()
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .home-container {
  312. background: #fff;
  313. min-height: 100vh;
  314. padding-bottom: 80rpx;
  315. }
  316. // 顶部搜索栏
  317. .header {
  318. display: flex;
  319. align-items: center;
  320. padding: 6rpx 32rpx;
  321. background: #fff;
  322. .search-container {
  323. flex: 1;
  324. }
  325. }
  326. // Tab栏
  327. .tab-container {
  328. background: #fff;
  329. // border-bottom: 1px solid #f0f0f0;
  330. top: 0;
  331. left: 0;
  332. right: 0;
  333. z-index: 999;
  334. .tab-scroll {
  335. white-space: nowrap;
  336. .tab-list {
  337. display: flex;
  338. padding: 0 20rpx;
  339. .tab-item {
  340. flex-shrink: 0;
  341. padding: 20rpx 20rpx;
  342. font-size: 32rpx;
  343. color: #666;
  344. position: relative;
  345. &.active {
  346. color: $primary-text-color;
  347. font-weight: 700;
  348. &::after {
  349. content: '';
  350. position: absolute;
  351. bottom: 0;
  352. left: 50%;
  353. transform: translateX(-50%);
  354. width: 22rpx;
  355. height: 4rpx;
  356. background: $primary-text-color;
  357. border-radius: 2rpx;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. // 轮播图容器
  365. .swiper-container {
  366. margin: 20rpx;
  367. border-radius: 12rpx;
  368. overflow: hidden;
  369. }
  370. // 内容区块
  371. .section {
  372. margin-top: 40rpx;
  373. .section-header {
  374. display: flex;
  375. align-items: center;
  376. justify-content: space-between;
  377. padding: 0 30rpx ;
  378. margin-bottom: 24rpx;
  379. .section-title {
  380. font-size: 36rpx;
  381. // font-weight: 600;
  382. color: $primary-text-color;
  383. }
  384. .section-more {
  385. display: flex;
  386. align-items: center;
  387. gap: 4rpx;
  388. text {
  389. font-size: 24rpx;
  390. color: $secondary-text-color;
  391. }
  392. }
  393. }
  394. .content-scroll {
  395. white-space: nowrap;
  396. }
  397. }
  398. // 今日更新列表
  399. .content-list {
  400. display: flex;
  401. padding: 0 30rpx;
  402. gap: 32rpx;
  403. .content-item {
  404. flex-shrink: 0;
  405. width: 602rpx;
  406. height: 212rpx;
  407. display: flex;
  408. align-items: center;
  409. background: #F8F8F8;
  410. padding: 16rpx;
  411. border-radius: 16rpx;
  412. gap: 16rpx;
  413. .item-cover {
  414. width: 136rpx;
  415. height: 200rpx;
  416. border-radius: 16rpx;
  417. // overflow: hidden;
  418. image {
  419. width: 136rpx;
  420. height: 200rpx;
  421. }
  422. }
  423. .item-info {
  424. // padding-top: 20rpx;
  425. gap: 16rpx;
  426. display: flex;
  427. flex-direction: column;
  428. .item-title {
  429. font-size: 32rpx;
  430. font-weight: 700;
  431. color: $primary-text-color;
  432. letter-spacing: 0;
  433. line-height: 48rpx;
  434. // margin-bottom: 12rpx;
  435. overflow: hidden;
  436. text-overflow: ellipsis;
  437. white-space: nowrap;
  438. }
  439. .item-author {
  440. font-size: 24rpx;
  441. color: $secondary-text-color;
  442. // margin-bottom: 8rpx;
  443. letter-spacing: 0;
  444. overflow: hidden;
  445. text-overflow: ellipsis;
  446. white-space: nowrap;
  447. }
  448. .item-duration {
  449. gap: 12rpx;
  450. display: flex;
  451. align-items: center;
  452. font-size: 22rpx;
  453. letter-spacing: 0;
  454. color: $secondary-text-color;
  455. .item-icon{
  456. width: 22rpx;
  457. height: 25rpx;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. // 推荐书籍列表
  464. .book-list {
  465. display: flex;
  466. padding: 0 30rpx;
  467. gap: 32rpx;
  468. .book-item {
  469. flex-shrink: 0;
  470. width: 270rpx;
  471. // border-radius: 16rpx;
  472. .book-cover {
  473. width: 100%;
  474. height: 360rpx;
  475. border-radius: 16rpx;
  476. overflow: hidden;
  477. position: relative;
  478. image {
  479. width: 100%;
  480. height: 100%;
  481. }
  482. .book-overlay {
  483. position: absolute;
  484. bottom: 0;
  485. left: 0;
  486. right: 0;
  487. width: 100%;
  488. height: 140rpx;
  489. padding-top: 4rpx;
  490. padding-right: 16rpx;
  491. padding-bottom: 8rpx;
  492. padding-left: 16rpx;
  493. backdrop-filter: blur(5px);
  494. box-sizing: border-box;
  495. background: #00000066;
  496. padding: 20rpx 16rpx 8rpx;
  497. // gap: 26rpx;
  498. .book-duration{
  499. display: flex;
  500. gap: 8rpx;
  501. &-icon{
  502. width: 24rpx;
  503. height: 24rpx;
  504. }
  505. &-text{
  506. font-size: 20rpx;
  507. color: #DCDCDC;
  508. }
  509. }
  510. .book-title {
  511. margin-top: 10rpx;
  512. max-width: 220rpx;
  513. font-size: 24rpx;
  514. line-height: 1.4;
  515. color: #fff;
  516. // max-height: 68rpx; /* = line-height * 2(34rpx * 2)作为保险 */
  517. display: -webkit-box;
  518. -webkit-box-orient: vertical;
  519. -webkit-line-clamp: 2; /* 关键:显示两行,超过两行才省略 */
  520. overflow: hidden;
  521. word-break: break-word; /* 长单词也能断行 */
  522. white-space: normal; /* 允许换行 */
  523. }
  524. }
  525. }
  526. }
  527. }
  528. // 书籍网格布局
  529. .book-grid {
  530. display: flex;
  531. flex-wrap: wrap;
  532. padding: 0 30rpx;
  533. gap: 32rpx;
  534. .book-grid-item {
  535. width: 208rpx;
  536. display: flex;
  537. flex-direction: column;
  538. .book-grid-cover {
  539. box-shadow: 0px 4px 4px 0px #C0BCBA75;
  540. width: 100%;
  541. height: 278rpx;
  542. border-radius: 16rpx;
  543. overflow: hidden;
  544. margin-bottom: 16rpx;
  545. image {
  546. width: 100%;
  547. height: 100%;
  548. }
  549. }
  550. .book-grid-info {
  551. padding: 6rpx;
  552. .book-grid-title {
  553. font-size: 28rpx;
  554. font-weight: 700;
  555. color: $primary-text-color;
  556. margin-bottom: 14rpx;
  557. overflow: hidden;
  558. text-overflow: ellipsis;
  559. white-space: nowrap;
  560. }
  561. .book-grid-meta {
  562. display: flex;
  563. align-items: center;
  564. // gap: 16rpx;
  565. .book-grid-duration-icon {
  566. width: 24rpx;
  567. height: 24rpx;
  568. margin-right: 12rpx;
  569. }
  570. .book-grid-grade {
  571. font-size: 24rpx;
  572. color: $secondary-text-color;
  573. margin-right: 8rpx;
  574. }
  575. .book-grid-duration {
  576. font-size: 24rpx;
  577. color: $secondary-text-color;
  578. }
  579. }
  580. }
  581. }
  582. }
  583. // 推荐列表样式
  584. .recommend-list {
  585. padding: 0 30rpx;
  586. .recommend-item {
  587. width: 100%;
  588. height: 200rpx;
  589. margin-bottom: 48rpx;
  590. border-radius: 32rpx;
  591. overflow: hidden;
  592. &:last-child {
  593. margin-bottom: 0;
  594. }
  595. .recommend-image {
  596. width: 100%;
  597. height: 100%;
  598. }
  599. }
  600. }
  601. </style>