index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import * as requestAPI from '../../models/dataModel'
  2. Page({
  3. data: {
  4. timesheetList: [],
  5. current: 1,
  6. size: 10,
  7. total: 0
  8. },
  9. //onLoad: function (options) {
  10. // this.gettimesheetList()
  11. // },
  12. onReady() {
  13. this.gettimesheetList()
  14. },
  15. // 获取列表
  16. gettimesheetList() {
  17. //wx.showLoading({title: '加载中', icon: 'loading'});
  18. let form = {
  19. current: this.data.current,
  20. size: this.data.size,
  21. eCnname:wx.getStorageSync('username')
  22. }
  23. requestAPI.getTimeSheetList(form).then(res => {
  24. this.setData({
  25. timesheetList: res.data.data.records,
  26. total: res.data.data.total
  27. })
  28. })
  29. },
  30. // 下拉刷新
  31. onPullDownRefresh: function () {
  32. wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画
  33. this.onLoad(); //刷新页面
  34. setTimeout(function () {
  35. wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
  36. wx.stopPullDownRefresh(); //停止下拉动作
  37. }, 2000)
  38. },
  39. // 下拉加载
  40. onReachBottom: function () {
  41. if (this.data.size > this.data.total) {
  42. return;
  43. } else {
  44. this.gettimesheetList();
  45. this.setData({
  46. size: this.data.size+10
  47. })
  48. }
  49. },
  50. openPreview: function (event) {
  51. wx.previewImage({
  52. urls: new Array(event.currentTarget.dataset.url),
  53. })
  54. },
  55. generate() {
  56. wx.navigateTo({
  57. url: `/pages/timesheet/detail`,
  58. })
  59. }
  60. })