From c865a8783a861a4fbfeee485a3c75fde3675f9f6 Mon Sep 17 00:00:00 2001
From: hzj <1304805162@qq.com>
Date: Wed, 12 Nov 2025 16:46:32 +0800
Subject: [PATCH] =?UTF-8?q?test(KYC=E9=A1=B5):=20=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/uploadFiles.js | 121 +++++++++++++++++++++++++++++++
src/views/Wallet/CashOut/KYC.vue | 102 ++++++++++++++++++++------
2 files changed, 202 insertions(+), 21 deletions(-)
create mode 100644 src/utils/uploadFiles.js
diff --git a/src/utils/uploadFiles.js b/src/utils/uploadFiles.js
new file mode 100644
index 0000000..53abe8d
--- /dev/null
+++ b/src/utils/uploadFiles.js
@@ -0,0 +1,121 @@
+/**
+ * 上传图片
+ * @param {Function} renderFun 回调函数,接收APP传递的access参数
+ */
+export function uploadImgFile(renderFun) {
+ window.renderData = renderFun
+ // 兼容历史版本
+ window.getIosAccessOriginParam = renderFun
+
+ try {
+ if (android()) {
+ console.debug('Flutter Android WebView 检测')
+ console.debug('window.app 对象:', window.app)
+
+ // 检查Flutter注入的接口
+ if (window.app) {
+ console.debug('window.app 的所有方法:')
+ console.debug(Object.keys(window.app))
+
+ // 检查具体的方法
+ console.debug('uploadImgFile 方法存在?', typeof window.app.uploadImgFile)
+ console.debug('uploadImgFile 是函数?', typeof window.app.uploadImgFile === 'function')
+ }
+
+ // 等待Flutter注入完成
+ const waitForFlutterInterface = () => {
+ let attempts = 0
+ const maxAttempts = 50 // 最多等待5秒
+
+ // 循环检测Flutter接口
+ const checkInterface = () => {
+ attempts++
+ console.debug(`尝试第 ${attempts} 次检查Flutter接口...`)
+
+ if (
+ window.app &&
+ window.app.uploadImgFile &&
+ typeof window.app.uploadImgFile === 'function'
+ ) {
+ console.debug('Flutter接口检测成功,调用 uploadImgFile')
+ try {
+ const result = window.app.uploadImgFile()
+ console.debug('uploadImgFile 返回结果:', result)
+ renderFun(result)
+ } catch (error) {
+ console.error('调用 uploadImgFile 出错:', error)
+ }
+ } else if (attempts < maxAttempts) {
+ // 继续等待
+ setTimeout(checkInterface, 100)
+ } else {
+ console.error('Flutter接口注入超时,使用默认数据')
+ // 使用默认的开发数据
+ const mockAccess = JSON.stringify('')
+ renderFun(mockAccess)
+ }
+ }
+
+ checkInterface()
+ }
+
+ // 如果window.app已存在,直接检查,否则等待
+ if (window.app) {
+ waitForFlutterInterface()
+ } else {
+ console.debug('等待Flutter注入window.app...')
+ // 监听window.app的创建
+ let checkCount = 0
+ const checkApp = () => {
+ checkCount++
+ if (window.app) {
+ console.debug('检测到window.app,开始连接')
+ waitForFlutterInterface()
+ } else if (checkCount < 50) {
+ setTimeout(checkApp, 100)
+ } else {
+ console.error('等待window.app超时')
+ // 手动通知Flutter注入接口
+ if (window.FlutterApp && window.FlutterApp.postMessage) {
+ window.FlutterApp.postMessage('uploadImgFile')
+ }
+ }
+ }
+ checkApp()
+ }
+ } else {
+ console.debug('非移动设备环境')
+ // 非APP环境,可能是浏览器调试
+ console.warn('Not in APP environment, using mock data for development')
+ // 开发环境可以提供模拟数据
+ if (process.env.NODE_ENV === 'development') {
+ const mockAccess = ''
+ setTimeout(() => renderFun(mockAccess), 100)
+ }
+ }
+ } catch (error) {
+ console.error('Failed to connect to APP:', error)
+ }
+}
+
+/**
+ * 解析APP传递的访问参数
+ * @param {string} access JSON字符串格式的访问参数
+ * @returns {Object} 解析后的参数对象
+ */
+export function parseAccessOrigin(access) {
+ try {
+ const accessParam = JSON.parse(access)
+ return {
+ success: true,
+ data: accessParam,
+ }
+ } catch (error) {
+ console.error('Failed to parse access origin:', error)
+ return {
+ success: false,
+ error: 'accessOrigin Error.',
+ data: null,
+ }
+ }
+}
diff --git a/src/views/Wallet/CashOut/KYC.vue b/src/views/Wallet/CashOut/KYC.vue
index 85b3d4b..45f86b2 100644
--- a/src/views/Wallet/CashOut/KYC.vue
+++ b/src/views/Wallet/CashOut/KYC.vue
@@ -61,7 +61,22 @@
alt=""
style="display: block; width: 15vw; aspect-ratio: 1/1; object-fit: cover"
/>
+
-
-
-