const app = getApp() // pages/list/list.js Page({ /** * 页面的初始数据 */ data: { imgUrl: app.urls.baseImgUrl, cardList: [] }, getList: function () { var self = this wx.showLoading({ title: '加载中...', }) app.http.get(app.urls.getCardList, { header: { token: app.globalData.token } }).then(res => { wx.hideLoading({}) self.setData({ cardList: res.data }) wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }) .catch(err => { wx.hideLoading({}) wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }) }, goDetail: function (e) { var id = e.currentTarget.dataset.id console.log(id) wx.navigateTo({ url: '../cardDetail/cardDetail?id=' + id, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var self = this wx.getStorage({ key: 'token', success: function (res) { self.setData({ token: res.data }) app.globalData.token = res.data self.getList() } }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.getList() }, })