index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="bg min100">
  3. <u-sticky h5-nav-height="0">
  4. <view class="status_bar bg-blue">
  5. </view>
  6. <view class="bg-blue white">
  7. <view class="center pd-20" style="padding-top: 52rpx;">
  8. <view class="size-36 mr-10">订单</view>
  9. </view>
  10. <u-tabs :list="tabList" font-size="32" bg-color="#286ceb" height="90" active-color="#fff" inactive-color="#eee"
  11. :is-scroll="false" :current="index" @change="change"></u-tabs>
  12. </view>
  13. </u-sticky>
  14. <view class="pd-30">
  15. <empty v-if="!list||list.length==0" text="暂无订单"></empty>
  16. <view v-for="(item,i) in list" :key="i" class="mb-30">
  17. <orderItem v-if="current==0" :type="2" :item="item"></orderItem>
  18. <sfItem @update="change(current)" v-if="current==1" type="2" :item="item"></sfItem>
  19. <hyItem v-if="current==2" type="2" :item="item"></hyItem>
  20. </view>
  21. <u-loadmore v-show="list&&list.length>9" :status="status" icon-type="flower" bg-color="transperant" margin-top="30"
  22. margin-bottom="30" />
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState
  29. } from 'vuex'
  30. export default {
  31. data() {
  32. return {
  33. index:0,
  34. current: '',
  35. timer3: null,
  36. page: 1,
  37. status: 'loadmore',
  38. list: []
  39. }
  40. },
  41. computed: {
  42. ...mapState(['tabList'])
  43. },
  44. onShow() {
  45. this.timer3 = setInterval(()=>{
  46. if(this.tabList&&this.tabList[0]){
  47. if(!this.current){
  48. this.current = this.tabList[0].id
  49. }
  50. this.page = 1
  51. this.list = []
  52. this.status = 'loadmore'
  53. if (this.current == 0) {
  54. this.getList1()
  55. } else if (this.current == 1) {
  56. this.getList2()
  57. }else if (this.current == 2) {
  58. this.getList3()
  59. }
  60. clearInterval(this.timer3)
  61. this.timer3 = null
  62. }
  63. },200)
  64. },
  65. onUnload() {
  66. clearInterval(this.timer3)
  67. },
  68. onHide() {
  69. clearInterval(this.timer3)
  70. },
  71. onPullDownRefresh() {
  72. this.page = 1
  73. this.list = []
  74. if (this.current == 0) {
  75. this.getList1()
  76. } else if (this.current == 1) {
  77. this.getList2()
  78. }else if (this.current == 2) {
  79. this.getList3()
  80. }
  81. },
  82. onReachBottom() {
  83. //避免多次触发
  84. if (this.status == 'loading' || this.status == 'nomore') {
  85. return;
  86. }
  87. if (this.current == 0) {
  88. this.getList1()
  89. } else if (this.current == 1) {
  90. this.getList2()
  91. }else if (this.current == 2) {
  92. this.getList3()
  93. }
  94. },
  95. methods: {
  96. change(index) {
  97. this.index = index;
  98. this.current = this.tabList[index].id;
  99. this.page = 1
  100. this.list = []
  101. this.status = 'loadmore'
  102. if (this.current == 0) {
  103. this.getList1()
  104. } else if (this.current == 1) {
  105. this.getList2()
  106. }else if (this.current == 2) {
  107. this.getList3()
  108. }
  109. },
  110. getList1() {
  111. this.$http('/addons/ddrive/order/order_info', {
  112. order_type: 1,
  113. }, "POST").then(res => {
  114. this.list = res.data
  115. uni.stopPullDownRefresh();
  116. })
  117. },
  118. getList2() {
  119. this.status = "loading"
  120. this.$http('/addons/ddrive/sforder/order_list',{
  121. page:this.page
  122. }).then(res => {
  123. let data = res
  124. if (data.length < 10) {
  125. this.status = "nomore"
  126. } else {
  127. this.page = this.page + 1
  128. this.status = "loadmore"
  129. }
  130. this.list = this.list.concat(data)
  131. uni.stopPullDownRefresh();
  132. })
  133. },
  134. getList3() {
  135. this.status = "loading"
  136. this.$http('/addons/ddrive/hyorder/order_list',{
  137. page:this.page,
  138. type:1
  139. }).then(res => {
  140. let data = res.data
  141. if (data.length < 10) {
  142. this.status = "nomore"
  143. } else {
  144. this.page = this.page + 1
  145. this.status = "loadmore"
  146. }
  147. this.list = this.list.concat(data)
  148. uni.stopPullDownRefresh();
  149. })
  150. },
  151. }
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. </style>