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