hookehuyr

refactor(反馈表单): 简化toast提示的icon参数处理

统一将错误提示的icon参数从'error'改为'none'
移除冗余的icon变量赋值逻辑
<!--
* @Date: 2025-08-27 17:44:53
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-29 15:49:47
* @LastEditTime: 2025-09-01 11:37:51
* @FilePath: /lls_program/src/pages/CreateFamily/index.vue
* @Description: 文件描述
-->
......@@ -280,10 +280,9 @@ const handleBlur = (index) => {
* 显示提示信息
*/
const showToast = (message, type = 'success') => {
const icon = type === 'error' ? 'error' : 'success';
Taro.showToast({
title: message,
icon: icon,
icon: type,
duration: 2000
});
};
......@@ -304,7 +303,7 @@ const chooseImage = () => {
filePath: tempFilePath,
success: function (fileInfo) {
if (fileInfo.size > 10 * 1024 * 1024) {
showToast('图片大小不能超过10MB', 'error');
showToast('图片大小不能超过10MB', 'none');
return;
}
uploadImage(tempFilePath);
......@@ -316,7 +315,7 @@ const chooseImage = () => {
});
},
fail: function () {
showToast('选择图片失败', 'error');
showToast('选择图片失败', 'none');
}
});
};
......@@ -346,7 +345,7 @@ const uploadImage = (filePath) => {
familyAvatar.value = upload_data.data.src;
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'error');
showToast('服务器错误,稍后重试!', 'none');
}
},
});
......@@ -354,7 +353,7 @@ const uploadImage = (filePath) => {
fail: function (res) {
Taro.hideLoading({
success: () => {
showToast('上传失败,稍后重试!', 'error');
showToast('上传失败,稍后重试!', 'none');
}
});
}
......@@ -418,7 +417,7 @@ const validateForm = () => {
validateFamilyIntro();
if (!familyName.value.trim()) {
showToast('请输入家庭名称', 'error');
showToast('请输入家庭名称', 'none');
return false;
}
......@@ -432,7 +431,7 @@ const validateForm = () => {
}
if (!familyIntro.value.trim()) {
showToast('请输入家庭介绍', 'error');
showToast('请输入家庭介绍', 'none');
return false;
}
......@@ -446,14 +445,14 @@ const validateForm = () => {
}
if (!selectedDistrict.value) {
showToast('请选择区域战队', 'error');
showToast('请选择区域战队', 'none');
return false;
}
// 检查家训口令是否完整填写
const mottoComplete = familyMotto.value.every(char => char.trim() !== '');
if (!mottoComplete) {
showToast('请完整填写家训口令', 'error');
showToast('请完整填写家训口令', 'none');
return false;
}
......
<!--
* @Date: 2025-08-27 17:44:53
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-29 14:26:44
* @LastEditTime: 2025-09-01 11:39:03
* @FilePath: /lls_program/src/pages/EditFamily/index.vue
* @Description: 文件描述
-->
......@@ -263,10 +263,9 @@ const handleBlur = (index) => {
* 显示提示信息
*/
const showToast = (message, type = 'success') => {
const icon = type === 'error' ? 'error' : 'success';
Taro.showToast({
title: message,
icon: icon,
icon: type,
duration: 2000
});
};
......@@ -287,7 +286,7 @@ const chooseImage = () => {
filePath: tempFilePath,
success: function (fileInfo) {
if (fileInfo.size > 10 * 1024 * 1024) {
showToast('图片大小不能超过10MB', 'error');
showToast('图片大小不能超过10MB', 'none');
return;
}
uploadImage(tempFilePath);
......@@ -299,7 +298,7 @@ const chooseImage = () => {
});
},
fail: function () {
showToast('选择图片失败', 'error');
showToast('选择图片失败', 'none');
}
});
};
......@@ -329,7 +328,7 @@ const uploadImage = (filePath) => {
familyAvatar.value = upload_data.data.src;
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'error');
showToast('服务器错误,稍后重试!', 'none');
}
},
});
......@@ -337,7 +336,7 @@ const uploadImage = (filePath) => {
fail: function (res) {
Taro.hideLoading({
success: () => {
showToast('上传失败,稍后重试!', 'error');
showToast('上传失败,稍后重试!', 'none');
}
});
}
......@@ -349,7 +348,7 @@ const uploadImage = (filePath) => {
*/
const previewAvatar = () => {
if (!familyAvatar.value) {
showToast('暂无图片可预览', 'error');
showToast('暂无图片可预览', 'none');
return;
}
previewImages.value = [{ src: familyAvatar.value }];
......@@ -401,7 +400,7 @@ const validateForm = () => {
validateFamilyIntro();
if (!familyName.value.trim()) {
showToast('请输入家庭名称', 'error');
showToast('请输入家庭名称', 'none');
return false;
}
......@@ -415,7 +414,7 @@ const validateForm = () => {
}
if (!familyIntro.value.trim()) {
showToast('请输入家庭介绍', 'error');
showToast('请输入家庭介绍', 'none');
return false;
}
......@@ -429,14 +428,14 @@ const validateForm = () => {
}
if (!selectedDistrict.value) {
showToast('请选择区域战队', 'error');
showToast('请选择区域战队', 'none');
return false;
}
// 检查家训口令是否完整填写
const mottoComplete = familyMotto.value.every(char => char.trim() !== '');
if (!mottoComplete) {
showToast('请完整填写家训口令', 'error');
showToast('请完整填写家训口令', 'none');
return false;
}
......
......@@ -124,10 +124,9 @@ const maxImages = 3;
* 显示提示信息
*/
const showToast = (message, type = 'success') => {
const icon = type === 'error' ? 'error' : 'success';
Taro.showToast({
title: message,
icon: icon,
icon: type,
duration: 2000
});
};
......@@ -242,15 +241,15 @@ const deleteImage = (index) => {
*/
const submitFeedback = () => {
if (!feedbackText.value) {
showToast('请描述您遇到的问题或建议', 'error');
showToast('请描述您遇到的问题或建议', 'none');
return;
}
if (!name.value) {
showToast('请输入您的姓名', 'error');
showToast('请输入您的姓名', 'none');
return;
}
if (!contact.value) {
showToast('请输入您的手机号或微信号', 'error');
showToast('请输入您的手机号或微信号', 'none');
return;
}
......