Commit 5865bf82 by chenwq1 Committed by 岑成威

fix:返回

1 parent ef8f8d04
...@@ -300,6 +300,7 @@ export default { ...@@ -300,6 +300,7 @@ export default {
}) })
} }
let currentIndex = this.imagelist.findIndex(item => item.index == 1) let currentIndex = this.imagelist.findIndex(item => item.index == 1)
if (currentIndex < 0 || !this.imagelist[currentIndex]) return
this.currentIndex = this.imagelist[currentIndex].isIndex this.currentIndex = this.imagelist[currentIndex].isIndex
}, },
changeBlock (item) { changeBlock (item) {
......
...@@ -22,6 +22,96 @@ ...@@ -22,6 +22,96 @@
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==" "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA=="
}, },
"@sentry-internal/feedback": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry-internal/feedback/-/feedback-7.120.4.tgz",
"integrity": "sha512-eSwgvTdrh03zYYaI6UVOjI9p4VmKg6+c2+CBQfRZX++6wwnCVsNv7XF7WUIpVGBAkJ0N2oapjQmCzJKGKBRWQg==",
"requires": {
"@sentry/core": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry-internal/replay-canvas": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry-internal/replay-canvas/-/replay-canvas-7.120.4.tgz",
"integrity": "sha512-2+W4CgUL1VzrPjArbTid4WhKh7HH21vREVilZdvffQPVwOEpgNTPAb69loQuTlhJVveh9hWTj2nE5UXLbLP+AA==",
"requires": {
"@sentry/core": "7.120.4",
"@sentry/replay": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry-internal/tracing": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry-internal/tracing/-/tracing-7.120.4.tgz",
"integrity": "sha512-Fz5+4XCg3akeoFK+K7g+d7HqGMjmnLoY2eJlpONJmaeT9pXY7yfUyXKZMmMajdE2LxxKJgQ2YKvSCaGVamTjHw==",
"requires": {
"@sentry/core": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry/browser": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/browser/-/browser-7.120.4.tgz",
"integrity": "sha512-ymlNtIPG6HAKzM/JXpWVGCzCNufZNADfy+O/olZuVJW5Be1DtOFyRnBvz0LeKbmxJbXb2lX/XMhuen6PXPdoQw==",
"requires": {
"@sentry-internal/feedback": "7.120.4",
"@sentry-internal/replay-canvas": "7.120.4",
"@sentry-internal/tracing": "7.120.4",
"@sentry/core": "7.120.4",
"@sentry/integrations": "7.120.4",
"@sentry/replay": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry/core": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/core/-/core-7.120.4.tgz",
"integrity": "sha512-TXu3Q5kKiq8db9OXGkWyXUbIxMMuttB5vJ031yolOl5T/B69JRyAoKuojLBjRv1XX583gS1rSSoX8YXX7ATFGA==",
"requires": {
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry/integrations": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/integrations/-/integrations-7.120.4.tgz",
"integrity": "sha512-kkBTLk053XlhDCg7OkBQTIMF4puqFibeRO3E3YiVc4PGLnocXMaVpOSCkMqAc1k1kZ09UgGi8DxfQhnFEjUkpA==",
"requires": {
"@sentry/core": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4",
"localforage": "^1.8.1"
}
},
"@sentry/replay": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/replay/-/replay-7.120.4.tgz",
"integrity": "sha512-FW8sPenNFfnO/K7sncsSTX4rIVak9j7VUiLIagJrcqZIC7d1dInFNjy8CdVJUlyz3Y3TOgIl3L3+ZpjfyMnaZg==",
"requires": {
"@sentry-internal/tracing": "7.120.4",
"@sentry/core": "7.120.4",
"@sentry/types": "7.120.4",
"@sentry/utils": "7.120.4"
}
},
"@sentry/types": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/types/-/types-7.120.4.tgz",
"integrity": "sha512-cUq2hSSe6/qrU6oZsEP4InMI5VVdD86aypE+ENrQ6eZEVLTCYm1w6XhW1NvIu3UuWh7gZec4a9J7AFpYxki88Q=="
},
"@sentry/utils": {
"version": "7.120.4",
"resolved": "https://registry.npmmirror.com/@sentry/utils/-/utils-7.120.4.tgz",
"integrity": "sha512-zCKpyDIWKHwtervNK2ZlaK8mMV7gVUijAgFeJStH+CU/imcdquizV3pFLlSQYRswG+Lbyd6CT/LGRh3IbtkCFw==",
"requires": {
"@sentry/types": "7.120.4"
}
},
"ajv": { "ajv": {
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
...@@ -177,6 +267,11 @@ ...@@ -177,6 +267,11 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
}, },
"crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"cwise-compiler": { "cwise-compiler": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/cwise-compiler/-/cwise-compiler-1.1.3.tgz", "resolved": "https://registry.npmjs.org/cwise-compiler/-/cwise-compiler-1.1.3.tgz",
...@@ -369,6 +464,15 @@ ...@@ -369,6 +464,15 @@
"minimatch": "~3.0.2" "minimatch": "~3.0.2"
} }
}, },
"glsk-toolkit": {
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/glsk-toolkit/-/glsk-toolkit-1.0.4.tgz",
"integrity": "sha512-43g3qaYtSfxzSG4dVjr0gDmD/tvVnCZuQ+ONK2mkmuqzhclsTsuSLfn6enjQZELmvWQGj45YhEU7XdQ8sTKroA==",
"requires": {
"@sentry/browser": "^7.101.1",
"crypto-js": "^4.2.0"
}
},
"graceful-fs": { "graceful-fs": {
"version": "4.2.11", "version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
...@@ -420,6 +524,11 @@ ...@@ -420,6 +524,11 @@
"sshpk": "^1.7.0" "sshpk": "^1.7.0"
} }
}, },
"immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmmirror.com/immediate/-/immediate-3.0.6.tgz",
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ=="
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
...@@ -521,6 +630,14 @@ ...@@ -521,6 +630,14 @@
"bin-pack": "~1.0.1" "bin-pack": "~1.0.1"
} }
}, },
"lie": {
"version": "3.1.1",
"resolved": "https://registry.npmmirror.com/lie/-/lie-3.1.1.tgz",
"integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==",
"requires": {
"immediate": "~3.0.5"
}
},
"loader-utils": { "loader-utils": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz",
...@@ -531,6 +648,14 @@ ...@@ -531,6 +648,14 @@
"json5": "^1.0.1" "json5": "^1.0.1"
} }
}, },
"localforage": {
"version": "1.10.0",
"resolved": "https://registry.npmmirror.com/localforage/-/localforage-1.10.0.tgz",
"integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==",
"requires": {
"lie": "3.1.1"
}
},
"lodash": { "lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
...@@ -667,6 +792,11 @@ ...@@ -667,6 +792,11 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
}, },
"pinyin.js": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/pinyin.js/-/pinyin.js-2.0.0.tgz",
"integrity": "sha512-HpljMH6dDmySP+uoll8AkejePNKzoCiSq6rQAv6Fif9Kp3PZsEwrEt+vC9oBC0O/Nf7e6kQ6Lxfv+BQQ48jbjg=="
},
"pixelsmith": { "pixelsmith": {
"version": "2.6.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/pixelsmith/-/pixelsmith-2.6.0.tgz", "resolved": "https://registry.npmjs.org/pixelsmith/-/pixelsmith-2.6.0.tgz",
...@@ -1019,6 +1149,11 @@ ...@@ -1019,6 +1149,11 @@
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}, },
"uview-ui": {
"version": "2.0.38",
"resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-2.0.38.tgz",
"integrity": "sha512-6egHDf9lXHKpG3hEjRE0vMx4+VWwKk/ReTf5x18KrIKqdvdPRqO3+B8Unh7vYYwrIxzAWIlmhZ9RJpKI/4UqPQ=="
},
"verror": { "verror": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
......
...@@ -327,7 +327,19 @@ ...@@ -327,7 +327,19 @@
{ {
"path": "pages/usedCar/inspectionReport/index", "path": "pages/usedCar/inspectionReport/index",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom",
"navigationBarTitleText": "检测报告",
"navigationBarBackgroundColor": "#f5f9ff",
"navigationBarTextStyle": "black",
"app-plus": {
"navigationStyle": "default",
"bounce": "none",
"titleNView": {
"backgroundColor": "#f5f9ff",
"titleColor": "#333333",
"autoBackButton": true
}
}
} }
} }
], ],
......
<!-- <!--
* @Author: cen * App::fullscreen="false" 时必须同时给出 webview-styles 的 top/left/width/height(px),
* @Date: 2026-04-01 16:08:12 * 否则子 webview 会缩在左上角一小块;再用 setStyle 重试对齐实测导航栏底边。
* @Description:
* @FilePath: /gl_tape/pages/usedCar/inspectionReport/index.vue * @FilePath: /gl_tape/pages/usedCar/inspectionReport/index.vue
* @LastEditTime: 2026-04-01 16:09:09
* @LastEditors: cenchengwei@foreverht.com
* 可以输入预定的版权声明、个性签名、空行等
--> -->
<template> <template>
<view class="inspection-report-webview"> <view class="inspection-page">
<web-view v-if="webviewSrc" :src="webviewSrc" @message="handleMessage"></web-view> <view class="header">
<view class="nav-bar" @click="back">
<view class="back">
<uni-icons type="left" :size="20" color="#000000"></uni-icons>
</view>
<view class="title">{{ title }}</view>
</view>
</view>
<view class="ai-window" v-if="webviewUrl">
<web-view
:src="webviewUrl"
:fullscreen="false"
:webview-styles="appWebviewStyles"
@message="handleMessage"
></web-view>
</view>
</view> </view>
</template> </template>
...@@ -20,28 +31,169 @@ export default { ...@@ -20,28 +31,169 @@ export default {
name: 'InspectionReport', name: 'InspectionReport',
data() { data() {
return { return {
webviewSrc: '' webviewUrl: '',
title: '检测报告',
measuredHeaderBottomPx: 0
} }
}, },
onLoad() { computed: {
isApp() {
return typeof plus !== 'undefined'
},
webviewTopPx() {
if (this.measuredHeaderBottomPx > 0) return this.measuredHeaderBottomPx
const sys = uni.getSystemInfoSync()
return Math.ceil(sys.windowHeight * 0.1)
},
appWebviewStyles() {
if (!this.isApp) return {}
const sys = uni.getSystemInfoSync()
const topPx = this.webviewTopPx
const h = Math.max(0, Math.floor(sys.windowHeight - topPx))
return {
top: topPx,
left: 0,
width: sys.windowWidth,
height: h
}
}
},
onLoad(options) {
if (options.pageTitle) {
this.title = options.pageTitle
}
const baseUrl = venusUsedcarH5BaseUrl const baseUrl = venusUsedcarH5BaseUrl
if (!baseUrl || typeof baseUrl !== 'string') {
uni.showToast({ title: '检测报告地址未配置', icon: 'none' })
return
}
const userInfo = uni.$storage.get('userInfo') || {} const userInfo = uni.$storage.get('userInfo') || {}
const token = userInfo.token || '' const token = userInfo.token || ''
const sep = baseUrl.includes('?') ? '&' : '?' const sep = baseUrl.includes('?') ? '&' : '?'
this.webviewSrc = token ? `${baseUrl}${sep}token=${encodeURIComponent(token)}` : baseUrl this.webviewUrl = token ? `${baseUrl}${sep}token=${encodeURIComponent(token)}` : baseUrl
},
onReady() {
this.measureHeaderThenInset()
if (this.isApp) {
this.$nextTick(() => {
;[120, 400, 800].forEach(ms => setTimeout(() => this.applyNativeWebviewInset(), ms))
})
}
},
onBackPress(options) {
if (options.from === 'backbutton') {
this.back()
return true
}
return false
}, },
methods: { methods: {
// 监听 H5 推送的消息(AUTH_TOKEN / LOGOUT) back() {
if (this.isApp) {
try {
const cur = this.$scope.$getAppWebview()
const sub = this.pickSubWebview(cur)
if (sub && typeof sub.close === 'function') {
sub.close()
}
if (cur && typeof cur.close === 'function') {
cur.close()
return
}
} catch (e) {
/* ignore */
}
}
uni.navigateBack()
},
measureHeaderThenInset() {
const run = () => {
uni.createSelectorQuery()
.in(this)
.select('.header')
.boundingClientRect(rect => {
if (!rect || rect.bottom <= 0) return
const bottom = Math.ceil(rect.bottom)
if (bottom === this.measuredHeaderBottomPx) return
this.measuredHeaderBottomPx = bottom
this.$nextTick(() => this.applyNativeWebviewInset())
})
.exec()
}
this.$nextTick(() => {
run()
setTimeout(run, 80)
setTimeout(run, 250)
})
},
pickSubWebview(currentWebview) {
try {
const kids = currentWebview.children()
if (!kids || !kids.length) return null
const candidates = []
for (let i = 0; i < kids.length; i++) {
const c = kids[i]
if (!c || typeof c.setStyle !== 'function') continue
let url = ''
try {
url = (c.getURL && c.getURL()) || ''
} catch (e) {
url = ''
}
candidates.push({ c, url })
}
if (!candidates.length) return null
const full = this.webviewUrl || ''
const hint = full.split('?')[0]
if (hint) {
const byHint = candidates.find(
({ url }) => url && (url === full || url.indexOf(hint) !== -1)
)
if (byHint) return byHint.c
}
const byHttp = candidates.find(({ url }) => url && /^https?:\/\//i.test(url))
if (byHttp) return byHttp.c
return candidates[candidates.length - 1].c
} catch (e) {
return null
}
},
applyNativeWebviewInset() {
if (!this.isApp || !this.webviewUrl) return
const sys = uni.getSystemInfoSync()
const topPx = this.webviewTopPx
const h = Math.max(0, Math.floor(sys.windowHeight - topPx))
const trySet = () => {
try {
const cur = this.$scope.$getAppWebview()
const wv = this.pickSubWebview(cur)
if (wv) {
wv.setStyle({
top: String(topPx),
left: '0',
width: String(sys.windowWidth),
height: String(h)
})
return true
}
} catch (e) {
/* ignore */
}
return false
}
const retry = (n = 0) => {
if (trySet() || n > 35) return
setTimeout(() => retry(n + 1), 50)
}
retry()
},
handleMessage(e) { handleMessage(e) {
// UniApp 里 e.detail.data 是数组,取第一项
const data = (e.detail && e.detail.data && e.detail.data[0]) || {} const data = (e.detail && e.detail.data && e.detail.data[0]) || {}
if (data.type === 'AUTH_TOKEN') { if (data.type === 'AUTH_TOKEN') {
// H5 登录后通知宿主同步 token,保存到 userInfo
const userInfo = uni.$storage.get('userInfo') || {} const userInfo = uni.$storage.get('userInfo') || {}
userInfo.token = data.token userInfo.token = data.token
uni.$storage.set('userInfo', userInfo) uni.$storage.set('userInfo', userInfo)
} else if (data.type === 'LOGOUT') { } else if (data.type === 'LOGOUT') {
// H5 退出后清除本地登录态
const userInfo = uni.$storage.get('userInfo') || {} const userInfo = uni.$storage.get('userInfo') || {}
userInfo.token = '' userInfo.token = ''
uni.$storage.set('userInfo', userInfo) uni.$storage.set('userInfo', userInfo)
...@@ -52,8 +204,52 @@ export default { ...@@ -52,8 +204,52 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.inspection-report-webview { .inspection-page {
width: 100%;
max-width: 100vw;
min-height: 100vh;
box-sizing: border-box;
}
.header {
padding-top: 30px;
background-color: #f5f9ff;
z-index: 9;
position: fixed;
top: 0;
left: 0;
height: 10%;
width: 100%;
box-sizing: border-box;
.nav-bar {
width: 100%;
height: 48px;
display: flex;
align-items: center;
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
}
.title {
color: #333333;
flex: 1;
font-size: 16px;
font-weight: 700;
text-align: center;
}
}
}
.ai-window {
position: absolute;
top: 10%;
left: 0;
width: 100%; width: 100%;
height: 100%; height: 90vh;
z-index: 1;
box-sizing: border-box;
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!