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