![]()
applyInfo.value.otherDescription.length) //字数
const tempFiles = ref([]) //用于提交的临时图片文件列表
-const previewUrls = ref([]) //预览图片数组
+// const previewUrls = ref([]) //预览图片数组
const resImgUrls = ref([]) //用于提交申请的图片数组
const updateStatus = ref(false) //是否为修改
@@ -227,7 +227,7 @@ const applyInfo = ref({
// 是否全填
const checkStatus = computed(() => {
- return applyInfo.value.contactNumber != '' && previewUrls.value.length > 0
+ return applyInfo.value.contactNumber != '' && resImgUrls.value.length > 0
})
// 点击图片选择按钮
@@ -245,7 +245,7 @@ const callNativeImagePicker = async () => {
console.log('调用原生图片选择器')
// 最多3张图片
- if (previewUrls.value.length >= 3) {
+ if (resImgUrls.value.length >= 3) {
throw new Error('Maximum number of images reached')
}
@@ -267,8 +267,7 @@ const callNativeImagePicker = async () => {
console.log('接收到原生图片数据:', file.path)
// 生成预览图
- previewUrls.value.push(file.path)
- tempFiles.value.push(file.path)
+ resImgUrls.value.push(file.path)
showSuccess(t('image_selected_success'))
resolve()
@@ -280,82 +279,19 @@ const callNativeImagePicker = async () => {
}
} catch (error) {
console.error('处理原生图片选择结果失败:', error)
- // showError(t('file_processing_failed'))
reject(error)
}
})
} catch (error) {
console.error('调用原生图片选择器失败:', error)
- // showError(t('native_image_picker_failed'))
reject(error)
}
})
}
-//点击文件选择按钮
-const onFileInputClick = () => {
- console.log('=== 点击文件选择按钮 ===')
-}
-
-// 处理文件选择(每次选一张)
-const handleFileChange = (e) => {
- console.log('=== 文件选择事件结束 ===')
- try {
- // 详细记录文件选择状态
- if (!e.target.files || e.target.files.length === 0) {
- console.warn('No files selected or unsupported environment')
- // 可以添加用户提示
- console.log(
- '触发条件: !e.target=',
- !e.target,
- ', !e.target.files=',
- !e.target.files,
- ', e.target.files.length === 0=',
- e.target.files?.length === 0
- )
-
- return
- }
-
- // 最多3张图片
- if (previewUrls.value.length < 3) {
- const fileList = e.target.files // 获取第一个文件对象
-
- // 检查是否有文件
- if (!fileList || fileList.length === 0) {
- console.error('未选择文件')
- return
- }
-
- // 提取第一个文件并验证
- const file = fileList[0]
- if (!file.type || !file.type.startsWith('image/')) {
- console.error(`不支持的文件类型: ${file.type || '未知'}`)
- showError(t('unsupported_file_type'))
- return
- }
-
- // 3. 通过验证后的操作(示例)
- console.log('文件名:', file.name) // defaultAvatar.png
- console.log('文件类型:', file.type) // image/png
- console.log('文件大小:', (file.size / 1024).toFixed(2), 'KB')
-
- // 生成预览图
- previewUrls.value.push(URL.createObjectURL(file))
- //临时文件列表,用于上传
- tempFiles.value.push(file)
- } else {
- showWarning(t('max_images_warning'))
- }
- } catch (error) {
- console.error('File selection error:', error)
- }
-}
-
+// 取消图片选择
const handleCancel = (index) => {
- previewUrls.value.splice(index, 1)
tempFiles.value.splice(index, 1)
- resImgUrls.value.splice(index, 1)
}
// 上传图片
@@ -374,12 +310,11 @@ const uploadImgUrl = async () => {
}
// 提交申请
-const Submit = async () => {
+const Submit = () => {
// 检查是否漏填
console.log('checkStatus.value:', checkStatus.value)
if (checkStatus.value) {
- await uploadImgUrl()
applyInfo.value.passportFrontUrl = JSON.stringify(resImgUrls.value)
if (updateStatus.value) {
console.log('更新信息:', applyInfo.value)
@@ -404,7 +339,6 @@ const getWithdrawInfoListData = async () => {
updateStatus.value = true
applyInfo.value = resWithdrawInfoList.body[0]
let imgList = JSON.parse(resWithdrawInfoList.body[0].passportFrontUrl)
- previewUrls.value = imgList.map((item) => item)
resImgUrls.value = imgList.map((item) => item)
}
} catch (error) {