index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. list: Array,
  5. contactsid: String,
  6. sys_enterpriseid: String,
  7. changeTotal: Function
  8. },
  9. data: {
  10. sheet: {
  11. actions: [{
  12. name: "呼叫"
  13. }, {
  14. name: "详情"
  15. }, {
  16. name: "编辑"
  17. }, {
  18. name: "删除"
  19. }],
  20. item: {},
  21. show: false
  22. },
  23. },
  24. methods: {
  25. itemClick(e) {
  26. const {
  27. item
  28. } = e.currentTarget.dataset;
  29. this.setData({
  30. "sheet.item": item,
  31. "sheet.show": true
  32. })
  33. },
  34. onCancel() {
  35. this.setData({
  36. "sheet.item": null,
  37. "sheet.show": false
  38. })
  39. },
  40. onSelect(e) {
  41. let item = this.data.sheet.item,
  42. that = this;
  43. switch (e.detail.name) {
  44. case "呼叫":
  45. wx.makePhoneCall({
  46. phoneNumber: item.phonenumber,
  47. })
  48. break;
  49. case "删除":
  50. wx.showModal({
  51. title: '提示',
  52. content: `是否确认删除"${item.name}"`,
  53. complete: (res) => {
  54. if (res.confirm) {
  55. _Http.basic({
  56. "id": "20221018145502",
  57. "content": {
  58. "contactsid": item.contactsid,
  59. "sys_enterpriseid": item.sys_enterpriseid
  60. }
  61. }).then(res => {
  62. console.log(res)
  63. if (res.msg != '成功') return wx.showToast({
  64. title: res.data,
  65. icon: "none"
  66. });
  67. that.setData({
  68. list: this.data.list.filter(v => v.contactsid != item.contactsid)
  69. });
  70. wx.showToast({
  71. title: `删除成功!`,
  72. icon: "none"
  73. })
  74. that.triggerEvent("changeTotal")
  75. })
  76. }
  77. }
  78. })
  79. break;
  80. case "编辑":
  81. wx.navigateTo({
  82. url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
  83. })
  84. break;
  85. default:
  86. console.log(e.detail.name)
  87. break;
  88. }
  89. console.log(e)
  90. this.onCancel()
  91. }
  92. }
  93. })