| | |
| | | const listLoaded = ref(false) |
| | | const listError = ref(false) |
| | | |
| | | const uploadUrl = (value: any): string => { |
| | | if (value == null) return '' |
| | | if (typeof value == 'object') { |
| | | const keys = ['url', 'path', 'fileUrl', 'file_url', 'downloadUrl', 'download_url'] |
| | | for (const key of keys) { |
| | | if (value[key] != null && String(value[key]).trim() != '') return String(value[key]).trim() |
| | | } |
| | | return '' |
| | | } |
| | | return String(value).trim() |
| | | } |
| | | const normalizeOrganization = (source: any): any => { |
| | | const item = source != null ? source : {} |
| | | const keys = ['windowInfoUrl', 'window_info_url', 'pdfFile', 'pdf_file', 'windowInfo', 'window_info', 'windowFile', 'window_file', 'fileUrl', 'file_url'] |
| | | let windowInfoUrl = '' |
| | | for (const key of keys) { |
| | | const candidate = uploadUrl(item[key]) |
| | | if (candidate != '') { windowInfoUrl = candidate; break } |
| | | } |
| | | const normalized: any = { ...item } |
| | | normalized.windowInfoUrl = windowInfoUrl |
| | | normalized.hasWindowInfo = windowInfoUrl != '' |
| | | if (normalized.phone == null) normalized.phone = '' |
| | | return normalized |
| | | } |
| | | |
| | | onLoad((options: any) => { |
| | | // #ifdef MP-WEIXIN |
| | | const capsule = uni.getMenuButtonBoundingClientRect() |
| | |
| | | heroImage.value = data.heroImage != null && data.heroImage != '' ? resolveApiUrl(data.heroImage as string) : '' |
| | | benefitAvailable.value = data.available === true |
| | | unavailableReason.value = data.unavailableReason || '该权益暂未开放' |
| | | orgs.value = data.organizations instanceof Array ? data.organizations as any[] : [] |
| | | orgs.value = data.organizations instanceof Array ? (data.organizations as any[]).map(normalizeOrganization) : [] |
| | | listLoading.value = false |
| | | listLoaded.value = true |
| | | }, () => { listLoading.value = false; listError.value = true }) |
| | |
| | | const replaceHero = () => { heroImage.value = '' } |
| | | const callOrg = (item: any) => { if (item.phone == null || item.phone == '') { uni.showToast({ title: '机构暂未提供咨询电话', icon: 'none' }); return }; uni.makePhoneCall({ phoneNumber: item.phone, fail: () => uni.showToast({ title: '暂时无法拨打电话', icon: 'none' }) }) } |
| | | const openWindowInfo = (item: any) => { |
| | | const source = item != null && item.windowInfoUrl != null ? String(item.windowInfoUrl) : '' |
| | | const normalized = normalizeOrganization(item) |
| | | const source = normalized.windowInfoUrl |
| | | if (source == '') { |
| | | uni.showToast({ title: '窗口信息文件暂未配置', icon: 'none' }) |
| | | return |
| | | } |
| | | const url = resolveApiUrl(source) |
| | | const url = resolveApiUrl(source.indexOf('/') == 0 || source.indexOf('http://') == 0 || source.indexOf('https://') == 0 ? source : '/' + source) |
| | | uni.showLoading({ title: '正在打开文件', mask: true }) |
| | | uni.downloadFile({ |
| | | url: url, |