diff --git a/activitylink/.env.development b/activitylink/.env.development
index 663e7fc..0fc2beb 100644
--- a/activitylink/.env.development
+++ b/activitylink/.env.development
@@ -1,7 +1,7 @@
VITE_ENV = 'development'
VITE_OUTPUT_DIR = 'dev'
VITE_PUBLIC_PATH = '/testBack/'
-VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
-# VITE_APP_BASE_API = 'http://localhost:12699'
+# VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
+VITE_APP_BASE_API = 'http://localhost:12699'
VITE_USE_MOCK = true
VITE_UPLOAD_URL='http://39.101.133.168:8828/hljw/api/aws/upload'
diff --git a/activitylink/src/views/zhongchou/gift/index.vue b/activitylink/src/views/zhongchou/gift/index.vue
index bc10d66..9a6b047 100644
--- a/activitylink/src/views/zhongchou/gift/index.vue
+++ b/activitylink/src/views/zhongchou/gift/index.vue
@@ -9,7 +9,8 @@
- {{ scope.$index + 1 + (pagination.pageNum - 1) * pagination.pageSize }}
+ {{ scope.$index + 1 + (pagination.pageNum - 1) * pagination.pageSize
+ }}
@@ -48,7 +49,7 @@
-
@@ -57,7 +58,7 @@
- 只能上传jpg、png格式的图片,且不超过500KB
+ 只能上传jpg、png格式的图片,且不超过1MB
@@ -86,7 +87,7 @@
-
@@ -95,7 +96,7 @@
- 只能上传jpg、png格式的图片,且不超过500KB
+ 只能上传jpg、png格式的图片,且不超过1MB
@@ -142,7 +143,7 @@ const addForm = ref({
})
const editForm = ref({
prizeName: '',
- gradeId: '',
+ gradeId: null,
imageUrl: null
})
const uploadUrl = import.meta.env.VITE_UPLOAD_URL
@@ -214,7 +215,7 @@ const submitAdd = async () => {
ElMessage.error('请上传图片');
return;
}
- if(addForm.value.prizeName.length > 15){
+ if (addForm.value.prizeName.length > 15) {
ElMessage.error('奖品名称最多输入15个字符');
return;
}
@@ -280,7 +281,7 @@ const submitEdit = async () => {
ElMessage.error('请上传图片');
return;
}
- if(editForm.value.prizeName.length > 15){
+ if (editForm.value.prizeName.length > 15) {
ElMessage.error('奖品名称最多输入15个字符');
return;
}
@@ -333,11 +334,11 @@ const customUpload = async (options) => {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
});
-
+ console.log('看看路径', import.meta.env.VITE_UPLOAD_URL)
if (response.data.code === 200 && response.data.data) {
// 传递原始文件对象和响应数据
handleUploadSuccess(response.data, options.file);
- ElMessage.success('上传成功');
+ ElMessage.success(response.data.msg || '上传成功');
} else {
ElMessage.error(response.data.msg || '上传失败');
}
@@ -354,63 +355,64 @@ const handleImageChange = (file) => {
uploadRef.value.submit();
}
const handleUploadSuccess = (response, file, fileList) => {
- if (response.code === 200) {
+ try {
if (addVisible.value) {
addForm.value.imageUrl = response.data.url;
} else if (editVisible.value) {
editForm.value.imageUrl = response.data.url;
+ } else {
+ if (addVisible.value) {
+ addForm.value.imageUrl = null;
+ } else if (editVisible.value) {
+ editForm.value.imageUrl = null;
+ }
}
- } else {
+ } catch (error) {
+ ElMessage.error(response.msg || '图片上传失败');
+ }
+}
+
+ const handleUploadError = (error) => {
+ console.error('上传失败:', error);
if (addVisible.value) {
addForm.value.imageUrl = null;
} else if (editVisible.value) {
editForm.value.imageUrl = null;
}
- ElMessage.error(response.message || '图片上传失败');
+ ElMessage.error('图片上传失败,请重试');
}
-}
-const handleUploadError = (error) => {
- console.error('上传失败:', error);
- if (addVisible.value) {
- addForm.value.imageUrl = null;
- } else if (editVisible.value) {
- editForm.value.imageUrl = null;
- }
- ElMessage.error('图片上传失败,请重试');
-}
+ const beforeUpload = (file) => {
+ const isJPG = file.type === 'image/jpeg';
+ const isPNG = file.type === 'image/png';
+ const isLt1 = file.size / 1024 < 1024;
-const beforeUpload = (file) => {
- const isJPG = file.type === 'image/jpeg';
- const isPNG = file.type === 'image/png';
- const isLt500K = file.size / 1024 < 500;
-
- if (!isJPG && !isPNG) {
- ElMessage.error('上传图片只能是 JPG 或 PNG 格式');
- return false;
- }
- if (!isLt500K) {
- ElMessage.error('上传图片大小不能超过 500KB');
- return false;
+ if (!isJPG && !isPNG) {
+ ElMessage.error('上传图片只能是 JPG 或 PNG 格式');
+ return false;
+ }
+ if (!isLt1) {
+ ElMessage.error('上传图片大小不能超过1MB');
+ return false;
+ }
+ return true;
}
- return true;
-}
-const handleSizeChange = (val) => {
- pagination.value.pageSize = val
- pagination.value.pageNum = 1
- getPrizes()
-}
+ const handleSizeChange = (val) => {
+ pagination.value.pageSize = val
+ pagination.value.pageNum = 1
+ getPrizes()
+ }
-const handleCurrentChange = (val) => {
- pagination.value.pageNum = val
- getPrizes()
-}
+ const handleCurrentChange = (val) => {
+ pagination.value.pageNum = val
+ getPrizes()
+ }
-onMounted(() => {
- getPrizes()
- getGradeNames()
-})
+ onMounted(() => {
+ getPrizes()
+ getGradeNames()
+ })