index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. })
  44. } else if(type == 'delete') {
  45. var that = this
  46. var order = e.currentTarget.dataset.order
  47. Dialog.confirm({
  48. title: '提示',
  49. message: '确定订单吗',
  50. })
  51. .then(() => {
  52. that.delete(order)
  53. })
  54. }
  55. },
  56. delete(order) {
  57. var that = this
  58. http({
  59. url: 'orders/delete',
  60. data: {
  61. id: order.id
  62. },
  63. success: function (res) {
  64. if (res.code == 0) {
  65. that.triggerEvent("update")
  66. }
  67. }
  68. })
  69. },
  70. submitCheck(order) {
  71. var that = this
  72. http({
  73. url: 'orders/check',
  74. data: {
  75. id: order.id,
  76. type: 'confirm',
  77. remark: order.remark
  78. },
  79. success: function (res) {
  80. if (res.code == 0) {
  81. that.triggerEvent("update")
  82. }
  83. }
  84. })
  85. },
  86. }
  87. })