index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. radio: false, //是否为单选
  5. content: {
  6. "ownertable": "sa_itemgroup",
  7. "ownerid": 11,
  8. pageSize: 20,
  9. pageNumber: 1,
  10. pageTotal: 1,
  11. "where": {
  12. "condition": ""
  13. }
  14. },
  15. list: [],
  16. result: [],
  17. },
  18. onLoad(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. if (options.radio) this.setData({
  29. radio: true
  30. })
  31. },
  32. onChange(e) {
  33. const userid = e.currentTarget.dataset.item.userid + "";
  34. if (!userid) return;
  35. if (this.data.radio) {
  36. this.setData({
  37. result: [userid]
  38. })
  39. } else {
  40. let result = this.data.result;
  41. if (result.some(v => v == userid)) {
  42. result = result.filter(v => v != userid)
  43. } else {
  44. result.push(userid)
  45. }
  46. this.setData({
  47. result
  48. })
  49. }
  50. },
  51. getList(init = false) {
  52. let content = this.data.content;
  53. if (init) {
  54. content.pageTotal = 1
  55. content.pageNumber = 1
  56. }
  57. if (content.pageNumber > content.pageTotal) return;
  58. _Http.basic({
  59. "id": 20221018122201,
  60. content
  61. }).then(res => {
  62. console.log("数据团队列表", res)
  63. this.setData({
  64. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  65. "content.pageTotal": res.pageTotal,
  66. "content.pageNumber": res.pageNumber + 1,
  67. })
  68. })
  69. },
  70. onReachBottom() {
  71. this.getList();
  72. }
  73. })