mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-05 04:44:13 +00:00
feat: 添加移动端提示可能要发送的图片
This commit is contained in:
parent
8bdd31ae67
commit
43d0a85061
66
resources/assets/js/functions/eeui.js
vendored
66
resources/assets/js/functions/eeui.js
vendored
@ -263,18 +263,68 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 获取最新一张照片
|
// 获取最新一张照片
|
||||||
eeuiAppGetLatestPhoto(callback) {
|
eeuiAppGetLatestPhoto(expiration = 60, timeout = 10) {
|
||||||
if (!$A.isEEUiApp) return;
|
return new Promise(async (resolve, reject) => {
|
||||||
$A.eeuiModule("eeui").then(obj => {
|
if (!$A.isEEUiApp) {
|
||||||
obj.getLatestPhoto(callback);
|
return reject({msg: "not eeui app"});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const eeui = await $A.eeuiModule("eeui")
|
||||||
|
if (!eeui) {
|
||||||
|
return reject({msg: "not eeui module"});
|
||||||
|
}
|
||||||
|
const timer = timeout > 0 ? setTimeout(() => {
|
||||||
|
reject({msg: "timeout"});
|
||||||
|
}, timeout * 1000) : null;
|
||||||
|
//
|
||||||
|
eeui.getLatestPhoto(result => {
|
||||||
|
timer && clearTimeout(timer);
|
||||||
|
if (
|
||||||
|
result.status !== 'success' ||
|
||||||
|
result.thumbnail.width < 10 || !result.thumbnail.base64 ||
|
||||||
|
result.original.width < 10 || !result.original.path
|
||||||
|
) {
|
||||||
|
return reject({msg: result.error || "no photo"});
|
||||||
|
}
|
||||||
|
if (expiration > 0 && (result.created + expiration) < $A.dayjs().unix()) {
|
||||||
|
return reject({msg: "photo expired"});
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
reject({msg: e.message});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 上传照片(通过 eeuiAppGetLatestPhoto 获取到的path,params 参数:{url,data,headers,path,fieldName})
|
// 上传照片(通过 eeuiAppGetLatestPhoto 获取到的path,params 参数:{url,data,headers,path,fieldName})
|
||||||
eeuiAppUploadPhoto(params, callback) {
|
eeuiAppUploadPhoto(params, timeout = 30) {
|
||||||
if (!$A.isEEUiApp) return;
|
return new Promise(async (resolve, reject) => {
|
||||||
$A.eeuiModule("eeui").then(obj => {
|
if (!$A.isEEUiApp) {
|
||||||
obj.uploadPhoto(params, callback);
|
return reject({msg: "not eeui app"});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const eeui = await $A.eeuiModule("eeui")
|
||||||
|
if (!eeui) {
|
||||||
|
return reject({msg: "not eeui module"});
|
||||||
|
}
|
||||||
|
const timer = timeout > 0 ? setTimeout(() => {
|
||||||
|
reject({msg: "timeout"});
|
||||||
|
}, timeout * 1000) : null;
|
||||||
|
//
|
||||||
|
eeui.uploadPhoto(params, result => {
|
||||||
|
timer && clearTimeout(timer);
|
||||||
|
if (result.status !== 'success') {
|
||||||
|
return reject({msg: result.error || "upload failed"});
|
||||||
|
}
|
||||||
|
if (result.data.ret !== 1) {
|
||||||
|
return reject({msg: result.data.msg || "upload failed"});
|
||||||
|
}
|
||||||
|
resolve(result.data.data);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
reject({msg: e.message});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -796,13 +796,7 @@ export default {
|
|||||||
this.showEmoji = false;
|
this.showEmoji = false;
|
||||||
this.emojiQuickShow = false;
|
this.emojiQuickShow = false;
|
||||||
//
|
//
|
||||||
$A.eeuiAppGetLatestPhoto(({status, created, thumbnail, original}) => {
|
$A.eeuiAppGetLatestPhoto(0).then(({thumbnail, original}) => {
|
||||||
if (status !== 'success'
|
|
||||||
// || created + 60 < $A.dayjs().unix()
|
|
||||||
|| !thumbnail.base64
|
|
||||||
|| !original.path) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const width = 120;
|
const width = 120;
|
||||||
const height = Math.min(150, thumbnail.height / (thumbnail.width / width));
|
const height = Math.min(150, thumbnail.height / (thumbnail.width / width));
|
||||||
this.maybePhotoStyle = {
|
this.maybePhotoStyle = {
|
||||||
@ -810,7 +804,7 @@ export default {
|
|||||||
height: height + 'px',
|
height: height + 'px',
|
||||||
backgroundImage: `url(${thumbnail.base64})`,
|
backgroundImage: `url(${thumbnail.base64})`,
|
||||||
}
|
}
|
||||||
this.maybePhotoData = original
|
this.maybePhotoData = {thumbnail, original}
|
||||||
this.maybePhotoShow = true
|
this.maybePhotoShow = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.more?.updatePopper()
|
this.$refs.more?.updatePopper()
|
||||||
@ -1643,29 +1637,15 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'maybe-photo':
|
case 'maybe-photo':
|
||||||
$A.eeuiAppUploadPhoto({
|
this.$emit('on-file', {
|
||||||
url: $A.apiUrl('dialog/msg/sendfile'),
|
type: 'photo',
|
||||||
data: {
|
msg: {
|
||||||
dialog_id: this.dialogId,
|
type: 'img',
|
||||||
},
|
path: this.maybePhotoData.original.path,
|
||||||
headers: {
|
width: this.maybePhotoData.original.width,
|
||||||
token: this.userToken,
|
height: this.maybePhotoData.original.height,
|
||||||
},
|
thumb: this.maybePhotoData.thumbnail.base64,
|
||||||
path: this.maybePhotoData.path,
|
}
|
||||||
fieldName: "files"
|
|
||||||
}, ({status, data}) => {
|
|
||||||
/*switch (status) {
|
|
||||||
case "uploading":
|
|
||||||
break;
|
|
||||||
case "success":
|
|
||||||
if (data.ret !== 1) {
|
|
||||||
$A.messageError(data.msg || "上传失败")
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "error":
|
|
||||||
$A
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -1700,6 +1700,10 @@ export default {
|
|||||||
this.pasteFile = [];
|
this.pasteFile = [];
|
||||||
this.pasteItem = [];
|
this.pasteItem = [];
|
||||||
files.some(file => {
|
files.some(file => {
|
||||||
|
if (file.type === 'photo') {
|
||||||
|
this.sendPhoto(file.msg)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const item = {
|
const item = {
|
||||||
type: $A.getMiddle(file.type, null, '/'),
|
type: $A.getMiddle(file.type, null, '/'),
|
||||||
name: file.name,
|
name: file.name,
|
||||||
@ -1724,6 +1728,40 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送照片
|
||||||
|
* @param msg
|
||||||
|
*/
|
||||||
|
sendPhoto(msg) {
|
||||||
|
const tempMsg = {
|
||||||
|
id: $A.randNum(1000000000, 9999999999),
|
||||||
|
file_uid: 0,
|
||||||
|
dialog_id: this.dialogData.id,
|
||||||
|
reply_id: this.quoteId,
|
||||||
|
type: 'file',
|
||||||
|
userid: this.userId,
|
||||||
|
msg,
|
||||||
|
}
|
||||||
|
this.tempMsgs.push(tempMsg)
|
||||||
|
//
|
||||||
|
$A.eeuiAppUploadPhoto({
|
||||||
|
url: $A.apiUrl('dialog/msg/sendfile'),
|
||||||
|
data: {
|
||||||
|
dialog_id: tempMsg.dialog_id,
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
token: this.userToken,
|
||||||
|
},
|
||||||
|
path: msg.path,
|
||||||
|
fieldName: "files"
|
||||||
|
}).then(data => {
|
||||||
|
this.sendSuccess(data, tempMsg.id)
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
this.forgetTempMsg(tempMsg.id)
|
||||||
|
$A.messageError(msg || "上传失败")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送位置消息
|
* 发送位置消息
|
||||||
* @param data
|
* @param data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user