index.js 1.7 KB

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