// pages/superiority-detail/superiority-detail.js import PolicyService from '../../utils/api/policyApi'; import utils from '../../utils/util'; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { showPageLoading: true, bean: {}, imgBasePath: app.globalData.imgPath }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var id = options.id if (id) { this.getDetailData(id) } else { wx.navigateBack() } }, getDetailData(id) { var _self = this PolicyService.doGetDetail(id) .then(res => { _self.setData({ showPageLoading: false }) if (res) { res.newsContentContent = utils.formatHtml(res.newsContentContent) _self.setData({ bean: res }) wx.setNavigationBarTitle({ title: res.newsContentTitle, }) } }, err => { _self.setData({ showPageLoading: false }) wx.showToast({ icon: 'none', title: '网络错误', }) }) } })