index.js 2.5 KB

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