import { imgUrl } from "../../api/request" Page({ /** * 页面的初始数据 */ data: { // 图片前缀 imgUrl: imgUrl, articles: '', fontSize: '中', isPlay: false }, chooseFontSize(e) { let temp = this.data.articles; switch (this.data.fontSize) { case '大': temp.DOCHTMLCON = temp.DOCHTMLCON.replace(/\
{ // console.log(res); res.data.data.DOCPUBTIME = res.data.data.DOCPUBTIME.split(" ")[0]; res.data.data.DOCHTMLCON = res.data.data.CONTENT.replace(/\
]*src="([^'"]+)[^>]*>/gi, function (match, capture) { // 替换小图片地址 if (capture.split("/").length > 1) { return match.replace(/src=['"]([^'"]+)[^>]/gi, 'src="' + 'https://www.cqna.gov.cn' + capture + '"'); } return match.replace(/src=['"]([^'"]+)[^>]/gi, 'src="' + url + capture + '"'); }); this.setData({ articles: res.data.data }) } }) }, audioPlay() { if (!this.data.isPlay) { let that = this; that.innerAudioContext = wx.createInnerAudioContext({ useWebAudioImplement: false }) that.innerAudioContext.src = 'https://www.cqna.gov.cn/voice_assistant/2022-11-28/a05-60ff109e2a32_10281519.mp3'; that.innerAudioContext.play() } else { this.innerAudioContext.pause(); } this.setData({ isPlay: !this.data.isPlay }) }, end() { if (this.innerAudioContext) { this.innerAudioContext.pause(); } }, onReady() { }, onShow() { }, onHide() { this.end(); //暂停音频 }, onUnload() { this.end(); //暂停音频 }, onPullDownRefresh() { }, onReachBottom() {}, onShareAppMessage() { return { title: this.data.articles.TITLE }; } })