classify.vue 3.3 KB

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