vip-books.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <text class="header-title">VIP书籍</text>
  9. <view class="search-btn" @click="goToSearch">
  10. <text class="search-icon">🔍</text>
  11. </view>
  12. </view>
  13. <!-- VIP提示横幅 -->
  14. <view class="vip-banner" @click="goToVip">
  15. <text class="vip-banner-text">开通VIP,畅享海量精品书籍</text>
  16. <text class="vip-banner-arrow">→</text>
  17. </view>
  18. <!-- 书籍列表 -->
  19. <scroll-view class="book-list-container" scroll-y @scrolltolower="loadMore" :lower-threshold="100">
  20. <view
  21. class="book-item"
  22. v-for="(book, index) in bookList"
  23. :key="book.id || index"
  24. @click="goToBookDetail(book)"
  25. >
  26. <view class="vip-badge" v-if="book.isVip">
  27. <text class="vip-badge-text">VIP</text>
  28. </view>
  29. <image
  30. class="book-cover"
  31. :src="book.cover"
  32. mode="aspectFill"
  33. :lazy-load="true"
  34. @error="handleImageError(index)"
  35. ></image>
  36. <view class="book-info">
  37. <text class="book-title">{{ book.title }}</text>
  38. <text class="book-desc">{{ book.desc }}</text>
  39. <text class="book-author">{{ book.author }}</text>
  40. </view>
  41. </view>
  42. <!-- 加载更多提示 -->
  43. <view class="load-more" v-if="hasMore">
  44. <text class="load-more-text">加载中...</text>
  45. </view>
  46. <view class="load-more" v-else-if="bookList.length > 0">
  47. <text class="load-more-text">没有更多了</text>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. // 生成书籍封面图片的函数
  56. const getBookImage = (seed) => {
  57. return `https://picsum.photos/seed/${seed}/200/300`;
  58. };
  59. return {
  60. hasMore: true,
  61. page: 1,
  62. bookList: [
  63. {
  64. id: 1,
  65. title: '互联网心理学',
  66. author: '雷雳',
  67. desc: '当连接万物的互联网遇见无处不在的心理学,我们需要用心理学的方式,重新思考互联网背后的人与社会。',
  68. cover: getBookImage('vip-internet-psychology'),
  69. isVip: true
  70. },
  71. {
  72. id: 2,
  73. title: '孝经 (中华经典诵读)',
  74. author: '孔子',
  75. desc: '以孔子与其弟子曾参之间问答的形式,将社会上各种阶层的人士,标示出其实践孝亲的法则与途径,阐述了「孝」的意义。',
  76. cover: getBookImage('vip-xiaojing'),
  77. isVip: true
  78. },
  79. {
  80. id: 3,
  81. title: '自省',
  82. author: '约翰·班扬',
  83. desc: '讲述了敬虔之人和不敬虔之人截然相反的结局。本书就是他的细细品味,文风一如从前,朴实无华却又字字珠玑。',
  84. cover: getBookImage('vip-self-reflection'),
  85. isVip: true
  86. },
  87. {
  88. id: 4,
  89. title: '思维的艺术',
  90. author: '延斯·森特根',
  91. desc: '一本关于思维方式和哲学思考的经典之作,帮助读者提升逻辑思维和批判性思考能力。',
  92. cover: getBookImage('vip-thinking-art'),
  93. isVip: true
  94. },
  95. {
  96. id: 5,
  97. title: '传习录:全译全注',
  98. author: '王阳明',
  99. desc: '王阳明心学的核心著作,记录了其与学生之间的对话,阐述了知行合一的哲学思想。',
  100. cover: getBookImage('vip-chuanxilu'),
  101. isVip: true
  102. },
  103. {
  104. id: 6,
  105. title: '社会契约论',
  106. author: '让·雅克·卢梭',
  107. desc: '探讨了政治权力的合法性和人民主权的基本原则,是现代民主理论的重要基石。',
  108. cover: getBookImage('vip-social-contract'),
  109. isVip: true
  110. },
  111. {
  112. id: 7,
  113. title: '没有烦恼的世界',
  114. author: '王觉仁',
  115. desc: '通过禅修和正念的实践,帮助读者摆脱内心的烦恼,获得内心的平静与智慧。',
  116. cover: getBookImage('vip-no-worries'),
  117. isVip: true
  118. },
  119. {
  120. id: 8,
  121. title: '透过电影看文化',
  122. author: '陈红',
  123. desc: '从电影的角度分析不同文化的特点,探讨电影如何反映和影响社会文化的发展。',
  124. cover: getBookImage('vip-film-culture'),
  125. isVip: true
  126. }
  127. ]
  128. }
  129. },
  130. onLoad() {
  131. // 页面加载时加载数据
  132. this.loadBookList();
  133. },
  134. methods: {
  135. goBack() {
  136. uni.navigateBack({
  137. delta: 1
  138. });
  139. },
  140. goToSearch() {
  141. uni.navigateTo({
  142. url: '/pages/search/search'
  143. });
  144. },
  145. goToVip() {
  146. uni.navigateTo({
  147. url: '/pages/vip/vip'
  148. });
  149. },
  150. goToBookDetail(book) {
  151. if (!book || !book.id) {
  152. uni.showToast({
  153. title: '书籍信息不完整',
  154. icon: 'none'
  155. })
  156. return
  157. }
  158. uni.navigateTo({
  159. url: `/pages/book-detail/book-detail?bookId=${book.id}`
  160. });
  161. },
  162. handleImageError(index) {
  163. // 图片加载失败时使用备用图片
  164. if (this.bookList[index]) {
  165. this.bookList[index].cover = `https://picsum.photos/seed/fallback${index}/200/300`;
  166. }
  167. },
  168. loadBookList() {
  169. // 加载VIP书籍列表
  170. // 这里可以调用API获取数据
  171. },
  172. loadMore() {
  173. // 滚动到底部加载更多
  174. if (this.hasMore) {
  175. setTimeout(() => {
  176. // 模拟加载更多数据
  177. const moreBooks = [
  178. {
  179. id: 9,
  180. title: '车尔尼钢琴流畅练习曲',
  181. author: '高新颜',
  182. desc: '经典的钢琴练习曲集,适合中级钢琴学习者,帮助提升演奏技巧和流畅度。',
  183. cover: `https://picsum.photos/seed/vip-czerny${this.page}/200/300`,
  184. isVip: true
  185. },
  186. {
  187. id: 10,
  188. title: '古典哲学的趣味',
  189. author: '朱利安·巴吉尼',
  190. desc: '用通俗易懂的方式介绍古典哲学的核心思想,让哲学变得生动有趣。',
  191. cover: `https://picsum.photos/seed/vip-philosophy${this.page}/200/300`,
  192. isVip: true
  193. },
  194. {
  195. id: 11,
  196. title: '走向大洋',
  197. author: '未知',
  198. desc: '一部关于海洋探索和人类文明发展的历史著作,展现了人类对未知世界的探索精神。',
  199. cover: `https://picsum.photos/seed/vip-ocean${this.page}/200/300`,
  200. isVip: true
  201. },
  202. {
  203. id: 12,
  204. title: '思维的艺术',
  205. author: '延斯·森特根',
  206. desc: '一本关于思维方式和哲学思考的经典之作,帮助读者提升逻辑思维和批判性思考能力。',
  207. cover: `https://picsum.photos/seed/vip-thinking-art2${this.page}/200/300`,
  208. isVip: true
  209. }
  210. ];
  211. if (this.page < 3) {
  212. const newBooks = moreBooks.map((book, idx) => ({
  213. ...book,
  214. id: book.id + this.page * 10
  215. }));
  216. this.bookList = [...this.bookList, ...newBooks];
  217. this.page++;
  218. } else {
  219. this.hasMore = false;
  220. }
  221. }, 500);
  222. }
  223. }
  224. }
  225. }
  226. </script>
  227. <style scoped>
  228. .container {
  229. width: 100%;
  230. height: 100vh;
  231. background-color: #FFFFFF;
  232. display: flex;
  233. flex-direction: column;
  234. }
  235. /* 顶部导航栏 */
  236. .header {
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-between;
  240. padding: 20rpx 30rpx;
  241. background-color: #FFFFFF;
  242. border-bottom: 1rpx solid #E5E5E5;
  243. }
  244. .back-btn {
  245. width: 60rpx;
  246. height: 60rpx;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. }
  251. .back-icon {
  252. font-size: 40rpx;
  253. color: #000000;
  254. font-weight: bold;
  255. }
  256. .header-title {
  257. font-size: 36rpx;
  258. font-weight: bold;
  259. color: #000000;
  260. position: absolute;
  261. left: 50%;
  262. transform: translateX(-50%);
  263. }
  264. .search-btn {
  265. width: 60rpx;
  266. height: 60rpx;
  267. display: flex;
  268. align-items: center;
  269. justify-content: center;
  270. }
  271. .search-icon {
  272. font-size: 36rpx;
  273. color: #000000;
  274. }
  275. /* VIP横幅 */
  276. .vip-banner {
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. padding: 20rpx 30rpx;
  281. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  282. margin: 20rpx 30rpx;
  283. border-radius: 12rpx;
  284. }
  285. .vip-banner-text {
  286. font-size: 28rpx;
  287. color: #FFFFFF;
  288. font-weight: bold;
  289. }
  290. .vip-banner-arrow {
  291. font-size: 32rpx;
  292. color: #FFFFFF;
  293. font-weight: bold;
  294. }
  295. /* 书籍列表容器 */
  296. .book-list-container {
  297. flex: 1;
  298. width: 100%;
  299. height: 0;
  300. overflow: hidden;
  301. background-color: #FFFFFF;
  302. }
  303. /* 书籍项 */
  304. .book-item {
  305. display: flex;
  306. padding: 30rpx;
  307. border-bottom: 1rpx solid #F0F0F0;
  308. position: relative;
  309. }
  310. .book-item:last-child {
  311. border-bottom: none;
  312. }
  313. /* VIP徽章 */
  314. .vip-badge {
  315. position: absolute;
  316. top: 30rpx;
  317. left: 30rpx;
  318. width: 80rpx;
  319. height: 40rpx;
  320. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  321. border-radius: 20rpx;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. z-index: 10;
  326. }
  327. .vip-badge-text {
  328. font-size: 20rpx;
  329. color: #FFFFFF;
  330. font-weight: bold;
  331. }
  332. /* 书籍封面 */
  333. .book-cover {
  334. width: 160rpx;
  335. height: 220rpx;
  336. border-radius: 8rpx;
  337. margin-right: 24rpx;
  338. flex-shrink: 0;
  339. background-color: #F5F5F5;
  340. }
  341. /* 书籍信息 */
  342. .book-info {
  343. flex: 1;
  344. display: flex;
  345. flex-direction: column;
  346. justify-content: flex-start;
  347. min-width: 0;
  348. }
  349. .book-title {
  350. font-size: 32rpx;
  351. font-weight: bold;
  352. color: #000000;
  353. margin-bottom: 16rpx;
  354. line-height: 1.4;
  355. display: -webkit-box;
  356. -webkit-box-orient: vertical;
  357. -webkit-line-clamp: 2;
  358. overflow: hidden;
  359. text-overflow: ellipsis;
  360. }
  361. .book-desc {
  362. font-size: 28rpx;
  363. color: #666666;
  364. line-height: 1.6;
  365. margin-bottom: 20rpx;
  366. display: -webkit-box;
  367. -webkit-box-orient: vertical;
  368. -webkit-line-clamp: 3;
  369. overflow: hidden;
  370. text-overflow: ellipsis;
  371. }
  372. .book-author {
  373. font-size: 26rpx;
  374. color: #999999;
  375. margin-top: auto;
  376. }
  377. /* 加载更多 */
  378. .load-more {
  379. width: 100%;
  380. height: 80rpx;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. margin-top: 20rpx;
  385. margin-bottom: 40rpx;
  386. }
  387. .load-more-text {
  388. font-size: 28rpx;
  389. color: #999999;
  390. }
  391. </style>