classify.vue 4.4 KB

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