index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import api from '../../api/api'
  2. Component({
  3. properties: {
  4. visible: {
  5. value: false,
  6. type: Boolean
  7. }
  8. },
  9. data: {
  10. visible: false,
  11. param: {
  12. "id": "20221216145803",
  13. "version": 1,
  14. "content": {
  15. "pageSize": 20,
  16. "pageNumber": 1,
  17. "where": {
  18. "condition": ""
  19. }
  20. }
  21. },
  22. list: []
  23. },
  24. lifetimes: {
  25. attached() {
  26. this.listData()
  27. getApp().globalData.Language.getLanguagePackage(this)
  28. this.setData({
  29. loadingTexts: ['下拉刷新', '松手刷新', '正在刷新', '刷新完成'].map(v => getApp().globalData.Language.getMapText(v))
  30. })
  31. }
  32. },
  33. methods: {
  34. async listData() {
  35. const res = await api._post(this.data.param)
  36. if (res.data.length > 0) {
  37. this.setData({
  38. list: this.data.list.concat(res.data)
  39. })
  40. } else {
  41. getApp().globalData.Language.showToast('没有更多了!')
  42. }
  43. },
  44. onSubmit(data) {
  45. this.data.param.content.where.condition = data.detail.value
  46. this.data.list = []
  47. this.data.param.content.pageNumber = 1
  48. this.listData()
  49. },
  50. onClear() {
  51. this.data.param.content.where.condition = ''
  52. this.data.list = []
  53. this.data.param.content.pageNumber = 1
  54. this.listData()
  55. },
  56. onClick(data) {
  57. let item = data.currentTarget.dataset.item
  58. this.setData({
  59. visible: false
  60. })
  61. this.triggerEvent('select', item)
  62. },
  63. onPullDownRefresh() {
  64. this.data.list = []
  65. this.data.param.content.pageNumber = 1
  66. this.listData()
  67. },
  68. onReachBottom() {
  69. this.data.param.content.pageNumber++
  70. this.listData()
  71. },
  72. }
  73. })