hookehuyr

fix: 修复上传图片后页面重复刷新问题并更新表单标签

修复上传图片后useDidShow重复触发的问题,通过添加isUploadingImage标记控制
将"用户名称"表单标签更新为更准确的"身份证姓名"
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-13 10:45:26
* @LastEditTime: 2025-08-13 16:22:54
* @FilePath: /jgdl/src/pages/collectionSettings/index.vue
* @Description: 收款设置
-->
......@@ -118,8 +118,8 @@
<view class="form-content">
<view class="form-item">
<text class="form-label"><text class="required-mark">*</text>用户名称</text>
<input v-model="tempIdentityInfo.userName" placeholder="请输入真实姓名" class="form-input native-input" />
<text class="form-label"><text class="required-mark">*</text>身份证姓名</text>
<input v-model="tempIdentityInfo.userName" placeholder="请输入身份证姓名" class="form-input native-input" />
</view>
<view class="form-item">
......
......@@ -419,8 +419,10 @@ const conditionPickerVisible = ref(false)
const brakeWearPickerVisible = ref(false)
const tireWearPickerVisible = ref(false)
// 收款说明弹框显示状态
// 收款协议弹框显示状态
const paymentAgreementVisible = ref(false)
// 标记是否是上传图片后触发的useDidShow
const isUploadingImage = ref(false)
// 新的品牌型号选择器状态
// 品牌型号选择器组件引用
......@@ -483,6 +485,9 @@ const wearLevelOptions = ref([
* @param {String} type - 图片类型 (front/left/right/other)
*/
const triggerUpload = (type) => {
// 设置上传标记
isUploadingImage.value = true
Taro.chooseImage({
count: 1,
sizeType: ['compressed'],
......@@ -492,6 +497,8 @@ const triggerUpload = (type) => {
uploadImage(tempFilePath, type)
},
fail: function () {
// 上传失败时重置标记
isUploadingImage.value = false
Taro.showToast({
title: '选择图片失败',
icon: 'none'
......@@ -524,6 +531,9 @@ const uploadImage = (filePath, type) => {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
// 重置上传标记
isUploadingImage.value = false
if (res.statusCode === 200) {
uploadedImages[type] = upload_data.data.src;
// 同时更新formData中对应的照片字段
......@@ -545,6 +555,9 @@ const uploadImage = (filePath, type) => {
fail: function () {
Taro.hideLoading({
success: () => {
// 重置上传标记
isUploadingImage.value = false
Taro.showToast({
icon: 'error',
title: '上传失败,稍后重试!',
......@@ -1214,6 +1227,11 @@ onMounted(async () => {
// 页面显示时执行(包括首次加载和从其他页面返回)
useDidShow(async () => {
// 如果是上传图片后触发的useDidShow,则跳过
if (isUploadingImage.value) {
return
}
const hasPermission = await checkUserPermission()
if (!hasPermission) {
......