index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. list: Array,
  8. changeTotal: Function
  9. },
  10. data: {},
  11. methods: {
  12. handleItem(e) {
  13. const {
  14. name,
  15. item
  16. } = e.target.dataset,
  17. that = this;
  18. switch (name) {
  19. case "call":
  20. wx.makePhoneCall({
  21. phoneNumber: item.phonenumber,
  22. })
  23. break;
  24. case "delete":
  25. wx.showModal({
  26. title: '提示',
  27. content: `是否确认删除"${item.name}"`,
  28. complete: (res) => {
  29. if (res.confirm) _Http.basic({
  30. "id": "20221018145502",
  31. "content": {
  32. "contactsid": item.contactsid,
  33. "sys_enterpriseid": item.sys_enterpriseid
  34. }
  35. }).then(res => {
  36. console.log("删除联系人", res)
  37. if (res.msg != '成功') return wx.showToast({
  38. title: res.data,
  39. icon: "none"
  40. });
  41. that.triggerEvent("changeTotal")
  42. wx.showToast({
  43. title: `删除成功!`,
  44. icon: "none"
  45. })
  46. getCurrentPages().forEach(v => {
  47. switch (v.__route__) {
  48. case "packageA/setclient/detail":
  49. const page = v.selectComponent("#Contacts");
  50. page.setData({
  51. list: page.data.list.filter(v => v.contactsid != item.contactsid)
  52. });
  53. break;
  54. case "packageA/setclient/modules/contacts/search/index":
  55. v.setData({
  56. list: v.data.list.filter(v => v.contactsid != item.contactsid)
  57. });
  58. break;
  59. case "packageA/setclient/modules/contacts/detail/index":
  60. wx.navigateBack()
  61. break;
  62. }
  63. })
  64. })
  65. }
  66. })
  67. break;
  68. case "edit":
  69. wx.navigateTo({
  70. url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
  71. })
  72. break;
  73. }
  74. },
  75. toDetail(e) {
  76. const {
  77. item
  78. } = e.currentTarget.dataset;
  79. wx.navigateTo({
  80. url: '/packageA/setclient/modules/contacts/detail/index?contactsid=' + item.contactsid
  81. })
  82. },
  83. }
  84. })