// pages/treaty/service/service.js import ProApi from "../../../net/api/projectApi" Page({ /** * 页面的初始数据 */ data: { content: "", title: '', id: '', errorHint: '', showError: false }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ id: options.id }) wx.setNavigationBarColor({ frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000 backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色 animation: { // 可选项 duration: 500, timingFunc: 'easeIn' } }) this.getDeal() }, //获取协议内容 getDeal() { var _self = this wx.showLoading({ title: '加载中...', }) ProApi.doGetRuleDate(_self.data.id) .then(res => { wx.hideLoading() if (res && res.content && res.content != '') { _self.setData({ title: res.title, content: res.content }) } else { _self.setData({ showError: true, errorHint: '很遗憾,当前服务器返回的数据有误,辛苦您过会儿再尝试。' }) setTimeout(() => { wx.navigateBack() }, 1500); } }) .catch((err) => { wx.hideLoading() console.log(err) _self.setData({ showError: true, errorHint: '很遗憾,当前服务器返回的数据有误,辛苦您过会儿再尝试。' }) setTimeout(() => { wx.navigateBack() }, 1500); }) } })