四零语境前端代码仓库
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.

664 lines
15 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. <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. image: '/static/首页背景图.png',
  169. title: '轮播图1'
  170. },
  171. {
  172. image: '/static/默认图片.png',
  173. title: '轮播图2'
  174. },
  175. {
  176. image: '/static/logo.png',
  177. title: '轮播图3'
  178. }
  179. ],
  180. // 今日更新数据
  181. todayUpdates: [
  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. cover: '/static/默认图片.png',
  196. title: '全脑孩子:12项革命性策略...',
  197. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  198. duration: '03:24'
  199. },
  200. {
  201. cover: '/static/默认图片.png',
  202. title: '全脑孩子:12项革命性策略...',
  203. author: 'Daniel J. Siegel / Tina Payne Bryso...',
  204. duration: '03:24'
  205. },
  206. ],
  207. // 推荐书籍数据
  208. recommendBooks: [
  209. {
  210. cover: '/static/默认图片.png',
  211. title: 'The Power of Now 擦拭才:The Power of Now :The Power of Now :',
  212. duration: '03:24'
  213. },
  214. {
  215. cover: '/static/默认图片.png',
  216. title: 'Dealing in Desire 擦擦:The Power of Now :The Power of Now :',
  217. duration: '03:24'
  218. },
  219. {
  220. cover: '/static/默认图片.png',
  221. title: 'A New Earth擦超2 :The Power of Now :The Power of Now :',
  222. duration: '03:24'
  223. }
  224. ],
  225. // 书籍网格数据
  226. bookGridList: [
  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. cover: '/static/默认图片.png',
  253. title: '精讲短文',
  254. grade: '四级',
  255. duration: '03:24'
  256. },
  257. {
  258. cover: '/static/默认图片.png',
  259. title: '精讲短文',
  260. grade: '四级',
  261. duration: '03:24'
  262. }
  263. ],
  264. // 推荐列表数据
  265. recommendList: [
  266. {
  267. image: '/static/默认图片.png'
  268. },
  269. {
  270. image: '/static/默认图片.png'
  271. },
  272. {
  273. image: '/static/默认图片.png'
  274. },
  275. {
  276. image: '/static/默认图片.png'
  277. }
  278. ]
  279. }
  280. },
  281. methods: {
  282. // 切换Tab
  283. switchTab(index) {
  284. this.activeTab = index
  285. },
  286. // 轮播图点击事件
  287. onBannerClick(index) {
  288. console.log('点击轮播图:', index)
  289. // 这里可以添加跳转逻辑
  290. },
  291. // 跳转计划定制
  292. goPlan() {
  293. uni.navigateTo({
  294. url: '/subPages/home/plan'
  295. })
  296. },
  297. goSearch() {
  298. uni.navigateTo({
  299. url: '/subPages/home/search'
  300. })
  301. },
  302. goBook() {
  303. uni.navigateTo({
  304. url: '/subPages/home/directory'
  305. })
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .home-container {
  312. background: #fff;
  313. min-height: 100vh;
  314. }
  315. // 顶部搜索栏
  316. .header {
  317. display: flex;
  318. align-items: center;
  319. padding: 6rpx 32rpx;
  320. background: #fff;
  321. .search-container {
  322. flex: 1;
  323. }
  324. }
  325. // Tab栏
  326. .tab-container {
  327. background: #fff;
  328. // border-bottom: 1px solid #f0f0f0;
  329. .tab-scroll {
  330. white-space: nowrap;
  331. .tab-list {
  332. display: flex;
  333. padding: 0 20rpx;
  334. .tab-item {
  335. flex-shrink: 0;
  336. padding: 20rpx 20rpx;
  337. font-size: 32rpx;
  338. color: #666;
  339. position: relative;
  340. &.active {
  341. color: $primary-text-color;
  342. font-weight: 700;
  343. &::after {
  344. content: '';
  345. position: absolute;
  346. bottom: 0;
  347. left: 50%;
  348. transform: translateX(-50%);
  349. width: 22rpx;
  350. height: 4rpx;
  351. background: $primary-text-color;
  352. border-radius: 2rpx;
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. // 轮播图容器
  360. .swiper-container {
  361. margin: 20rpx;
  362. border-radius: 12rpx;
  363. overflow: hidden;
  364. }
  365. // 内容区块
  366. .section {
  367. margin-top: 40rpx;
  368. .section-header {
  369. display: flex;
  370. align-items: center;
  371. justify-content: space-between;
  372. padding: 0 30rpx ;
  373. margin-bottom: 24rpx;
  374. .section-title {
  375. font-size: 36rpx;
  376. // font-weight: 600;
  377. color: $primary-text-color;
  378. }
  379. .section-more {
  380. display: flex;
  381. align-items: center;
  382. gap: 4rpx;
  383. text {
  384. font-size: 24rpx;
  385. color: $secondary-text-color;
  386. }
  387. }
  388. }
  389. .content-scroll {
  390. white-space: nowrap;
  391. }
  392. }
  393. // 今日更新列表
  394. .content-list {
  395. display: flex;
  396. padding: 0 30rpx;
  397. gap: 32rpx;
  398. .content-item {
  399. flex-shrink: 0;
  400. width: 602rpx;
  401. height: 212rpx;
  402. display: flex;
  403. align-items: center;
  404. background: #F8F8F8;
  405. padding: 16rpx;
  406. border-radius: 16rpx;
  407. gap: 16rpx;
  408. .item-cover {
  409. width: 136rpx;
  410. height: 200rpx;
  411. border-radius: 16rpx;
  412. // overflow: hidden;
  413. image {
  414. width: 136rpx;
  415. height: 200rpx;
  416. }
  417. }
  418. .item-info {
  419. // padding-top: 20rpx;
  420. gap: 16rpx;
  421. display: flex;
  422. flex-direction: column;
  423. .item-title {
  424. font-size: 32rpx;
  425. font-weight: 700;
  426. color: $primary-text-color;
  427. letter-spacing: 0;
  428. line-height: 48rpx;
  429. // margin-bottom: 12rpx;
  430. overflow: hidden;
  431. text-overflow: ellipsis;
  432. white-space: nowrap;
  433. }
  434. .item-author {
  435. font-size: 24rpx;
  436. color: $secondary-text-color;
  437. // margin-bottom: 8rpx;
  438. letter-spacing: 0;
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. white-space: nowrap;
  442. }
  443. .item-duration {
  444. gap: 12rpx;
  445. display: flex;
  446. align-items: center;
  447. font-size: 22rpx;
  448. letter-spacing: 0;
  449. color: $secondary-text-color;
  450. .item-icon{
  451. width: 22rpx;
  452. height: 25rpx;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. // 推荐书籍列表
  459. .book-list {
  460. display: flex;
  461. padding: 0 30rpx;
  462. gap: 32rpx;
  463. .book-item {
  464. flex-shrink: 0;
  465. width: 270rpx;
  466. // border-radius: 16rpx;
  467. .book-cover {
  468. width: 100%;
  469. height: 360rpx;
  470. border-radius: 16rpx;
  471. overflow: hidden;
  472. position: relative;
  473. image {
  474. width: 100%;
  475. height: 100%;
  476. }
  477. .book-overlay {
  478. position: absolute;
  479. bottom: 0;
  480. left: 0;
  481. right: 0;
  482. width: 100%;
  483. height: 140rpx;
  484. padding-top: 4rpx;
  485. padding-right: 16rpx;
  486. padding-bottom: 8rpx;
  487. padding-left: 16rpx;
  488. backdrop-filter: blur(5px);
  489. box-sizing: border-box;
  490. background: #00000066;
  491. padding: 20rpx 16rpx 8rpx;
  492. // gap: 26rpx;
  493. .book-duration{
  494. display: flex;
  495. gap: 8rpx;
  496. &-icon{
  497. width: 24rpx;
  498. height: 24rpx;
  499. }
  500. &-text{
  501. font-size: 20rpx;
  502. color: #DCDCDC;
  503. }
  504. }
  505. .book-title {
  506. margin-top: 10rpx;
  507. max-width: 220rpx;
  508. font-size: 24rpx;
  509. line-height: 1.4;
  510. color: #fff;
  511. // max-height: 68rpx; /* = line-height * 2(34rpx * 2)作为保险 */
  512. display: -webkit-box;
  513. -webkit-box-orient: vertical;
  514. -webkit-line-clamp: 2; /* 关键:显示两行,超过两行才省略 */
  515. overflow: hidden;
  516. word-break: break-word; /* 长单词也能断行 */
  517. white-space: normal; /* 允许换行 */
  518. }
  519. }
  520. }
  521. }
  522. }
  523. // 书籍网格布局
  524. .book-grid {
  525. display: flex;
  526. flex-wrap: wrap;
  527. padding: 0 30rpx;
  528. gap: 32rpx;
  529. .book-grid-item {
  530. width: 208rpx;
  531. display: flex;
  532. flex-direction: column;
  533. .book-grid-cover {
  534. box-shadow: 0px 4px 4px 0px #C0BCBA75;
  535. width: 100%;
  536. height: 278rpx;
  537. border-radius: 16rpx;
  538. overflow: hidden;
  539. margin-bottom: 16rpx;
  540. image {
  541. width: 100%;
  542. height: 100%;
  543. }
  544. }
  545. .book-grid-info {
  546. padding: 6rpx;
  547. .book-grid-title {
  548. font-size: 28rpx;
  549. font-weight: 700;
  550. color: $primary-text-color;
  551. margin-bottom: 14rpx;
  552. overflow: hidden;
  553. text-overflow: ellipsis;
  554. white-space: nowrap;
  555. }
  556. .book-grid-meta {
  557. display: flex;
  558. align-items: center;
  559. // gap: 16rpx;
  560. .book-grid-duration-icon {
  561. width: 24rpx;
  562. height: 24rpx;
  563. margin-right: 12rpx;
  564. }
  565. .book-grid-grade {
  566. font-size: 24rpx;
  567. color: $secondary-text-color;
  568. margin-right: 8rpx;
  569. }
  570. .book-grid-duration {
  571. font-size: 24rpx;
  572. color: $secondary-text-color;
  573. }
  574. }
  575. }
  576. }
  577. }
  578. // 推荐列表样式
  579. .recommend-list {
  580. padding: 0 30rpx;
  581. .recommend-item {
  582. width: 100%;
  583. height: 200rpx;
  584. margin-bottom: 48rpx;
  585. border-radius: 32rpx;
  586. overflow: hidden;
  587. &:last-child {
  588. margin-bottom: 0;
  589. }
  590. .recommend-image {
  591. width: 100%;
  592. height: 100%;
  593. }
  594. }
  595. }
  596. </style>