refactor(反馈表单): 简化toast提示的icon参数处理
统一将错误提示的icon参数从'error'改为'none' 移除冗余的icon变量赋值逻辑
Showing
3 changed files
with
26 additions
and
29 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-08-27 17:44:53 | 2 | * @Date: 2025-08-27 17:44:53 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-08-29 15:49:47 | 4 | + * @LastEditTime: 2025-09-01 11:37:51 |
| 5 | * @FilePath: /lls_program/src/pages/CreateFamily/index.vue | 5 | * @FilePath: /lls_program/src/pages/CreateFamily/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -280,10 +280,9 @@ const handleBlur = (index) => { | ... | @@ -280,10 +280,9 @@ const handleBlur = (index) => { |
| 280 | * 显示提示信息 | 280 | * 显示提示信息 |
| 281 | */ | 281 | */ |
| 282 | const showToast = (message, type = 'success') => { | 282 | const showToast = (message, type = 'success') => { |
| 283 | - const icon = type === 'error' ? 'error' : 'success'; | ||
| 284 | Taro.showToast({ | 283 | Taro.showToast({ |
| 285 | title: message, | 284 | title: message, |
| 286 | - icon: icon, | 285 | + icon: type, |
| 287 | duration: 2000 | 286 | duration: 2000 |
| 288 | }); | 287 | }); |
| 289 | }; | 288 | }; |
| ... | @@ -304,7 +303,7 @@ const chooseImage = () => { | ... | @@ -304,7 +303,7 @@ const chooseImage = () => { |
| 304 | filePath: tempFilePath, | 303 | filePath: tempFilePath, |
| 305 | success: function (fileInfo) { | 304 | success: function (fileInfo) { |
| 306 | if (fileInfo.size > 10 * 1024 * 1024) { | 305 | if (fileInfo.size > 10 * 1024 * 1024) { |
| 307 | - showToast('图片大小不能超过10MB', 'error'); | 306 | + showToast('图片大小不能超过10MB', 'none'); |
| 308 | return; | 307 | return; |
| 309 | } | 308 | } |
| 310 | uploadImage(tempFilePath); | 309 | uploadImage(tempFilePath); |
| ... | @@ -316,7 +315,7 @@ const chooseImage = () => { | ... | @@ -316,7 +315,7 @@ const chooseImage = () => { |
| 316 | }); | 315 | }); |
| 317 | }, | 316 | }, |
| 318 | fail: function () { | 317 | fail: function () { |
| 319 | - showToast('选择图片失败', 'error'); | 318 | + showToast('选择图片失败', 'none'); |
| 320 | } | 319 | } |
| 321 | }); | 320 | }); |
| 322 | }; | 321 | }; |
| ... | @@ -346,7 +345,7 @@ const uploadImage = (filePath) => { | ... | @@ -346,7 +345,7 @@ const uploadImage = (filePath) => { |
| 346 | familyAvatar.value = upload_data.data.src; | 345 | familyAvatar.value = upload_data.data.src; |
| 347 | showToast('上传成功', 'success'); | 346 | showToast('上传成功', 'success'); |
| 348 | } else { | 347 | } else { |
| 349 | - showToast('服务器错误,稍后重试!', 'error'); | 348 | + showToast('服务器错误,稍后重试!', 'none'); |
| 350 | } | 349 | } |
| 351 | }, | 350 | }, |
| 352 | }); | 351 | }); |
| ... | @@ -354,7 +353,7 @@ const uploadImage = (filePath) => { | ... | @@ -354,7 +353,7 @@ const uploadImage = (filePath) => { |
| 354 | fail: function (res) { | 353 | fail: function (res) { |
| 355 | Taro.hideLoading({ | 354 | Taro.hideLoading({ |
| 356 | success: () => { | 355 | success: () => { |
| 357 | - showToast('上传失败,稍后重试!', 'error'); | 356 | + showToast('上传失败,稍后重试!', 'none'); |
| 358 | } | 357 | } |
| 359 | }); | 358 | }); |
| 360 | } | 359 | } |
| ... | @@ -418,7 +417,7 @@ const validateForm = () => { | ... | @@ -418,7 +417,7 @@ const validateForm = () => { |
| 418 | validateFamilyIntro(); | 417 | validateFamilyIntro(); |
| 419 | 418 | ||
| 420 | if (!familyName.value.trim()) { | 419 | if (!familyName.value.trim()) { |
| 421 | - showToast('请输入家庭名称', 'error'); | 420 | + showToast('请输入家庭名称', 'none'); |
| 422 | return false; | 421 | return false; |
| 423 | } | 422 | } |
| 424 | 423 | ||
| ... | @@ -432,7 +431,7 @@ const validateForm = () => { | ... | @@ -432,7 +431,7 @@ const validateForm = () => { |
| 432 | } | 431 | } |
| 433 | 432 | ||
| 434 | if (!familyIntro.value.trim()) { | 433 | if (!familyIntro.value.trim()) { |
| 435 | - showToast('请输入家庭介绍', 'error'); | 434 | + showToast('请输入家庭介绍', 'none'); |
| 436 | return false; | 435 | return false; |
| 437 | } | 436 | } |
| 438 | 437 | ||
| ... | @@ -446,14 +445,14 @@ const validateForm = () => { | ... | @@ -446,14 +445,14 @@ const validateForm = () => { |
| 446 | } | 445 | } |
| 447 | 446 | ||
| 448 | if (!selectedDistrict.value) { | 447 | if (!selectedDistrict.value) { |
| 449 | - showToast('请选择区域战队', 'error'); | 448 | + showToast('请选择区域战队', 'none'); |
| 450 | return false; | 449 | return false; |
| 451 | } | 450 | } |
| 452 | 451 | ||
| 453 | // 检查家训口令是否完整填写 | 452 | // 检查家训口令是否完整填写 |
| 454 | const mottoComplete = familyMotto.value.every(char => char.trim() !== ''); | 453 | const mottoComplete = familyMotto.value.every(char => char.trim() !== ''); |
| 455 | if (!mottoComplete) { | 454 | if (!mottoComplete) { |
| 456 | - showToast('请完整填写家训口令', 'error'); | 455 | + showToast('请完整填写家训口令', 'none'); |
| 457 | return false; | 456 | return false; |
| 458 | } | 457 | } |
| 459 | 458 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-08-27 17:44:53 | 2 | * @Date: 2025-08-27 17:44:53 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-08-29 14:26:44 | 4 | + * @LastEditTime: 2025-09-01 11:39:03 |
| 5 | * @FilePath: /lls_program/src/pages/EditFamily/index.vue | 5 | * @FilePath: /lls_program/src/pages/EditFamily/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -263,10 +263,9 @@ const handleBlur = (index) => { | ... | @@ -263,10 +263,9 @@ const handleBlur = (index) => { |
| 263 | * 显示提示信息 | 263 | * 显示提示信息 |
| 264 | */ | 264 | */ |
| 265 | const showToast = (message, type = 'success') => { | 265 | const showToast = (message, type = 'success') => { |
| 266 | - const icon = type === 'error' ? 'error' : 'success'; | ||
| 267 | Taro.showToast({ | 266 | Taro.showToast({ |
| 268 | title: message, | 267 | title: message, |
| 269 | - icon: icon, | 268 | + icon: type, |
| 270 | duration: 2000 | 269 | duration: 2000 |
| 271 | }); | 270 | }); |
| 272 | }; | 271 | }; |
| ... | @@ -287,7 +286,7 @@ const chooseImage = () => { | ... | @@ -287,7 +286,7 @@ const chooseImage = () => { |
| 287 | filePath: tempFilePath, | 286 | filePath: tempFilePath, |
| 288 | success: function (fileInfo) { | 287 | success: function (fileInfo) { |
| 289 | if (fileInfo.size > 10 * 1024 * 1024) { | 288 | if (fileInfo.size > 10 * 1024 * 1024) { |
| 290 | - showToast('图片大小不能超过10MB', 'error'); | 289 | + showToast('图片大小不能超过10MB', 'none'); |
| 291 | return; | 290 | return; |
| 292 | } | 291 | } |
| 293 | uploadImage(tempFilePath); | 292 | uploadImage(tempFilePath); |
| ... | @@ -299,7 +298,7 @@ const chooseImage = () => { | ... | @@ -299,7 +298,7 @@ const chooseImage = () => { |
| 299 | }); | 298 | }); |
| 300 | }, | 299 | }, |
| 301 | fail: function () { | 300 | fail: function () { |
| 302 | - showToast('选择图片失败', 'error'); | 301 | + showToast('选择图片失败', 'none'); |
| 303 | } | 302 | } |
| 304 | }); | 303 | }); |
| 305 | }; | 304 | }; |
| ... | @@ -329,7 +328,7 @@ const uploadImage = (filePath) => { | ... | @@ -329,7 +328,7 @@ const uploadImage = (filePath) => { |
| 329 | familyAvatar.value = upload_data.data.src; | 328 | familyAvatar.value = upload_data.data.src; |
| 330 | showToast('上传成功', 'success'); | 329 | showToast('上传成功', 'success'); |
| 331 | } else { | 330 | } else { |
| 332 | - showToast('服务器错误,稍后重试!', 'error'); | 331 | + showToast('服务器错误,稍后重试!', 'none'); |
| 333 | } | 332 | } |
| 334 | }, | 333 | }, |
| 335 | }); | 334 | }); |
| ... | @@ -337,7 +336,7 @@ const uploadImage = (filePath) => { | ... | @@ -337,7 +336,7 @@ const uploadImage = (filePath) => { |
| 337 | fail: function (res) { | 336 | fail: function (res) { |
| 338 | Taro.hideLoading({ | 337 | Taro.hideLoading({ |
| 339 | success: () => { | 338 | success: () => { |
| 340 | - showToast('上传失败,稍后重试!', 'error'); | 339 | + showToast('上传失败,稍后重试!', 'none'); |
| 341 | } | 340 | } |
| 342 | }); | 341 | }); |
| 343 | } | 342 | } |
| ... | @@ -349,7 +348,7 @@ const uploadImage = (filePath) => { | ... | @@ -349,7 +348,7 @@ const uploadImage = (filePath) => { |
| 349 | */ | 348 | */ |
| 350 | const previewAvatar = () => { | 349 | const previewAvatar = () => { |
| 351 | if (!familyAvatar.value) { | 350 | if (!familyAvatar.value) { |
| 352 | - showToast('暂无图片可预览', 'error'); | 351 | + showToast('暂无图片可预览', 'none'); |
| 353 | return; | 352 | return; |
| 354 | } | 353 | } |
| 355 | previewImages.value = [{ src: familyAvatar.value }]; | 354 | previewImages.value = [{ src: familyAvatar.value }]; |
| ... | @@ -399,9 +398,9 @@ const validateForm = () => { | ... | @@ -399,9 +398,9 @@ const validateForm = () => { |
| 399 | // 先验证字数 | 398 | // 先验证字数 |
| 400 | validateFamilyName(); | 399 | validateFamilyName(); |
| 401 | validateFamilyIntro(); | 400 | validateFamilyIntro(); |
| 402 | - | 401 | + |
| 403 | if (!familyName.value.trim()) { | 402 | if (!familyName.value.trim()) { |
| 404 | - showToast('请输入家庭名称', 'error'); | 403 | + showToast('请输入家庭名称', 'none'); |
| 405 | return false; | 404 | return false; |
| 406 | } | 405 | } |
| 407 | 406 | ||
| ... | @@ -415,7 +414,7 @@ const validateForm = () => { | ... | @@ -415,7 +414,7 @@ const validateForm = () => { |
| 415 | } | 414 | } |
| 416 | 415 | ||
| 417 | if (!familyIntro.value.trim()) { | 416 | if (!familyIntro.value.trim()) { |
| 418 | - showToast('请输入家庭介绍', 'error'); | 417 | + showToast('请输入家庭介绍', 'none'); |
| 419 | return false; | 418 | return false; |
| 420 | } | 419 | } |
| 421 | 420 | ||
| ... | @@ -429,14 +428,14 @@ const validateForm = () => { | ... | @@ -429,14 +428,14 @@ const validateForm = () => { |
| 429 | } | 428 | } |
| 430 | 429 | ||
| 431 | if (!selectedDistrict.value) { | 430 | if (!selectedDistrict.value) { |
| 432 | - showToast('请选择区域战队', 'error'); | 431 | + showToast('请选择区域战队', 'none'); |
| 433 | return false; | 432 | return false; |
| 434 | } | 433 | } |
| 435 | 434 | ||
| 436 | // 检查家训口令是否完整填写 | 435 | // 检查家训口令是否完整填写 |
| 437 | const mottoComplete = familyMotto.value.every(char => char.trim() !== ''); | 436 | const mottoComplete = familyMotto.value.every(char => char.trim() !== ''); |
| 438 | if (!mottoComplete) { | 437 | if (!mottoComplete) { |
| 439 | - showToast('请完整填写家训口令', 'error'); | 438 | + showToast('请完整填写家训口令', 'none'); |
| 440 | return false; | 439 | return false; |
| 441 | } | 440 | } |
| 442 | 441 | ... | ... |
| ... | @@ -124,10 +124,9 @@ const maxImages = 3; | ... | @@ -124,10 +124,9 @@ const maxImages = 3; |
| 124 | * 显示提示信息 | 124 | * 显示提示信息 |
| 125 | */ | 125 | */ |
| 126 | const showToast = (message, type = 'success') => { | 126 | const showToast = (message, type = 'success') => { |
| 127 | - const icon = type === 'error' ? 'error' : 'success'; | ||
| 128 | Taro.showToast({ | 127 | Taro.showToast({ |
| 129 | title: message, | 128 | title: message, |
| 130 | - icon: icon, | 129 | + icon: type, |
| 131 | duration: 2000 | 130 | duration: 2000 |
| 132 | }); | 131 | }); |
| 133 | }; | 132 | }; |
| ... | @@ -242,15 +241,15 @@ const deleteImage = (index) => { | ... | @@ -242,15 +241,15 @@ const deleteImage = (index) => { |
| 242 | */ | 241 | */ |
| 243 | const submitFeedback = () => { | 242 | const submitFeedback = () => { |
| 244 | if (!feedbackText.value) { | 243 | if (!feedbackText.value) { |
| 245 | - showToast('请描述您遇到的问题或建议', 'error'); | 244 | + showToast('请描述您遇到的问题或建议', 'none'); |
| 246 | return; | 245 | return; |
| 247 | } | 246 | } |
| 248 | if (!name.value) { | 247 | if (!name.value) { |
| 249 | - showToast('请输入您的姓名', 'error'); | 248 | + showToast('请输入您的姓名', 'none'); |
| 250 | return; | 249 | return; |
| 251 | } | 250 | } |
| 252 | if (!contact.value) { | 251 | if (!contact.value) { |
| 253 | - showToast('请输入您的手机号或微信号', 'error'); | 252 | + showToast('请输入您的手机号或微信号', 'none'); |
| 254 | return; | 253 | return; |
| 255 | } | 254 | } |
| 256 | 255 | ... | ... |
-
Please register or login to post a comment