city-casereport/pages/newsDetail/newsDetail.js
2023-12-08 11:30:29 +08:00

56 lines
896 B
JavaScript

// pages/newsDetail/newsDetail.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
token: '',
id: '',
bean: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var _self = this;
_self.setData({
id: options.id
})
wx.getStorage({
key: 'token',
success: function (res) {
_self.setData({
token: res.data
})
_self.getNewsDetail();
}
})
},
getNewsDetail() {
var _self = this;
wx.showLoading({
title: '加载中...',
})
app.restAjax.get(app.restAjax.path('{reqesutUrl}app/news/get/' + _self.data.id, [app.requestUrl]), null, {
headers: {
token: _self.data.token
}
}, function (code, data) {
wx.hideLoading();
_self.setData({
bean: data
})
}, (code, error) => {
wx.hideLoading();
wx.showToast({
title: '加载失败',
icon: 'error'
})
});
}
})