优化公会创建-图片上传功能,增加loading和提示
This commit is contained in:
@@ -130,7 +130,7 @@ function getToken(file, type) {
|
|||||||
StartTime: res.data.startTime,
|
StartTime: res.data.startTime,
|
||||||
ExpiredTime: res.data.expireTime,
|
ExpiredTime: res.data.expireTime,
|
||||||
});
|
});
|
||||||
console.log(cos);
|
// console.log(cos,'------');
|
||||||
var customDomain = res.data.customDomain;
|
var customDomain = res.data.customDomain;
|
||||||
cos.uploadFile({
|
cos.uploadFile({
|
||||||
Bucket: res.data.bucket, /* 填写自己的 bucket,必须字段 */
|
Bucket: res.data.bucket, /* 填写自己的 bucket,必须字段 */
|
||||||
@@ -142,13 +142,37 @@ function getToken(file, type) {
|
|||||||
console.log(JSON.stringify(progressData));
|
console.log(JSON.stringify(progressData));
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (type == 1) {//背景
|
// console.log(res,'-------res');
|
||||||
$('.info .agencyAvatar').attr('src', `${customDomain}/${file.name}`);
|
const imageUrl = `${customDomain}/${file.name}`
|
||||||
} else if (type == 2) {//背景
|
// 创建一个新的 Image 对象来加载图片
|
||||||
$('.info .agentIDCardImg').attr('src', `${customDomain}/${file.name}`);
|
const img = new Image();
|
||||||
} else {
|
img.src = imageUrl;
|
||||||
$('.inviterInfo .inviterPicImg').attr('src', `${customDomain}/${file.name}`);
|
// 监听图片加载完成事件
|
||||||
}
|
img.onload = () => {
|
||||||
|
if (type == 1) { // 背景
|
||||||
|
$('.info .agencyAvatar').attr('src', imageUrl);
|
||||||
|
} else if (type == 2) { // 身份证
|
||||||
|
$('.info .agentIDCardImg').attr('src', imageUrl);
|
||||||
|
} else { // 邀请人图片
|
||||||
|
$('.inviterInfo .inviterPicImg').attr('src', imageUrl);
|
||||||
|
}
|
||||||
|
hideLoading(layerIndex);
|
||||||
|
};
|
||||||
|
// 监听图片加载失败事件
|
||||||
|
img.onerror = () => {
|
||||||
|
console.error('图片加载失败:', imageUrl);
|
||||||
|
hideLoading(layerIndex);
|
||||||
|
toastMsg(langReplace(localLang.createGuild.imgerr));
|
||||||
|
};
|
||||||
|
|
||||||
|
// if (type == 1) {//背景
|
||||||
|
// $('.info .agencyAvatar').attr('src', `${customDomain}/${file.name}`);
|
||||||
|
// } else if (type == 2) {//背景
|
||||||
|
// $('.info .agentIDCardImg').attr('src', `${customDomain}/${file.name}`);
|
||||||
|
// } else {
|
||||||
|
// $('.inviterInfo .inviterPicImg').attr('src', `${customDomain}/${file.name}`);
|
||||||
|
// }
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log('上传失败', err);
|
console.log('上传失败', err);
|
||||||
hideLoading(layerIndex)
|
hideLoading(layerIndex)
|
||||||
@@ -156,8 +180,8 @@ function getToken(file, type) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toastMsg(res.message)
|
toastMsg(res.message)
|
||||||
}
|
|
||||||
hideLoading(layerIndex)
|
hideLoading(layerIndex)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error(err) {
|
error(err) {
|
||||||
hideLoading(layerIndex)
|
hideLoading(layerIndex)
|
||||||
|
@@ -108,6 +108,8 @@ langAr = {
|
|||||||
text10: `تأكيد`,
|
text10: `تأكيد`,
|
||||||
placeholder: `يرجى الإدخال`,
|
placeholder: `يرجى الإدخال`,
|
||||||
null: `لا يمكن ترك الحقول الإلزامية فارغة`,
|
null: `لا يمكن ترك الحقول الإلزامية فارغة`,
|
||||||
|
imgerr:'فشل تحميل الصورة ، يرجى المحاولة مرة أخرى'
|
||||||
|
|
||||||
},
|
},
|
||||||
guildInfoSet: {
|
guildInfoSet: {
|
||||||
text1: `إعدادات معلومات الوكالة `,
|
text1: `إعدادات معلومات الوكالة `,
|
||||||
|
@@ -108,6 +108,8 @@ langEn = {
|
|||||||
text10: `Confirm`,
|
text10: `Confirm`,
|
||||||
placeholder: `Please enter`,
|
placeholder: `Please enter`,
|
||||||
null: `Mandatory fields cannot be blank`,
|
null: `Mandatory fields cannot be blank`,
|
||||||
|
imgerr:'Image upload failed, please try again'
|
||||||
|
|
||||||
},
|
},
|
||||||
guildInfoSet: {
|
guildInfoSet: {
|
||||||
text1: `Agency Settings`,
|
text1: `Agency Settings`,
|
||||||
|
@@ -107,6 +107,8 @@ langTr = {
|
|||||||
text10: `Onayla`,
|
text10: `Onayla`,
|
||||||
placeholder: `Lütfen girin`,
|
placeholder: `Lütfen girin`,
|
||||||
null: `Zorunlu alanlar boş bırakılamaz`,
|
null: `Zorunlu alanlar boş bırakılamaz`,
|
||||||
|
imgerr:'Resim yükleme başarısız oldu, lütfen tekrar deneyin'
|
||||||
|
|
||||||
},
|
},
|
||||||
guildInfoSet: {
|
guildInfoSet: {
|
||||||
text1: `Ajans Ayarları`,
|
text1: `Ajans Ayarları`,
|
||||||
|
@@ -109,6 +109,7 @@ langZh = {
|
|||||||
text10: `確認`,
|
text10: `確認`,
|
||||||
placeholder: `請輸入`,
|
placeholder: `請輸入`,
|
||||||
null: `必填項不能為空`,
|
null: `必填項不能為空`,
|
||||||
|
imgerr:'圖片上傳失敗,請重試'
|
||||||
},
|
},
|
||||||
guildInfoSet: {
|
guildInfoSet: {
|
||||||
text1: `公會信息設置`,
|
text1: `公會信息設置`,
|
||||||
|
Reference in New Issue
Block a user