// pages/superiority-detail/superiority-detail.js import IndexService from '../../utils/api/indexApi'; 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 IndexService.doGetSuperiorityDetail({ newsDirectoriesId: id }) .then(res => { _self.setData({ showPageLoading: false }) if (res && res.rows) { res.rows[0].newsContentContent = utils.formatHtml(res.rows[0].newsContentContent) _self.setData({ bean: res.rows[0] }) wx.setNavigationBarTitle({ title: res.rows[0].newsContentTitle, }) } }, err => { _self.setData({ showPageLoading: false }) wx.showToast({ title: '网络错误', }) }) } })