order.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="container">
  3. <u-sticky style="top: 0" offset-top="0">
  4. <u-tabs :list="statusArray" :current="statusIndex" @change="handleStatusChange"></u-tabs>
  5. </u-sticky>
  6. <view class="order-list">
  7. <view v-for="(item, index) in orderList" :key="item.orderNo" class="order-item">
  8. <view class="item-title">{{ item.orderNo }}</view>
  9. <view class="item-content">{{ item.orderStatus }}</view>
  10. <view class="item-btn-group"></view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { getOrderPage } from '../../api/order'
  17. export default {
  18. name: 'order',
  19. data() {
  20. return {
  21. pageNo: 1,
  22. statusIndex: 0,
  23. statusArray: [
  24. {
  25. name: '全部',
  26. status: '-1'
  27. },
  28. {
  29. name: '待付款',
  30. status: '0'
  31. },
  32. {
  33. name: '待发货',
  34. status: '10'
  35. },
  36. {
  37. name: '待收货',
  38. status: '20'
  39. },
  40. {
  41. name: '已完成',
  42. status: '30'
  43. },
  44. {
  45. name: '已取消', // TODO @辰尘:已取消不展示
  46. status: '50'
  47. }
  48. ],
  49. orderList: []
  50. }
  51. },
  52. onLoad(e) {
  53. const status = e.status
  54. if (status !== undefined) {
  55. this.statusArray.forEach((item, index) => {
  56. if (item.status === status) {
  57. this.statusIndex = index
  58. }
  59. })
  60. }
  61. this.loadOrderPageData()
  62. },
  63. methods: {
  64. handleStatusChange(item) {
  65. this.statusIndex = item.status
  66. },
  67. loadOrderPageData() {
  68. let params = { pageNo: this.pageNo }
  69. const status = this.statusArray[this.statusIndex].status
  70. if (status >= 0) {
  71. params.orderStatus = status
  72. }
  73. getOrderPage(params)
  74. .then(res => {
  75. console.log(res)
  76. })
  77. .catch(err => {
  78. console.log(err)
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped></style>