const app = getApp(); // pages/messageDetail/index.js Page({ /** * 页面的初始数据 */ data: { iosDialogTobe: false, serviceInfo: {}, pageType: null, currentId: null, currentInfo: {}, tagStyle: { p: "margin-top: 0; margin-bottom: 0;line-height: 1.8; white-space:pre-wrap;", body: " margin: 0; color: #333; font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-variant: tabular-nums; line-height: 1.8; -webkit-font-feature-settings: 'tnum'; font-feature-settings: 'tnum';", h1: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:24px; ", h2: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:21px; ", h3: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1;font-size:16px; ", h4: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", h5: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", h6: " margin-top: 0; margin-bottom: 0.5em;margin-top:0.3em; color: rgba(0, 0, 0, 0.85); font-weight: 500;line-height: 1.1 ", strong: "font-weight: bolder;", b: "font-weight: bolder;", dl: "margin-top: 0; margin-bottom: 1em;", ol: "margin-top: 0; margin-bottom: 1em;", ul: "margin-top: 0; margin-bottom: 1em;", li: "line-height: 1.8", hr: "box-sizing: content-box;height:1rpx;overflow: visible;background-color: #ddd;border:0;", table: "border-collapse: collapse;border: 1px solid #d9d9d9;margin: 18px 0 16px 0;line-height: 1.8", td: "border: 1px solid #d9d9d9;vertical-align: top;padding: 4px 8px;line-height: 1.8", }, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options); if (options.type) { this.setData({ pageType: options.type, }); } if (options.id) { this.setData({ currentId: options.id, }); this.requestInfo(); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() {}, /** * 生命周期函数--监听页面显示 */ onShow() { setTimeout(() => { this.setData({ serviceInfo: app.globalData.serviceInfo, }); }, 10); }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage1() {}, requestInfo() { let that = this; wx.showLoading({ title: "正在获取内容", }); wx.request({ url: app.globalData.ip + "/bocai/cms/details/" + this.data.currentId, header: app.globalData.headers, success: function (res) { console.log(res); if (res.data.status == 200) { setTimeout(() => { // let reg = /]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g.exec(res.data.data.content); // console.log(reg); that.setData({ currentInfo: res.data.data, html: res.data.data.content.replace(//g, ""), }); wx.hideLoading(); }, 1000); wx.request({ url: app.globalData.ip + "/bocai/cms/read/" + that.data.currentId, header: app.globalData.headers, success: function (res) { console.log(res); if (res.data.status == 200) { } }, }); } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 2000, }); wx.hideLoading(); } }, }); }, showTobe() { this.setData({ iosDialogTobe: true, }); }, closeDialog() { this.setData({ iosDialogTobe: false, }); }, });