index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. },
  17. /**
  18. * 组件的方法列表
  19. */
  20. methods: {
  21. navigate: function(e) {
  22. wx.navigateTo({
  23. url: e.currentTarget.dataset.url,
  24. })
  25. },
  26. doAction: function(e) {
  27. var type = e.currentTarget.dataset.type
  28. if(type == 'edit' || type == 'detail') {
  29. this.navigate(e)
  30. } else if(type == 'confirm') {
  31. var that = this
  32. var order = e.currentTarget.dataset.order
  33. Dialog.confirm({
  34. title: '提示',
  35. message: '确定订单吗',
  36. })
  37. .then(() => {
  38. that.submitCheck(order)
  39. })
  40. } else if(type == 'delete') {
  41. var that = this
  42. var order = e.currentTarget.dataset.order
  43. Dialog.confirm({
  44. title: '提示',
  45. message: '确定订单吗',
  46. })
  47. .then(() => {
  48. that.delete(order)
  49. })
  50. }
  51. },
  52. delete(order) {
  53. var that = this
  54. http({
  55. url: 'orders/delete',
  56. data: {
  57. id: order.id
  58. },
  59. success: function (res) {
  60. if (res.code == 0) {
  61. that.triggerEvent("update")
  62. }
  63. }
  64. })
  65. },
  66. submitCheck(order) {
  67. var that = this
  68. http({
  69. url: 'orders/check',
  70. data: {
  71. id: order.id,
  72. type: 'confirm',
  73. remark: order.remark
  74. },
  75. success: function (res) {
  76. if (res.code == 0) {
  77. that.triggerEvent("update")
  78. }
  79. }
  80. })
  81. },
  82. }
  83. })