index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 pageNo = ref(1)
  17. const imgList = ref([])
  18. const more = ref(false)
  19. const { data, run: setData } = useRequest(
  20. () =>
  21. getPhotoList({
  22. bizId: id.value,
  23. bizType: { studyTour: '2', activity: '1' }[type.value],
  24. pageSize: 10,
  25. }),
  26. { initialData: { list: [], total: 0 } },
  27. )
  28. const { data: imgData, run: setImgData } = useRequest(
  29. () =>
  30. getPhotoList2({
  31. id: img.value?.id,
  32. bizType: { studyTour: '2', activity: '1' }[type.value],
  33. pageNo:pageNo.value,
  34. pageSize: 10,
  35. }),
  36. { initialData: { list: [], total: 0 } },
  37. )
  38. const previewImg = (i,index) => {
  39. console.log(data)
  40. uni.previewImage({
  41. urls:data.value?.list[i].picture,
  42. current:index
  43. })
  44. }
  45. const previewImgNew = (i) => {
  46. console.log(data)
  47. uni.previewImage({
  48. urls:[i]
  49. })
  50. }
  51. onReachBottom(async ()=>{
  52. console.log("11111")
  53. if(!more.value){
  54. pageNo.value ++
  55. let imgInfo = await setImgData()
  56. imgList.value = imgList.value.concat(imgInfo.list)
  57. if(imgList.value.length >= imgInfo.total){
  58. more.value = true
  59. }
  60. }
  61. })
  62. onLoad(async (query: { id: string; type: 'activity' | 'studyTour'; title: string }) => {
  63. await uni.setNavigationBarTitle({ title: query.title })
  64. id.value = query.id
  65. type.value = query.type
  66. let res = await setData();
  67. console.log(res.list)
  68. if(res.list.length > 0){
  69. img.value = res.list[0]
  70. let imgInfo = await setImgData()
  71. imgList.value = imgInfo.list
  72. if(imgList.value.length >= imgInfo.total){
  73. more.value = true
  74. }
  75. }
  76. })
  77. </script>
  78. <template>
  79. <div class="flex flex-col flex-grow p-4 bg-white gap-4">
  80. <template v-for="(it, i) in imgList" :key="i">
  81. <SectionHeading
  82. :title="'第' + Number(i + 1) + '天 ' + dayjs(img.travelDate).format('YYYY-MM-DD')"
  83. ></SectionHeading>
  84. <video v-if="it.type=='1'" class="w-full" :src="it.url"></video>
  85. <wd-img v-else width="100%" mode="widthFix" :src="it.url" @click="previewImgNew(it.url)" />
  86. <!-- <template v-for="(video, index) in it.video" :key="index">
  87. <video class="w-full" :src="video"></video>
  88. </template>
  89. <template v-for="(img, index) in it.picture" :key="index">
  90. <wd-img width="100%" mode="widthFix" :src="img" @click="previewImg(i,index)" />
  91. </template> -->
  92. </template>
  93. </div>
  94. </template>