list.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. const app = getApp()
  2. const util = require('../../../utils/util.js');
  3. const api = require('../../../api/api.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. today:'',
  10. userInfo: {
  11. nickName: '点击登录',
  12. avatarUrl: '/static/images/my.png'
  13. },
  14. hasLogin:false,
  15. list:[],
  16. page: 1,
  17. limit: 10,
  18. totalPages: 1,
  19. },
  20. getList(){
  21. let that=this;
  22. wx.showLoading();
  23. util.request(api.PreList,{
  24. page:this.data.page,
  25. limit:this.data.limit
  26. }).then(res=>{
  27. wx.hideLoading();
  28. console.info(res.data)
  29. that.setData({
  30. list: that.data.list.concat(res.data.list),
  31. totalPages: res.data.pages
  32. });
  33. })
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. let userInfo = wx.getStorageSync('userInfo');
  50. if(userInfo){
  51. this.setData({
  52. userInfo: userInfo,
  53. hasLogin: true
  54. });
  55. }
  56. this.setData({
  57. list:[],
  58. today:util.formatDate(new Date()),
  59. })
  60. this.getList();
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. if (this.data.totalPages > this.data.page) {
  82. this.setData({
  83. page: this.data.page + 1
  84. });
  85. this.getList();
  86. } else {
  87. wx.showToast({
  88. title: '没有更多预检单了',
  89. icon: 'none',
  90. duration: 2000
  91. });
  92. return false;
  93. }
  94. },
  95. editPre(e){
  96. let bookNo=e.currentTarget.dataset.bookno;
  97. wx.navigateTo({
  98. url: '/pages/pre/previewing/index?bookNo='+bookNo,
  99. });
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage: function () {
  105. }
  106. })