my-order.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="bg min100 pb-10">
  3. <u-sticky>
  4. <view class="bg-blue white">
  5. <u-tabs v-if="tabList.length>1" :list="tabList" font-size="32" bg-color="#286ceb" height="90" active-color="#fff" inactive-color="#eee"
  6. :is-scroll="false" :current="index" @change="change"></u-tabs>
  7. </view>
  8. </u-sticky>
  9. <view class="pd-30">
  10. <empty v-if="list.length==0" text="暂无订单"></empty>
  11. <view v-for="(item,i) in list" :key="i" class="mb-30">
  12. <orderItem v-if="current==0" :type="3" :item="item"></orderItem>
  13. <sfItem v-if="current==1" type="3" :item="item"></sfItem>
  14. <hyItem v-if="current==2" type="3" :item="item"></hyItem>
  15. </view>
  16. <u-loadmore v-show="list.length>9" :status="status" icon-type="flower" bg-color="transperant" margin-top="30"
  17. margin-bottom="30" />
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapState
  24. } from 'vuex'
  25. export default {
  26. data() {
  27. return {
  28. index:0,
  29. current: '',
  30. timer3: null,
  31. page: 1,
  32. status: 'loadmore',
  33. list: [],
  34. }
  35. },
  36. onLoad() {
  37. this.timer3 = setInterval(()=>{
  38. if(this.tabList&&this.tabList[0]){
  39. this.current = this.tabList[0].id
  40. this.getList()
  41. clearInterval(this.timer3)
  42. this.timer3 = null
  43. }
  44. },200)
  45. },
  46. onUnload() {
  47. clearInterval(this.timer3)
  48. },
  49. onHide() {
  50. clearInterval(this.timer3)
  51. },
  52. computed: {...mapState(['tabList'])},
  53. onPullDownRefresh() {
  54. this.page = 1
  55. this.list = []
  56. this.getList()
  57. },
  58. onReachBottom() {
  59. //避免多次触发
  60. if (this.status == 'loading' || this.status == 'nomore') {
  61. return;
  62. }
  63. this.getList()
  64. },
  65. methods: {
  66. change(index) {
  67. this.index = index;
  68. this.current = this.tabList[index].id;
  69. this.page = 1
  70. this.list = []
  71. this.status = 'loadmore'
  72. this.getList()
  73. },
  74. getList() {
  75. this.status = "loading";
  76. if(this.current==2){
  77. this.$http('/addons/ddrive/hyorder/order_list', {
  78. type: 2,
  79. }, "POST").then(res => {
  80. let data = res.data
  81. if (data.length < 10) {
  82. this.status = "nomore"
  83. } else {
  84. this.page = this.page + 1
  85. this.status = "loadmore"
  86. }
  87. this.list = this.list.concat(data)
  88. uni.stopPullDownRefresh();
  89. })
  90. }else{
  91. this.$http(this.current==0?'/addons/ddrive/order/order_info':'/addons/ddrive/sforder/user_order', {
  92. order_type: 2,
  93. }, "POST").then(res => {
  94. let data = this.current==0?res.data:res
  95. if (data.length < 10) {
  96. this.status = "nomore"
  97. } else {
  98. this.page = this.page + 1
  99. this.status = "loadmore"
  100. }
  101. this.list = this.list.concat(data)
  102. uni.stopPullDownRefresh();
  103. })
  104. }
  105. },
  106. }
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. </style>