classify.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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" :total="pages.total"/>
  19. <view v-else>
  20. <NoneView value="您还没有相关订单" />
  21. </view>
  22. </view>
  23. </view>
  24. <custom-tab-bar page="order" />
  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. const pages = ref({
  103. current: 1,
  104. pageSize: 10,
  105. total: null,
  106. })
  107. async function getList(type) {
  108. console.log("TCL: getList -> type", type)
  109. try {
  110. console.log(data.value.length, pages.value.total);
  111. if(type === 'top'){
  112. data.value = [];
  113. pages.value.total = 0;
  114. }
  115. if(type ==='bottom' ){
  116. if(data.value.length < pages.value.total){
  117. listRef.value && listRef.value.handleBottom(true);
  118. pages.value.current++;
  119. }else {
  120. listRef.value && listRef.value.handleBottom(false)
  121. return;
  122. }
  123. }else{
  124. uni.showLoading({
  125. title: '数据加载中...',
  126. })
  127. }
  128. const listApi = userType === 1 ? userMainOrderList : getVolunteerOrderList
  129. const res = await listApi({
  130. orderStatus: tab.value,
  131. pageNum: pages.value.current,
  132. pageSize: pages.value.pageSize,
  133. })
  134. data.value =[...data.value,...res.rows];
  135. pages.value.total = res.total;
  136. type ==='bottom'&& listRef.value && listRef.value.handleBottom(false);
  137. } catch (error) {
  138. console.log('error', error)
  139. uni.showToast({
  140. title: error.msg,
  141. icon: 'error',
  142. })
  143. } finally {
  144. if(listRef.value && listRef.value.handleRefreshing && type ==='top'){
  145. listRef.value.handleRefreshing(false)
  146. }
  147. setTimeout(() => {
  148. if (data.value.length === pages.value.total && pages.value.total > 0) {
  149. listRef.value && listRef.value.handleBottom(false)
  150. }
  151. }, 500)
  152. type !=='bottom' && uni.hideLoading()
  153. }
  154. }
  155. /**
  156. * 1: 查看
  157. * 2:沟通
  158. * 3:开始或结束服务
  159. */
  160. function btnClick(row, type) {
  161. if (type === 1) {
  162. uni.navigateTo({
  163. url: `/pages_classify/pages/order/index?secondOrderId=${row.secondOrderId}`,
  164. })
  165. return
  166. }
  167. if (type === 3) {
  168. uni.navigateTo({
  169. url: `/pages_classify/pages/handle/index?secondOrderId=${row.secondOrderId}`,
  170. })
  171. return
  172. }
  173. //前往沟通
  174. uni.navigateTo({
  175. url: `/pages_orderuser/pages/talk/pages/index/index?orderId=${row.mainOrderId}`
  176. });
  177. }
  178. provide('onClick', btnClick)
  179. function onChange(tabItem) {
  180. tab.value = tabItem.value;
  181. pages.value.current = 1;
  182. data.value = [];
  183. getList()
  184. }
  185. onMounted(() => {
  186. // getList()
  187. })
  188. onShow(() => {
  189. const initIndex = userType === 1? 2:1;//默认选中待服务
  190. const params = getApp().globalData.switchTabParams || {}
  191. tabKey.value = params.tabKey || initIndex;
  192. onChange(column.value[tabKey.value])
  193. // 使用后建议清除参数,避免重复读取
  194. getApp().globalData.switchTabParams = null
  195. })
  196. </script>
  197. <style lang="scss" scoped>
  198. .classify-main {
  199. height: 100vh;
  200. .list {
  201. position: fixed;
  202. top: 50px;
  203. bottom: 150rpx;
  204. left: 0px;
  205. right: 0px;
  206. background: rgba(245, 245, 245, 1);
  207. }
  208. }
  209. </style>