classify.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="classify-main">
  3. <up-tabs :list="column" :scrollable="false" @change="onChange" :activeStyle="{
  4. color: 'rgba(255, 87, 4, 1)',
  5. fontWeight: 'bold',
  6. transform: 'scale(1.05)'
  7. }" lineColor="rgba(255, 87, 4, 1)" :current="tabKey" >
  8. </up-tabs>
  9. <view class="list">
  10. <List :data="data" v-if="data.length > 0" />
  11. <view v-else class="empty-null">
  12. <img src="/static/empty/订单为空.png" alt="">
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref } from 'vue';
  19. import List from './order/list/index.vue';
  20. import { provide } from 'vue';
  21. import { getVolunteerOrderList } from '@/api/volunteer.js'
  22. import { onMounted } from 'vue';
  23. import {useDict} from '@/utils/dict.js';
  24. import { onLoad, onShow } from '@dcloudio/uni-app';
  25. const { order_status } = useDict('order_status');
  26. provide('order_status', order_status);//订单/服务状态
  27. const tab = ref('');
  28. const tabKey = ref(0);
  29. const data = ref([]);
  30. /**
  31. * 0待支付 1已支付 2支付超时或取消 3进行中 4已完成 5申请退款中 6已退款 7部分退款 8 待确认
  32. */
  33. const column = [
  34. {
  35. name: "全部",
  36. value: "",
  37. },
  38. {
  39. name: "待服务",
  40. value: "1",
  41. },
  42. {
  43. name: "进行中",
  44. value: "3",
  45. },
  46. {
  47. name: "已完成",
  48. value: "4",
  49. },
  50. {
  51. name: "已取消",
  52. value: "2",
  53. }
  54. ]
  55. async function getList(parmas) {
  56. console.log('getList', parmas);
  57. try {
  58. uni.hideLoading();
  59. uni.showLoading({
  60. title: '数据加载中...'
  61. });
  62. const res = await getVolunteerOrderList({ orderStatus: tab.value });
  63. data.value = res.data;
  64. } catch (error) {
  65. console.log('error', error);
  66. uni.showToast({
  67. title: error.msg,
  68. icon: 'error',
  69. })
  70. } finally {
  71. uni.hideLoading();
  72. }
  73. }
  74. /**
  75. * 1: 查看
  76. * 2:沟通
  77. * 3:上传照片
  78. */
  79. function btnClick(row,type) {
  80. console.log('btnClick', type, row);
  81. if (type === 1) {
  82. uni.navigateTo({
  83. url: `/pages/order/order?orderId=${row.secondOrderId}`
  84. });
  85. return
  86. }
  87. uni.navigateTo({
  88. url: `/pages/order/handle?orderId=${row.secondOrderId}`
  89. });
  90. }
  91. provide('onClick', btnClick);
  92. function onChange(tabItem) {
  93. tab.value = tabItem.value;
  94. getList();
  95. console.log('change', tabItem, tab.value);
  96. }
  97. // onMounted(init)
  98. onLoad((options) => {
  99. console.log('options',options);
  100. tab.value = options.status;
  101. })
  102. onShow(() => {
  103. const params = getApp().globalData.switchTabParams;
  104. tabKey.value = params.tabKey;
  105. console.log(params); // { id: 123, type: "test" }
  106. onChange(column[tabKey.value])
  107. // 使用后建议清除参数,避免重复读取
  108. getApp().globalData.switchTabParams = null;
  109. // init();
  110. })
  111. </script>
  112. <style lang="scss" scoped>
  113. .classify-main {
  114. height: 100vh;
  115. .list {
  116. position: fixed;
  117. top: 50px;
  118. bottom: 0px;
  119. left: 0px;
  120. right: 0px;
  121. }
  122. }
  123. </style>