| // pages/bill/bill.js |
| Page({ |
| |
| /** |
| * 页面的初始数据 |
| */ |
| data: { |
| hasBill: false |
| }, |
| |
| /** |
| * 生命周期函数--监听页面加载 |
| */ |
| onLoad: function(options) { |
| var that = this; |
| wx.showLoading("加载中"); |
| var param = { |
| "pageno": 1 |
| } |
| wx.$doPost('/v1/bills', param, function(ok, ret) { |
| wx.hideLoading(); |
| if (ok) { |
| ret = ret.data; |
| console.log(ret) |
| if (ret.code == 200) { |
| if (ret.page && ret.page.count > 0) { |
| that.setData({ |
| hasBill: true |
| }) |
| } else { |
| |
| wx.showModal({ |
| title: '提示', |
| content: '暂无数据', |
| showCancel: false, |
| success(res) { |
| wx.navigateBack({ |
| |
| }) |
| } |
| }) |
| |
| } |
| |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.msg, |
| duration: 2000 |
| }) |
| |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: "请求失败了" + ret.data.status + ",请稍后再试", |
| duration: 2000 |
| }) |
| } |
| }) |
| }, |
| |
| /** |
| * 生命周期函数--监听页面初次渲染完成 |
| */ |
| onReady: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面显示 |
| */ |
| onShow: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面隐藏 |
| */ |
| onHide: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面卸载 |
| */ |
| onUnload: function() { |
| |
| }, |
| |
| /** |
| * 页面相关事件处理函数--监听用户下拉动作 |
| */ |
| onPullDownRefresh: function() { |
| |
| }, |
| |
| /** |
| * 页面上拉触底事件的处理函数 |
| */ |
| onReachBottom: function() { |
| |
| }, |
| |
| /** |
| * 用户点击右上角分享 |
| */ |
| onShareAppMessage: function() { |
| |
| } |
| }) |