// 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 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var id = options.id if (id) { this.getDetail(id) } else { wx.navigateBack() } }, getDetail(id) { var _self = this DomainService.doDetail(id) .then(res => { if (res) { wx.setNavigationBarTitle({ title: res.newsContentTitle, }) res.newsContentContent = utils.formatHtml(res.newsContentContent) _self.setData({ bean: res }) } _self.setData({ showPageLoading: false }) }, err => { _self.setData({ showPageLoading: false }) wx.showToast({ title: '网络错误(unique)', }) }) } })