cloudroam
2025-07-17 f3ea52bf97e61f6917ccaab904817d74d9d4860c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<template>
  <view class="spot-detail-page">
    <!-- 顶部信息 -->
    <view class="header">
      <view class="header-info">
        <view class="geo-row">
          <view class="geo-path">{{ geoPath }}</view>
          <image src="/static/common/earth.png" class="earth-icon" />
        </view>
        <view class="title-row">
          <view class="title">{{ location?.locationName || '景点详情' }}</view>
          <up-icon name="heart" size="40rpx" :color="collected ? '#FF4D4F' : '#ccc'" @click="toggleCollect" />
        </view>
      </view>
    </view>
 
    <!-- 主图 -->
    <view class="main-image">
      <image :src="mainImage" mode="aspectFill" class="main-img" />
    </view>
 
    <!-- 地址、类型、电话、身份准入等 -->
    <view class="info-list">
      <view class="info-item">{{ location?.address }}</view>
      <view class="info-item"><up-icon name="/static/common/marker.png" size="32rpx" /> {{  location?.sceneType || '类型未知' }}</view>
      <view class="info-item"><up-icon name="/static/common/parking.png" size="32rpx" /> {{ location?.parkingInfo || '无电话' }}</view>
      <view class="info-item"><up-icon name="/static/common/visit.png" size="32rpx" />  {{ location?.isOpenVisitStr === '是' ? '允许参观' : '不允许参观' }}</view>
    </view>
 
    <!-- 介绍描述 -->
    <view class="divider-line"></view>
    <view class="desc-block">
      <text>{{ location?.landmarkDesc || location?.visitInfo || '暂无介绍' }}</text>
    </view>
 
    <!-- 地图 -->
    <view class="map-block" v-if="showMap">
      <!-- 腾讯地图小程序组件(uni-app中需配置腾讯地图key) -->
      <map
          :latitude="location?.gpsLat"
          :longitude="location?.gpsLng"
          :markers="mapMarkers"
          style="width: 100%; height: 300rpx;"
          v-if="location?.gpsLat && location?.gpsLng"
      />
      <image v-else src="/static/common/geo-earth.png" class="map-placeholder" />
    </view>
 
    <!-- 实景图 -->
    <view class="scene-block" v-if="sceneImages.length">
      <view class="scene-title">实景图 <text class="scene-count">{{ sceneImages.length }}</text></view>
      <view class="scene-list">
        <image
            v-for="(img, idx) in sceneImages"
            :key="idx"
            :src="img"
            mode="aspectFill"
            class="scene-image"
            @tap="previewScene(idx)"
        />
      </view>
    </view>
 
    <!-- 关联影视作品 -->
    <view class="film-block" v-if="relatedFilms.length">
      <view class="film-title">关联影视作品</view>
      <view class="film-list">
        <view class="film-item" v-for="film in relatedFilms" :key="film.id">
          <image :src="film.coverUrl" class="film-cover" />
          <view class="film-info">
            <view class="film-name">{{ film.nameCn }}</view>
            <view class="film-en">{{ film.nameEn }}</view>
            <view class="film-meta">
              <text>{{ film.typeStr }}</text>
              <text v-if="film.country"> / {{ film.country }}</text>
              <text v-if="film.releaseYear"> / {{ film.releaseYear }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>
 
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useGlobal } from '@/composables/useGlobal'
const { $http, $message } = useGlobal()
import { FilmLocationVO, FilmWorks } from '@/types/index'
 
const location = ref<FilmLocationVO>()
const collected = ref(false)
const geoPath = ref('亚洲-中国-海南省-海口市')
const mainImage = ref('')
const sceneImages = ref<string[]>([])
const relatedFilms = ref<FilmWorks[]>([])
const showMap = ref(true)
 
 
onLoad(async (options: any) => {
  const id = options.id
  if (id) {
    await getLocationDetail(id)
    await getRelatedFilms(id)
  }
})
 
const getLocationDetail = async (id: string) => {
  const { code, data } = await $http.request('get', '/api/filmLocation/list/view', {
    params: { id }
  })
  if (code === 0) {
    location.value = data
    // 主图优先locationUrl,其次visitorPhotos
    if (data.locationUrl) {
      mainImage.value = data.locationUrl
      console.log(data.locationUrl)
      console.log( mainImage.value)
    } else if (data.visitorPhotos) {
      try {
        const arr = JSON.parse(data.visitorPhotos)
        mainImage.value = arr[0]?.url || ''
      } catch {
        mainImage.value = ''
      }
    }
    // 实景图
    if (data.visitorPhotos) {
      try {
        const arr = JSON.parse(data.visitorPhotos)
        sceneImages.value = arr.map((item: any) => item.url)
      } catch {
        sceneImages.value = []
      }
    } else {
      sceneImages.value = []
    }
    // 拼接地理层级
    geoPath.value = [
      '亚洲',
      '中国',
      data.province,
      data.city
    ].filter(Boolean).join('-')
  } else {
    $message.showToast('获取景点信息失败')
  }
}
 
