吉安感知网项目-前端
罗广辉
6 days ago 9859152fdaebb4162e80e8a112705bf397f35e09
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
<!-- 工单详情 -->
<template>
    <div class="workDetailContainer">
        <!-- 自定义导航栏 -->
        <u-navbar title="工单详情" :is-back="true" back-text="" :back-icon-size="40" @left-click="onBackClick">
            <template #right>
        <div v-if="isH5" class="tapShare-icon"><img src="/static/images/work/share.svg"  @click="onShareClick"/></div>
                <div v-else class="share-btn" @click="onShareClick"></div>
            </template>
        </u-navbar>
        <div class="detailTop">
            <div class="image-container">
                <u-swiper
                    class="detailImage"
                    :list="getImageList"
                    mode="round"
                    indicator
                    indicatorMode="dot"
                    indicatorActiveColor="#4C85FF"
                    indicatorInactiveColor="#fff"
                    indicatorPosition="center"
                    height="410rpx"
                    @click="previewImage"
                ></u-swiper>
            </div>
        </div>
    <!-- 工单内容 -->
    <div class="worderContainer">
      <div class="workOrderContent">
        <div class="workOrderTitle">工单内容</div>
        <div class="workOrderContainer">
          <div class="orderRow">
            <div class="rowTitle">工单名称</div>
            <div>{{ workDetailData.eventName }}</div>
          </div>
          <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 class="actionButton" >
      <div class="btngroups" v-if="workDetailData.eventStatus !== 3">
        <up-button type="primary"  color="#AEAEAE" text="退回" @click="rejectTicket"></up-button>
        <up-button type="primary" color="#1D6FE9" text="确认" @click="confirmTheTicket"></up-button>
      </div>
      <div class="btngroups" v-if="workDetailData.eventStatus === 3">
        <up-button type="primary" color="#1D6FE9" text="已确认" @click="confirmedHandle"></up-button>
      </div>
    </div>
    <!-- 分享弹出层 -->
    <div v-if="showShareModal" class="share-modal-overlay" @click="onShareModalClose">
      <div class="share-modal-content" @click.stop>
        <div class="share-modal-header">
          <div class="share-modal-title">分享到</div>
          <!-- <div class="share-modal-close" @click="onShareModalClose">×</div> -->
        </div>
        <div class="share-modal-body">
<!--          <div class="share-item" @click="shareToWechat">-->
<!--            <div class="share-icon wechat"></div>-->
<!--            <div class="share-name">微信好友</div>-->
<!--          </div>-->
<!--          <div class="share-item" @click="shareToMoments">-->
<!--            <div class="share-icon moments"></div>-->
<!--            <div class="share-name">朋友圈</div>-->
<!--          </div>-->
          <div class="share-item" @click="copyLink">
            <div class="share-icon link"></div>
            <div class="share-name">复制链接</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script setup>
// import { getShowImg, getSmallImg } from '@/utils/util'
import {getGddetailedData,backGdApi,shareCacheApi} from '/src/api/work/index.js'
import { getWebViewUrl } from '@/utils/index.js'
import WebViewPlus from '@/components/WebViewPlus.vue'
 
