classify.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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: 0,
  106. })
  107. async function getList(type) {
  108. try {
  109. console.log(data.value.length, pages.value.total);
  110. if(type ==='bottom' ){
  111. if(data.value.length < pages.value.total){
  112. listRef.value && listRef.value.handleBottom(true);
  113. pages.value.current++;
  114. }else {
  115. listRef.value && listRef.value.handleBottom(false)
  116. return;
  117. }
  118. }else{
  119. uni.showLoading({
  120. title: '数据加载中...',
  121. })
  122. }
  123. const listApi = userType === 1 ? userMainOrderList : getVolunteerOrderList
  124. const res = await listApi({
  125. orderStatus: tab.value,
  126. pageNum: pages.value.current,
  127. pageSize: pages.value.pageSize,
  128. })
  129. data.value =[...data.value,...res.rows];
  130. pages.value.total = res.total;
  131. type ==='bottom'&& listRef.value && listRef.value.handleBottom(false);
  132. } catch (error) {
  133. console.log('error', error)
  134. uni.showToast({
  135. title: error.msg,
  136. icon: 'error',
  137. })
  138. } finally {
  139. if(listRef.value && listRef.value.handleRefreshing && type ==='top'){
  140. listRef.value.handleRefreshing(false)
  141. }
  142. type !=='bottom' && uni.hideLoading()
  143. }
  144. }
  145. /**
  146. * 1: 查看
  147. * 2:沟通
  148. * 3:开始或结束服务
  149. */
  150. function btnClick(row, type) {
  151. if (type === 1) {
  152. uni.navigateTo({
  153. url: `/pages_classify/pages/order/index?secondOrderId=${row.secondOrderId}`,
  154. })
  155. return
  156. }
  157. if (type === 3) {
  158. uni.navigateTo({
  159. url: `/pages_classify/pages/handle/index?secondOrderId=${row.secondOrderId}`,
  160. })
  161. return
  162. }
  163. //前往沟通
  164. // wxMakePhoneCall(phone)
  165. // uni.navigateTo({
  166. // url: `/pages_orderuser/pages/talk/pages/index/index?orderId=${row.secondOrderId}`
  167. // });
  168. }
  169. provide('onClick', btnClick)
  170. function onChange(tabItem) {
  171. tab.value = tabItem.value;
  172. pages.value.current = 1;
  173. data.value = [];
  174. getList()
  175. }
  176. onMounted(() => {
  177. // getList()
  178. })
  179. onShow(() => {
  180. const initIndex = userType === 1? 2:1;//默认选中待服务
  181. const params = getApp().globalData.switchTabParams || {}
  182. tabKey.value = params.tabKey || initIndex;
  183. onChange(column.value[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: 150rpx;
  195. left: 0px;
  196. right: 0px;
  197. background: rgba(245, 245, 245, 1);
  198. }
  199. }
  200. </style>