info.vue 4.0 KB

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