novel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <view class="novel-page">
  3. <!-- 状态栏占位 -->
  4. <view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
  5. <!-- 顶部导航栏 -->
  6. <view class="nav-bar">
  7. <view class="nav-back" @click="handleBack">
  8. <image class="w64 h64" src="@/static/images/enter/back_white_icon24.png"></image>
  9. </view>
  10. <view class="nav-title">小说</view>
  11. <view class="nav-actions">
  12. <view class="nav-icon-btn" @click="handleRefresh">
  13. <image class="w48 h48" src="@/static/images/enter/share_icom24.png"></image>
  14. </view>
  15. <view class="nav-icon-btn" @click="handleBookshelf">
  16. <image class="w32 h32" src="@/static/images/enter/shujia_icon16.png"></image>
  17. <text class="nav-icon-text">书架</text>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 页面内容 -->
  22. <scroll-view class="page-content" scroll-y>
  23. <!-- 分类标签栏 -->
  24. <view class="category-tabs">
  25. <scroll-view class="tabs-scroll" scroll-x>
  26. <view class="tabs-wrapper">
  27. <view
  28. class="tab-item"
  29. v-for="(tab, index) in categoryTabs"
  30. :key="index"
  31. :class="{ active: currentTabIndex === index, 'tab-recommend': index === 0 }"
  32. @click="handleTabClick(index)"
  33. >
  34. <text class="flame-icon" v-if="index === 0">🔥</text>
  35. <text class="tab-text">{{ tab.name }}</text>
  36. <text class="flame-icon" v-if="index === 0">🔥</text>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. <!-- 推荐榜 -->
  42. <view class="recommend-section">
  43. <view class="section-header">
  44. <text class="flame-icon">🔥</text>
  45. <text class="section-title">推荐榜</text>
  46. <text class="flame-icon">🔥</text>
  47. </view>
  48. <view class="recommend-list">
  49. <view
  50. class="recommend-item"
  51. v-for="(book, index) in recommendList"
  52. :key="index"
  53. @click="handleBookClick(book)"
  54. >
  55. <view class="item-number">{{ index + 1 }}</view>
  56. <view class="item-cover-wrapper">
  57. <image class="item-cover" :src="book.cover" mode="aspectFill"></image>
  58. <view class="cover-tag" v-if="book.tag">{{ book.tag }}</view>
  59. </view>
  60. <view class="item-info">
  61. <view class="item-title">{{ book.title }}</view>
  62. <view class="item-desc">{{ book.desc }}</view>
  63. <view class="item-category">{{ book.category }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 故事精选 -->
  69. <view class="featured-section">
  70. <view class="section-header">
  71. <text class="section-title">故事精选</text>
  72. </view>
  73. <view class="featured-list">
  74. <view
  75. class="featured-item"
  76. v-for="(story, index) in featuredList"
  77. :key="index"
  78. @click="handleStoryClick(story)"
  79. >
  80. <view class="story-cover-wrapper">
  81. <image class="story-cover" :src="story.cover" mode="aspectFill"></image>
  82. <view class="story-tag" v-if="story.tag">{{ story.tag }}</view>
  83. </view>
  84. <view class="story-info">
  85. <view class="story-title">{{ story.title }}</view>
  86. <view class="story-desc">{{ story.desc }}</view>
  87. <view class="story-category">{{ story.category }}</view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 底部安全区域 -->
  93. <view class="safe-area-bottom" :style="{ height: safeAreaBottom + 'px' }"></view>
  94. </scroll-view>
  95. </view>
  96. </template>
  97. <script>
  98. export default {
  99. data() {
  100. return {
  101. statusBarHeight: 0,
  102. safeAreaBottom: 0,
  103. currentTabIndex: 1, // 默认选中"全部"
  104. categoryTabs: [
  105. { name: '推荐榜' },
  106. { name: '全部' },
  107. { name: '悬疑' },
  108. { name: '古代言情' },
  109. { name: '现代言情' },
  110. { name: '都市' },
  111. { name: '玄幻' },
  112. { name: '科幻' }
  113. ],
  114. recommendList: [
  115. {
  116. id: 1,
  117. title: '刚穿越成超被...',
  118. desc: 'best of times, worst of times, reborn...',
  119. category: '现代都市',
  120. cover: '/static/image/default/novel1.jpg',
  121. tag: null
  122. },
  123. {
  124. id: 2,
  125. title: '我的叔叔堂吉诃德',
  126. desc: 'Li Wei, parents passed away, huge debt...',
  127. category: '现代都市',
  128. cover: '/static/image/default/novel2.jpg',
  129. tag: null
  130. },
  131. {
  132. id: 3,
  133. title: '末世农场主系统...',
  134. desc: 'resigned, inherited farm, bound system...',
  135. category: '现代都市',
  136. cover: '/static/image/default/novel3.jpg',
  137. tag: null
  138. },
  139. {
  140. id: 4,
  141. title: '诸天穿...',
  142. desc: 'best of times, worst of times',
  143. category: '现代都市',
  144. cover: '/static/image/default/novel4.jpg',
  145. tag: '起点读书'
  146. },
  147. {
  148. id: 5,
  149. title: '从高三开...',
  150. desc: 'Financial Freedom Starting from High School Year 3',
  151. category: '现代都市',
  152. cover: '/static/image/default/novel5.jpg',
  153. tag: '起点读书'
  154. },
  155. {
  156. id: 6,
  157. title: '都重生了...',
  158. desc: 'Everyone is Reborn, I Must Become an Internet Celebrity',
  159. category: '现代都市',
  160. cover: '/static/image/default/novel6.jpg',
  161. tag: '起点读书'
  162. }
  163. ],
  164. featuredList: [
  165. {
  166. id: 1,
  167. title: '海棠瘦尽春未晚',
  168. desc: 'haven\'t been home for years, uncle\'s family asked me to go home for Chinese New Year...',
  169. category: '现代都市',
  170. cover: '/static/image/default/story1.jpg',
  171. tag: null
  172. },
  173. {
  174. id: 2,
  175. title: '生还者偏差',
  176. desc: 'reborn in the past, envision the future, dream reality, reshape a legendary life!...',
  177. category: '都市超自然',
  178. cover: '/static/image/default/story2.jpg',
  179. tag: '起点 9万人在追'
  180. },
  181. {
  182. id: 3,
  183. title: '海棠瘦尽春未晚',
  184. desc: 'haven\'t been home for years, uncle\'s family asked me to go home for Chinese New Year...',
  185. category: '现代都市',
  186. cover: '/static/image/default/story1.jpg',
  187. tag: null
  188. },
  189. {
  190. id: 4,
  191. title: '生还者偏差',
  192. desc: 'reborn in the past, envision the future, dream reality, reshape a legendary life!...',
  193. category: '都市超自然',
  194. cover: '/static/image/default/story2.jpg',
  195. tag: '起点 9万人在追'
  196. }
  197. ]
  198. }
  199. },
  200. onLoad() {
  201. this.getSystemInfo();
  202. },
  203. methods: {
  204. getSystemInfo() {
  205. const systemInfo = uni.getSystemInfoSync();
  206. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  207. if (systemInfo.safeArea) {
  208. this.safeAreaBottom = systemInfo.screenHeight - systemInfo.safeArea.bottom;
  209. }
  210. },
  211. handleBack() {
  212. uni.navigateBack();
  213. },
  214. handleRefresh() {
  215. uni.showToast({
  216. title: '刷新中...',
  217. icon: 'none'
  218. });
  219. },
  220. handleBookshelf() {
  221. uni.showToast({
  222. title: '我的书架',
  223. icon: 'none'
  224. });
  225. },
  226. handleTabClick(index) {
  227. this.currentTabIndex = index;
  228. // 这里可以加载对应分类的数据
  229. },
  230. handleBookClick(book) {
  231. uni.showToast({
  232. title: `打开${book.title}`,
  233. icon: 'none'
  234. });
  235. },
  236. handleStoryClick(story) {
  237. uni.showToast({
  238. title: `打开${story.title}`,
  239. icon: 'none'
  240. });
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .novel-page {
  247. width: 100%;
  248. min-height: 100vh;
  249. background-color: #ffffff;
  250. display: flex;
  251. flex-direction: column;
  252. }
  253. .status-bar {
  254. width: 100%;
  255. background-color: #ffffff;
  256. }
  257. .nav-bar {
  258. width: 100%;
  259. height: 88rpx;
  260. background-color: #ffffff;
  261. display: flex;
  262. align-items: center;
  263. justify-content: space-between;
  264. padding: 0 30rpx;
  265. .nav-back {
  266. width: 60rpx;
  267. height: 60rpx;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. }
  272. .nav-title {
  273. font-size: 36rpx;
  274. font-weight: 500;
  275. color: #333333;
  276. position: absolute;
  277. left: 50%;
  278. transform: translateX(-50%);
  279. }
  280. .nav-actions {
  281. display: flex;
  282. align-items: center;
  283. gap: 20rpx;
  284. .nav-icon-btn {
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. justify-content: center;
  289. min-width: 60rpx;
  290. .nav-icon-text {
  291. font-size: 20rpx;
  292. color: #333333;
  293. margin-top: 4rpx;
  294. line-height: 1;
  295. }
  296. }
  297. }
  298. }
  299. .page-content {
  300. flex: 1;
  301. width: 100%;
  302. }
  303. // 分类标签栏
  304. .category-tabs {
  305. width: 100%;
  306. padding: 20rpx 0;
  307. background-color: #ffffff;
  308. border-bottom: 1rpx solid #f0f0f0;
  309. .tabs-scroll {
  310. width: 100%;
  311. white-space: nowrap;
  312. }
  313. .tabs-wrapper {
  314. display: flex;
  315. padding: 0 30rpx;
  316. gap: 20rpx;
  317. }
  318. .tab-item {
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. padding: 12rpx 24rpx;
  323. border-radius: 30rpx;
  324. background-color: #ffffff;
  325. white-space: nowrap;
  326. font-size: 28rpx;
  327. color: #333333;
  328. transition: all 0.3s ease;
  329. .tab-text {
  330. margin: 0 8rpx;
  331. }
  332. .flame-icon {
  333. font-size: 24rpx;
  334. }
  335. &.tab-recommend {
  336. background-color: #FFF4E6;
  337. }
  338. &.active {
  339. background-color: #FF6B35;
  340. color: #ffffff;
  341. .flame-icon {
  342. display: none;
  343. }
  344. }
  345. }
  346. }
  347. // 推荐榜
  348. .recommend-section {
  349. width: 100%;
  350. padding: 40rpx 30rpx;
  351. .section-header {
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. margin-bottom: 30rpx;
  356. .flame-icon {
  357. font-size: 32rpx;
  358. margin: 0 10rpx;
  359. }
  360. .section-title {
  361. font-size: 36rpx;
  362. font-weight: 600;
  363. color: #333333;
  364. }
  365. }
  366. .recommend-list {
  367. display: grid;
  368. grid-template-columns: repeat(2, 1fr);
  369. gap: 30rpx 20rpx;
  370. }
  371. .recommend-item {
  372. display: flex;
  373. flex-direction: column;
  374. position: relative;
  375. }
  376. .item-number {
  377. position: absolute;
  378. top: -10rpx;
  379. left: 10rpx;
  380. width: 48rpx;
  381. height: 48rpx;
  382. background-color: #FF6B35;
  383. border-radius: 50%;
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. font-size: 24rpx;
  388. font-weight: 600;
  389. color: #ffffff;
  390. z-index: 2;
  391. }
  392. .item-cover-wrapper {
  393. width: 100%;
  394. height: 240rpx;
  395. border-radius: 12rpx;
  396. overflow: hidden;
  397. position: relative;
  398. margin-bottom: 16rpx;
  399. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  400. }
  401. .item-cover {
  402. width: 100%;
  403. height: 100%;
  404. background-color: #f0f0f0;
  405. }
  406. .cover-tag {
  407. position: absolute;
  408. bottom: 8rpx;
  409. left: 8rpx;
  410. background-color: #FF4757;
  411. color: #ffffff;
  412. padding: 4rpx 12rpx;
  413. border-radius: 4rpx;
  414. font-size: 20rpx;
  415. }
  416. .item-info {
  417. display: flex;
  418. flex-direction: column;
  419. }
  420. .item-title {
  421. font-size: 28rpx;
  422. font-weight: 600;
  423. color: #333333;
  424. margin-bottom: 8rpx;
  425. overflow: hidden;
  426. text-overflow: ellipsis;
  427. white-space: nowrap;
  428. }
  429. .item-desc {
  430. font-size: 22rpx;
  431. color: #999999;
  432. margin-bottom: 8rpx;
  433. overflow: hidden;
  434. text-overflow: ellipsis;
  435. display: -webkit-box;
  436. -webkit-line-clamp: 2;
  437. -webkit-box-orient: vertical;
  438. line-height: 1.4;
  439. }
  440. .item-category {
  441. display: inline-block;
  442. background-color: #FFF4E6;
  443. color: #FF6B35;
  444. padding: 4rpx 12rpx;
  445. border-radius: 4rpx;
  446. font-size: 20rpx;
  447. width: fit-content;
  448. }
  449. }
  450. // 故事精选
  451. .featured-section {
  452. width: 100%;
  453. padding: 40rpx 30rpx;
  454. .section-header {
  455. display: flex;
  456. align-items: center;
  457. justify-content: center;
  458. margin-bottom: 30rpx;
  459. .section-title {
  460. font-size: 36rpx;
  461. font-weight: 600;
  462. color: #333333;
  463. }
  464. }
  465. .featured-list {
  466. display: grid;
  467. grid-template-columns: repeat(2, 1fr);
  468. gap: 30rpx 20rpx;
  469. }
  470. .featured-item {
  471. display: flex;
  472. flex-direction: column;
  473. }
  474. .story-cover-wrapper {
  475. width: 100%;
  476. height: 320rpx;
  477. border-radius: 12rpx;
  478. overflow: hidden;
  479. position: relative;
  480. margin-bottom: 16rpx;
  481. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  482. }
  483. .story-cover {
  484. width: 100%;
  485. height: 100%;
  486. background-color: #f0f0f0;
  487. }
  488. .story-tag {
  489. position: absolute;
  490. bottom: 8rpx;
  491. left: 8rpx;
  492. background-color: #FF4757;
  493. color: #ffffff;
  494. padding: 6rpx 12rpx;
  495. border-radius: 4rpx;
  496. font-size: 20rpx;
  497. }
  498. .story-info {
  499. display: flex;
  500. flex-direction: column;
  501. }
  502. .story-title {
  503. font-size: 30rpx;
  504. font-weight: 600;
  505. color: #333333;
  506. margin-bottom: 12rpx;
  507. overflow: hidden;
  508. text-overflow: ellipsis;
  509. white-space: nowrap;
  510. }
  511. .story-desc {
  512. font-size: 24rpx;
  513. color: #666666;
  514. margin-bottom: 12rpx;
  515. overflow: hidden;
  516. text-overflow: ellipsis;
  517. display: -webkit-box;
  518. -webkit-line-clamp: 3;
  519. -webkit-box-orient: vertical;
  520. line-height: 1.5;
  521. }
  522. .story-category {
  523. display: inline-block;
  524. background-color: #FFF4E6;
  525. color: #FF6B35;
  526. padding: 4rpx 12rpx;
  527. border-radius: 4rpx;
  528. font-size: 20rpx;
  529. width: fit-content;
  530. }
  531. }
  532. .safe-area-bottom {
  533. width: 100%;
  534. height: 40rpx;
  535. }
  536. </style>