瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.0 KiB

11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view>
  3. <view class="dynamics" v-html="$utils.stringFormatHtml(item.title)">
  4. </view>
  5. <view class="Artworkimages">
  6. <view class="wrokimg" @click.stop="previewMedia(media, i)" :key="i" v-for="(media, i) in mediaList">
  7. <image v-if="media.type === 'image'" :src="media.url" mode="aspectFill"></image>
  8. <video v-else-if="media.type === 'video'" :src="media.url"
  9. controls
  10. :poster="media.poster || ''"
  11. style="width: 190rpx; height: 190rpx; border-radius: 20rpx;"></video>
  12. <!-- <view v-if="media.type === 'video'" class="video-overlay">
  13. <uv-icon name="play-circle-fill" size="60rpx" color="#fff"></uv-icon>
  14. </view> -->
  15. </view>
  16. </view>
  17. <addressSpot
  18. :address="item.address"
  19. :latitude="item.latitude"
  20. :longitude="item.longitude"
  21. />
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. item: {},
  28. },
  29. computed : {
  30. images(){
  31. if(!this.item.image){
  32. return []
  33. }
  34. let arr = this.item.image.split(',')
  35. if(this.item.wxImage){
  36. arr.unshift(this.item.wxImage)
  37. }
  38. return arr
  39. },
  40. mediaList(){
  41. let mediaArray = []
  42. // 添加微信二维码图片
  43. if(this.item.wxImage){
  44. mediaArray.push({
  45. url: this.item.wxImage,
  46. type: 'image'
  47. })
  48. }
  49. // 从 image 字段解析所有文件(图片和视频)
  50. if(this.item.image){
  51. this.item.image.split(',').forEach(url => {
  52. if(url.trim()){
  53. // 根据文件扩展名判断类型
  54. const isVideo = this.isVideoFile(url.trim())
  55. mediaArray.push({
  56. url: url.trim(),
  57. type: isVideo ? 'video' : 'image'
  58. })
  59. }
  60. })
  61. }
  62. return mediaArray
  63. }
  64. },
  65. data() {
  66. return {
  67. }
  68. },
  69. methods: {
  70. previewMedia(media, index){
  71. if(media.type === 'image'){
  72. // 只预览图片
  73. const imageUrls = this.mediaList.filter(item => item.type === 'image').map(item => item.url)
  74. const imageIndex = this.mediaList.slice(0, index).filter(item => item.type === 'image').length
  75. uni.previewImage({
  76. urls: imageUrls,
  77. current: imageIndex
  78. })
  79. } else if(media.type === 'video'){
  80. // 视频点击播放(已经有controls属性,无需额外处理)
  81. console.log('播放视频:', media.url)
  82. }
  83. },
  84. isVideoFile(url) {
  85. const videoExtensions = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.webm', '.m4v']
  86. const lowerUrl = url.toLowerCase()
  87. return videoExtensions.some(ext => lowerUrl.includes(ext))
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .dynamics {
  94. margin-top: 20rpx;
  95. font-size: 28rpx;
  96. letter-spacing: 3rpx;
  97. }
  98. .Artworkimages {
  99. display: flex;
  100. flex-wrap: wrap;
  101. .wrokimg {
  102. margin: 10rpx;
  103. position: relative;
  104. image {
  105. height: 190rpx;
  106. width: 190rpx;
  107. border-radius: 20rpx;
  108. }
  109. video {
  110. height: 190rpx;
  111. width: 190rpx;
  112. border-radius: 20rpx;
  113. }
  114. .video-overlay {
  115. position: absolute;
  116. top: 50%;
  117. left: 50%;
  118. transform: translate(-50%, -50%);
  119. pointer-events: none;
  120. z-index: 1;
  121. }
  122. }
  123. }
  124. </style>