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() {
  56. try {
  57. uni.hideLoading();
  58. uni.showLoading({
  59. title: '数据加载中...'
  60. });
  61. const res = await getVolunteerOrderList({ orderStatus: tab.value });
  62. data.value = res.data;
  63. } catch (error) {
  64. console.log('error', error);
  65. uni.showToast({
  66. title: error.msg,
  67. icon: 'error',
  68. })
  69. } finally {
  70. uni.hideLoading();
  71. }
  72. }
  73. /**
  74. * 1: 查看
  75. * 2:沟通
  76. * 3:上传照片
  77. */
  78. function btnClick(row, type) {
  79. console.log('btnClick', type, row);
  80. if (type === 1) {
  81. uni.navigateTo({
  82. url: `/pages/order/handle?orderId=${row.secondOrderId}`
  83. });
  84. // uni.navigateTo({
  85. // url: `/pages/order/order?orderId=${row.secondOrderId}`
  86. // });
  87. return
  88. }
  89. uni.navigateTo({
  90. url: `/pages/talk/pages/index/index?orderId=${row.secondOrderId}`
  91. });
  92. }
  93. provide('onClick', btnClick);
  94. function onChange(tabItem) {
  95. tab.value = tabItem.value;
  96. getList();
  97. console.log('change', tabItem, tab.value);
  98. }
  99. onMounted(getList)
  100. onShow(() => {
  101. const params = getApp().globalData.switchTabParams;
  102. if(!params.tabKey) return;
  103. tabKey.value = params.tabKey;
  104. console.log(params); // { id: 123, type: "test" }
  105. onChange(column[tabKey.value])
  106. // 使用后建议清除参数,避免重复读取
  107. getApp().globalData.switchTabParams = null;
  108. })
  109. </script>
  110. <style lang="scss" scoped>
  111. .classify-main {
  112. height: 100vh;
  113. .list {
  114. position: fixed;
  115. top: 50px;
  116. bottom: 0px;
  117. left: 0px;
  118. right: 0px;
  119. }
  120. }
  121. </style>