hookehuyr

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

修复上传图片后useDidShow重复触发的问题,通过添加isUploadingImage标记控制
将"用户名称"表单标签更新为更准确的"身份证姓名"
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-13 10:45:26 4 + * @LastEditTime: 2025-08-13 16:22:54
5 * @FilePath: /jgdl/src/pages/collectionSettings/index.vue 5 * @FilePath: /jgdl/src/pages/collectionSettings/index.vue
6 * @Description: 收款设置 6 * @Description: 收款设置
7 --> 7 -->
...@@ -118,8 +118,8 @@ ...@@ -118,8 +118,8 @@
118 118
119 <view class="form-content"> 119 <view class="form-content">
120 <view class="form-item"> 120 <view class="form-item">
121 - <text class="form-label"><text class="required-mark">*</text>用户名称</text> 121 + <text class="form-label"><text class="required-mark">*</text>身份证姓名</text>
122 - <input v-model="tempIdentityInfo.userName" placeholder="请输入真实姓名" class="form-input native-input" /> 122 + <input v-model="tempIdentityInfo.userName" placeholder="请输入身份证姓名" class="form-input native-input" />
123 </view> 123 </view>
124 124
125 <view class="form-item"> 125 <view class="form-item">
......
...@@ -419,8 +419,10 @@ const conditionPickerVisible = ref(false) ...@@ -419,8 +419,10 @@ const conditionPickerVisible = ref(false)
419 const brakeWearPickerVisible = ref(false) 419 const brakeWearPickerVisible = ref(false)
420 const tireWearPickerVisible = ref(false) 420 const tireWearPickerVisible = ref(false)
421 421
422 -// 收款说明弹框显示状态 422 +// 收款协议弹框显示状态
423 const paymentAgreementVisible = ref(false) 423 const paymentAgreementVisible = ref(false)
424 +// 标记是否是上传图片后触发的useDidShow
425 +const isUploadingImage = ref(false)
424 426
425 // 新的品牌型号选择器状态 427 // 新的品牌型号选择器状态
426 // 品牌型号选择器组件引用 428 // 品牌型号选择器组件引用
...@@ -483,6 +485,9 @@ const wearLevelOptions = ref([ ...@@ -483,6 +485,9 @@ const wearLevelOptions = ref([
483 * @param {String} type - 图片类型 (front/left/right/other) 485 * @param {String} type - 图片类型 (front/left/right/other)
484 */ 486 */
485 const triggerUpload = (type) => { 487 const triggerUpload = (type) => {
488 + // 设置上传标记
489 + isUploadingImage.value = true
490 +
486 Taro.chooseImage({ 491 Taro.chooseImage({
487 count: 1, 492 count: 1,
488 sizeType: ['compressed'], 493 sizeType: ['compressed'],
...@@ -492,6 +497,8 @@ const triggerUpload = (type) => { ...@@ -492,6 +497,8 @@ const triggerUpload = (type) => {
492 uploadImage(tempFilePath, type) 497 uploadImage(tempFilePath, type)
493 }, 498 },
494 fail: function () { 499 fail: function () {
500 + // 上传失败时重置标记
501 + isUploadingImage.value = false
495 Taro.showToast({ 502 Taro.showToast({
496 title: '选择图片失败', 503 title: '选择图片失败',
497 icon: 'none' 504 icon: 'none'
...@@ -524,6 +531,9 @@ const uploadImage = (filePath, type) => { ...@@ -524,6 +531,9 @@ const uploadImage = (filePath, type) => {
524 let upload_data = JSON.parse(res.data); 531 let upload_data = JSON.parse(res.data);
525 Taro.hideLoading({ 532 Taro.hideLoading({
526 success: () => { 533 success: () => {
534 + // 重置上传标记
535 + isUploadingImage.value = false
536 +
527 if (res.statusCode === 200) { 537 if (res.statusCode === 200) {
528 uploadedImages[type] = upload_data.data.src; 538 uploadedImages[type] = upload_data.data.src;
529 // 同时更新formData中对应的照片字段 539 // 同时更新formData中对应的照片字段
...@@ -545,6 +555,9 @@ const uploadImage = (filePath, type) => { ...@@ -545,6 +555,9 @@ const uploadImage = (filePath, type) => {
545 fail: function () { 555 fail: function () {
546 Taro.hideLoading({ 556 Taro.hideLoading({
547 success: () => { 557 success: () => {
558 + // 重置上传标记
559 + isUploadingImage.value = false
560 +
548 Taro.showToast({ 561 Taro.showToast({
549 icon: 'error', 562 icon: 'error',
550 title: '上传失败,稍后重试!', 563 title: '上传失败,稍后重试!',
...@@ -1214,6 +1227,11 @@ onMounted(async () => { ...@@ -1214,6 +1227,11 @@ onMounted(async () => {
1214 1227
1215 // 页面显示时执行(包括首次加载和从其他页面返回) 1228 // 页面显示时执行(包括首次加载和从其他页面返回)
1216 useDidShow(async () => { 1229 useDidShow(async () => {
1230 + // 如果是上传图片后触发的useDidShow,则跳过
1231 + if (isUploadingImage.value) {
1232 + return
1233 + }
1234 +
1217 const hasPermission = await checkUserPermission() 1235 const hasPermission = await checkUserPermission()
1218 1236
1219 if (!hasPermission) { 1237 if (!hasPermission) {
......