// 地图标记
const mapMarkers = ref([
  {
    id: 1,
    latitude: location.value?.gpsLat,
    longitude: location.value?.gpsLng,
    iconPath: '/static/common/marker.png',
    width: 40,
    height: 40
  }
])
 
const previewScene = (idx: number) => {
  uni.previewImage({
    current: sceneImages.value[idx],
    urls: sceneImages.value
  })
}
 
// 影视作品接口示例
const getRelatedFilms = async (locationId: string) => {
  // 假设接口 /api/filmWorks/related?locationId=xxx
  const { code, data } = await $http.request('get', '/api/filmLocation/related', {
    params: { locationId }
  })
  if (code === 0 && Array.isArray(data)) {
    relatedFilms.value = data
  } else {
    relatedFilms.value = []
  }
}
 
const toggleCollect = () => {
  collected.value = !collected.value
  $message.showToast(collected.value ? '已收藏' : '已取消收藏')
}
</script>
 
<style scoped>
.spot-detail-page {
  background: #fff;
  min-height: 100vh;
}
.header {
  display: flex;
  align-items: flex-start;
  padding: 30rpx 20rpx 10rpx 20rpx;
}
.header-info {
  flex: 1;
  margin-left: 20rpx;
}
.geo-path {
  color: #6c8fc5;
  font-size: 22rpx;
  margin-bottom: 10rpx;
}
.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30rpx; /* 增加名称与上方的间距 */
}
.title {
  font-size: 36rpx;
  font-weight: bold;
  margin-right: 16rpx;
}
.earth-icon {
  width: 144rpx; /* 放大三倍 */
  height: 144rpx;
}
.main-image {
  width: 100%;
  height: 320rpx;
  margin-top: 40rpx; /* 增加名称和图片之间的间隔 */
  margin-bottom: 40rpx;
}
.main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10rpx;
}
/*.info-list {*/
/*  padding: 0 20rpx;*/
/*  margin-bottom: 20rpx;*/
/*}*/
/*.info-item {*/
/*  font-size: 28rpx;*/
/*  color: #333;*/
/*  margin-bottom: 16rpx;*/
/*  display: flex;*/
/*  align-items: center;*/
/*}*/
/*.desc-block {*/
/*  padding: 0 20rpx 30rpx 20rpx;*/
/*  color: #666;*/
/*  font-size: 26rpx;*/
/*}*/
.info-list {
  padding: 20rpx; /* 增加内边距 */
  margin: 20rpx 0; /* 调整上下外边距 */
  background-color: #f9f9f9;
  border-radius: 12rpx;
}
 
.info-item {
  font-size: 28rpx;
  color: #333;
  margin-bottom: 20rpx; /* 调整间距 */
  display: flex;
  align-items: center;
  line-height: 1.6;
}
 
.info-item:last-child {
  margin-bottom: 0;
}
 
/* 添加分割线样式 */
.divider-line {
  height: 1px;
  background-color: #eee;
  margin: 30rpx 20rpx 20rpx 20rpx;
}
 
/* 调整描述区块的间距 */
.desc-block {
  padding: 0 20rpx 30rpx 20rpx;
  color: #666;
  font-size: 26rpx;
  line-height: 1.8;
  margin-top: 20rpx;
}
.map-block {
  margin: 20rpx 0;
}
.map-placeholder {
  width: 100%;
  height: 300rpx;
  object-fit: cover;
  border-radius: 10rpx;
}
.scene-block {
  padding: 0 20rpx 30rpx 20rpx;
}
.scene-title {
  font-size: 28rpx;
  font-weight: bold;
  margin-bottom: 10rpx;
}
.scene-count {
  color: #888;
  font-size: 22rpx;
  margin-left: 10rpx;
}
.scene-list {
  display: flex;
  gap: 20rpx;
  flex-wrap: wrap;
}
.scene-image {
  width: 45vw;
  height: 140rpx;
  object-fit: cover;
  border-radius: 8rpx;
  margin-bottom: 10rpx;
}
.film-block {
  padding: 0 20rpx 30rpx 20rpx;
}
.film-title {
  font-size: 28rpx;
  font-weight: bold;
  margin-bottom: 10rpx;
}
.film-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}
.film-item {
  display: flex;
  align-items: flex-start;
  gap: 20rpx;
}
.film-cover {
  width: 120rpx;
  height: 160rpx;
  object-fit: cover;
  border-radius: 8rpx;
}
.film-info {
  flex: 1;
}
.film-name {
  font-size: 28rpx;
  font-weight: bold;
}
.film-en {
  font-size: 22rpx;
  color: #888;
  margin-bottom: 6rpx;
}
.film-meta {
  font-size: 22rpx;
  color: #888;
}
.geo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15rpx;
}
</style>