test(KYC页): 测试图片上传方式
This commit is contained in:
parent
3f482aa23c
commit
8e4b4d4d6f
@ -17,17 +17,17 @@ export function uploadImgFile(renderFun) {
|
||||
|
||||
try {
|
||||
if (android()) {
|
||||
console.debug('Flutter Android WebView 检测')
|
||||
console.debug('window.app 对象:', window.app)
|
||||
console.log('Flutter Android WebView 检测')
|
||||
console.log('window.app 对象:', window.app)
|
||||
|
||||
// 检查Flutter注入的接口
|
||||
if (window.app) {
|
||||
console.debug('window.app 的所有方法:')
|
||||
console.debug(Object.keys(window.app))
|
||||
console.log('window.app 的所有方法:')
|
||||
console.log(Object.keys(window.app))
|
||||
|
||||
// 检查具体的方法
|
||||
console.debug('uploadImgFile 方法存在?', typeof window.app.uploadImgFile)
|
||||
console.debug('uploadImgFile 是函数?', typeof window.app.uploadImgFile === 'function')
|
||||
console.log('uploadImgFile 方法存在?', typeof window.app.uploadImgFile)
|
||||
console.log('uploadImgFile 是函数?', typeof window.app.uploadImgFile === 'function')
|
||||
}
|
||||
|
||||
// 等待Flutter注入完成
|
||||
@ -38,17 +38,17 @@ export function uploadImgFile(renderFun) {
|
||||
// 循环检测Flutter接口
|
||||
const checkInterface = () => {
|
||||
attempts++
|
||||
console.debug(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
console.log(`尝试第 ${attempts} 次检查Flutter接口...`)
|
||||
|
||||
if (
|
||||
window.app &&
|
||||
window.app.uploadImgFile &&
|
||||
typeof window.app.uploadImgFile === 'function'
|
||||
) {
|
||||
console.debug('Flutter接口检测成功,调用 uploadImgFile')
|
||||
console.log('Flutter接口检测成功,调用 uploadImgFile')
|
||||
try {
|
||||
const result = window.app.uploadImgFile()
|
||||
console.debug('uploadImgFile 返回结果:', result)
|
||||
console.log('uploadImgFile 返回结果:', result)
|
||||
renderFun(result)
|
||||
} catch (error) {
|
||||
console.error('调用 uploadImgFile 出错:', error)
|
||||
@ -71,13 +71,13 @@ export function uploadImgFile(renderFun) {
|
||||
if (window.app) {
|
||||
waitForFlutterInterface()
|
||||
} else {
|
||||
console.debug('等待Flutter注入window.app...')
|
||||
console.log('等待Flutter注入window.app...')
|
||||
// 监听window.app的创建
|
||||
let checkCount = 0
|
||||
const checkApp = () => {
|
||||
checkCount++
|
||||
if (window.app) {
|
||||
console.debug('检测到window.app,开始连接')
|
||||
console.log('检测到window.app,开始连接')
|
||||
waitForFlutterInterface()
|
||||
} else if (checkCount < 50) {
|
||||
setTimeout(checkApp, 100)
|
||||
@ -92,7 +92,7 @@ export function uploadImgFile(renderFun) {
|
||||
checkApp()
|
||||
}
|
||||
} else {
|
||||
console.debug('非移动设备环境')
|
||||
console.log('非移动设备环境')
|
||||
// 非APP环境,可能是浏览器调试
|
||||
console.warn('Not in APP environment, using mock data for development')
|
||||
// 开发环境可以提供模拟数据
|
||||
|
||||
@ -248,7 +248,6 @@ const callNativeImagePicker = () => {
|
||||
// 处理空数据情况
|
||||
if (!access || access === '""' || access === '') {
|
||||
console.warn('接收到空的图片数据')
|
||||
showWarning(t('no_image_selected'))
|
||||
reject(new Error('No image selected'))
|
||||
return
|
||||
}
|
||||
@ -275,18 +274,18 @@ const callNativeImagePicker = () => {
|
||||
} else {
|
||||
const errorMsg = result.error || t('file_selection_failed')
|
||||
console.error('图片选择失败:', errorMsg)
|
||||
showError(errorMsg)
|
||||
// showError(errorMsg)
|
||||
reject(new Error(errorMsg))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理原生图片选择结果失败:', error)
|
||||
showError(t('file_processing_failed'))
|
||||
// showError(t('file_processing_failed'))
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('调用原生图片选择器失败:', error)
|
||||
showError(t('native_image_picker_failed'))
|
||||
// showError(t('native_image_picker_failed'))
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user