myActivityOrder.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="common-page">
  3. <u-sticky bgColor="#fff">
  4. <view class="tabs-box">
  5. <u-tabs class="coupon-tabs" :scrollable="false" :current="currentIndex" lineColor="#C29556 " :activeStyle="{
  6. color: '#C29556 ',
  7. marginTop: '4rpx',
  8. fontSize: '14px',}"
  9. :inactiveStyle="{
  10. marginTop: '4rpx',
  11. fontSize: '14px',}"
  12. lineWidth="48rpx"
  13. lineHeight="6rpx"
  14. :list="tabs" @click="handleTabs"/>
  15. </view>
  16. </u-sticky>
  17. <view class="list">
  18. <order-item @refresh="refreshData" v-for="(item, index) in orderList" :key="index" :data="item">
  19. </order-item>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import OrderItem from './activityOrderItem'
  25. import {myActivities} from '../../common/api/activity'
  26. export default {
  27. components: {OrderItem},
  28. data() {
  29. return {
  30. total: 0,
  31. currentIndex: 0,
  32. pageParams: {
  33. page: 1,
  34. pageSize: 5,
  35. },
  36. topData: {
  37. top: 0,
  38. height: 0
  39. },
  40. currentStatus: '',
  41. tabs: [
  42. {name: '全部', value: ''},
  43. {name: '已报名', value: '3'},
  44. {name: '已完成', value: '4'},
  45. {name: '已取消', value: '0'},
  46. ],
  47. orderList: []
  48. }
  49. },
  50. watch: {
  51. currentIndex(nv) {
  52. if (nv == 5) {
  53. // 获取售后列表
  54. this.getAfterList(true)
  55. } else {
  56. this.getOrderList(true)
  57. }
  58. }
  59. },
  60. onLoad() {
  61. this.currentIndex = uni.getStorageSync("orderIndex")
  62. if (this.tabs[this.currentIndex]) {
  63. this.currentStatus = this.tabs[this.currentIndex].value
  64. } else {
  65. this.currentIndex = 0
  66. }
  67. if (this.currentIndex == 0) {
  68. this.getOrderList(true)
  69. }
  70. },
  71. onShow() {
  72. const topData = uni.getMenuButtonBoundingClientRect()
  73. this.topData.top = topData.top
  74. this.topData.height = topData.height
  75. },
  76. onReachBottom() {
  77. if (this.currentIndex == 5) {
  78. this.getAfterList()
  79. } else {
  80. this.getOrderList()
  81. }
  82. },
  83. methods: {
  84. leftClick() {
  85. uni.switchTab({
  86. url: '/pages/mine/index'
  87. })
  88. },
  89. toHome() {
  90. uni.switchTab({
  91. url: '/pages/home/index'
  92. })
  93. },
  94. getAfterList(initFlag) {
  95. if (!initFlag) {
  96. if (this.pageParams.page * this.pageParams.pageSize < this.total) {
  97. this.pageParams.page++
  98. } else {
  99. return
  100. }
  101. } else {
  102. this.pageParams.page = 1
  103. this.total = 0
  104. this.orderList = []
  105. }
  106. let sendData = {
  107. ...this.pageParams
  108. }
  109. this.$api.getAfterSalesList(sendData).then(res => {
  110. const {list, page} = res.data
  111. this.orderList = this.orderList.concat(list)
  112. this.total = page.total
  113. })
  114. },
  115. refreshData() {
  116. this.pageParams.page = 1
  117. console.log('refresh')
  118. if (this.currentIndex == 5) {
  119. // 获取售后列表
  120. this.getAfterList(true)
  121. } else {
  122. this.getOrderList(true)
  123. }
  124. this.getOrderList(true)
  125. },
  126. handleTabs(tabData) {
  127. this.currentStatus = tabData.value
  128. this.pageParams.page = 1
  129. this.currentIndex = tabData.index
  130. },
  131. getOrderList(initFlag) {
  132. if (!initFlag) {
  133. if (this.pageParams.page * this.pageParams.pageSize < this.total) {
  134. this.pageParams.page++
  135. } else {
  136. return
  137. }
  138. } else {
  139. this.pageParams.page = 1
  140. this.total = 0
  141. this.orderList = []
  142. }
  143. let sendData = {
  144. status: this.currentStatus,
  145. ...this.pageParams
  146. }
  147. myActivities(sendData).then(res => {
  148. const {list, page} = res.data
  149. this.orderList = this.orderList.concat(list)
  150. this.total = page.total
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .common-page {
  158. min-height: 100vh;
  159. // overflow-y: auto;
  160. box-sizing: border-box;
  161. }
  162. .tabs-box {
  163. background-color: #fff;
  164. // padding: ;
  165. }
  166. .list {
  167. padding: 20rpx 30rpx;
  168. box-sizing: border-box;
  169. }
  170. </style>