index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <route lang="json">
  2. {
  3. "style": {
  4. "navigationBarTitleText": "活动图片",
  5. "navigationBarBackgroundColor": "#ffffff"
  6. }
  7. }
  8. </route>
  9. <script setup lang="ts">
  10. import { getPhotoList, getPhotoList2 } from '../../../../core/libs/requests'
  11. import SectionHeading from '@/components/section-heading.vue'
  12. import dayjs from 'dayjs'
  13. const id = ref()
  14. const type = ref()
  15. const img = ref()
  16. const imgTab = ref([])
  17. const imgTabIndex = ref(0)
  18. const pageNo = ref(1)
  19. const imgList = ref([])
  20. const more = ref(false)
  21. const { data, run: setData } = useRequest(
  22. () =>
  23. getPhotoList({
  24. bizId: id.value,
  25. bizType: { studyTour: '2', activity: '1' }[type.value],
  26. pageSize: 10,
  27. }),
  28. { initialData: { list: [], total: 0 } },
  29. )
  30. const { data: imgData, run: setImgData } = useRequest(
  31. () =>
  32. getPhotoList2({
  33. id: img.value?.id,
  34. bizType: { studyTour: '2', activity: '1' }[type.value],
  35. pageNo:pageNo.value,
  36. pageSize: 10,
  37. }),
  38. { initialData: { list: [], total: 0 } },
  39. )
  40. const previewImg = (i,index) => {
  41. console.log(data)
  42. uni.previewImage({
  43. urls:data.value?.list[i].picture,
  44. current:index
  45. })
  46. }
  47. const previewImgNew = (i) => {
  48. console.log(data)
  49. uni.previewImage({
  50. urls:[i]
  51. })
  52. }
  53. const timeTabChange = async (it,i) =>{
  54. more.value = false;
  55. pageNo.value = 1;
  56. img.value = it
  57. imgTabIndex.value = i;
  58. let imgInfo = await setImgData()
  59. console.log(imgInfo)
  60. imgList.value = imgInfo.list
  61. if(imgList.value.length >= imgInfo.total){
  62. more.value = true
  63. }
  64. }
  65. onReachBottom(async ()=>{
  66. if(!more.value){
  67. pageNo.value ++
  68. let imgInfo = await setImgData()
  69. imgList.value = imgList.value.concat(imgInfo.list)
  70. if(imgList.value.length >= imgInfo.total){
  71. more.value = true
  72. }
  73. }
  74. })
  75. onLoad(async (query: { id: string; type: 'activity' | 'studyTour'; title: string }) => {
  76. await uni.setNavigationBarTitle({ title: query.title })
  77. id.value = query.id
  78. type.value = query.type
  79. let res = await setData();
  80. imgTab.value = res.list
  81. console.log(imgTab.value)
  82. if(imgTab.value.length > 0){
  83. img.value = imgTab.value[0]
  84. let imgInfo = await setImgData()
  85. console.log(imgInfo)
  86. imgList.value = imgInfo.list
  87. if(imgList.value.length >= imgInfo.total){
  88. more.value = true
  89. }
  90. }
  91. })
  92. </script>
  93. <template>
  94. <div class="flex flex-col flex-grow p-4 bg-white gap-4">
  95. <div class="flex items-center overflow-x-scroll">
  96. <div class="px-[14rpx] py-[8rpx] text-[24rpx] rounded-[10rpx] mr-[20rpx] shrink-0" :class="imgTabIndex===i?'bg-black text-white':'bg-black/10'" v-for="(it, i) in imgTab" :key="i" @click="timeTabChange(it,i)">{{ dayjs(it.travelDate).format('YYYY-MM-DD') || "2022" }}</div>
  97. </div>
  98. <template v-for="(it, i) in imgList" :key="i">
  99. <!-- <SectionHeading
  100. :title="'第' + Number(i + 1) + '天 ' + dayjs(img.travelDate).format('YYYY-MM-DD')"
  101. ></SectionHeading> -->
  102. <video v-if="it.type=='1'" class="w-full" :src="it.url"></video>
  103. <wd-img v-else width="100%" mode="widthFix" :src="it.url" @click="previewImgNew(it.url)" />
  104. <!-- <template v-for="(video, index) in it.video" :key="index">
  105. <video class="w-full" :src="video"></video>
  106. </template>
  107. <template v-for="(img, index) in it.picture" :key="index">
  108. <wd-img width="100%" mode="widthFix" :src="img" @click="previewImg(i,index)" />
  109. </template> -->
  110. </template>
  111. </div>
  112. </template>