classify.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. <OrderList :dataList="dataList" @fetchData="getListData"/>
  19. </template>
  20. <script setup>
  21. import {
  22. ref
  23. } from 'vue';
  24. import List from '@/pages_classify/components/orderList/index.vue';
  25. import {
  26. provide
  27. } from 'vue';
  28. import {
  29. getVolunteerOrderList
  30. } from '@/api/volunteer.js'
  31. import {
  32. onMounted
  33. } from 'vue';
  34. import {
  35. useDict
  36. } from '@/utils/dict.js';
  37. import {
  38. onLoad,
  39. onShow
  40. } from '@dcloudio/uni-app';
  41. import OrderList from '@/components/pages/classify/orderlist.vue'
  42. import {
  43. userMainOrderList
  44. } from "@/api/userList.js"
  45. const {
  46. order_status,
  47. lrr_service_status
  48. } = useDict('order_status','lrr_service_status');
  49. provide('order_status', order_status); //订单/服务状态
  50. provide('lrr_service_status', lrr_service_status); //订单/服务状态
  51. const userType = uni.getStorageSync('userType') //读取本地存储
  52. // 用户/志愿者 识别标识
  53. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  54. const tab = ref('');
  55. const tabKey = ref(0);
  56. const dataList = ref([]) //用户
  57. const data = ref([]); //志愿者
  58. /**
  59. * 0待支付 1已支付 2支付超时或取消 3进行中 4已完成 5申请退款中 6已退款 7部分退款 8 待确认
  60. */
  61. const column = [{
  62. name: "全部",
  63. value: "",
  64. },
  65. {
  66. name: "待服务",
  67. value: "0",
  68. },
  69. {
  70. name: "进行中",
  71. value: "1",
  72. },
  73. {
  74. name: "已完成",
  75. value: "2",
  76. },
  77. {
  78. name: "已取消",
  79. value: "3",
  80. }
  81. ]
  82. const column2 = [{
  83. name: "全部",
  84. value: "",
  85. },
  86. {
  87. name: "待支付",
  88. value: "1",
  89. },
  90. {
  91. name: "待服务",
  92. value: "2",
  93. },
  94. {
  95. name: "进行中",
  96. value: "3",
  97. },
  98. {
  99. name: "已完成",
  100. value: "4",
  101. },
  102. {
  103. name: "已取消",
  104. value: "5",
  105. }
  106. ]
  107. async function getList() {
  108. console.log('>>>>userType', userType);
  109. try {
  110. uni.hideLoading();
  111. uni.showLoading({
  112. title: '数据加载中...'
  113. });
  114. // 判断 userType 来决定调用哪个接口
  115. let res;
  116. if (userType === 1) {
  117. // 如果 userType 是 1,调用 userMainOrderList 接口
  118. getListData();
  119. } else if (userType === 2) {
  120. // 如果 userType 是 2,调用 getVolunteerOrderList 接口
  121. res = await getVolunteerOrderList({
  122. orderStatus: tab.value
  123. });
  124. data.value = res.data;
  125. }
  126. } catch (error) {
  127. console.log('error', error);
  128. uni.showToast({
  129. title: error.msg,
  130. icon: 'error',
  131. });
  132. } finally {
  133. uni.hideLoading();
  134. }
  135. }
  136. const getListData = async (orderStatus = tab.value) => {
  137. console.log('>>>>>执行111111');
  138. const res = await userMainOrderList({
  139. orderStatus: orderStatus
  140. });
  141. dataList.value = res.data
  142. }
  143. /**
  144. * 1: 查看
  145. * 2:沟通
  146. * 3:上传照片
  147. */
  148. function btnClick(row, type) {
  149. console.log('btnClick', type, row, row.orderStatus);
  150. if (type === 1 && row.orderStatus === 2) {
  151. uni.navigateTo({
  152. url: `/pages_classify/pages/order/index?orderId=${row.secondOrderId}`
  153. });
  154. return;
  155. }
  156. if (type === 1) {
  157. uni.navigateTo({
  158. url: `/pages_classify/pages/handle/index?orderId=${row.secondOrderId}`
  159. });
  160. return
  161. }
  162. //前往沟通
  163. uni.navigateTo({
  164. url: `/pages_orderuser/pages/talk/pages/index/index?orderId=${row.secondOrderId}`
  165. });
  166. }
  167. provide('onClick', btnClick);
  168. function onChange(tabItem) {
  169. console.log('onChange called with tabItem:', tabItem); // 确认是否进入 onChange
  170. tab.value = tabItem.value;
  171. getList();
  172. console.log('change', tabItem, tab.value);
  173. }
  174. onMounted(() => {
  175. getList()
  176. console.log('>>>>>>执行周期2222');
  177. getListData()
  178. })
  179. onShow(() => {
  180. const params = getApp().globalData.switchTabParams || {};
  181. tabKey.value = params.tabKey || 0;
  182. console.log(params);
  183. onChange(column[tabKey.value])
  184. // 使用后建议清除参数,避免重复读取
  185. getApp().globalData.switchTabParams = null;
  186. })
  187. </script>
  188. <style lang="scss" scoped>
  189. .classify-main {
  190. height: 100vh;
  191. .list {
  192. position: fixed;
  193. top: 50px;
  194. bottom: 0px;
  195. left: 0px;
  196. right: 0px;
  197. }
  198. }
  199. </style>