index.vue 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <hc-sys :isNavBar="false">
  3. <template v-for="(item,index) in dataList" :key="index">
  4. <template v-if="item.list && item.list.length > 0">
  5. <view class="p-3">{{item.name}}</view>
  6. <view class="relative bg-white text-gray-5">
  7. <template v-for="(items, indexs) in item.list" :key="indexs">
  8. <view class="relative px-3 py-2 flex items-center" un-border-b="1 solid gray-2" @click="toMedialist(items)">
  9. <view class="text-60 flex items-center">
  10. <text class="i-iconoir-media-image-list" v-if="items.fileType === 2"/>
  11. <text class="i-iconoir-media-video" v-else/>
  12. </view>
  13. <view class="relative ml-3 flex-1">
  14. <view class="text-black text-28">{{items.classfName}}</view>
  15. <view class="text-24 mt-1 ">
  16. <text>{{items.count}}</text>
  17. <text>{{items.fileType === 2 ? '张照片' : '个视频'}}</text>
  18. </view>
  19. </view>
  20. <view class="text-40 flex items-center justify-end">
  21. <text class="i-ri-arrow-right-s-line"/>
  22. </view>
  23. </view>
  24. </template>
  25. </view>
  26. </template>
  27. </template>
  28. </hc-sys>
  29. </template>
  30. <script setup>
  31. import {ref} from "vue";
  32. import {onShow} from '@dcloudio/uni-app'
  33. import {getArrValue, getObjValue} from "js-fast-way";
  34. import mainApi from '~api/image/index';
  35. import {useAppStore} from "@/store";
  36. //初始变量
  37. const store = useAppStore()
  38. const projectId = ref(store.projectId);
  39. const contractId = ref(store.contractId);
  40. //页面显示
  41. onShow(() => {
  42. getClassIfyList()
  43. })
  44. //获取数据
  45. const dataList = ref([])
  46. const getClassIfyList = async () => {
  47. dataList.value = []
  48. uni.showLoading({title: '获取数据中...', mask: true});
  49. const { data } = await mainApi.getClassIfyList({
  50. projectId: projectId.value,
  51. contractId: contractId.value
  52. })
  53. //处理数据
  54. let newData = [{name:'项目前期', list:[]}, {name:'项目中期', list:[]},{name:'项目后期', list:[]}]
  55. const arr = getArrValue(data)
  56. for (let i = 0; i < arr.length; i++) {
  57. const { projectStage } = getObjValue(arr[i])
  58. if (projectStage ==='项目前期') {
  59. newData[0].list.push(arr[i])
  60. } else if (projectStage ==='项目中期') {
  61. newData[1].list.push(arr[i])
  62. } else if (projectStage ==='项目后期') {
  63. newData[2].list.push(arr[i])
  64. }
  65. }
  66. dataList.value = newData
  67. uni.hideLoading();
  68. }
  69. //被点击
  70. const toMedialist = ({id, fileType, storageDirectoryFormat}) => {
  71. const node = encodeURIComponent(JSON.stringify({
  72. id: id,
  73. fileType: fileType,
  74. type: storageDirectoryFormat
  75. }));
  76. if (storageDirectoryFormat === 1) {
  77. uni.navigateTo({
  78. url: `/pages/image/position?node=${node}`
  79. });
  80. } else {
  81. uni.navigateTo({
  82. url: `/pages/image/view?node=${node}`
  83. });
  84. }
  85. }
  86. </script>