const eventNum = ref('')
// 工单内容
const workDetailData = ref({})
// 环境判断
const isH5 = ref(false)
const sWebViewRef = ref(null);
const viewUrl = ref("");
onLoad(async options => {
  eventNum.value = options.id
  await getDataList(options.id,options.aiImg)
  checkEnvironment()
  viewUrl.value = getWebViewUrl("/workDetail", { workDetailData: JSON.stringify(workDetailData.value) });
})
const getDataList = async (val,aiImg) => {
  const params = {
    id: val,
  }
  const res = await getGddetailedData(params)
  const response = res.data.data
  workDetailData.value = {...response,aiImg}
}
// 检查运行环境
const checkEnvironment = () => {
  const systemInfo = uni.getSystemInfoSync()
  // #ifdef APP-PLUS
  isH5.value = false
  // #endif
 
  // #ifdef H5
  isH5.value = true
  // #endif
 
  // console.log('当前环境:', isH5.value ? 'H5' : 'App')
}
// 图片预览
const previewImage = index => {
  if (getImageList.value.length === 0) return
  const currentIndex = typeof index === 'number' ? index : 0
  uni.previewImage({
    urls: getImageList.value,
    current: currentIndex,
  })
}
const getImageList = computed(() => {
  const imageArr = []
  const detail = workDetailData.value
  if (detail.eventImageUrl) {
    imageArr.push(detail.aiImg || detail.eventImageUrl)
  }
  return imageArr
})
// 跳转地图
const jumpMap = item => {
  // const contactStr = encodeURIComponent(JSON.stringify(item))
    const contactStr = JSON.stringify(item)
  uni.navigateTo({
    url: `/subPackages/workDetail/mapWork/index?eventNum=${contactStr}`,
  })
}
// 退回
const rejectTicket = () => {
  const id = workDetailData.value.id
  backGdApi({eventId : id,eventStatus:'0'}).then(res => {
    uni.showToast({
      title: '退回成功',
      icon: 'success',
      duration: 1500
    })
    setTimeout(() => {
      uni.navigateBack()
    })
  })
 
}
// 确认工单
const confirmTheTicket = () => {
  const id = workDetailData.value.id
  backGdApi({eventId : id,eventStatus:'1'}).then(res => {
    uni.showToast({
      title: '确认成功',
      icon: 'success',
      duration: 1500
    })
    setTimeout(() => {
      uni.navigateBack()
    })
  })
}
// 已确认
const confirmedHandle = () => {
  uni.navigateBack()
}
// 分享模态框状态
const showShareModal = ref(false)
 
// 分享按钮点击事件 - 显示分享模态框
const onShareClick = () => {
    showShareModal.value = true
}
 
// 关闭分享模态框
const onShareModalClose = () => {
    showShareModal.value = false
}
 
// 微信好友分享
const shareToWechat = () => {
    shareToPlatform('weixin', 'WXSceneSession')
}
 
// 朋友圈分享
const shareToMoments = () => {
    shareToPlatform('weixin', 'WXSceneTimeline')
}
 
// 复制链接
const copyLink = async () => {
  const res = await shareCacheApi(workDetailData.value)
  const shareUrl = getWebViewUrl("/workDetail", { workDetailData: JSON.stringify(res.data.data) })
    try {
        await uni.setClipboardData({
            data: shareUrl,
        })
        uni.showToast({
            title: '链接已复制',
            icon: 'success',
        })
    } catch (error) {
        console.error('复制失败:', error)
        uni.showToast({
            title: '复制失败,请重试',
            icon: 'none',
        })
    }
    onShareModalClose()
}
 
// 通用分享平台函数
const shareToPlatform = (provider, scene = '') => {
    // 检查当前平台是否支持分享功能
    const platform = uni.getSystemInfoSync().platform
 
    // H5平台不支持uni.share API
    if (platform === 'web') {
        uni.showToast({
            title: 'H5平台暂不支持分享功能',
            icon: 'none',
        })
        onShareModalClose()
        return
    }
 
    // 检查uni.share是否存在
    if (typeof uni.share !== 'function') {
        uni.showToast({
            title: '当前环境不支持分享功能',
            icon: 'none',
        })
        onShareModalClose()
        return
    }
 
    try {
        const shareConfig = {
            provider,
            type: 0,
            title: workDetailData.value.event_name || '工单详情',
            summary: '查看工单详情',
      href: getWebViewUrl("/workDetail", { workDetailData: JSON.stringify(workDetailData.value) }),
            imageUrl: workDetailData.value.eventImageUrl,
            success: () => {
                uni.showToast({ title: '分享成功', icon: 'success' })
                onShareModalClose()
            },
            fail: err => {
                console.log('分享失败', err)
                uni.showToast({
                    title: '分享失败,请重试',
                    icon: 'none',
                })
                onShareModalClose()
            },
        }
 
        // 添加场景参数(如果有)
        if (scene) {
            shareConfig.scene = scene
        }
 
        uni.share(shareConfig)
    } catch (error) {
        console.error('分享出错:', error)
        uni.showToast({
            title: '分享功能异常',
            icon: 'none',
        })
        onShareModalClose()
    }
}
 
// 返回按钮点击事件
const onBackClick = () => {
  uni.navigateBack()
}
 
