| | |
| | | <image :src="hostMethodIcon" class="field-icon" mode="aspectFit"></image> |
| | | <view class="field-copy"> |
| | | <text class="field-label host-method-label">接待人验证方式</text> |
| | | <view class="method-badge"> |
| | | <text class="method-badge-text">{{ detail.hostVerify }}</text> |
| | | <view class="method-badge" :class="{ 'method-badge-warn': isCardVerifyMethod(detail.hostVerify) }"> |
| | | <text class="method-badge-text" :class="{ 'method-badge-text-warn': isCardVerifyMethod(detail.hostVerify) }">{{ detail.hostVerify }}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <image :src="signoutMethodIcon" class="field-icon" mode="aspectFit"></image> |
| | | <view class="field-copy"> |
| | | <text class="field-label">接待人验证方式</text> |
| | | <view class="method-badge method-badge-warn"> |
| | | <text class="method-badge-text method-badge-text-warn">{{ detail.signoutVerify }}</text> |
| | | <view class="method-badge" :class="{ 'method-badge-warn': isCardVerifyMethod(detail.signoutVerify) }"> |
| | | <text class="method-badge-text" :class="{ 'method-badge-text-warn': isCardVerifyMethod(detail.signoutVerify) }">{{ detail.signoutVerify }}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | return { text: '来访中', class: 'stay' }; |
| | | case 'SIGNED_OUT': |
| | | return { text: '已签离', class: 'done' }; |
| | | case 'PENDING_CONFIRM': |
| | | case 'OVERDUE': |
| | | return { text: '逾期滞留', class: 'warn' }; |
| | | case 'OVERDUE_AUTO_SIGNED_OUT': |
| | |
| | | return typeStr || '未知'; |
| | | }; |
| | | |
| | | const getDetailSnapshotStorageKey = (recordId) => `${DETAIL_SNAPSHOT_STORAGE_PREFIX}${recordId}`; |
| | | const isCardVerifyMethod = (verifyMethod = '') => { |
| | | return String(verifyMethod || '').includes('刷卡'); |
| | | }; |
| | | |
| | | const normalizeDetailData = (data = {}) => { |
| | | const statusInfo = getStatusInfo(data.status); |
| | |
| | | }; |
| | | }; |
| | | |
| | | const applyDetailSnapshot = (snapshot) => { |
| | | if (!snapshot) { |
| | | return false; |
| | | } |
| | | |
| | | detail.value = { |
| | | ...createDefaultDetail(), |
| | | ...snapshot, |
| | | }; |
| | | return true; |
| | | }; |
| | | |
| | | const loadLocalDetail = async (recordId) => { |
| | | const snapshotStorage = uni.getStorageSync(getDetailSnapshotStorageKey(recordId)); |
| | | const snapshotValue = snapshotStorage?.value || snapshotStorage; |
| | | if (snapshotValue) { |
| | | return applyDetailSnapshot(snapshotValue); |
| | | } |
| | | |
| | | const cachedRecord = await getHistoryRecordByRecordId(recordId); |
| | | if (!cachedRecord) { |
| | | return false; |
| | | } |
| | | |
| | | const normalizedSnapshot = normalizeDetailData(cachedRecord); |
| | | uni.setStorageSync(getDetailSnapshotStorageKey(recordId), { |
| | | value: normalizedSnapshot, |
| | | updateTime: Number(cachedRecord?._cacheTime || 0) || Date.now(), |
| | | }); |
| | | return applyDetailSnapshot(normalizedSnapshot); |
| | | }; |
| | | |
| | | const fetchDetail = async (recordId) => { |
| | | const loadDetail = async (recordId) => { |
| | | uni.showLoading({ title: '加载中...' }); |
| | | try { |
| | | uni.showLoading({ title: '加载中...' }); |
| | | const res = await getVisitorRecordDetail({ recordId }); |
| | | if (res && res.code === 200 && res.data) { |
| | | const normalizedSnapshot = normalizeDetailData(res.data); |
| | | detail.value = normalizedSnapshot; |
| | | uni.setStorageSync(getDetailSnapshotStorageKey(recordId), { |
| | | value: normalizedSnapshot, |
| | | updateTime: Date.now(), |
| | | }); |
| | | return; |
| | | } else if (res && res.msg) { |
| | | throw new Error(res.msg); |
| | | detail.value = normalizeDetailData(res.data); |
| | | } else { |
| | | throw new Error(res?.msg || '获取详情失败'); |
| | | } |
| | | } catch (error) { |
| | | console.error('获取详情失败', error); |
| | | const hasLocalDetail = await loadLocalDetail(recordId); |
| | | uni.showToast({ title: hasLocalDetail ? '已加载离线详情' : '获取详情失败', icon: 'none' }); |
| | | } catch (err) { |
| | | console.error('获取在线详情失败:', err); |
| | | uni.showToast({ title: '网络异常,获取详情失败', icon: 'none' }); |
| | | } finally { |
| | | uni.hideLoading(); |
| | | } |
| | |
| | | onLoad((options) => { |
| | | id.value = options?.id || ''; |
| | | if (id.value) { |
| | | loadLocalDetail(id.value); |
| | | fetchDetail(id.value); |
| | | loadDetail(id.value); |
| | | } |
| | | }); |
| | | |
| | |
| | | .host-item, |
| | | .permission-title-row { |
| | | display: flex; |
| | | align-items: center; |
| | | /* align-items: center; */ |
| | | gap: 10px; |
| | | } |
| | | |