diff --git a/.env b/.env index 56fa04a..2d93cfe 100644 --- a/.env +++ b/.env @@ -7,3 +7,5 @@ # VITE_API_BASE_URL=/api/v1 # VITE_API_BASE_URL=http://127.0.0.1:8888/api/v1 VITE_API_BASE_URL=https://www.tianyuancha.cn/api/v1 +# H5 站点根地址(报告分享 / webview 链接),默认由 VITE_API_BASE_URL 推导 +VITE_H5_BASE_URL=https://www.tianyuancha.cn diff --git a/src/api/query.js b/src/api/query.js index fe80590..426cc69 100644 --- a/src/api/query.js +++ b/src/api/query.js @@ -35,3 +35,9 @@ export async function postQueryService(productEn, body, requestConfig) { const res = await http.post(`/query/service/${enc}`, body, requestConfig) return res.data } + +/** 生成报告分享链接(与 H5 ShareReportButton:POST /query/generate_share_link) */ +export async function postGenerateShareLink(body, requestConfig) { + const res = await http.post('/query/generate_share_link', body, requestConfig) + return res.data +} diff --git a/src/components/report/blocks/VehicleBlockQCXGYTS2.vue b/src/components/report/blocks/VehicleBlockQCXGYTS2.vue index 26cd18e..e0002a2 100644 --- a/src/components/report/blocks/VehicleBlockQCXGYTS2.vue +++ b/src/components/report/blocks/VehicleBlockQCXGYTS2.vue @@ -18,12 +18,23 @@ const maskedName = computed(() => { return name.length > 1 ? `${name[0]}${'*'.repeat(name.length - 1)}` : '*' }) -const status = computed(() => { - const s = Number(p.value.status) - if ([0, -1, -2, -4].includes(s)) - return s +/** 接口实际为 { result: { status } },示例数据可能为顶层 { status } */ +function readStatus(payload) { + if (!payload || typeof payload !== 'object') + return null + const direct = Number(payload.status) + if ([0, -1, -2, -4].includes(direct)) + return direct + const nested = payload.result + if (nested && typeof nested === 'object') { + const s = Number(nested.status) + if ([0, -1, -2, -4].includes(s)) + return s + } return null -}) +} + +const status = computed(() => readStatus(p.value)) const resultText = computed(() => { const s = status.value diff --git a/src/pages.json b/src/pages.json index b86d6b5..92ae2d1 100644 --- a/src/pages.json +++ b/src/pages.json @@ -182,6 +182,16 @@ "navigationBarTextStyle": "black", "enablePullDownRefresh": false } + }, + { + "path": "pages/webview/index", + "type": "page", + "style": { + "navigationBarTitleText": "网页", + "navigationStyle": "default", + "navigationBarBackgroundColor": "#ffffff", + "navigationBarTextStyle": "black" + } } ], "subPackages": [], diff --git a/src/pages/report.vue b/src/pages/report.vue index bfedc89..4cb27aa 100644 --- a/src/pages/report.vue +++ b/src/pages/report.vue @@ -35,7 +35,7 @@ function readQueryParams(row: Record): Record } function pickVin(qp: Record): string { - const keys = ['vin_code', 'vin', 'frame_no', 'VIN', '车架号'] + const keys = ['vin_code', 'vin', 'frame_no', 'VIN', '车架号', 'plate_no', 'car_license', '车牌号'] for (const k of keys) { const v = qp[k] if (typeof v === 'string' && v.trim()) @@ -47,7 +47,7 @@ function pickVin(qp: Record): string { } function pickModel(qp: Record): string { - const keys = ['model', 'vehicle_model', 'car_model', '车型', 'name', 'car_name'] + const keys = ['carplate_type', 'car_type', 'model', 'vehicle_model', 'car_model', '车型', 'car_name'] for (const k of keys) { const v = qp[k] if (typeof v === 'string' && v.trim()) diff --git a/src/pages/report/detail.vue b/src/pages/report/detail.vue index 4a148e1..bdc4465 100644 --- a/src/pages/report/detail.vue +++ b/src/pages/report/detail.vue @@ -1,8 +1,9 @@ @@ -97,4 +169,35 @@ async function load() { padding: 24rpx 24rpx 48rpx; box-sizing: border-box; } + +.share-bar { + margin-top: 32rpx; + padding: 0 8rpx 16rpx; + display: flex; + flex-direction: column; + align-items: center; +} + +.share-btn { + width: 100%; + height: 88rpx; + line-height: 88rpx; + border-radius: 44rpx; + background: #1768ff; + color: #fff; + font-size: 30rpx; + font-weight: 500; + border: none; +} + +.share-btn::after { + border: none; +} + +.share-tip { + margin-top: 16rpx; + font-size: 24rpx; + color: #86909c; + text-align: center; +} diff --git a/src/pages/webview/index.vue b/src/pages/webview/index.vue new file mode 100644 index 0000000..7922eba --- /dev/null +++ b/src/pages/webview/index.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/report-ui/vehicles/CQCXGYTS2.vue b/src/report-ui/vehicles/CQCXGYTS2.vue index be1cee4..a924886 100644 --- a/src/report-ui/vehicles/CQCXGYTS2.vue +++ b/src/report-ui/vehicles/CQCXGYTS2.vue @@ -51,10 +51,13 @@ const maskedName = computed(() => { return name.length > 1 ? name[0] + '*'.repeat(name.length - 1) : '*'; }); -// status: 0 一致, -1 不一致, -2 非法姓名, -4 无记录 +// status: 0 一致, -1 不一致, -2 非法姓名, -4 无记录(接口多为 result.status) const status = computed(() => { - const s = props.data?.status; - if (s === 0 || s === -1 || s === -2 || s === -4) return s; + const d = props.data; + const direct = d?.status; + if (direct === 0 || direct === -1 || direct === -2 || direct === -4) return direct; + const nested = d?.result?.status; + if (nested === 0 || nested === -1 || nested === -2 || nested === -4) return nested; return null; }); diff --git a/src/utils/h5BaseUrl.js b/src/utils/h5BaseUrl.js new file mode 100644 index 0000000..d31b6df --- /dev/null +++ b/src/utils/h5BaseUrl.js @@ -0,0 +1,18 @@ +/** H5 站点根地址,用于构造报告分享 / 网页版链接 */ +export function resolveH5BaseUrl() { + const fromEnv = import.meta.env.VITE_H5_BASE_URL + if (fromEnv) + return String(fromEnv).replace(/\/$/, '') + + const apiBase = import.meta.env.VITE_API_BASE_URL || '' + if (apiBase.includes('/api/v1')) + return apiBase.replace(/\/api\/v1\/?$/, '') + + return 'https://www.tianyuancha.cn' +} + +/** 与 tyc-webview-v2 ShareReportButton 一致:/report/share/:linkId */ +export function buildReportShareUrl(linkId) { + const base = resolveH5BaseUrl() + return `${base}/report/share/${encodeURIComponent(linkId)}` +} diff --git a/uni-pages.d.ts b/uni-pages.d.ts index 8908d8c..351ca39 100644 --- a/uni-pages.d.ts +++ b/uni-pages.d.ts @@ -21,7 +21,8 @@ type _LocationUrl = "/pages/report/detail" | "/pages/toolbox/category" | "/pages/toolbox/index" | - "/pages/toolbox/query"; + "/pages/toolbox/query" | + "/pages/webview/index"; interface NavigateToOptions { url: _LocationUrl;