index.js 3.5 KB

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