cps.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const WXAPI = require('apifm-wxapi')
  2. Page({
  3. data: {
  4. tabIndex: 0,
  5. page: 1
  6. },
  7. onLoad(e) {
  8. this.cpsJdOrders()
  9. },
  10. onShow() {
  11. },
  12. tabChange(e) {
  13. this.setData({
  14. page: 1,
  15. tabIndex: e.detail.index
  16. })
  17. if (e.detail.index == 0) {
  18. this.cpsJdOrders()
  19. }
  20. if (e.detail.index == 1) {
  21. this.cpsPddOrders()
  22. }
  23. },
  24. async cpsJdOrders() {
  25. wx.showLoading({
  26. title: '',
  27. })
  28. const res = await WXAPI.cpsJdOrders({
  29. token: wx.getStorageSync('token')
  30. })
  31. wx.hideLoading()
  32. if (res.code == 0) {
  33. this.setData({
  34. list: res.data.result
  35. })
  36. }
  37. },
  38. async cpsPddOrders() {
  39. wx.showLoading({
  40. title: '',
  41. })
  42. const res = await WXAPI.cpsPddOrders({
  43. token: wx.getStorageSync('token')
  44. })
  45. wx.hideLoading()
  46. if (res.code == 0) {
  47. this.setData({
  48. list: res.data.result
  49. })
  50. }
  51. },
  52. onPullDownRefresh() {
  53. this.setData({
  54. page: 1
  55. })
  56. if (this.data.tabIndex == 0) {
  57. this.cpsJdOrders()
  58. }
  59. if (this.data.tabIndex == 1) {
  60. this.cpsPddOrders()
  61. }
  62. wx.stopPullDownRefresh()
  63. },
  64. huishou(e) {
  65. console.log(e);
  66. const type = e.currentTarget.dataset.type
  67. const orderId = e.currentTarget.dataset.orderid
  68. const platform = e.currentTarget.dataset.platform
  69. wx.navigateTo({
  70. url: `/pages/recycle/index?type=${type}&orderId=${orderId}&platform=${platform}`,
  71. })
  72. }
  73. })