1
yyb
2026-04-29 aec5cbead319feabb2e44ddd5bf99a0af01ca506
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
<template>
  <view class="client-visit-detail">
    <PageHeader title="客户拜访详情"
                @back="goBack" />
    <!-- 内容容器 -->
    <view class="content-container">
      <!-- 客户信息 -->
      <view class="section">
        <view class="section-title">客户信息</view>
        <view class="info-item">
          <text class="info-label">客户名称</text>
          <text class="info-value">{{ form.customerName || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">联系人</text>
          <text class="info-value">{{ form.contact || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">联系电话</text>
          <text class="info-value">{{ form.contactPhone || '-' }}</text>
        </view>
      </view>
      <!-- 拜访信息 -->
      <view class="section">
        <view class="section-title">拜访信息</view>
        <view class="info-item">
          <text class="info-label">拜访目的</text>
          <text class="info-value">{{ form.purposeVisit || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">拜访时间</text>
          <text class="info-value">{{ form.purposeDate || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">拜访地点</text>
          <text class="info-value multi-line">{{ form.visitAddress || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">拜访人</text>
          <text class="info-value">{{ form.visitingPeople || '-' }}</text>
        </view>
        <view class="info-item"
              v-if="form.latitude && form.longitude">
          <text class="info-label">经纬度</text>
          <text class="info-value">{{ form.latitude }}, {{ form.longitude }}</text>
        </view>
        <view class="info-item photo-item">
          <text class="info-label">拜访照片</text>
          <view class="photo-wrap">
            <view v-if="visitImageList.length"
                  class="photo-list">
              <image v-for="(img, idx) in visitImageList"
                     :key="img.id || img.url || idx"
                     class="photo-img"
                     :src="img.url"
                     mode="aspectFill"
                     @click="previewVisitImage(idx)" />
            </view>
            <text v-else
                  class="empty-text">-</text>
          </view>
        </view>
      </view>
      <!-- 备注信息 -->
      <view class="section">
        <view class="section-title">备注信息</view>
        <view class="info-item remark-item">
          <text class="info-label">备注</text>
          <text class="info-value multi-line">{{ form.remark }}</text>
        </view>
      </view>
    </view>
  </view>
</template>
 
<script setup>
  // 替换 toast 方法
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
 
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import { normalizeFileUrl } from "@/utils/filePreview";
  import useUserStore from "@/store/modules/user";
 
  const userStore = useUserStore();
 
  // 表单数据
  const form = ref({
    customerName: "",
    contact: "",
    contactPhone: "",
    visitingPeople: "",
    purposeVisit: "",
    purposeDate: "",
    visitAddress: "",
    latitude: "",
    longitude: "",
    locationAddress: "",
    remark: "",
  });
  const visitImageList = ref([]);
 
  const isLikelyPathValue = value => {
    const v = String(value || "").trim();
    if (!v) return false;
    if (/^(https?:)?\/\//i.test(v)) return true;
    if (/^(blob:|data:|wxfile:|file:|content:)/i.test(v)) return true;
    if (v.includes("/") || v.includes("\\")) return true;
    if (/\.[a-zA-Z0-9]{2,8}($|\?)/.test(v)) return true;
    return false;
  };
 
  const buildVisitFilePreviewUrl = file => {
    const candidates = [
      file?.link,
      file?.url,
      file?.downloadUrl,
      file?.path,
      file?.filePath,
      file?.tempPath,
      file?.urlFull,
    ].filter(Boolean);
    for (const raw of candidates) {
      if (!isLikelyPathValue(raw)) continue;
      const normalized = normalizeFileUrl(raw);
      if (normalized) return normalized;
    }
    return "";
  };
 
  const buildVisitImageList = row => {
    const rawList = [];
    if (Array.isArray(row?.commonFileList)) rawList.push(...row.commonFileList);
    if (Array.isArray(row?.storageBlobDTO)) rawList.push(...row.storageBlobDTO);
    const uniq = [];
    const seen = new Set();
    rawList.forEach(item => {
      const url = buildVisitFilePreviewUrl(item);
      if (!url || seen.has(url)) return;
      seen.add(url);
      uniq.push({ ...item, url });
    });
    visitImageList.value = uniq;
  };
 
  const previewVisitImage = idx => {
    const urls = visitImageList.value.map(item => item?.url).filter(Boolean);
    if (!urls.length) return;
    uni.previewImage({ urls, current: urls[idx] || urls[0] });
  };
 
  // 返回上一页
  const goBack = () => {
    // 返回时清除本地存储的ID
    uni.removeStorageSync("clientVisit");
    uni.navigateBack();
  };
 
  // 初始化页面数据
  const initPageData = () => {
    // 从本地存储获取拜访记录详情
    const row = uni.getStorageSync("clientVisit");
    if (row) {
      form.value = { ...row };
      buildVisitImageList(row);
    } else {
      showToast("暂无拜访记录数据");
    }
  };
 
  onMounted(() => {
    initPageData();
  });
</script>
 
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
 
  .client-visit-detail {
    min-height: 100vh;
    background-color: #f8f9fa;
  }
 
  .content-container {
    padding: 16px;
  }
 
  .section {
    background-color: #ffffff;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
 
  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f0f0f0;
  }
 
  .info-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f8f8f8;
    align-items: flex-start;
  }
 
  .info-item:last-child {
    border-bottom: none;
  }
 
  .info-label {
    font-size: 14px;
    color: #666666;
    min-width: 80px;
    flex-shrink: 0;
    line-height: 22px;
  }
 
  .info-value {
    font-size: 14px;
    color: #333333;
    flex: 1;
    line-height: 22px;
    text-align: right;
  }
 
  .photo-item {
    align-items: flex-start;
  }
 
  .photo-wrap {
    flex: 1;
    display: flex;
    justify-content: flex-start;
  }
 
  .photo-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
  }
 
  .photo-img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: #f5f5f5;
  }
 
  .empty-text {
    color: #999;
    line-height: 22px;
  }
 
  .multi-line {
    text-align: left;
    word-break: break-all;
    line-height: 1.6;
  }
 
  .remark-item {
    padding-bottom: 16px;
  }
</style>