pickOrderList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="container">
  3. <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(6)">
  4. <view style="padding: 10px 0" v-if="!orderList.length">
  5. <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
  6. </view>
  7. <orderItem v-for="(item, index) in orderList" :key="index" :orderData="item" :isPick="true"></orderItem>
  8. </scroll-view>
  9. <u-top-tips ref="uTips"></u-top-tips>
  10. </view>
  11. </template>
  12. <script>
  13. const NET = require('@/utils/request')
  14. const API = require('@/config/api')
  15. import orderItem from '@/pagesMain/orderItem.vue'
  16. export default {
  17. components: {
  18. orderItem
  19. },
  20. data() {
  21. return {
  22. pageIndex: 1,
  23. isOver: false,
  24. orderList: [],
  25. type: 6
  26. }
  27. },
  28. onLoad(options) {
  29. this.type = options.type
  30. },
  31. onShow(options) {
  32. this.pageIndex = 1
  33. this.isOver = false
  34. this.orderList = []
  35. this.getOrderList(this.type)
  36. },
  37. onPullDownRefresh() {
  38. this.pageIndex = 1
  39. this.isOver = false
  40. this.orderList = []
  41. this.getOrderList(this.type, 'refresh')
  42. },
  43. methods: {
  44. // 刷新数据
  45. reasetList() {
  46. this.pageIndex = 1
  47. this.isOver = false
  48. this.orderList = []
  49. this.getOrderList(this.type)
  50. },
  51. // 懒加载
  52. handleLoadMore(type) {
  53. if (!this.isOver) {
  54. this.pageIndex++
  55. this.getOrderList(type)
  56. }
  57. },
  58. // 获取全部订单
  59. getOrderList(type, refresh) {
  60. NET.request(API.getOrderList + this.pageIndex + '/10', {
  61. flag: type,
  62. }, 'GET').then(res => {
  63. if (refresh == 'refresh') {
  64. uni.stopPullDownRefresh();
  65. }
  66. this.isOver = res.data.list.length != 10
  67. this.orderList = this.orderList.concat(res.data.list)
  68. if (this.orderList.length) {
  69. this.orderList.forEach(v => {
  70. v.noPick = true
  71. if (v.products.some(vv => {return vv.productType == 3} )) {
  72. v.noPick = false
  73. }
  74. })
  75. }
  76. }).catch(error => {
  77. this.$refs.uTips.show({
  78. title: error.data.msg,
  79. type: 'warning',
  80. })
  81. })
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang="less" scoped>
  87. page {
  88. width: 100%;
  89. height: 100%;
  90. }
  91. .container {
  92. width: 100%;
  93. height: 100%;
  94. float: left;
  95. background-color: #f7f7f7;
  96. .order-tab {
  97. width: 100%;
  98. height: 45px;
  99. float: left;
  100. }
  101. .order-list {
  102. width: calc(100% - 30px);
  103. height: calc(100% - 46px);
  104. float: left;
  105. margin: 0 15px;
  106. box-sizing: border-box;
  107. padding-top: 15px;
  108. }
  109. }
  110. </style>