diff --git a/.env b/.env index 4bfc0ff..da50170 100644 --- a/.env +++ b/.env @@ -15,3 +15,4 @@ VITE_API_BASE_URL=https://www.quannengcha.com/api/v1 # 想用本地接口时注释掉上面那行,取消下面这行注释: # VITE_API_BASE_URL=http://127.0.0.1:8888/api/v1 + diff --git a/.env.production b/.env.production index 4e3fbec..0689124 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,4 @@ # 生产构建:指向 qnc-server-v3 线上网关 VITE_API_BASE_URL=https://www.quannengcha.com/api/v1 +# qnc-webview-v3 H5 站点(小程序 web-view / 分享链接) +VITE_H5_ORIGIN=https://www.quannengcha.com diff --git a/components.d.ts b/components.d.ts index bc3e1b6..27e6584 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,6 +10,7 @@ declare module 'vue' { AppFooter: typeof import('./src/components/AppFooter.vue')['default'] AppLogos: typeof import('./src/components/AppLogos.vue')['default'] InputEntry: typeof import('./src/components/InputEntry.vue')['default'] + ReportShareBar: typeof import('./src/components/report/ReportShareBar.vue')['default'] VehicleBlockFallback: typeof import('./src/components/report/VehicleBlockFallback.vue')['default'] VehicleBlockQCXG1H7Y: typeof import('./src/components/report/blocks/VehicleBlockQCXG1H7Y.vue')['default'] VehicleBlockQCXG1U4U: typeof import('./src/components/report/blocks/VehicleBlockQCXG1U4U.vue')['default'] diff --git a/env.d.ts b/env.d.ts index 411e28e..d5d1a17 100644 --- a/env.d.ts +++ b/env.d.ts @@ -5,6 +5,8 @@ interface ImportMetaEnv { readonly VITE_API_BASE_URL?: string /** H5 开发代理目标,仅 vite 使用,默认 http://127.0.0.1:8888 */ readonly VITE_API_PROXY_TARGET?: string + /** qnc-webview-v3 站点根地址,如 https://www.quannengcha.com */ + readonly VITE_H5_ORIGIN?: string } interface ImportMeta { diff --git a/src/api/query.js b/src/api/query.js index 7c598dd..c3b13ec 100644 --- a/src/api/query.js +++ b/src/api/query.js @@ -29,6 +29,16 @@ export async function getQueryList(params = {}, requestConfig) { return res.data } +/** 生成报告分享链接(与 H5 ShareReportButton POST /query/generate_share_link 一致) */ +export async function generateQueryShareLink(body, requestConfig = {}) { + const res = await http.post('/query/generate_share_link', body, { + skipLoading: true, + skipBizToast: true, + ...requestConfig, + }) + return res.data +} + /** 创建查询临时单(与 H5 `InquireForm` 一致:POST /api/v1/query/service/:product) */ export async function postQueryService(productEn, body, requestConfig) { const enc = encodeURIComponent(productEn) diff --git a/src/components/report/ReportShareBar.vue b/src/components/report/ReportShareBar.vue new file mode 100644 index 0000000..1d26021 --- /dev/null +++ b/src/components/report/ReportShareBar.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/src/components/report/blocks/VehicleBlockQCXGGB2Q.vue b/src/components/report/blocks/VehicleBlockQCXGGB2Q.vue index ef17466..d882f8a 100644 --- a/src/components/report/blocks/VehicleBlockQCXGGB2Q.vue +++ b/src/components/report/blocks/VehicleBlockQCXGGB2Q.vue @@ -1,7 +1,7 @@ @@ -134,8 +140,12 @@ async function load(opts = {}) { box-sizing: border-box; } +.page-root.has-share-bar { + padding-bottom: calc(128rpx + env(safe-area-inset-bottom)); +} + .state { - padding: 100rpx 32rpx; + padding: 48rpx 32rpx 0; text-align: center; font-size: 28rpx; color: #86909c; diff --git a/src/pages/report/webview.vue b/src/pages/report/webview.vue new file mode 100644 index 0000000..92ef2dd --- /dev/null +++ b/src/pages/report/webview.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/report-ui/vehicles/CQCXGGB2Q.vue b/src/report-ui/vehicles/CQCXGGB2Q.vue index a7f0ab2..6e52583 100644 --- a/src/report-ui/vehicles/CQCXGGB2Q.vue +++ b/src/report-ui/vehicles/CQCXGGB2Q.vue @@ -65,17 +65,17 @@ const maskedName = computed(() => { return name.length > 1 ? name[0] + '*'.repeat(name.length - 1) : '*'; }); -// verify_code: 1 一致,2 不匹配 +// verify_code: 1 一致,0 不一致 const isMatch = computed(() => { - const code = props.data?.verify_code; - if (code === 1) return true; - if (code === 2) return false; - return null; // 无有效数据时 + const n = Number(props.data?.verify_code); + if (n === 1) return true; + if (n === 0) return false; + return null; }); const resultText = computed(() => { if (isMatch.value === true) return '一致'; - if (isMatch.value === false) return '不匹配'; + if (isMatch.value === false) return '不一致'; return '暂无结果'; }); diff --git a/src/utils/reportH5Link.js b/src/utils/reportH5Link.js new file mode 100644 index 0000000..917070f --- /dev/null +++ b/src/utils/reportH5Link.js @@ -0,0 +1,27 @@ +import { generateQueryShareLink } from '@/api/query' +import { getH5Origin } from '@/config/h5' + +/** 登录用户直接打开 H5 报告(需 H5 端同账号登录) */ +export function buildDirectReportUrl({ orderId, orderNo }) { + const base = getH5Origin() + if (orderNo) + return `${base}/report?orderNo=${encodeURIComponent(orderNo)}` + if (orderId) + return `${base}/report?orderId=${encodeURIComponent(String(orderId))}` + return '' +} + +/** 与 H5 ShareReportButton 一致:POST /query/generate_share_link → /report/share/:id */ +export async function fetchReportShareUrl({ orderId, orderNo }) { + const body = orderId + ? { order_id: String(orderId) } + : { order_no: String(orderNo) } + + const res = await generateQueryShareLink(body) + const linkId = res?.data?.share_link + if (res?.code !== 200 || !linkId) + throw new Error(res?.msg || '生成分享链接失败') + + const base = getH5Origin() + return `${base}/report/share/${encodeURIComponent(linkId)}` +} diff --git a/uni-pages.d.ts b/uni-pages.d.ts index 8908d8c..0372a5d 100644 --- a/uni-pages.d.ts +++ b/uni-pages.d.ts @@ -19,6 +19,7 @@ type _LocationUrl = "/pages/legal/privacy-policy" | "/pages/legal/user-agreement" | "/pages/report/detail" | + "/pages/report/webview" | "/pages/toolbox/category" | "/pages/toolbox/index" | "/pages/toolbox/query";