book-cover.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. bookInfo: {
  7. id: 1,
  8. title: "西游记",
  9. author: "(明) 吴承恩",
  10. image: "https://picsum.photos/seed/xiyouji/400/600"
  11. }
  12. };
  13. },
  14. onLoad(options) {
  15. if (options.bookId) {
  16. this.bookInfo.id = parseInt(options.bookId);
  17. }
  18. if (options.title) {
  19. this.bookInfo.title = decodeURIComponent(options.title);
  20. }
  21. if (options.image) {
  22. this.bookInfo.image = decodeURIComponent(options.image);
  23. }
  24. if (options.author) {
  25. this.bookInfo.author = decodeURIComponent(options.author);
  26. }
  27. },
  28. methods: {
  29. goBack() {
  30. common_vendor.index.navigateBack({
  31. delta: 1
  32. });
  33. },
  34. startReading() {
  35. common_vendor.index.showToast({
  36. title: "开始阅读",
  37. icon: "success"
  38. });
  39. setTimeout(() => {
  40. common_vendor.index.navigateTo({
  41. url: `/pages/reader/reader?bookId=${this.bookInfo.id}&title=${encodeURIComponent(this.bookInfo.title)}&image=${encodeURIComponent(this.bookInfo.image)}&author=${encodeURIComponent(this.bookInfo.author)}`
  42. });
  43. }, 500);
  44. }
  45. }
  46. };
  47. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  48. return {
  49. a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  50. b: $data.bookInfo.image,
  51. c: common_vendor.t($data.bookInfo.title),
  52. d: common_vendor.t($data.bookInfo.author),
  53. e: common_vendor.o((...args) => $options.startReading && $options.startReading(...args))
  54. };
  55. }
  56. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2149f422"]]);
  57. wx.createPage(MiniProgramPage);
  58. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/book-cover/book-cover.js.map