index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. ownertable: null,
  5. ownerid: null,
  6. active: 0,
  7. copyTeams: [], //用来本地搜索
  8. keyword: "", //搜索关键字
  9. },
  10. onLoad(options) {
  11. if (options.item) {
  12. let item = JSON.parse(options.item);
  13. this.setData({
  14. ...item
  15. });
  16. this.getList()
  17. }
  18. },
  19. onInput({
  20. detail
  21. }) {
  22. let list = this.data.copyTeams[this.data.active];
  23. if (detail.value) list = list.filter(v => v.position.includes(detail.value) || v.name.includes(detail.value));
  24. this.setData({
  25. [`teams[${this.data.active}].team`]: list
  26. })
  27. },
  28. /* 取消搜索 */
  29. cancelTheSearch() {
  30. this.setData({
  31. keyword: "",
  32. [`teams[${this.data.active}].team`]: this.data.copyTeams[this.data.active]
  33. })
  34. },
  35. /* 切换tabs */
  36. onChange({
  37. detail
  38. }) {
  39. this.setData({
  40. active: detail.index
  41. })
  42. },
  43. //获取列表
  44. getList() {
  45. _Http.basic({
  46. "id": 20220930103501,
  47. "content": {
  48. "ownertable": this.data.ownertable,
  49. "ownerid": this.data.ownerid
  50. }
  51. }).then(res => {
  52. console.log("团队成员列表", res)
  53. if (res.msg != '成功') return wx.showToast({
  54. title: res.data,
  55. icon: "none"
  56. })
  57. this.setData({
  58. teams: res.data,
  59. copyTeams: res.data.map(v => v.team)
  60. })
  61. })
  62. },
  63. onReachBottom() {
  64. this.getList();
  65. }
  66. })