hot-books.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. const getBookImage = (seed) => {
  6. return `https://picsum.photos/seed/${seed}/200/300`;
  7. };
  8. return {
  9. hasMore: true,
  10. page: 1,
  11. bookList: [
  12. {
  13. id: 1,
  14. title: "互联网心理学",
  15. author: "雷雳",
  16. desc: "当连接万物的互联网遇见无处不在的心理学,我们需要用心理学的方式,重新思考互联网背后的人与社会。",
  17. cover: getBookImage("internet-psychology")
  18. },
  19. {
  20. id: 2,
  21. title: "孝经 (中华经典诵读)",
  22. author: "孔子",
  23. desc: "以孔子与其弟子曾参之间问答的形式,将社会上各种阶层的人士,标示出其实践孝亲的法则与途径,阐述了「孝」的意义。",
  24. cover: getBookImage("xiaojing")
  25. },
  26. {
  27. id: 3,
  28. title: "自省",
  29. author: "约翰·班扬",
  30. desc: "讲述了敬虔之人和不敬虔之人截然相反的结局。本书就是他的细细品味,文风一如从前,朴实无华却又字字珠玑。",
  31. cover: getBookImage("self-reflection")
  32. },
  33. {
  34. id: 4,
  35. title: "思维的艺术",
  36. author: "延斯·森特根",
  37. desc: "一本关于思维方式和哲学思考的经典之作,帮助读者提升逻辑思维和批判性思考能力。",
  38. cover: getBookImage("thinking-art")
  39. },
  40. {
  41. id: 5,
  42. title: "传习录:全译全注",
  43. author: "王阳明",
  44. desc: "王阳明心学的核心著作,记录了其与学生之间的对话,阐述了知行合一的哲学思想。",
  45. cover: getBookImage("chuanxilu")
  46. },
  47. {
  48. id: 6,
  49. title: "社会契约论",
  50. author: "让·雅克·卢梭",
  51. desc: "探讨了政治权力的合法性和人民主权的基本原则,是现代民主理论的重要基石。",
  52. cover: getBookImage("social-contract")
  53. },
  54. {
  55. id: 7,
  56. title: "没有烦恼的世界",
  57. author: "王觉仁",
  58. desc: "通过禅修和正念的实践,帮助读者摆脱内心的烦恼,获得内心的平静与智慧。",
  59. cover: getBookImage("no-worries")
  60. },
  61. {
  62. id: 8,
  63. title: "透过电影看文化",
  64. author: "陈红",
  65. desc: "从电影的角度分析不同文化的特点,探讨电影如何反映和影响社会文化的发展。",
  66. cover: getBookImage("film-culture")
  67. }
  68. ]
  69. };
  70. },
  71. onLoad() {
  72. this.loadBookList();
  73. },
  74. methods: {
  75. goBack() {
  76. common_vendor.index.navigateBack({
  77. delta: 1
  78. });
  79. },
  80. goToSearch() {
  81. common_vendor.index.navigateTo({
  82. url: "/pages/search/search"
  83. });
  84. },
  85. goToBookDetail(book) {
  86. if (!book || !book.id) {
  87. common_vendor.index.showToast({
  88. title: "书籍信息不完整",
  89. icon: "none"
  90. });
  91. return;
  92. }
  93. common_vendor.index.navigateTo({
  94. url: `/pages/book-detail/book-detail?bookId=${book.id}`
  95. });
  96. },
  97. handleImageError(index) {
  98. if (this.bookList[index]) {
  99. this.bookList[index].cover = `https://picsum.photos/seed/fallback${index}/200/300`;
  100. }
  101. },
  102. loadBookList() {
  103. },
  104. loadMore() {
  105. if (this.hasMore) {
  106. setTimeout(() => {
  107. const moreBooks = [
  108. {
  109. id: 9,
  110. title: "车尔尼钢琴流畅练习曲",
  111. author: "高新颜",
  112. desc: "经典的钢琴练习曲集,适合中级钢琴学习者,帮助提升演奏技巧和流畅度。",
  113. cover: `https://picsum.photos/seed/czerny${this.page}/200/300`
  114. },
  115. {
  116. id: 10,
  117. title: "古典哲学的趣味",
  118. author: "朱利安·巴吉尼",
  119. desc: "用通俗易懂的方式介绍古典哲学的核心思想,让哲学变得生动有趣。",
  120. cover: `https://picsum.photos/seed/philosophy${this.page}/200/300`
  121. },
  122. {
  123. id: 11,
  124. title: "走向大洋",
  125. author: "未知",
  126. desc: "一部关于海洋探索和人类文明发展的历史著作,展现了人类对未知世界的探索精神。",
  127. cover: `https://picsum.photos/seed/ocean${this.page}/200/300`
  128. },
  129. {
  130. id: 12,
  131. title: "思维的艺术",
  132. author: "延斯·森特根",
  133. desc: "一本关于思维方式和哲学思考的经典之作,帮助读者提升逻辑思维和批判性思考能力。",
  134. cover: `https://picsum.photos/seed/thinking-art2${this.page}/200/300`
  135. }
  136. ];
  137. if (this.page < 3) {
  138. const newBooks = moreBooks.map((book, idx) => ({
  139. ...book,
  140. id: book.id + this.page * 10
  141. }));
  142. this.bookList = [...this.bookList, ...newBooks];
  143. this.page++;
  144. } else {
  145. this.hasMore = false;
  146. }
  147. }, 500);
  148. }
  149. }
  150. }
  151. };
  152. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  153. return common_vendor.e({
  154. a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  155. b: common_vendor.o((...args) => $options.goToSearch && $options.goToSearch(...args)),
  156. c: common_vendor.f($data.bookList, (book, index, i0) => {
  157. return {
  158. a: book.cover,
  159. b: common_vendor.o(($event) => $options.handleImageError(index), book.id || index),
  160. c: common_vendor.t(book.title),
  161. d: common_vendor.t(book.desc),
  162. e: common_vendor.t(book.author),
  163. f: book.id || index,
  164. g: common_vendor.o(($event) => $options.goToBookDetail(book), book.id || index)
  165. };
  166. }),
  167. d: $data.hasMore
  168. }, $data.hasMore ? {} : $data.bookList.length > 0 ? {} : {}, {
  169. e: $data.bookList.length > 0,
  170. f: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
  171. });
  172. }
  173. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1e672318"]]);
  174. wx.createPage(MiniProgramPage);
  175. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/hot-books/hot-books.js.map