myServerOrder.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 './serverOrderItem'
  25. import {getYvyueOrderList} from '../../common/api/yvyeService'
  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: '1'},
  44. {name: '待完成', value: '3'},
  45. {name: '已完成', value: '9'},
  46. {name: '已取消', value: '-2'},
  47. ],
  48. orderList: []
  49. }
  50. },
  51. watch: {
  52. currentIndex(nv) {
  53. if (nv == 5) {
  54. // 获取售后列表
  55. this.getAfterList(true)
  56. } else {
  57. this.getOrderList(true)
  58. }
  59. }
  60. },
  61. onLoad() {
  62. this.currentIndex = uni.getStorageSync("orderIndex")
  63. if (this.tabs[this.currentIndex]) {
  64. this.currentStatus = this.tabs[this.currentIndex].value
  65. } else {
  66. this.currentIndex = 0
  67. }
  68. if (this.currentIndex == 0) {
  69. this.getOrderList(true)
  70. }
  71. },
  72. onShow() {
  73. const topData = uni.getMenuButtonBoundingClientRect()
  74. this.topData.top = topData.top
  75. this.topData.height = topData.height
  76. },
  77. onReachBottom() {
  78. if (this.currentIndex == 5) {
  79. this.getAfterList()
  80. } else {
  81. this.getOrderList()
  82. }
  83. },
  84. methods: {
  85. leftClick() {
  86. uni.switchTab({
  87. url: '/pages/mine/index'
  88. })
  89. },
  90. toHome() {
  91. uni.switchTab({
  92. url: '/pages/home/index'
  93. })
  94. },
  95. getAfterList(initFlag) {
  96. if (!initFlag) {
  97. if (this.pageParams.page * this.pageParams.pageSize < this.total) {
  98. this.pageParams.page++
  99. } else {
  100. return
  101. }
  102. } else {
  103. this.pageParams.page = 1
  104. this.total = 0
  105. this.orderList = []
  106. }
  107. let sendData = {
  108. ...this.pageParams
  109. }
  110. this.$api.getAfterSalesList(sendData).then(res => {
  111. const {list, page} = res.data
  112. this.orderList = this.orderList.concat(list)
  113. this.total = page.total
  114. })
  115. },
  116. refreshData() {
  117. this.pageParams.page = 1
  118. console.log('refresh')
  119. if (this.currentIndex == 5) {
  120. // 获取售后列表
  121. this.getAfterList(true)
  122. } else {
  123. this.getOrderList(true)
  124. }
  125. this.getOrderList(true)
  126. },
  127. handleTabs(tabData) {
  128. this.currentStatus = tabData.value
  129. this.pageParams.page = 1
  130. this.currentIndex = tabData.index
  131. },
  132. getOrderList(initFlag) {
  133. if (!initFlag) {
  134. if (this.pageParams.page * this.pageParams.pageSize < this.total) {
  135. this.pageParams.page++
  136. } else {
  137. return
  138. }
  139. } else {
  140. this.pageParams.page = 1
  141. this.total = 0
  142. this.orderList = []
  143. }
  144. let sendData = {
  145. status: this.currentStatus,
  146. ...this.pageParams
  147. }
  148. getYvyueOrderList(sendData).then(res => {
  149. const {list, page} = res.data
  150. this.orderList = this.orderList.concat(list)
  151. this.total = page.total
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .common-page {
  159. min-height: 100vh;
  160. // overflow-y: auto;
  161. box-sizing: border-box;
  162. }
  163. .tabs-box {
  164. background-color: #fff;
  165. // padding: ;
  166. }
  167. .list {
  168. padding: 20rpx 30rpx;
  169. box-sizing: border-box;
  170. }
  171. </style>