detail.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. sa_orderid: null,
  6. tabsActive: 0,
  7. tabsList: [{
  8. label: "详细信息",
  9. icon: "icon-tabchanpin",
  10. model: "#Product"
  11. }, {
  12. label: "物流查询",
  13. icon: "icon-tabfujian1",
  14. model: "#Query"
  15. }, {
  16. label: "装箱明细",
  17. icon: "icon-tabcaozuojilu1",
  18. model: "#Progress"
  19. }],
  20. },
  21. onLoad(options) {
  22. /* this.setData({
  23. sa_orderid: options.id
  24. });
  25. this.getDetail(true); */
  26. },
  27. /* 获取详情 */
  28. getDetail(init = false, show = true) {
  29. _Http.basic({
  30. "id": 20221108151302,
  31. "content": {
  32. nocache: true,
  33. "sa_orderid": this.data.sa_orderid
  34. }
  35. }, show).then(res => {
  36. console.log("订单详情", res)
  37. if (res.msg != '成功') return wx.showToast({
  38. title: res.msg,
  39. icon: "none"
  40. });
  41. this.setData({
  42. detail: res.data,
  43. loading: false
  44. });
  45. if (init) this.partialRenewal(true)
  46. })
  47. },
  48. //tabs 切换
  49. tabsChange({
  50. detail
  51. }) {
  52. this.setData({
  53. tabsActive: detail
  54. });
  55. this.partialRenewal();
  56. },
  57. //局部数据更新 tabs
  58. partialRenewal(init = false) {
  59. return ;
  60. let model = this.data.tabsList[this.data.tabsActive].model;
  61. if (model) {
  62. let Component = this.selectComponent(model),
  63. {
  64. total,
  65. pageNumber,
  66. pageTotal
  67. } = Component.data.content,
  68. id = this.data.detail.sa_orderid;
  69. if (total == null || init) {
  70. Component.getList(id, init);
  71. } else if (pageNumber < pageTotal) {
  72. Component.getList(id, false);
  73. }
  74. }
  75. },
  76. onReachBottom() {
  77. this.partialRenewal();
  78. },
  79. })