index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // pages/home/index.js
  2. const imageCdn = 'https://tdesign.gtimg.com/miniprogram/images/';
  3. const swiperList = [
  4. `${imageCdn}/swiper1.png`,
  5. `${imageCdn}/swiper2.png`,
  6. `${imageCdn}/swiper3.png`,
  7. `${imageCdn}/swiper4.png`,
  8. `${imageCdn}/swiper5.png`,
  9. ];
  10. const app = getApp()
  11. import api from '../api/api'
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. current: 0,
  18. autoplay: false,
  19. duration: 500,
  20. interval: 5000,
  21. swiperList,
  22. list: [],
  23. pageNumber: 1,
  24. pageSize: 20,
  25. status: '待接单',
  26. statistics: {}
  27. },
  28. async listData() {
  29. const res = await api._post({
  30. "id": "20230208140203",
  31. "version": 1,
  32. "content": {
  33. "pageNumber": this.data.pageNumber,
  34. "pageSize": this.data.pageSize,
  35. "where": {
  36. "status": this.data.status,
  37. "condition": ""
  38. }
  39. }
  40. })
  41. this.setData({
  42. statistics: res.data[0].rows_total[0]
  43. })
  44. if (!res.data[0].billno) return false;
  45. this.setData({
  46. list: this.data.list.concat(res.data)
  47. })
  48. console.log(this.data.statistics)
  49. },
  50. onTabsChange(e) {
  51. this.data.status = e.detail.value;
  52. this.onPullDownRefresh()
  53. },
  54. onLoad(options) {
  55. this.listData()
  56. },
  57. onPullDownRefresh() {
  58. this.setData({
  59. pageNumber: 1,
  60. list: []
  61. })
  62. this.listData()
  63. },
  64. onReachBottom() {
  65. this.data.pageNumber++
  66. this.setData({
  67. pageNumber: this.data.pageNumber,
  68. })
  69. this.listData()
  70. },
  71. })