index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="content">
  3. <view style="width: 100%;" v-if="currentIndex === 1">
  4. <homePage :workTypeData="workTypeData" :ticketsData="ticketsData"></homePage>
  5. </view>
  6. <view style="width: 100%;" v-if="currentIndex === 2">
  7. <stat></stat>
  8. </view>
  9. <view style="width: 100%;" v-if="currentIndex === 3">
  10. <mine :workTypeData="workTypeData" :userInfo="userInfo"></mine>
  11. </view>
  12. <view style="width: 100%;height: 160rpx;"></view>
  13. <x-tabbar :currentIndex="currentIndex" @switchTab="switchTab"></x-tabbar>
  14. </view>
  15. </template>
  16. <script setup lang="ts">
  17. import { GetOrderList, GetRepairStatus } from "@/api/order";
  18. import { GetInfo } from "@/api/login";
  19. import homePage from '@/pages/index/index.vue'
  20. import stat from '@/pages/stat/index.vue'
  21. import mine from '@/pages/mine/index.vue'
  22. import { onLaunch, onShow, onHide, onReady } from "@dcloudio/uni-app";
  23. import { ref, nextTick } from 'vue'
  24. const currentIndex = ref(1)
  25. const switchTab = (val : any) => {
  26. currentIndex.value = val.key
  27. if (currentIndex.value == 1) {
  28. } else if (currentIndex.value == 2) {
  29. } else if (currentIndex.value == 3) {
  30. getInfoList()
  31. }
  32. }
  33. const ticketsData : any = ref([])
  34. // 用户信息
  35. const userInfo : any = ref({})
  36. // 工单状态列表
  37. const workTypeData : any = ref([])
  38. onLaunch(() => {
  39. // uni.hideTabBar();
  40. })
  41. const listFlag = ref(true)
  42. onReady(() => {
  43. // #ifdef APP-PLUS
  44. plus.navigator.setStatusBarStyle("light");
  45. // #endif
  46. })
  47. onShow(() => {
  48. // #ifdef APP-PLUS
  49. plus.navigator.setStatusBarStyle("light");
  50. // #endif
  51. nextTick(() => {
  52. if (listFlag && currentIndex.value == 1) {
  53. listFlag.value = false
  54. getList(1)
  55. } else if (currentIndex.value == 3) {
  56. getInfoList()
  57. }
  58. getRepairStatus()
  59. })
  60. })
  61. // 获取列表工单
  62. const getList = (status : any) => {
  63. GetOrderList({
  64. isMe: true,
  65. pageNum: 1,
  66. pageSize: 999,
  67. orderStatus: status,
  68. state: '1749115737095',
  69. }).then((res : any) => {
  70. if (res.code == 200) {
  71. ticketsData.value = res.rows
  72. listFlag.value = true
  73. }
  74. })
  75. }
  76. // 获取工单状态
  77. const getRepairStatus = () => {
  78. GetRepairStatus({}).then((res : any) => {
  79. if (res.code == 200) {
  80. let arrData = res.data
  81. workTypeData.value = [{
  82. icon: 'pending',
  83. color: '#E6A23C',
  84. title: arrData[0].dictLabel,
  85. }, {
  86. icon: 'underway',
  87. color: '#409EFF',
  88. title: arrData[1].dictLabel,
  89. }, {
  90. icon: 'done',
  91. color: '#67C23A',
  92. title: arrData[2].dictLabel,
  93. }, {
  94. icon: 'stale',
  95. color: '#909399',
  96. title: arrData[3].dictLabel,
  97. }]
  98. }
  99. })
  100. }
  101. // 获取用户信息列表
  102. const getInfoList = () => {
  103. GetInfo({}).then((res : any) => {
  104. if (res.code == 200) {
  105. userInfo.value = res.user
  106. }
  107. })
  108. }
  109. </script>
  110. <style>
  111. .content {
  112. width: 100%;
  113. display: flex;
  114. flex-direction: column;
  115. align-items: center;
  116. justify-content: center;
  117. }
  118. .pagebox {
  119. width: 100%;
  120. }
  121. </style>