// 监听导航栏右侧按钮点击事件(兼容原来的配置)
const onNavigationBarButtonTap = e => {
  if (e.index === 0) {
    onShareClick()
  }
}
</script>
<style lang="scss" scoped>
.workDetailContainer {
  // 添加导航栏高度的padding-top,避免内容被遮挡
  padding-top: 88rpx;
  :deep(){
  .u-navbar__content{
    background: url("https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_app_assets/images/user/bg.png")  no-repeat !important;
    background-size: 100%!important;
    height: 88rpx !important;
  }
}  // 分享按钮样式
  .share-btn {
    // #ifdef APP-PLUS
    width: 40rpx;
    height: 40rpx;
    background-image: url('/static/images/work/share.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    // #endif
  }
  .tapShare-icon {
    width: 40rpx;
    height: 40rpx;
    img {
      width: 40rpx;
      height: 40rpx;
    }
  }
  .detailTop {
  // #ifdef APP-PLUS
  padding-top: 60rpx;
  // #endif
    .image-container {
      position: relative;
      width: 100%;
      height: 410rpx;
 
      .detailImage {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
      }
      // 轮播图容器
      :deep(.u-swiper) {
        // 指示器容器 - 修改为居中对齐
        .u-swiper__indicator {
          position: absolute;
          left: 50%;
          transform: translateX(-50%);
          bottom: 20rpx;
          display: flex;
          justify-content: center;
          align-items: center;
          z-index: 10;
        }
        .u-swiper-indicator__wrapper__dot--active {
          width: 5px !important;
        }
      }
 
    }
  }
 
  .worderContainer {
    padding: 0 24rpx;
    padding-bottom: 4rpx;
    background: #f6f6f6;
    margin-top: 20rpx;
  }
  .workOrderContent {
    margin-top: 30epx;
    background-color: #fff;
    border-radius: 12rpx;
    padding: 20rpx;
    margin-bottom: 34rpx;
    .workOrderTitle {
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: bold;
      font-size: 32rpx;
      color: #222324;
    }
    .workOrderContainer {
      .orderRow {
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 96rpx;
        border-bottom: 1px solid #f5f5f5;
        color: #7b7b7b;
        .rowTitle {
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 30rpx;
          color: #222324;
          white-space: nowrap;
        }
        .rowAddress {
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 28rpx;
          color: #1d6fe9;
          text-decoration: underline;
          text-align: right;
 
          padding-top: 1px;
          padding-left: 5px;
          padding-right: 2px;
        }
      }
    }
  }
 
  .actionButton {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 61px;
 
    border-radius: 6px 6px 6px 6px;
 
    .btngroups {
      display: flex;
      justify-content: space-between;
      align-items: center;
      :deep(.u-button) {
        width: 276rpx !important;
        height: 76rpx !important;
        &:last-child {
          margin-left: 30rpx;
        }
      }
    }
  }
}
 
/* 分享弹出层样式 */
.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    z-index: 9999;
}
 
.share-modal-content {
    background-color: #fff;
    border-radius: 20rpx 20rpx 0 0;
    padding: 30rpx;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}
 
.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30rpx;
}
 
.share-modal-title {
    font-size: 36rpx;
    font-weight: bold;
    color: #222324;
    text-align: center;
    flex: 1;
}
 
.share-modal-close {
    font-size: 60rpx;
    color: #999;
    line-height: 40rpx;
}
 
.share-modal-body {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding-bottom: 30rpx;
}
 
.share-modal-footer {
    display: flex;
    justify-content: space-around;
    padding-top: 30rpx;
    border-top: 1px solid #f0f0f0;
}
 
.share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20rpx;
    width: 120rpx;
}
 
.share-icon {
    width: 90rpx;
    height: 90rpx;
    border-radius: 50%;
    margin-bottom: 15rpx;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
 
.share-icon.wechat {
    background-image: url('@/static/images/work/wechat.svg');
}
 
.share-icon.moments {
    background-image: url('@/static/images/work/moments.svg');
}
 
 
.share-icon.link {
    background-image: url('@/static/images/work/link.svg');
}
.share-name {
    font-size: 24rpx;
    color: #666;
    margin-top: 10rpx;
}
</style>