index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. },
  27. async listData () {
  28. const res = await api._post({
  29. "id": "20230208140203",
  30. "version":1,
  31. "content": {
  32. "pageNumber":this.data.pageNumber,
  33. "pageSize":this.data.pageSize,
  34. "where":{
  35. "status":this.data.status,
  36. "condition":""
  37. }
  38. }
  39. })
  40. if (res.data.length === 0) return false
  41. this.setData({
  42. list:this.data.list.concat(res.data)
  43. })
  44. },
  45. onTabsChange (e) {
  46. this.data.status = e.detail.label
  47. this.onPullDownRefresh()
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. this.listData()
  54. this.setData({
  55. tabbarlist:app.globalData.tabbarList
  56. })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow() {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide() {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload() {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh() {
  82. this.setData({
  83. pageNumber:1,
  84. list:[]
  85. })
  86. this.listData()
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom() {
  92. this.data.pageNumber ++
  93. this.setData({
  94. pageNumber:this.data.pageNumber,
  95. })
  96. this.listData()
  97. },
  98. /**
  99. * 用户点击右上角分享
  100. */
  101. onShareAppMessage() {
  102. }
  103. })