index.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. page.changeTotal();
  54. break;
  55. case "packageA/setclient/modules/contacts/search/index":
  56. v.setData({
  57. list: v.data.list.filter(v => v.contactsid != item.contactsid)
  58. });
  59. break;
  60. case "packageA/setclient/modules/contacts/detail/index":
  61. wx.navigateBack()
  62. break;
  63. }
  64. })
  65. })
  66. }
  67. })
  68. break;
  69. case "edit":
  70. wx.navigateTo({
  71. url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
  72. })
  73. break;
  74. }
  75. },
  76. toDetail(e) {
  77. const {
  78. item
  79. } = e.currentTarget.dataset;
  80. wx.navigateTo({
  81. url: '/packageA/setclient/modules/contacts/detail/index?contactsid=' + item.contactsid
  82. })
  83. },
  84. }
  85. })