index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. "ownertable": "sa_itemgroup",
  6. "ownerid": 11,
  7. pageSize: 20,
  8. pageNumber: 1,
  9. pageTotal: 1,
  10. "where": {
  11. "condition": ""
  12. }
  13. },
  14. list: [],
  15. result: [],
  16. },
  17. onLoad(options) {
  18. console.log(options)
  19. if (options.ownertable) {
  20. this.setData({
  21. content: {
  22. ...options
  23. }
  24. });
  25. this.getList();
  26. console.log(this.data.content)
  27. }
  28. },
  29. onChange(e) {
  30. const userid = e.currentTarget.dataset.item.userid + "";
  31. if (!userid) return;
  32. let result = this.data.result;
  33. if (result.some(v => v == userid)) {
  34. result = result.filter(v => v != userid)
  35. } else {
  36. result.push(userid)
  37. }
  38. this.setData({
  39. result
  40. })
  41. },
  42. getList(init = false) {
  43. let content = this.data.content;
  44. if (init) {
  45. content.pageTotal = 1
  46. content.pageNumber = 1
  47. }
  48. if (content.pageNumber > content.pageTotal) return;
  49. _Http.basic({
  50. "id": 20221018122201,
  51. content
  52. }).then(res => {
  53. console.log("数据团队列表", res)
  54. this.setData({
  55. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  56. "content.pageTotal": res.pageTotal,
  57. "content.pageNumber": res.pageNumber + 1,
  58. })
  59. })
  60. },
  61. onReachBottom() {
  62. this.getList();
  63. }
  64. })