index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // components/out-order-item/index.js
  2. import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
  3. import http from '../../utils/http'
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. item: Object,
  10. role: Object,
  11. showDelete: {
  12. type: Boolean,
  13. value: true
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. },
  21. /**
  22. * 组件的方法列表
  23. */
  24. methods: {
  25. navigate: function (e) {
  26. wx.navigateTo({
  27. url: e.currentTarget.dataset.url,
  28. })
  29. },
  30. doAction: function (e) {
  31. var type = e.currentTarget.dataset.type
  32. if (type == 'edit' || type == 'detail') {
  33. this.navigate(e)
  34. } else if (type == 'confirm') {
  35. var that = this
  36. var order = e.currentTarget.dataset.order
  37. Dialog.confirm({
  38. title: '提示',
  39. message: '确定订单吗',
  40. })
  41. .then(() => {
  42. that.submitCheck(order)
  43. }).catch(() => {
  44. Dialog.close()
  45. })
  46. } else if (type == 'delete') {
  47. var that = this
  48. var order = e.currentTarget.dataset.order
  49. Dialog.confirm({
  50. title: '提示',
  51. message: '确定订单吗',
  52. })
  53. .then(() => {
  54. that.delete(order)
  55. }).catch(() => {
  56. Dialog.close()
  57. })
  58. }
  59. },
  60. delete(order) {
  61. var that = this
  62. http({
  63. url: 'orders/delete',
  64. data: {
  65. id: order.id
  66. },
  67. success: function (res) {
  68. if (res.code == 0) {
  69. that.triggerEvent("update")
  70. Dialog.close()
  71. }
  72. }
  73. })
  74. },
  75. submitCheck(order) {
  76. var that = this
  77. http({
  78. url: 'orders/check',
  79. data: {
  80. id: order.id,
  81. type: 'confirm',
  82. remark: order.remark
  83. },
  84. success: function (res) {
  85. if (res.code == 0) {
  86. that.triggerEvent("update")
  87. Dialog.close()
  88. }
  89. }
  90. })
  91. },
  92. }
  93. })