index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. lifetimes: {
  9. attached: function () {
  10. // 在组件实例进入页面节点树时执行
  11. this.setData({
  12. user_id: wx.getStorageSync('sg-userinfo').id
  13. })
  14. console.log(this.properties.role)
  15. },
  16. detached: function () {
  17. // 在组件实例被从页面节点树移除时执行
  18. },
  19. },
  20. properties: {
  21. item: Object,
  22. role: Object,
  23. showDelete: {
  24. type: Boolean,
  25. value: true
  26. }
  27. },
  28. /**
  29. * 组件的初始数据
  30. */
  31. data: {
  32. user_id: ""
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. navigate: function (e) {
  39. wx.navigateTo({
  40. url: e.currentTarget.dataset.url,
  41. })
  42. },
  43. doAction: function (e) {
  44. var type = e.currentTarget.dataset.type
  45. var that = this
  46. var order = e.currentTarget.dataset.order
  47. if (type == 'edit' || type == 'detail') {
  48. this.navigate(e)
  49. } else if (type == 'confirm') {
  50. Dialog.confirm({
  51. title: '提示',
  52. message: '确定订单吗',
  53. })
  54. .then(() => {
  55. that.submitCheck(order)
  56. }).catch(() => {
  57. Dialog.close()
  58. })
  59. } else if (type == 'delete') {
  60. Dialog.confirm({
  61. title: '提示',
  62. message: '确定删除订单吗',
  63. })
  64. .then(() => {
  65. that.delete(order)
  66. }).catch(() => {
  67. Dialog.close()
  68. })
  69. }
  70. },
  71. delete(order) {
  72. var that = this
  73. http({
  74. url: 'orders/delete',
  75. data: {
  76. id: order.id
  77. },
  78. success: function (res) {
  79. if (res.code == 0) {
  80. that.triggerEvent("update")
  81. Dialog.close()
  82. }
  83. }
  84. })
  85. },
  86. submitCheck(order) {
  87. var that = this
  88. http({
  89. url: 'orders/check',
  90. data: {
  91. id: order.id,
  92. type: 'confirm',
  93. remark: order.remark
  94. },
  95. success: function (res) {
  96. if (res.code == 0) {
  97. that.triggerEvent('update', {})
  98. Dialog.close()
  99. }
  100. }
  101. })
  102. },
  103. }
  104. })