index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. if (res.data.length === 0) return false;
  42. this.setData({
  43. list: this.data.list.concat(res.data),
  44. statistics: res.data[0].rows_total[0]
  45. })
  46. console.log(this.data.statistics)
  47. },
  48. onTabsChange(e) {
  49. this.data.status = e.detail.value;
  50. this.onPullDownRefresh()
  51. },
  52. onLoad(options) {
  53. this.listData()
  54. },
  55. onPullDownRefresh() {
  56. this.setData({
  57. pageNumber: 1,
  58. list: []
  59. })
  60. this.listData()
  61. },
  62. onReachBottom() {
  63. this.data.pageNumber++
  64. this.setData({
  65. pageNumber: this.data.pageNumber,
  66. })
  67. this.listData()
  68. },
  69. })