吉安感知网项目-前端
罗广辉
6 days ago d89b40229d445828b84ae456cfa2430d6b3eaef4
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
<template>
    <div class="workDetailContainer">
        <div class="detailTop">
            <div class="image-container">
                <video
                    v-if="isVideoAttachment && mediaSrc"
                    ref="videoRef"
                    class="video-js vjs-default-skin vjs-big-play-centered detailVideo"
                    controls
                    preload="auto"
                    playsinline
                ></video>
                <van-swipe v-else :autoplay="3000" indicator-color="#4C85FF">
                    <van-swipe-item v-for="(img, index) in [mediaSrc]" :key="index">
                        <van-image class="detailImage" :src="img" fit="cover" width="100%" height="235px"
                            @click="openPreview(index)" preview-visible="false" />
                    </van-swipe-item>
                </van-swipe>
            </div>
        </div>
    <!-- 工单内容 -->
    <div class="worderContainer">
      <div class="workOrderContent">
        <div class="workOrderTitle">工单内容</div>
        <div class="workOrderContainer">
          <div class="orderRow">
            <div class="rowTitle">工单编号</div>
            <div>{{ workDetailData.eventNum }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">工单处置人</div>
            <div>{{ workDetailData.disposeUserName }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">处置部门</div>
            <div>{{ workDetailData.disposeDeptName }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">拍摄时间</div>
            <div>{{ workDetailData.shootTime }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">分发人员</div>
            <div>{{ workDetailData.distributeUserName }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">分发部门</div>
            <div>{{ workDetailData.distributeDeptName }}</div>
          </div>
 
          <div class="orderRow">
            <div class="rowTitle">分发时间</div>
            <div>{{ workDetailData.distributeTime }}</div>
          </div>
          <div class="orderRow">
            <div class="rowTitle">工单位置</div>
            <div class="rowAddress" @click="jumpMap(workDetailData)">{{ workDetailData.eventLocation }}</div>
          </div>
        </div>
      </div>
    </div>
    </div>
</template>
 
<script setup>
import {getSharingDetailsApi} from '@/api/work/index'
import { showToast, showNotify, showImagePreview } from 'vant'
import { getShowImg, getSmallImg } from '@/utils/util'
import { useRoute,useRouter } from 'vue-router'
import { getAiImg } from '@ztzf/utils'
import videojs from 'video.js'
import 'video.js/dist/video-js.css'
const keyword = ref('')
const route = useRoute()
const router = useRouter()
 
const workDetailData = ref({})
const videoRef = ref(null)
let player = null
 
const isVideoAttachment = computed(() => Number(workDetailData.value.attachmentType) === 3)
 
// 预览图片
const getImageList = computed(() => {
    const imageArr = []
    const detail = workDetailData.value
    if (detail.eventImageUrl) {
        const smallUrl = detail.eventImageUrl
        imageArr.push(smallUrl)
    }
    return imageArr
})
const openPreview = () => {
    if (isVideoAttachment.value || !mediaSrc.value) return
    showImagePreview({
        images: [mediaSrc.value],
        startPosition: 0,
    })
}
// 跳转地图
const jumpMap = item => {
router.push({
        path: '/webViewWrapper/mapWork',
        query: {
            currentItem: JSON.stringify(item)
        }
    })
}
 
function replaceWithProxy(url) {
    if (!url) return ''
    return url.replace(
        /^https?:\/\/[^/]+/,
        'https://wrj.shuixiongit.com/ja-proxy'
    )
}
 
function getVideoType(url) {
    const path = (url || '').split('?')[0].toLowerCase()
    if (path.endsWith('.m3u8')) return 'application/x-mpegURL'
    if (path.endsWith('.mp4')) return 'video/mp4'
    if (path.endsWith('.webm')) return 'video/webm'
    if (path.endsWith('.ogg') || path.endsWith('.ogv')) return 'video/ogg'
    if (path.endsWith('.mov')) return 'video/quicktime'
    return ''
}
 
function getVideoSource() {
    const type = getVideoType(mediaSrc.value)
    return {
        src: mediaSrc.value,
        ...(type ? { type } : {}),
    }
}
 
function destroyPlayer() {
    if (!player) return
    player.dispose()
    player = null
}
 
async function initPlayer() {
    if (!isVideoAttachment.value || !mediaSrc.value) return
    await nextTick()
    if (!videoRef.value) return
 
    if (player) {
        player.src(getVideoSource())
        player.load()
        return
    }
 
    player = videojs(videoRef.value, {
        controls: true,
        preload: 'auto',
        autoplay: false,
        fluid: false,
        sources: [getVideoSource()],
    })
    player.on('error', () => {
        console.error('视频播放失败:', player?.error(), mediaSrc.value)
    })
}
 
const mediaSrc = ref('')
 
watch([isVideoAttachment, mediaSrc], () => {
    if (isVideoAttachment.value) {
        initPlayer()
    } else {
        destroyPlayer()
    }
})
 
onMounted(async () => {
    keyword.value = JSON.parse(route.query.workDetailData)
    try {
        const res = await getSharingDetailsApi({ cacheKey: keyword.value })
        workDetailData.value = res.data.data
        let {eventImageUrl,geojson} = workDetailData.value
        // http://220.177.172.27:8100 改为 https://wrj.shuixiongit.com/ja-proxy
        eventImageUrl = replaceWithProxy(eventImageUrl)
        if (eventImageUrl){
            mediaSrc.value = !isVideoAttachment.value && geojson ? await getAiImg(eventImageUrl,geojson) : eventImageUrl
        }
    } catch (error) {
        showToast('分享链接失效')
    }
 
})
 
onBeforeUnmount(destroyPlayer)
</script>
<style lang="scss" scoped>
.workDetailContainer {
    .detailTop {
        .image-container {
            position: relative;
            width: 100%;
            height: 235px;
            .detailImage {
                width: 100%;
                height: 100%;
                display: block;
                object-fit: cover;
            }
 
            .detailVideo {
                width: 100%;
                height: 235px;
            }
 
            :deep(.video-js .vjs-tech) {
                width: 100%;
                height: 100%;
            }
        }
    }
 
    .worderContainer {
        padding: 0 12px;
        // padding-bottom: 2px;
        background: #f6f6f6;
    }
 
    .workOrderContent {
        margin-top: 15px;
        background-color: #fff;
        border-radius: 6px;
        padding: 8px 10px;
        margin-bottom: 17px;
 
        .workOrderTitle {
            font-family: Source Han Sans CN, Source Han Sans CN;
            font-weight: bold;
            font-size: 16px;
            color: #222324;
        }
 
        .workOrderContainer {
            .orderRow {
                display: flex;
                justify-content: space-between;
                align-items: center;
                min-height: 48px;
                border-bottom: 1px solid #f5f5f5;
                color: #7b7b7b;
            }
 
            .rowCard {
                margin-top: 10px;
 
                min-height: 48px;
                border-bottom: 1px solid #f5f5f5;
                color: #7b7b7b;
            }
 
            .guanlian {
                display: flex;
            }
 
            .rowTitle {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 15px;
                color: #222324;
                white-space: nowrap;
 
                span {
                    font-family: Source Han Sans CN, Source Han Sans CN;
                    font-weight: 400;
                    font-size: 10px;
                    color: #3a3a3a;
                }
            }
 
            .addressBox {
                display: flex;
                align-items: center;
                overflow: hidden;
            }
 
            .rowAddress {
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 14px;
                color: #1d6fe9;
                text-decoration: underline;
                text-align: right;
                padding-top: 1px;
                padding-left: 5px;
                padding-right: 2px;
            }
            :deep(.custom-field) {
                padding: 0 !important;
                padding-left: 10px !important;
            }
 
            :deep(.custom-field .van-field__control) {
                padding: 0 !important;
            }
 
        }
    }
 
}
</style>