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

653 lines
15 KiB

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