index.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (!item.phonenumber) return wx.showToast({
  21. title: '该用户手机号为空',
  22. icon: "none"
  23. })
  24. wx.makePhoneCall({
  25. phoneNumber: item.phonenumber,
  26. })
  27. break;
  28. case "delete":
  29. wx.showModal({
  30. title: '提示',
  31. content: `是否确认删除"${item.name}"`,
  32. complete: (res) => {
  33. if (res.confirm) _Http.basic({
  34. "id": "20221111130904",
  35. "content": {
  36. sa_project_contactsids: [item.sa_project_contactsid],
  37. }
  38. }).then(res => {
  39. console.log("删除联系人", res)
  40. if (res.msg != '成功') return wx.showToast({
  41. title: res.data,
  42. icon: "none"
  43. });
  44. wx.showToast({
  45. title: `删除成功!`,
  46. icon: "none"
  47. })
  48. getCurrentPages().forEach(v => {
  49. if (v.selectComponent("#Contacts")) {
  50. const page = v.selectComponent("#Contacts");
  51. page.setData({
  52. list: page.data.list.filter(v => v.contactsid != item.contactsid)
  53. });
  54. page.changeTotal();
  55. } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
  56. v.setData({
  57. list: v.data.list.filter(v => v.contactsid != item.contactsid),
  58. 'content.total': v.data.content.total - 1
  59. });
  60. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  61. wx.navigateBack()
  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. }
  76. })