index.js 1.9 KB

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