select.js 1.7 KB

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