info.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <hc-sys navBarUi="white">
  3. <template #navBar>
  4. <hc-nav-back-bar title="声像资料详情">
  5. <text class="text-26" @click="editFormClick">编辑</text>
  6. </hc-nav-back-bar>
  7. </template>
  8. <!-- 轮播图 -->
  9. <swiper class="screen-swiper square-dot h-8xl" indicator-dots circular autoplay interval="5000" duration="500">
  10. <swiper-item v-for="(item,index) in imageList" :key="index">
  11. <image :src="item" mode="aspectFill"/>
  12. </swiper-item>
  13. </swiper>
  14. <!-- 详情 -->
  15. <view class="relative bg-white">
  16. <view class="text-black text-36 hc-p">{{dataInfo.title}}</view>
  17. <view class="text-26 hc-p" un-border-t="1 solid gray-1">{{dataInfo.textContent}}</view>
  18. <view class="hc-flex hc-p text-26 text-black" un-border-t="1 solid gray-1">
  19. <view class="flex-1 hc-flex">
  20. <text class="i-iconoir-user"/>
  21. <text class="ml-0.5">{{ dataInfo.shootingUser }}</text>
  22. </view>
  23. <view class="flex-1 hc-flex-center">
  24. <text class="i-iconoir-clock"/>
  25. <text class="ml-0.5">{{ dataInfo.shootingTimeStr }}</text>
  26. </view>
  27. <view class="flex-1 hc-flex-end">
  28. <text class="i-iconoir-page"/>
  29. <text class="ml-0.5">{{ dataInfo.fileSize }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="hc-flex bg-white hc-p mt-2" @click="viewPdfClick" v-if="dataInfo.type === 2">
  34. <view class="flex-1 text-26">查看PDF文件</view>
  35. <text class="i-iconoir-nav-arrow-right"/>
  36. </view>
  37. </hc-sys>
  38. </template>
  39. <script setup>
  40. import {ref} from "vue";
  41. import {onLoad} from '@dcloudio/uni-app'
  42. import mainApi from '~api/image/index';
  43. import {getObjValue, isString} from "js-fast-way";
  44. import {errorToast, toPdfPreview} from "@/utils/tools";
  45. const dataId = ref('');
  46. const dataInfo = ref({})
  47. const imageList = ref([])
  48. //页面启动
  49. onLoad(({id}) => {
  50. dataId.value = id ?? '';
  51. getInfoApi()
  52. })
  53. //获取详情
  54. const getInfoApi = async () => {
  55. dataInfo.value = {}
  56. imageList.value = []
  57. if (!dataId.value) {
  58. errorToast('参数异常,请退出重试')
  59. return false;
  60. }
  61. uni.showLoading({title: '获取数据中...', mask: true});
  62. const { data } = await mainApi.queryById({
  63. id: dataId.value
  64. })
  65. const res = getObjValue(data)
  66. console.log(res)
  67. dataInfo.value = res
  68. imageList.value = res.imageUrl.toString().split(',')
  69. uni.hideLoading();
  70. }
  71. //查看PDF文件
  72. const viewPdfClick = async () => {
  73. const { id, margePdfUrl } = dataInfo.value
  74. if (margePdfUrl) {
  75. await toPdfPreview(margePdfUrl)
  76. } else {
  77. const { data } = await mainApi.imageClassificationFile({id})
  78. const url = isString(data) ? data : ''
  79. if (url) {
  80. dataInfo.value.margePdfUrl = url
  81. await toPdfPreview(url)
  82. } else {
  83. errorToast('预览资料文件异常')
  84. }
  85. }
  86. }
  87. //编辑资料
  88. const editFormClick = () => {
  89. const { id } = dataInfo.value
  90. uni.navigateTo({
  91. url: `/pages/image/form?id=${id}`
  92. })
  93. }
  94. </script>