Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
pptist
Commits
b1d1e961
Commit
b1d1e961
authored
May 29, 2024
by
zhengke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传头像
parent
a0d8452f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
9 deletions
+44
-9
UserService.ts
src/services/UserService.ts
+5
-0
aliyun.ts
src/utils/upload/aliyun.ts
+19
-0
Setting.vue
src/views/UserCenter/Setting.vue
+20
-9
No files found.
src/services/UserService.ts
View file @
b1d1e961
...
...
@@ -3,6 +3,11 @@ import Api, { HttpResponse, Result } from './../utils/request';
class
UserServices
{
static
async
ModifyUserPhoto
(
photo
:
String
):
Promise
<
HttpResponse
>
{
let
msg
=
{
photo
}
return
Api
.
Post
(
"travel_ModifyUserPhoto"
,
msg
)
}
static
async
getPPTGroupStatic
():
Promise
<
HttpResponse
>
{
let
msg
=
{}
return
Api
.
Post
(
"travel_PPTGroupStatic"
,
msg
)
...
...
src/utils/upload/aliyun.ts
View file @
b1d1e961
...
...
@@ -19,6 +19,25 @@ class AliyunUpload {
return
''
}
}
static
UploadAvatar
=
async
(
file
:
any
,
name
:
string
)
=>
{
console
.
log
(
name
,
'----name'
)
try
{
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
const
response
=
await
fetch
(
`
${
domainManager
().
UploadUrl
}
/Upload?filePath=
${
encodeURIComponent
(
name
)}
`
,
{
method
:
'POST'
,
body
:
formData
,
});
if
(
response
.
ok
){
let
result
=
await
response
.
text
()
let
datas
=
JSON
.
parse
(
result
)
return
'https://im.oytour.com'
+
datas
.
FilePath
}
return
''
}
catch
(
error
)
{
return
''
}
}
}
export
default
AliyunUpload
\ No newline at end of file
src/views/UserCenter/Setting.vue
View file @
b1d1e961
...
...
@@ -2,10 +2,10 @@
<div
class=
"user-setting"
>
<div
class=
"row flex-center"
>
<el-upload
drag
action=
"https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15
"
:action=
"getUploadActionUrl()
"
:on-success=
"handleAvatarSuccess"
:before-upload=
"beforeAvatarUpload"
class=
"avatar-upload"
>
class=
"avatar-upload"
v-loading=
"loadingImg"
>
<el-avatar
:size=
"72"
:src=
"userInfo.photo"
shape=
"square"
class=
"bg-transparent"
></el-avatar>
<div
class=
"after-overlayer"
>
上传
</div>
</el-upload>
...
...
@@ -118,6 +118,8 @@ import { ApiResult } from '@/configs/axios';
import
UserServices
from
'@/services/UserService'
import
VueHcaptcha
from
"@hcaptcha/vue3-hcaptcha"
;
import
{
domainManager
}
from
'@/utils/domainManager'
import
AliyunUpload
from
'@/utils/upload/aliyun'
import
CryptoJS
from
'crypto-js'
const
useUser
=
useUserStore
()
const
{
userInfo
}
=
storeToRefs
(
useUser
)
...
...
@@ -145,6 +147,7 @@ const sending = ref(false)
const
isSend
=
ref
(
false
)
const
isCountdown
=
ref
(
false
)
const
countValue
=
ref
<
number
>
(
0
)
const
loadingImg
=
ref
(
false
)
const
validateMail
=
(
rule
:
any
,
value
:
any
,
callback
:
any
)
=>
{
if
(
value
===
''
)
{
callback
(
new
Error
(
'请输入你的邮箱账户'
))
...
...
@@ -174,21 +177,26 @@ const rules = reactive<FormRules<RuleForm>>({
//上传头像地址
const
getUploadActionUrl
=
()
=>
{
let
uid
=
userInfo
.
value
.
id
;
const
url
=
domainManager
().
domainUrl
.
replace
(
"common"
,
"file"
)
+
`?cmd=dmc_post_LocalFileUpload&Type=19&fileType=3&PPTEmployeeId=
${
encodeURIComponent
(
uid
)}
`
let
uid
=
userInfo
.
value
.
id
;
const
url
=
domainManager
().
UploadUrl
return
url
;
}
const
handleAvatarSuccess
=
async
(
res
:
any
)
=>
{
if
(
res
.
data
&&
res
.
data
.
failUrl
){
userInfo
.
value
.
photo
=
domainManager
().
DownloadUrl
.
replace
(
"common"
,
"file"
)
+
`
${
res
.
data
.
failUrl
}
`
}
console
.
log
(
"handleAvatarSuccess_res"
,
res
);
}
const
beforeAvatarUpload
=
async
(
res
:
any
)
=>
{
console
.
log
(
"beforeAvatarUpload_res"
,
res
);
dialogType
.
value
=
3
loadingImg
.
value
=
true
let
timestamp
=
new
Date
().
getTime
()
let
url
=
await
AliyunUpload
.
UploadAvatar
(
res
,
`
${
res
.
name
.
split
(
'.'
)[
0
]}${
timestamp
}
`
)
console
.
log
(
"beforeAvatarUpload_res"
,
userInfo
.
value
.
photo
);
if
(
url
!=
''
)
{
console
.
log
(
url
,
';--------------url'
)
// userInfo.value.photo =url
// await bindHandler()
}
}
const
closeForm
=
()
=>
{
...
...
@@ -218,6 +226,7 @@ const bindHandler = async () =>{
if
(
dialogType
.
value
==
0
)
response
=
await
UserServices
.
setMyNickNamed
(
userInfo
.
value
.
nickname
)
if
(
dialogType
.
value
==
1
)
response
=
await
UserServices
.
setBindUserEmail
(
model
.
value
.
mail
,
model
.
value
.
code
)
if
(
dialogType
.
value
==
2
)
response
=
await
UserServices
.
setModifyUserPwd
(
model
.
value
.
oldpwd
,
model
.
value
.
pwd
)
if
(
dialogType
.
value
==
3
)
response
=
await
UserServices
.
ModifyUserPhoto
(
userInfo
.
value
.
photo
)
if
(
response
){
if
(
response
.
data
.
resultCode
==
ApiResult
.
SUCCESS
){
if
(
dialogType
.
value
==
1
)
{
...
...
@@ -230,11 +239,13 @@ const bindHandler = async () =>{
}
dialogVisible
.
value
=
false
dialogType
.
value
=
null
loadingImg
.
value
=
false
return
}
ElMessage
.
error
({
message
:
response
.
data
.
message
})
invisibleHcaptchaBind
.
value
?.
reset
()
validateToken
.
value
=
''
loadingImg
.
value
=
false
}
}
...
...
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