index.js 1.8 KB

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