|
|
@@ -0,0 +1,133 @@
|
|
|
+<template>
|
|
|
+ <view class="page">
|
|
|
+ <view v-if="webViewUrl" class="webview-wrap">
|
|
|
+ <web-view :src="webViewUrl"></web-view>
|
|
|
+ </view>
|
|
|
+ <view v-else class="panel">
|
|
|
+ <text class="title">AI 视频检测</text>
|
|
|
+ <text class="desc">{{ failed ? '检测页加载失败,请按下方提示操作后返回查看报告。' : '正在获取检测页面,请稍候…' }}</text>
|
|
|
+ <text class="hint">若 web-view 受限或加载失败,请在浏览器打开检测链接完成采集,返回后即可查看报告。</text>
|
|
|
+ <view class="btn" @click="openInBrowser"><text class="btn-text">在浏览器打开</text></view>
|
|
|
+ <view class="btn btn-ghost" @click="goBack"><text class="btn-text">返回</text></view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { aiyunyiGetPath } from '@/utils/api.js'
|
|
|
+
|
|
|
+// 同一组生命周期处理函数同时挂到根选项(uni-app 页面生命周期)和 methods
|
|
|
+// (页面内可显式调用;契约单测的轻量实例也只从 methods 取函数)。
|
|
|
+function onLoad(options) {
|
|
|
+ this.detectionPackageItemId = Number((options && options.detectionPackageItemId) || 0)
|
|
|
+ this.detectionReportUserId = Number((options && options.detectionReportUserId) || 0)
|
|
|
+ this.loadDetectPath()
|
|
|
+ // 首次 onShow 由 onLoad 负责加载,跳过;从 web-view 返回时再刷新报告。
|
|
|
+ this._onLoadFired = true
|
|
|
+}
|
|
|
+
|
|
|
+function onShow() {
|
|
|
+ if (this._onLoadFired) {
|
|
|
+ this._onLoadFired = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.showReportAfterDetect()
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ onLoad: onLoad,
|
|
|
+ onShow: onShow,
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ webViewUrl: '',
|
|
|
+ detectionPackageItemId: 0,
|
|
|
+ detectionReportUserId: 0,
|
|
|
+ failed: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onLoad: onLoad,
|
|
|
+ onShow: onShow,
|
|
|
+ // §3.4 第 8/9 步:经本系统代理取 H5 路径,两个必填 ID 原样透传(§A.5)。
|
|
|
+ loadDetectPath() {
|
|
|
+ var self = this
|
|
|
+ aiyunyiGetPath({
|
|
|
+ detectionPackageItemId: this.detectionPackageItemId,
|
|
|
+ detectionReportUserId: this.detectionReportUserId
|
|
|
+ }).then(function(res) {
|
|
|
+ var data = res && res.data
|
|
|
+ var path = ''
|
|
|
+ if (typeof data === 'string') {
|
|
|
+ path = data
|
|
|
+ } else if (data && typeof data === 'object') {
|
|
|
+ path = data.path || ''
|
|
|
+ }
|
|
|
+ path = typeof path === 'string' ? path.trim() : ''
|
|
|
+ if (!path) {
|
|
|
+ self.onPathFailed()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.webViewUrl = path
|
|
|
+ self.failed = false
|
|
|
+ }).catch(function() {
|
|
|
+ self.onPathFailed()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // §4.5 错误归一 / §7 R7:不白屏,给出「在浏览器打开」降级提示。
|
|
|
+ onPathFailed() {
|
|
|
+ this.webViewUrl = ''
|
|
|
+ this.failed = true
|
|
|
+ uni.showModal({
|
|
|
+ title: '检测页加载失败',
|
|
|
+ content: '视频检测页面暂不可用,请在浏览器打开检测链接完成采集,或稍后重试。',
|
|
|
+ showCancel: true,
|
|
|
+ confirmText: '复制链接',
|
|
|
+ cancelText: '返回',
|
|
|
+ success: (res) => {
|
|
|
+ if (res && res.confirm) this.openInBrowser()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 降级入口:复制 H5 链接供用户在浏览器打开(App 端可直接唤起系统浏览器)。
|
|
|
+ openInBrowser() {
|
|
|
+ if (!this.webViewUrl) {
|
|
|
+ uni.showToast({ title: '暂无检测链接,请在浏览器打开后重试', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plus.runtime.openURL(this.webViewUrl)
|
|
|
+ // #endif
|
|
|
+ uni.setClipboardData({
|
|
|
+ data: this.webViewUrl,
|
|
|
+ success: () => {
|
|
|
+ uni.showToast({ title: '链接已复制,请在浏览器打开', icon: 'none' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // §8 验收第 3 条 / §3.4 第 10/11 步:web-view 返回后展示报告。
|
|
|
+ showReportAfterDetect() {
|
|
|
+ if (!this.webViewUrl && !this.failed) return
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/health/ai-report-detail?detectionPackageItemId=' + this.detectionPackageItemId
|
|
|
+ + '&detectionReportUserId=' + this.detectionReportUserId
|
|
|
+ })
|
|
|
+ },
|
|
|
+ goBack() {
|
|
|
+ uni.navigateBack({ delta: 1 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.page { min-height: 100vh; background: #f7f8fa; box-sizing: border-box; }
|
|
|
+.webview-wrap { width: 100%; height: 100vh; }
|
|
|
+.panel { padding: 32rpx; }
|
|
|
+.title { display: block; font-size: 36rpx; font-weight: 600; color: #1a1a1a; margin: 24rpx 0; }
|
|
|
+.desc { display: block; font-size: 28rpx; color: #4b5563; line-height: 1.6; margin-bottom: 16rpx; }
|
|
|
+.hint { display: block; font-size: 26rpx; color: #6b7280; line-height: 1.6; margin-bottom: 40rpx; }
|
|
|
+.btn { background: #2563eb; border-radius: 12rpx; padding: 24rpx; text-align: center; margin-bottom: 20rpx; }
|
|
|
+.btn-ghost { background: #f3f4f6; }
|
|
|
+.btn-text { font-size: 28rpx; color: #ffffff; }
|
|
|
+.btn-ghost .btn-text { color: #374151; }
|
|
|
+</style>
|