select.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. condition: "",
  5. defaultGroup: [],
  6. myGroup: []
  7. },
  8. onLoad(options) {
  9. this.getList()
  10. },
  11. getList(init = false) {
  12. _Http.basic({
  13. "id": "20240102153304",
  14. "content": {
  15. nocache: true,
  16. pageSize: 9999,
  17. where: {
  18. condition: this.data.condition
  19. }
  20. }
  21. }).then(res => {
  22. console.log("群组", res)
  23. if (res.msg != '成功') return wx.showToast({
  24. title: res.msg,
  25. icon: "none"
  26. });
  27. this.setData({
  28. defaultGroup: [res.data.find(v => v.groupname == '默认群组')],
  29. myGroup: res.data.filter(v => v.sys_phonebookgroupid)
  30. })
  31. })
  32. },
  33. onSelected(e) {
  34. let {
  35. item
  36. } = e.currentTarget.dataset;
  37. console.log(item)
  38. getApp().globalData.handleSelect && getApp().globalData.handleSelect({
  39. id: [item.sys_phonebookgroupid],
  40. item,
  41. value: [item.groupname, [item.sys_phonebookgroupid]]
  42. })
  43. },
  44. /* 开始搜索 */
  45. startSearch({
  46. detail
  47. }) {
  48. let condition = this.data.condition;
  49. if (detail == condition) return;
  50. this.setData({
  51. condition: detail,
  52. });
  53. this.getList(true);
  54. },
  55. /* 取消搜索 */
  56. onClear() {
  57. this.setData({
  58. condition: "",
  59. });
  60. this.getList(true);
  61. },
  62. onUnload() {
  63. getApp().globalData.handleSelect = null;
  64. }
  65. })