const app = getApp() // pages/list/list.js Page({ /** * 页面的初始数据 */ data: { cardUrl: app.cardUrl, cardList: [] }, getList: function () { var self = this wx.showNavigationBarLoading() app.http.get(app.urls.getCardList, { header: { token: app.globalData.token }, data: {} }).then(res => { self.setData({ cardList: res.data }) wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }) .catch(err => { wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }) // app.restAjax.get(app.restAjax.path('{cardUrl}app/cardtemplate/listcardtemplate', [app.cardUrl]), {}, { // headers: { // token: app.globalData.token // } // }, function(code, data) { // self.setData({ // cardList: data // }) // }, function(code, data) { // app.dialog.msg(data.msg); // }); }, 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() } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.getList() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })