order-detail.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="order-detail">
  3. <view class="sticky-header">
  4. <!-- 订单类型切换 -->
  5. <view class="type-tabs-wrapper">
  6. <u-subsection :list="typeList" :current="currentType" @change="handleTypeChange" active-color="#38C148" mode="subsection"></u-subsection>
  7. </view>
  8. <!-- 标签页 -->
  9. <view class="tabs-wrapper">
  10. <u-tabs :list="tabList" :current="currentTab" @change="handleTabChange" :is-scroll="false"
  11. active-color="#38C148" bar-width="60"></u-tabs>
  12. </view>
  13. </view>
  14. <!-- 订单列表 -->
  15. <page-scroll :page-size="12" @updateList="handleUpdateList" ref="pageRef" slotEmpty
  16. :url="currentUrl" :params="params" :immediate="false">
  17. <view v-if="orderList.length > 0" class="pad-20">
  18. <partner-order-item v-for="(order, index) in orderList" :key="index" :order="order" :type="currentType"></partner-order-item>
  19. </view>
  20. </page-scroll>
  21. </view>
  22. </template>
  23. <script>
  24. import PartnerOrderItem from '../../components/partner-order-item.vue'
  25. import pageScroll from '@/components/pageScroll/index.vue'
  26. export default {
  27. components: {
  28. PartnerOrderItem,
  29. pageScroll,
  30. },
  31. data() {
  32. return {
  33. typeList: [
  34. { name: '卖书订单' },
  35. { name: '买书订单' }
  36. ],
  37. currentType: 0,
  38. currentUrl: '/token/userPartner/geOrderList',
  39. tabList: [{
  40. name: '全部',
  41. status: ""
  42. },
  43. {
  44. name: '未结算',
  45. status: "1"
  46. },
  47. {
  48. name: '未到账',
  49. status: "2"
  50. },
  51. {
  52. name: '已到账',
  53. status: "3"
  54. },
  55. {
  56. name: '已失效',
  57. status: "4"
  58. }
  59. ],
  60. currentTab: 0,
  61. orderList: [],
  62. params: {},
  63. // 模拟数据
  64. mockOrders: []
  65. }
  66. },
  67. // #ifdef MP-ALIPAY
  68. onPullDownRefresh() {
  69. this.$refs.pageRef?.loadData(true)
  70. },
  71. // #endif
  72. onLoad(options) {
  73. // 如果有传入状态,切换到对应tab
  74. if (options.status) {
  75. this.currentTab = this.tabList.findIndex(item => item.status === options.status)
  76. this.params.status = options.status
  77. }
  78. },
  79. onShow() {
  80. this.loadOrders(true, this.params)
  81. },
  82. methods: {
  83. loadOrders(bool = false, params = {}) {
  84. this.$nextTick(() => {
  85. this.$refs.pageRef?.loadData(bool, params);
  86. })
  87. },
  88. handleTypeChange(index) {
  89. this.currentType = index
  90. this.currentUrl = index === 0 ? '/token/userPartner/geOrderList' : '/token/userPartner/getShopOrderList'
  91. this.orderList = []
  92. this.$nextTick(() => {
  93. this.loadOrders(true, this.params)
  94. })
  95. },
  96. handleTabChange(index) {
  97. this.currentTab = index
  98. this.params.status = this.tabList[index].status
  99. this.loadOrders(true, this.params)
  100. },
  101. handleUpdateList(list) {
  102. this.orderList = list
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .order-detail {
  109. min-height: 100vh;
  110. background-color: #F5F5F5;
  111. .sticky-header {
  112. position: sticky;
  113. top: 0;
  114. z-index: 99;
  115. background: #FFFFFF;
  116. }
  117. .type-tabs-wrapper {
  118. padding: 20rpx 30rpx 0;
  119. background-color: #FFFFFF;
  120. }
  121. .tabs-wrapper {
  122. background: #FFFFFF;
  123. }
  124. .pad-20 {
  125. padding: 20rpx;
  126. }
  127. }
  128. </style>