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