| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const utils_api = require("../../utils/api.js");
- const _sfc_main = {
- data() {
- return {
- audioList: [],
- isLoading: false
- };
- },
- onLoad() {
- this.loadAudioList();
- },
- methods: {
- async loadAudioList() {
- this.isLoading = true;
- try {
- const res = await utils_api.getRecommendAudiobooks(50);
- if (res && res.code === 200 && Array.isArray(res.data)) {
- this.audioList = res.data.map((item) => ({
- id: item.id,
- title: item.title,
- author: item.author || "",
- desc: item.brief || item.desc || "",
- cover: item.image || item.cover || "https://picsum.photos/seed/audio-novel/200/300"
- }));
- } else {
- this.audioList = [];
- }
- } catch (error) {
- common_vendor.index.__f__("error", "at pages/audio-novel/audio-novel.vue:85", "加载有声小说失败:", error);
- this.audioList = [];
- common_vendor.index.showToast({
- title: "加载失败",
- icon: "none"
- });
- } finally {
- this.isLoading = false;
- }
- },
- goBack() {
- common_vendor.index.navigateBack({
- delta: 1
- });
- },
- goToSearch() {
- common_vendor.index.navigateTo({
- url: "/pages/search/search"
- });
- },
- goToAudioDetail(audio) {
- if (!audio || !audio.id) {
- common_vendor.index.showToast({
- title: "听书信息不完整",
- icon: "none"
- });
- return;
- }
- common_vendor.index.navigateTo({
- url: `/pages/listen-detail/listen-detail?audiobookId=${audio.id}`
- });
- },
- handlePlay(audio) {
- if (!audio || !audio.id) {
- common_vendor.index.showToast({
- title: "听书信息不完整",
- icon: "none"
- });
- return;
- }
- this.goToAudioDetail(audio);
- },
- handleImageError(index) {
- if (this.audioList[index]) {
- this.audioList[index].cover = `https://picsum.photos/seed/audio-novel-fallback${index}/200/300`;
- }
- }
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
- b: common_vendor.o((...args) => $options.goToSearch && $options.goToSearch(...args)),
- c: $data.isLoading
- }, $data.isLoading ? {} : $data.audioList.length === 0 ? {} : {}, {
- d: $data.audioList.length === 0,
- e: common_vendor.f($data.audioList, (audio, index, i0) => {
- return {
- a: audio.cover,
- b: common_vendor.o(($event) => $options.handleImageError(index), audio.id || index),
- c: common_vendor.t(audio.title),
- d: common_vendor.t(audio.desc),
- e: common_vendor.t(audio.author),
- f: common_vendor.o(($event) => $options.handlePlay(audio), audio.id || index),
- g: audio.id || index,
- h: common_vendor.o(($event) => $options.goToAudioDetail(audio), audio.id || index)
- };
- })
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-0c5530b9"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/audio-novel/audio-novel.js.map
|