// pages/exerciseNews/exerciseNews.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { indicatorDots: true, autoplay: true, curTab: '021634c9-2a4b-4dd6-a997-3155e185d45d', requestIp: '', token: '', newsList: [], swiperList: [] }, getSwiper: function () { var self = this wx.request({ url: self.data.requestIp + 'wxminiapp/article/listpagearticlebycategoryrelease', data: { articleCategoryId: '38a3409d-9ffb-4441-9f31-951306896e8f' }, header: { "token": self.data.token }, success: function (res) { var images = '' for (var i = 0; i < res.data.rows.length; i++) { if (i == 0) { images = images + res.data.rows[i].images } else { images = images + ',' + res.data.rows[i].images } } var result = images.split(',') console.log(result) self.setData({ swiperList: result }) } }) }, changeTab: function (e) { this.setData({ curTab: e.currentTarget.dataset.id }) this.getList() }, goDetail: function (e) { wx.navigateTo({ url: '../newsDetail/newsDetail?articleContentId=' + e.currentTarget.dataset.id, }) }, getList: function () { var self = this wx.request({ url: self.data.requestIp + 'wxminiapp/article/listpagearticlebycategoryrelease', data: { articleCategoryId: 'c4c21643-4557-48ae-a5ac-0d2ea9cc2ce0' }, header: { 'token': self.data.token }, success: function (res) { self.setData({ newsList: res.data.rows }) } }) }, getToken: function () { var self = this wx.getStorage({ key: 'token', success: function (res) { self.setData({ token: res.data }) self.getList() self.getSwiper() }, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ requestIp: app.globalData.requestIp }) this.getToken() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })