var t = require("../../miniprogram_npm/@vant/weapp/toast/toast"), a = require("../../lib/aes.js"), e = getApp(), o = wx.getBackgroundAudioManager(); o.title = e.globalData.appTitle, Page({ data: { poetryId: 0, poetry: void 0, currentBook: {}, active: 0, type: "", playing: !1, pinyin: !0 }, onLoad: function(t) { this.setData({ poetryId: t.id, type: t.type }), this.getPoetry(), this.handleAutoPlay(); }, onUnload: function(t) { o.stop(); }, onShow: function() {}, handleAutoPlay: function() { var t = this; o.onEnded(function(a) { t.setData({ playing: !1 }); }), o.onPlay(function(a) { t.setData({ playing: !0 }); }), o.onError(function(a) { t.setData({ playing: !1 }); }); }, getPoetry: function() { var t = this, o = t.data.poetryId, n = t.data.type, i = e.globalData.API_URL + "/h5/api/textbook/poetry/detail", r = { id: o, type: n }; wx.request({ url: i, data: r, success: function(o) { var n = a.decrypt(o.data, e.globalData.key), i = JSON.parse(n); t.setData({ poetry: i }); } }); }, choosePinyin: function(t) { this.setData({ pinyin: !this.data.pinyin }); }, playPoetry: function(a) { var e = this.data.poetry; console.log(e.voice), e.voice || t("本篇古诗暂无音频哦"), this.data.playing ? (this.setData({ playing: !1 }), o.stop()) : this.play(e.voice); }, play: function(t) { o.src = t, o.play(); }, toRecord: function(t) { o.stop(), wx.navigateTo({ url: "../record/record?id=" + this.data.poetryId }); }, onShareAppMessage: function(t) { return { title: e.globalData.share_title, path: "/pages/index/index", success: function(t) {}, fail: function(t) {} }; } });