classify.vue 4.0 KB

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