orders.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const WXAPI = require('apifm-wxapi')
  2. Page({
  3. data: {
  4. },
  5. onLoad(e) {
  6. this.recycleOrders()
  7. },
  8. onShow() {
  9. },
  10. async recycleOrders() {
  11. wx.showLoading({
  12. title: '',
  13. })
  14. const res = await WXAPI.recycleOrders({
  15. token: wx.getStorageSync('token')
  16. })
  17. wx.hideLoading()
  18. if (res.code == 0) {
  19. this.setData({
  20. list: res.data.result
  21. })
  22. }
  23. },
  24. onPullDownRefresh() {
  25. this.recycleOrders()
  26. wx.stopPullDownRefresh()
  27. },
  28. detail(e) {
  29. const id = e.currentTarget.dataset.id
  30. wx.navigateTo({
  31. url: `/pages/recycle/order-detail?id=${id}`,
  32. })
  33. },
  34. async recycleOrderClose(e) {
  35. wx.showModal({
  36. title: '提示',
  37. content: '确认要取消该订单吗?',
  38. success: res => {
  39. if (res.confirm) {
  40. this._recycleOrderClose(e)
  41. }
  42. }
  43. })
  44. },
  45. async _recycleOrderClose(e) {
  46. const id = e.currentTarget.dataset.id
  47. const res = await WXAPI.recycleOrderClose(wx.getStorageSync('token'), id)
  48. if (res.code != 0) {
  49. wx.showToast({
  50. title: res.msg,
  51. icon: 'none'
  52. })
  53. return
  54. }
  55. wx.showToast({
  56. title: '已取消',
  57. })
  58. this.recycleOrders()
  59. },
  60. async recycleOrderDelete(e) {
  61. wx.showModal({
  62. title: '提示',
  63. content: '确认要删除该订单吗?',
  64. success: res => {
  65. if (res.confirm) {
  66. this._recycleOrderDelete(e)
  67. }
  68. }
  69. })
  70. },
  71. async _recycleOrderDelete(e) {
  72. const id = e.currentTarget.dataset.id
  73. const res = await WXAPI.recycleOrderDelete(wx.getStorageSync('token'), id)
  74. if (res.code != 0) {
  75. wx.showToast({
  76. title: res.msg,
  77. icon: 'none'
  78. })
  79. return
  80. }
  81. wx.showToast({
  82. title: '删除成功',
  83. })
  84. this.recycleOrders()
  85. }
  86. })