Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
875c0060
authored
Aug 05, 2021
by
吴云建
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
图片的上传与显示
parent
3bb0d1c4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
62 deletions
components/message-input.vue
components/message.vue
hybrid-input/index.vue
service/upload.ts
components/message-input.vue
View file @
875c0060
...
...
@@ -121,7 +121,7 @@ export default class MessageInput extends Vue {
};
img
.
remove
();
}
uploadFile
(
file
,
this
.
chatId
||
0
,
w
,
h
)
uploadFile
(
file
)
.
then
((
r
)
=>
{
if
(
r
)
{
const
msg
=
{
...
...
components/message.vue
View file @
875c0060
...
...
@@ -264,10 +264,14 @@ export default class Message extends Mixins(Filters) {
return
false
;
}
p
ublic
created
()
{
p
rivate
created
()
{
this
.
getUserName
(
this
.
data
.
eid
);
}
private
mounted
()
{
this
.
buildMessageUrl
()
}
private
getUserName
(
eid
:
string
)
{
this
.
senderName
=
this
.
chatMembers
.
find
(
member
=>
member
.
eid
===
eid
)?.
name
??
""
;
}
...
...
@@ -375,22 +379,10 @@ export default class Message extends Mixins(Filters) {
}
const
url
=
this
.
messageBody
.
msg
.
url
as
string
;
if
(
url
)
{
// const service = XimService.getInstance()
if
(
isAccessibleUrl
(
url
))
{
return
(
this
.
messageRealUrl
=
url
);
}
this
.
loadingRealUrl
=
true
;
// service
// .getFileUrlById(url, this.chatId || 0, this.isCustomer())
// .then((data) => {
// if (data && data.itemList) {
// this.messageRealUrl = data.itemList[0].url
// } else {
// this.fileFailed2Load = true
// }
// })
// .catch(() => (this.fileFailed2Load = true))
// .finally(() => (this.loadingRealUrl = false))
}
else
{
this
.
fileFailed2Load
=
true
;
}
...
...
hybrid-input/index.vue
View file @
875c0060
...
...
@@ -15,9 +15,9 @@
>
<img
class=
"tool-bar-icon"
src=
"@/customer-service/imgs/pic.png"
/>
</label>
<label
for=
"chat-upload-file"
:title=
"tip4File"
@
click=
"allowLoadFile"
>
<
!--
<
label
for=
"chat-upload-file"
:title=
"tip4File"
@
click=
"allowLoadFile"
>
<img
class=
"tool-bar-icon"
src=
"@/customer-service/imgs/file.png"
/>
</label>
</label>
-->
<input
@
change=
"onChange"
...
...
@@ -518,8 +518,7 @@ export default class Input extends Vue {
padding-left
:
20px
;
/deep/.input-el-scrollbar.el-scrollbar
{
//
28px
:
tool-bar
的高度
height
:
calc
(
100%
-
28px
);
height
:
calc
(
100%
-
35px
);
>
.el-scrollbar__wrap
{
overflow-x
:
hidden
;
...
...
service/upload.ts
View file @
875c0060
import
Axios
from
"axios"
;
import
Vue
from
"vue"
;
import
{
UniplatSdk
}
from
"uniplat-sdk"
import
tokenManager
from
"../xim/token"
;
import
{
invokePost
}
from
"./request"
;
const
orgId
=
()
=>
Vue
.
prototype
.
global
.
org
?.
id
??
"0"
;
export
async
function
uploadFile
(
file
:
File
,
chatId
:
number
,
width
?:
number
,
height
?:
number
)
{
const
splits
=
file
.
name
.
split
(
"."
);
const
parameter
=
{
file_name
:
file
.
name
,
size
:
file
.
size
,
introduction
:
file
.
name
,
owner_type
:
"FILE_TYPE_CS"
,
owner_id
:
chatId
,
org_id
:
orgId
(),
ext_type
:
splits
[
splits
.
length
-
1
],
};
if
(
width
&&
height
)
{
Object
.
assign
(
parameter
,
{
width
,
height
});
}
const
token
=
await
invokePost
<
{
url_id
:
string
;
sign
:
string
;
domain
:
string
;
file_name
:
string
;
id
:
number
;
}
>
(
"/xchat/personal/upload_token"
,
await
tokenManager
.
getToken
(),
parameter
);
const
uri
=
`
${
token
.
domain
}
/gw/file/upload`
;
const
form
=
new
FormData
();
form
.
append
(
"file"
,
file
);
form
.
append
(
"fileId"
,
token
.
url_id
);
form
.
append
(
"fileSize"
,
file
.
size
.
toString
());
form
.
append
(
"orgId"
,
orgId
());
form
.
append
(
"sign"
,
token
.
sign
);
const
result
=
await
Axios
.
post
(
uri
,
form
,
{
headers
:
{
"Content-Type"
:
"multipart/form-data"
},
});
if
(
result
&&
result
.
data
&&
result
.
data
.
errcode
===
0
)
{
return
token
.
url_id
;
}
return
""
;
export
async
function
uploadFile
(
file
:
File
)
{
let
{
url
}
=
await
(
Vue
.
prototype
.
sdk
as
UniplatSdk
).
uploadFileV2
(
file
)
const
realUrl
=
`
${
Vue
.
prototype
.
sdk
.
global
.
baseUrl
}${
url
}
`
;
return
realUrl
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment