info.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. <template v-if="dataInfo.type === 2">
  34. <view class="hc-flex bg-white hc-p mt-2">
  35. <view class="flex-1 text-26">照片号</view>
  36. <text class="text-black">{{dataInfo.photoCode}}</text>
  37. </view>
  38. <view class="hc-flex bg-white hc-p">
  39. <view class="flex-1 text-26">底片号</view>
  40. <text class="text-black">{{dataInfo.filmCode}}</text>
  41. </view>
  42. <view class="hc-flex bg-white hc-p">
  43. <view class="flex-1 text-26">参见号</view>
  44. <text class="text-black">{{dataInfo.seeAlsoCode}}</text>
  45. </view>
  46. <view class="hc-flex bg-white hc-p mt-2" @click="viewPdfClick">
  47. <view class="flex-1 text-26">查看PDF文件</view>
  48. <text class="i-iconoir-nav-arrow-right"/>
  49. </view>
  50. </template>
  51. </hc-sys>
  52. </template>
  53. <script setup>
  54. import {ref} from "vue";
  55. import {onLoad} from '@dcloudio/uni-app'
  56. import mainApi from '~api/image/index';
  57. import {getObjValue, isString} from "js-fast-way";
  58. import {errorToast, toPdfPreview} from "@/utils/tools";
  59. const dataId = ref('');
  60. const dataInfo = ref({})
  61. const imageList = ref([])
  62. //页面启动
  63. onLoad(({id}) => {
  64. dataId.value = id ?? '';
  65. getInfoApi()
  66. })
  67. //获取详情
  68. const getInfoApi = async () => {
  69. dataInfo.value = {}
  70. imageList.value = []
  71. if (!dataId.value) {
  72. errorToast('参数异常,请退出重试')
  73. return false;
  74. }
  75. uni.showLoading({title: '获取数据中...', mask: true});
  76. const { data } = await mainApi.queryById({
  77. id: dataId.value
  78. })
  79. const res = getObjValue(data)
  80. console.log(res)
  81. dataInfo.value = res
  82. imageList.value = res.imageUrl.toString().split(',')
  83. uni.hideLoading();
  84. }
  85. //查看PDF文件
  86. const viewPdfClick = async () => {
  87. const { id, margePdfUrl } = dataInfo.value
  88. if (margePdfUrl) {
  89. await toPdfPreview(margePdfUrl)
  90. } else {
  91. const { data } = await mainApi.imageClassificationFile({id})
  92. const url = isString(data) ? data : ''
  93. if (url) {
  94. dataInfo.value.margePdfUrl = url
  95. await toPdfPreview(url)
  96. } else {
  97. errorToast('预览资料文件异常')
  98. }
  99. }
  100. }
  101. //编辑资料
  102. const editFormClick = () => {
  103. const { id } = dataInfo.value
  104. uni.navigateTo({
  105. url: `/pages/image/form?id=${id}`
  106. })
  107. }
  108. </script>