diff --git a/src/stores/lastImg.js b/src/stores/lastImg.js new file mode 100644 index 0000000..229bbad --- /dev/null +++ b/src/stores/lastImg.js @@ -0,0 +1,16 @@ +import { defineStore } from 'pinia' + +export const useLastImgStore = defineStore('lastImg', { + state: () => ({ + imgUrl: null, + }), + actions: { + setLastImgUrl(lastImgUrl) { + this.imgUrl = lastImgUrl + }, + + clearCache() { + this.imgUrl = null + }, + }, +}) diff --git a/src/views/Wallet/CashOut/KYC.vue b/src/views/Wallet/CashOut/KYC.vue index 2a01c03..f8c863e 100644 --- a/src/views/Wallet/CashOut/KYC.vue +++ b/src/views/Wallet/CashOut/KYC.vue @@ -195,9 +195,13 @@ import { uploadImg } from '@/api/upload.js' import { setDocumentDirection } from '@/locales/i18n' import { getWithdrawInfoList, addWithdrawInfo, updateWithdrawInfo } from '@/api/wallet' import { uploadImgFile, parseAccessOrigin } from '@/utils/uploadFiles.js' +import { useLastImgStore } from '@/stores/lastImg' +import { storeToRefs } from 'pinia' const { t, locale } = useI18n() const router = useRouter() +const lastImgStore = useLastImgStore() //获取图片缓存 +const { imgUrl: lastImgUrl } = storeToRefs(lastImgStore) //国家信息 // 监听语言变化并设置文档方向 locale.value && setDocumentDirection(locale.value) @@ -207,7 +211,6 @@ const count = computed(() => applyInfo.value.otherDescription.length) //字数 const tempFiles = ref([]) //用于提交的临时图片文件列表 // const previewUrls = ref([]) //预览图片数组 const resImgUrls = ref([]) //用于提交申请的图片数组 -const lastImgUrl = ref(null) //上一次最新添加的图片 const updateStatus = ref(false) //是否为修改 @@ -294,7 +297,7 @@ const callNativeImagePicker = async () => { const file = result.data console.log('接收到原生图片数据:', file.path) - lastImgUrl.value = file.path // 更新上一次实际选择的图片路径 + lastImgStore.setLastImgUrl(file.path) // 更新上一次实际选择的图片路径 // 生成预览图 resImgUrls.value.push(file.path) resolve() @@ -368,8 +371,6 @@ const getWithdrawInfoListData = async () => { applyInfo.value = resWithdrawInfoList.body[0] let imgList = JSON.parse(resWithdrawInfoList.body[0].passportFrontUrl) resImgUrls.value = imgList.map((item) => item) - lastImgUrl.value = - resImgUrls.value.length > 0 ? resImgUrls.value[resImgUrls.value.length - 1] : null } } catch (error) { console.error('获取提现信息列表失败:', error)