index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. <template>
  2. <view class="container">
  3. <!-- 搜索栏 -->
  4. <view class="search-bar" @click="goToSearch">
  5. <input class="search-input" placeholder="水浒传" disabled />
  6. <text class="search-icon">🔍</text>
  7. </view>
  8. <scroll-view class="scroll-content" scroll-y>
  9. <!-- 轮播图 -->
  10. <view class="swiper-container">
  11. <swiper
  12. class="swiper"
  13. :indicator-dots="true"
  14. :autoplay="true"
  15. :interval="4000"
  16. :duration="600"
  17. indicator-color="rgba(255,255,255,0.5)"
  18. indicator-active-color="#4FC3F7"
  19. :circular="true"
  20. :previous-margin="0"
  21. :next-margin="0"
  22. >
  23. <swiper-item v-for="(item, index) in bannerList" :key="index" @click="handleBannerClick(item)">
  24. <view class="swiper-item-wrapper">
  25. <image class="swiper-image" :src="item.image" mode="aspectFill" :lazy-load="true" @error="handleImageError(index)"></image>
  26. <view class="swiper-overlay">
  27. <text class="swiper-title">{{ item.title }}</text>
  28. </view>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. <!-- 分类导航 -->
  34. <view class="category-nav">
  35. <view class="category-item" v-for="(item, index) in categories" :key="index" @click="handleCategoryClick(item, index)">
  36. <view class="category-icon" :style="{ backgroundColor: item.color }">
  37. <text class="icon-text">{{ item.icon }}</text>
  38. </view>
  39. <text class="category-text">{{ item.name }}</text>
  40. </view>
  41. </view>
  42. <!-- 今日推荐 -->
  43. <view class="section">
  44. <view class="section-header">
  45. <text class="section-title">今日推荐</text>
  46. <text class="section-more" @click.stop="goToMoreBooks('today')">更多></text>
  47. </view>
  48. <!-- 加载中 -->
  49. <view class="loading-state" v-if="isLoading && todayRecommend.length === 0">
  50. <text class="loading-text">加载中...</text>
  51. </view>
  52. <!-- 书籍列表 -->
  53. <view class="book-grid" v-else-if="todayRecommend.length > 0">
  54. <view class="book-item" v-for="(book, index) in todayRecommend" :key="book.id || index" @click="goToBookDetail(book)">
  55. <image class="book-cover" :src="book.image" mode="aspectFill" :lazy-load="true" @error="handleBookImageError(book, 'todayRecommend')"></image>
  56. <text class="book-name">{{ book.title }}</text>
  57. </view>
  58. </view>
  59. <!-- 空状态 -->
  60. <view class="empty-state" v-else>
  61. <text class="empty-text">暂无推荐书籍</text>
  62. <text class="empty-hint">请检查后端服务是否启动,数据库是否有数据</text>
  63. </view>
  64. </view>
  65. <!-- 畅销书籍 -->
  66. <view class="section">
  67. <view class="section-header">
  68. <text class="section-title">畅销书籍</text>
  69. <text class="section-more" @click.stop="goToMoreBooks('bestseller')">更多></text>
  70. </view>
  71. <!-- 加载中 -->
  72. <view class="loading-state" v-if="isLoading && bestsellers.length === 0">
  73. <text class="loading-text">加载中...</text>
  74. </view>
  75. <!-- 书籍列表 -->
  76. <view class="book-list" v-else-if="bestsellers.length > 0">
  77. <view class="book-list-item" v-for="(book, index) in bestsellers" :key="book.id || index" @click="goToBookDetail(book)">
  78. <image class="book-cover-small" :src="book.image" mode="aspectFill" :lazy-load="true" @error="handleBookImageError(book, 'bestsellers')"></image>
  79. <view class="book-info">
  80. <text class="book-title">{{ book.title }}</text>
  81. <text class="book-desc">{{ book.desc }}</text>
  82. <text class="book-author">{{ book.author }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 空状态 -->
  87. <view class="empty-state" v-else>
  88. <text class="empty-text">暂无畅销书籍</text>
  89. <text class="empty-hint">请检查后端服务是否启动,数据库是否有数据</text>
  90. </view>
  91. </view>
  92. <!-- 精品书单 -->
  93. <view class="section">
  94. <view class="section-header">
  95. <text class="section-title">精品书单</text>
  96. <text class="section-more" @click.stop="goToMoreBooks('featured')">更多></text>
  97. </view>
  98. <view class="loading-state" v-if="featuredLoading">
  99. <text class="loading-text">加载中...</text>
  100. </view>
  101. <scroll-view class="book-list-horizontal" scroll-x v-else-if="featuredList.length > 0">
  102. <view class="book-item-horizontal" v-for="(book, index) in featuredList" :key="book.id || index" @click="goToBookDetail(book)">
  103. <image class="book-cover-horizontal" :src="book.image" mode="aspectFill" :lazy-load="true" @error="handleBookImageError(book, 'featuredList')"></image>
  104. <text class="book-name-horizontal">{{ book.title }}</text>
  105. </view>
  106. </scroll-view>
  107. <view class="empty-state" v-else>
  108. <text class="empty-text">暂无精品书单</text>
  109. <text class="empty-hint">请检查后端服务或数据库</text>
  110. </view>
  111. </view>
  112. <!-- 更多推荐 -->
  113. <view class="section">
  114. <view class="section-header">
  115. <text class="section-title">更多推荐</text>
  116. </view>
  117. <view class="loading-state" v-if="moreLoading">
  118. <text class="loading-text">加载中...</text>
  119. </view>
  120. <view class="book-grid-two" v-else-if="moreRecommend.length > 0">
  121. <view class="book-item-two" v-for="(book, index) in moreRecommend" :key="book.id || index" @click="goToBookDetail(book)">
  122. <image class="book-cover-two" :src="book.image" mode="aspectFill" :lazy-load="true" @error="handleBookImageError(book, 'moreRecommend')"></image>
  123. <text class="book-title-two">{{ book.title }}</text>
  124. <text class="book-author-two">{{ book.author }}</text>
  125. </view>
  126. </view>
  127. <view class="empty-state" v-else>
  128. <text class="empty-text">暂无推荐书籍</text>
  129. <text class="empty-hint">请检查后端服务或数据库</text>
  130. </view>
  131. </view>
  132. </scroll-view>
  133. </view>
  134. </template>
  135. <script>
  136. import { getTodayRecommend, getBestsellers, getFeaturedList, getMoreRecommend, getBannersByCode } from '../../utils/api.js'
  137. export default {
  138. data() {
  139. // 生成高质量、高雅、大气的图书相关图片URL的函数
  140. const getBookImage = (index) => {
  141. // 使用更优雅的图书相关关键词,确保图片高雅大气
  142. const elegantKeywords = [
  143. 'classic+books+library', // 经典图书图书馆
  144. 'literature+books+elegant', // 文学书籍优雅
  145. 'ancient+books+scholarship', // 古籍学术
  146. 'reading+books+premium', // 阅读书籍高端
  147. 'bookshelf+library+grand' // 书架图书馆宏伟
  148. ];
  149. const keyword = elegantKeywords[index % elegantKeywords.length];
  150. // 使用 Unsplash 高质量图片,尺寸较大确保清晰度
  151. // 使用不同的随机数确保每次获取不同的高雅图片
  152. return `https://source.unsplash.com/1080x600/?${keyword}&sig=${Date.now() + index}`;
  153. };
  154. return {
  155. bannerList: [],
  156. categories: [
  157. { name: '全部分类', icon: '📄', color: '#81C784' },
  158. { name: '排行榜', icon: '👑', color: '#FFD54F' },
  159. { name: '热门书籍', icon: '🔥', color: '#E57373' },
  160. { name: '新书榜', icon: '📖', color: '#81C784' },
  161. { name: 'VIP书籍', icon: '📚', color: '#4FC3F7' }
  162. ],
  163. todayRecommend: [],
  164. bestsellers: [],
  165. featuredList: [],
  166. moreRecommend: [],
  167. isLoading: false,
  168. featuredLoading: false,
  169. moreLoading: false
  170. }
  171. },
  172. onLoad() {
  173. this.loadBanners()
  174. this.loadTodayRecommend()
  175. this.loadBestsellers()
  176. this.loadFeaturedList()
  177. this.loadMoreRecommend()
  178. },
  179. onShow() {
  180. // 页面显示时刷新数据
  181. this.loadTodayRecommend()
  182. this.loadBestsellers()
  183. this.loadFeaturedList()
  184. this.loadMoreRecommend()
  185. },
  186. methods: {
  187. async loadBanners() {
  188. try {
  189. const res = await getBannersByCode('home_banner')
  190. if (res && res.code === 200 && Array.isArray(res.data)) {
  191. this.bannerList = res.data.map(b => ({
  192. image: b.image,
  193. title: b.title || '',
  194. targetType: b.targetType,
  195. targetId: b.targetId,
  196. link: b.link
  197. }))
  198. }
  199. } catch (e) {
  200. console.error('加载轮播失败', e)
  201. }
  202. },
  203. // 加载今日推荐
  204. loadTodayRecommend() {
  205. console.log('开始加载今日推荐...')
  206. this.isLoading = true
  207. getTodayRecommend(8)
  208. .then((res) => {
  209. console.log('今日推荐API响应:', res)
  210. this.isLoading = false
  211. // 检查响应数据
  212. if (res && res.code === 200) {
  213. // 检查data是否存在且是数组
  214. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  215. // 处理数据格式,确保图片URL正确
  216. this.todayRecommend = res.data.map((book) => {
  217. return {
  218. id: book.id,
  219. title: book.title || '未知书名',
  220. image: book.image || book.cover || 'https://picsum.photos/seed/default/200/300',
  221. author: book.author || ''
  222. }
  223. })
  224. console.log('今日推荐数据加载成功,共', this.todayRecommend.length, '本')
  225. } else {
  226. console.warn('今日推荐数据为空或格式不正确:', res.data)
  227. this.todayRecommend = []
  228. }
  229. } else {
  230. console.warn('今日推荐API返回错误:', res)
  231. this.todayRecommend = []
  232. // 显示错误提示
  233. uni.showToast({
  234. title: res.message || '获取推荐失败',
  235. icon: 'none',
  236. duration: 2000
  237. })
  238. }
  239. })
  240. .catch((err) => {
  241. this.isLoading = false
  242. console.error('获取今日推荐失败:', err)
  243. this.todayRecommend = []
  244. // 显示错误提示
  245. uni.showToast({
  246. title: err.message || '网络请求失败,请检查后端服务',
  247. icon: 'none',
  248. duration: 3000
  249. })
  250. })
  251. },
  252. // 加载畅销书籍
  253. loadBestsellers() {
  254. console.log('开始加载畅销书籍...')
  255. this.isLoading = true
  256. getBestsellers(10)
  257. .then((res) => {
  258. console.log('畅销书籍API响应:', res)
  259. this.isLoading = false
  260. // 检查响应数据
  261. if (res && res.code === 200) {
  262. // 检查data是否存在且是数组
  263. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  264. // 处理数据格式,确保图片URL和描述正确
  265. this.bestsellers = res.data.map((book) => {
  266. return {
  267. id: book.id,
  268. title: book.title || '未知书名',
  269. desc: book.desc || book.brief || book.introduction || '',
  270. author: book.author || '',
  271. image: book.image || book.cover || 'https://picsum.photos/seed/default/200/300'
  272. }
  273. })
  274. console.log('畅销书籍数据加载成功,共', this.bestsellers.length, '本')
  275. } else {
  276. console.warn('畅销书籍数据为空或格式不正确:', res.data)
  277. this.bestsellers = []
  278. }
  279. } else {
  280. console.warn('畅销书籍API返回错误:', res)
  281. this.bestsellers = []
  282. // 显示错误提示
  283. uni.showToast({
  284. title: res.message || '获取畅销书籍失败',
  285. icon: 'none',
  286. duration: 2000
  287. })
  288. }
  289. })
  290. .catch((err) => {
  291. this.isLoading = false
  292. console.error('获取畅销书籍失败:', err)
  293. this.bestsellers = []
  294. // 显示错误提示
  295. uni.showToast({
  296. title: err.message || '网络请求失败,请检查后端服务',
  297. icon: 'none',
  298. duration: 3000
  299. })
  300. })
  301. },
  302. // 加载精品书单
  303. loadFeaturedList() {
  304. console.log('开始加载精品书单...')
  305. this.featuredLoading = true
  306. getFeaturedList(4)
  307. .then((res) => {
  308. console.log('精品书单API响应:', res)
  309. this.featuredLoading = false
  310. if (res && res.code === 200) {
  311. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  312. this.featuredList = res.data.map((book) => {
  313. return {
  314. id: book.id,
  315. title: book.title || '未知书名',
  316. image: book.image || book.cover || 'https://picsum.photos/seed/featured/200/300'
  317. }
  318. })
  319. console.log('精品书单加载成功,共', this.featuredList.length, '本')
  320. } else {
  321. console.warn('精品书单数据为空或格式不正确:', res.data)
  322. this.featuredList = []
  323. }
  324. } else {
  325. console.warn('精品书单API返回错误:', res)
  326. this.featuredList = []
  327. uni.showToast({
  328. title: res.message || '获取精品书单失败',
  329. icon: 'none',
  330. duration: 2000
  331. })
  332. }
  333. })
  334. .catch((err) => {
  335. this.featuredLoading = false
  336. console.error('获取精品书单失败:', err)
  337. this.featuredList = []
  338. uni.showToast({
  339. title: err.message || '网络请求失败,请检查后端服务',
  340. icon: 'none',
  341. duration: 3000
  342. })
  343. })
  344. },
  345. // 加载更多推荐书籍
  346. loadMoreRecommend() {
  347. console.log('开始加载更多推荐书籍...')
  348. this.moreLoading = true
  349. getMoreRecommend(6)
  350. .then((res) => {
  351. console.log('更多推荐API响应:', res)
  352. this.moreLoading = false
  353. if (res && res.code === 200) {
  354. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  355. this.moreRecommend = res.data.map((book) => {
  356. return {
  357. id: book.id,
  358. title: book.title || '未知书名',
  359. author: book.author || '',
  360. image: book.image || book.cover || 'https://picsum.photos/seed/more/200/300'
  361. }
  362. })
  363. console.log('更多推荐加载成功,共', this.moreRecommend.length, '本')
  364. } else {
  365. console.warn('更多推荐数据为空或格式不正确:', res.data)
  366. this.moreRecommend = []
  367. }
  368. } else {
  369. console.warn('更多推荐API返回错误:', res)
  370. this.moreRecommend = []
  371. uni.showToast({
  372. title: res.message || '获取更多推荐失败',
  373. icon: 'none',
  374. duration: 2000
  375. })
  376. }
  377. })
  378. .catch((err) => {
  379. this.moreLoading = false
  380. console.error('获取更多推荐失败:', err)
  381. this.moreRecommend = []
  382. uni.showToast({
  383. title: err.message || '网络请求失败,请检查后端服务',
  384. icon: 'none',
  385. duration: 3000
  386. })
  387. })
  388. },
  389. handleCategoryClick(item, index) {
  390. if (index === 0) {
  391. uni.navigateTo({
  392. url: '/pages/category/category'
  393. })
  394. } else if (index === 1) {
  395. uni.navigateTo({
  396. url: '/pages/ranking/ranking'
  397. })
  398. } else if (index === 2) {
  399. uni.navigateTo({
  400. url: '/pages/hot-books/hot-books'
  401. })
  402. } else if (index === 3) {
  403. uni.navigateTo({
  404. url: '/pages/new-books/new-books'
  405. })
  406. } else if (index === 4) {
  407. uni.navigateTo({
  408. url: '/pages/vip-books/vip-books'
  409. })
  410. }
  411. },
  412. goToBookDetail(book) {
  413. if (!book || !book.id) {
  414. uni.showToast({
  415. title: '书籍信息不完整',
  416. icon: 'none'
  417. })
  418. return
  419. }
  420. uni.navigateTo({
  421. url: `/pages/book-detail/book-detail?bookId=${book.id}`
  422. })
  423. },
  424. goToMoreBooks(type) {
  425. uni.navigateTo({
  426. url: `/pages/more-books/more-books?type=${type}`
  427. })
  428. },
  429. goToSearch() {
  430. uni.navigateTo({
  431. url: '/pages/search/search'
  432. })
  433. },
  434. handleBannerClick(item) {
  435. if (!item) return
  436. console.log('轮播图点击:', item)
  437. // 优先检查 targetType 和 targetId
  438. if (item.targetType === 'book' && item.targetId) {
  439. this.goToBookDetail({ id: item.targetId })
  440. return
  441. }
  442. if (item.targetType === 'audiobook' && item.targetId) {
  443. uni.navigateTo({ url: `/pages/listen-detail/listen-detail?audiobookId=${item.targetId}` })
  444. return
  445. }
  446. // 检查是否为外链跳转
  447. if (item.targetType === 'url' && item.link) {
  448. // H5可直接跳转
  449. // #ifdef H5
  450. window.location.href = item.link
  451. // #endif
  452. // 小程序环境提示
  453. // #ifdef MP-WEIXIN
  454. uni.showModal({
  455. title: '提示',
  456. content: '此链接需要复制后在浏览器打开',
  457. confirmText: '复制链接',
  458. success: (res) => {
  459. if (res.confirm) {
  460. uni.setClipboardData({
  461. data: item.link,
  462. success: () => {
  463. uni.showToast({
  464. title: '链接已复制',
  465. icon: 'success'
  466. })
  467. }
  468. })
  469. }
  470. }
  471. })
  472. // #endif
  473. // APP环境使用浏览器打开
  474. // #ifdef APP-PLUS
  475. plus.runtime.openURL(item.link)
  476. // #endif
  477. return
  478. }
  479. // 如果没有设置跳转类型但有链接,也尝试跳转(兼容旧数据)
  480. if (item.link && !item.targetType) {
  481. // #ifdef H5
  482. window.location.href = item.link
  483. // #endif
  484. }
  485. },
  486. handleImageError(index) {
  487. // 图片加载失败时使用备用图片
  488. const fallbackImages = [
  489. 'https://picsum.photos/seed/library1/1080/600',
  490. 'https://picsum.photos/seed/library2/1080/600',
  491. 'https://picsum.photos/seed/library3/1080/600',
  492. 'https://picsum.photos/seed/library4/1080/600',
  493. 'https://picsum.photos/seed/library5/1080/600'
  494. ];
  495. if (this.bannerList[index]) {
  496. this.bannerList[index].image = fallbackImages[index] || fallbackImages[0];
  497. }
  498. },
  499. handleBookImageError(book, listType) {
  500. // 书籍图片加载失败时使用备用图片
  501. book.image = 'https://picsum.photos/seed/default/200/300'
  502. }
  503. }
  504. }
  505. </script>
  506. <style scoped>
  507. .container {
  508. width: 100%;
  509. height: 100vh;
  510. background-color: #F5F5F5;
  511. display: flex;
  512. flex-direction: column;
  513. padding-top: 60px;
  514. box-sizing: border-box;
  515. }
  516. .search-bar {
  517. position: relative;
  518. padding: 20rpx 30rpx;
  519. background-color: #FFFFFF;
  520. }
  521. .search-input {
  522. width: 100%;
  523. height: 70rpx;
  524. background-color: #F5F5F5;
  525. border-radius: 35rpx;
  526. padding: 0 80rpx 0 30rpx;
  527. font-size: 28rpx;
  528. color: #333333;
  529. }
  530. .search-icon {
  531. position: absolute;
  532. right: 50rpx;
  533. top: 50%;
  534. transform: translateY(-50%);
  535. font-size: 32rpx;
  536. }
  537. .scroll-content {
  538. flex: 1;
  539. width: 100%;
  540. height: 0;
  541. overflow: hidden;
  542. }
  543. .swiper-container {
  544. width: 100%;
  545. height: 360rpx;
  546. margin-bottom: 20rpx;
  547. background-color: #F5F5F5;
  548. border-radius: 0;
  549. overflow: hidden;
  550. }
  551. .swiper {
  552. width: 100%;
  553. height: 100%;
  554. }
  555. .swiper-item-wrapper {
  556. width: 100%;
  557. height: 100%;
  558. position: relative;
  559. }
  560. .swiper-image {
  561. width: 100%;
  562. height: 100%;
  563. display: block;
  564. object-fit: cover;
  565. }
  566. .swiper-overlay {
  567. position: absolute;
  568. bottom: 0;
  569. left: 0;
  570. right: 0;
  571. background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  572. padding: 60rpx 40rpx 30rpx;
  573. }
  574. .swiper-title {
  575. font-size: 36rpx;
  576. font-weight: bold;
  577. color: #FFFFFF;
  578. text-shadow: 0 2rpx 8rpx rgba(0,0,0,0.5);
  579. }
  580. .category-nav {
  581. display: flex;
  582. justify-content: space-around;
  583. padding: 40rpx 20rpx;
  584. background-color: #FFFFFF;
  585. margin-bottom: 20rpx;
  586. }
  587. .category-item {
  588. display: flex;
  589. flex-direction: column;
  590. align-items: center;
  591. }
  592. .category-icon {
  593. width: 90rpx;
  594. height: 90rpx;
  595. border-radius: 50%;
  596. display: flex;
  597. align-items: center;
  598. justify-content: center;
  599. margin-bottom: 15rpx;
  600. }
  601. .icon-text {
  602. font-size: 44rpx;
  603. }
  604. .category-text {
  605. font-size: 24rpx;
  606. color: #333333;
  607. }
  608. .section {
  609. padding: 40rpx 30rpx;
  610. background-color: #FFFFFF;
  611. margin-bottom: 20rpx;
  612. }
  613. .section-header {
  614. display: flex;
  615. justify-content: space-between;
  616. align-items: center;
  617. margin-bottom: 30rpx;
  618. }
  619. .section-title {
  620. font-size: 36rpx;
  621. font-weight: bold;
  622. color: #333333;
  623. }
  624. .section-more {
  625. font-size: 28rpx;
  626. color: #999999;
  627. }
  628. .book-grid {
  629. display: flex;
  630. flex-wrap: wrap;
  631. justify-content: space-between;
  632. }
  633. .book-item {
  634. width: 160rpx;
  635. margin-bottom: 30rpx;
  636. }
  637. .book-cover {
  638. width: 160rpx;
  639. height: 220rpx;
  640. border-radius: 8rpx;
  641. margin-bottom: 15rpx;
  642. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  643. background-color: #F5F5F5;
  644. }
  645. .book-name {
  646. font-size: 24rpx;
  647. color: #333333;
  648. display: block;
  649. overflow: hidden;
  650. text-overflow: ellipsis;
  651. white-space: nowrap;
  652. }
  653. .book-list {
  654. display: flex;
  655. flex-direction: column;
  656. }
  657. .book-list-item {
  658. display: flex;
  659. margin-bottom: 30rpx;
  660. align-items: center;
  661. }
  662. .book-cover-small {
  663. width: 120rpx;
  664. height: 160rpx;
  665. border-radius: 8rpx;
  666. margin-right: 20rpx;
  667. flex-shrink: 0;
  668. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  669. background-color: #F5F5F5;
  670. }
  671. .book-info {
  672. flex: 1;
  673. display: flex;
  674. flex-direction: column;
  675. justify-content: space-between;
  676. min-width: 0;
  677. }
  678. .book-title {
  679. font-size: 32rpx;
  680. font-weight: bold;
  681. color: #333333;
  682. margin-bottom: 10rpx;
  683. overflow: hidden;
  684. text-overflow: ellipsis;
  685. white-space: nowrap;
  686. }
  687. .book-desc {
  688. font-size: 26rpx;
  689. color: #666666;
  690. line-height: 1.4;
  691. margin-bottom: 10rpx;
  692. display: -webkit-box;
  693. -webkit-box-orient: vertical;
  694. -webkit-line-clamp: 2;
  695. overflow: hidden;
  696. }
  697. .book-author {
  698. font-size: 24rpx;
  699. color: #999999;
  700. }
  701. .book-list-horizontal {
  702. white-space: nowrap;
  703. width: 100%;
  704. height: 280rpx;
  705. }
  706. .book-item-horizontal {
  707. display: inline-block;
  708. width: 160rpx;
  709. margin-right: 20rpx;
  710. vertical-align: top;
  711. }
  712. .book-cover-horizontal {
  713. width: 160rpx;
  714. height: 220rpx;
  715. border-radius: 8rpx;
  716. margin-bottom: 15rpx;
  717. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  718. background-color: #F5F5F5;
  719. }
  720. .book-name-horizontal {
  721. font-size: 24rpx;
  722. color: #333333;
  723. display: block;
  724. overflow: hidden;
  725. text-overflow: ellipsis;
  726. white-space: nowrap;
  727. }
  728. .book-grid-two {
  729. display: flex;
  730. flex-wrap: wrap;
  731. justify-content: space-between;
  732. }
  733. .book-item-two {
  734. width: calc(50% - 10rpx);
  735. margin-bottom: 30rpx;
  736. }
  737. .book-cover-two {
  738. width: 100%;
  739. height: 280rpx;
  740. border-radius: 8rpx;
  741. margin-bottom: 15rpx;
  742. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  743. background-color: #F5F5F5;
  744. }
  745. .book-title-two {
  746. font-size: 28rpx;
  747. font-weight: bold;
  748. color: #333333;
  749. margin-bottom: 8rpx;
  750. display: block;
  751. overflow: hidden;
  752. text-overflow: ellipsis;
  753. white-space: nowrap;
  754. }
  755. .book-author-two {
  756. font-size: 24rpx;
  757. color: #999999;
  758. display: block;
  759. overflow: hidden;
  760. text-overflow: ellipsis;
  761. white-space: nowrap;
  762. }
  763. .empty-state {
  764. padding: 60rpx 0;
  765. text-align: center;
  766. }
  767. .empty-text {
  768. font-size: 28rpx;
  769. color: #999999;
  770. display: block;
  771. margin-bottom: 10rpx;
  772. }
  773. .empty-hint {
  774. font-size: 24rpx;
  775. color: #CCCCCC;
  776. display: block;
  777. }
  778. .loading-state {
  779. padding: 60rpx 0;
  780. text-align: center;
  781. }
  782. .loading-text {
  783. font-size: 28rpx;
  784. color: #999999;
  785. }
  786. </style>