mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
feat: 添加移动端提示可能要发送的图片
This commit is contained in:
parent
21aa4f7b2b
commit
1f0ab02702
42
resources/assets/js/functions/eeui.js
vendored
42
resources/assets/js/functions/eeui.js
vendored
@ -289,6 +289,10 @@
|
||||
if (expiration > 0 && (result.created + expiration) < $A.dayjs().unix()) {
|
||||
return reject({msg: "photo expired"});
|
||||
}
|
||||
if ($A.__latestPhotoCreated && $A.__latestPhotoCreated === result.created) {
|
||||
return reject({msg: "photo expired"});
|
||||
}
|
||||
$A.__latestPhotoCreated = result.created;
|
||||
resolve(result);
|
||||
});
|
||||
} catch (e) {
|
||||
@ -296,6 +300,7 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
__latestPhotoCreated: null,
|
||||
|
||||
// 上传照片(通过 eeuiAppGetLatestPhoto 获取到的path,params 参数:{url,data,headers,path,fieldName})
|
||||
eeuiAppUploadPhoto(params, timeout = 30) {
|
||||
@ -312,7 +317,21 @@
|
||||
reject({msg: "timeout"});
|
||||
}, timeout * 1000) : null;
|
||||
//
|
||||
if (!$A.isJson(params)) {
|
||||
return reject({msg: "params error"});
|
||||
}
|
||||
let onReady = () => {};
|
||||
if (typeof params.onReady !== "undefined") {
|
||||
if (typeof params.onReady === "function") {
|
||||
onReady = params.onReady;
|
||||
}
|
||||
delete params.onReady;
|
||||
}
|
||||
eeui.uploadPhoto(params, result => {
|
||||
if (result.status === 'ready') {
|
||||
onReady(result.id)
|
||||
return
|
||||
}
|
||||
timer && clearTimeout(timer);
|
||||
if (result.status !== 'success') {
|
||||
return reject({msg: result.error || "upload failed"});
|
||||
@ -326,6 +345,29 @@
|
||||
reject({msg: e.message});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 取消上传照片
|
||||
eeuiAppCancelUploadPhoto(id) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (!$A.isEEUiApp) {
|
||||
return reject({msg: "not eeui app"});
|
||||
}
|
||||
try {
|
||||
const eeui = await $A.eeuiModule("eeui")
|
||||
if (!eeui) {
|
||||
return reject({msg: "not eeui module"});
|
||||
}
|
||||
eeui.cancelUploadPhoto(id, result => {
|
||||
if (result.status !== 'success') {
|
||||
return reject({msg: result.error || "cancel failed"});
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
} catch (e) {
|
||||
reject({msg: e.message});
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -796,7 +796,7 @@ export default {
|
||||
this.showEmoji = false;
|
||||
this.emojiQuickShow = false;
|
||||
//
|
||||
$A.eeuiAppGetLatestPhoto(0).then(({thumbnail, original}) => {
|
||||
$A.eeuiAppGetLatestPhoto().then(({thumbnail, original}) => {
|
||||
const width = 120;
|
||||
const height = Math.min(150, thumbnail.height / (thumbnail.width / width));
|
||||
this.maybePhotoStyle = {
|
||||
|
||||
@ -1736,6 +1736,7 @@ export default {
|
||||
const tempMsg = {
|
||||
id: $A.randNum(1000000000, 9999999999),
|
||||
file_uid: 0,
|
||||
file_method: 'photo',
|
||||
dialog_id: this.dialogData.id,
|
||||
reply_id: this.quoteId,
|
||||
type: 'file',
|
||||
@ -1753,7 +1754,10 @@ export default {
|
||||
token: this.userToken,
|
||||
},
|
||||
path: msg.path,
|
||||
fieldName: "files"
|
||||
fieldName: "files",
|
||||
onReady: (id) => {
|
||||
this.$set(tempMsg, 'file_uid', id)
|
||||
},
|
||||
}).then(data => {
|
||||
this.sendSuccess(data, tempMsg.id)
|
||||
}).catch(({msg}) => {
|
||||
@ -2317,6 +2321,7 @@ export default {
|
||||
const tempMsg = {
|
||||
id: file.tempId,
|
||||
file_uid: file.uid,
|
||||
file_method: 'uplaod',
|
||||
dialog_id: this.dialogData.id,
|
||||
reply_id: this.quoteId,
|
||||
type: 'file',
|
||||
@ -3260,19 +3265,24 @@ export default {
|
||||
content: '你确定要取消发送吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (this.operateItem.created_at) {
|
||||
reject("消息已发送,不可取消");
|
||||
return
|
||||
}
|
||||
if (this.operateItem.type === 'file') {
|
||||
if (this.operateItem.type === "file") {
|
||||
// 取消文件上传
|
||||
if (this.$refs.chatUpload.cancel(this.operateItem.file_uid)) {
|
||||
const {file_uid, file_method} = this.operateItem
|
||||
if (file_method === "photo") {
|
||||
await $A.eeuiAppCancelUploadPhoto(file_uid)
|
||||
this.forgetTempMsg(this.operateItem.id)
|
||||
resolve();
|
||||
} else {
|
||||
reject("取消发送失败");
|
||||
return resolve();
|
||||
}
|
||||
if (this.$refs.chatUpload.cancel(file_uid)) {
|
||||
this.forgetTempMsg(this.operateItem.id)
|
||||
return resolve();
|
||||
}
|
||||
reject("取消发送失败");
|
||||
} else {
|
||||
// 取消消息发送
|
||||
this.$store.dispatch('callCancel', this.operateItem.id).then(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user