index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. "content": {
  5. nocache: true,
  6. sys_enterpriseid: "",
  7. pageNumber: 1,
  8. pageTotal: 1,
  9. "where": {
  10. "condition": "",
  11. "workaddress": 1
  12. }
  13. }
  14. },
  15. onLoad(options) {
  16. this.setData({
  17. "content.sys_enterpriseid": options.id
  18. })
  19. this.getList(true);
  20. },
  21. /* 获取产品 */
  22. getList(init = false) {
  23. if (init.detail != undefined) init = init.detail;
  24. let content = this.data.content;
  25. if (init) content.pageNumber = 1;
  26. if (content.pageNumber > content.pageTotal) return;
  27. _Http.basic({
  28. "id": "20221009155803",
  29. content
  30. }).then(res => {
  31. console.log("我的地址列表", res)
  32. this.selectComponent('#ListBox').RefreshToComplete();
  33. if (res.msg != '成功') return wx.showToast({
  34. title: res.msg,
  35. icon: "none",
  36. mask: true
  37. });
  38. content.pageNumber = res.pageNumber + 1;
  39. content.pageTotal = res.pageTotal;
  40. res.data = res.data.filter(v => v.type != '收货')
  41. let list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  42. selected = "";
  43. try {
  44. selected = list.find(v => v.isdefault).contactsid
  45. } catch (error) {}
  46. this.setData({
  47. list,
  48. selected
  49. })
  50. })
  51. },
  52. /* 开始搜索 */
  53. onSearch({
  54. detail
  55. }) {
  56. if (detail == this.data.content.where.condition) return;
  57. this.data.content.where.condition = detail;
  58. this.getList(true);
  59. },
  60. // 修改默认
  61. radioChange({
  62. detail
  63. }) {
  64. let list = this.data.list,
  65. data = list.find(v => v.contactsid == detail)
  66. if (data.isdefault == 1) return;
  67. data.isdefault = 1;
  68. _Http.basic({
  69. "id": "20221009155703",
  70. "content": data
  71. }, false).then(res => {
  72. console.log(res)
  73. if (res.code != '1') return wx.showToast({
  74. title: res.data,
  75. icon: "none"
  76. });
  77. this.setData({
  78. list
  79. })
  80. })
  81. },
  82. onClear(e) {
  83. this.data.content.where.condition = "";
  84. this.getList(true);
  85. },
  86. onReady() {
  87. this.selectComponent("#ListBox").setHeight(".top", this);
  88. }
  89. })