index.js 3.0 KB

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