Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨炀
/
ztx_wx_gzt
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
58c2b92e
authored
2026-06-05 17:15:20 +0800
by
lttnew
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
上传头像问题
1 parent
c9bf47f3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
40 deletions
common/api.js
common/utils.js
config.js
personal/home.vue
personalVip/addVip.vue
personalVip/list.vue
common/api.js
View file @
58c2b92
...
...
@@ -323,7 +323,7 @@ export function uploadImgCorpPhoto(tempFilePath) {
title
:
'加载中'
});
return
uni
.
uploadFile
({
url
:
config
.
baseUrl_api
+
'/
upload/uploadImgToLocalServer
CaiJian'
,
url
:
config
.
baseUrl_api
+
'/
fileServer/uploadImgToMinio
CaiJian'
,
header
:
{
'Authorization'
:
uni
.
getStorageSync
(
'token'
),
},
...
...
@@ -344,6 +344,14 @@ export function getInfo(perId) {
})
}
export
function
updateInfo
(
data
)
{
return
request
({
url
:
'/person/info'
,
method
:
'put'
,
params
:
data
})
}
// 查询个人会员信息列表
export
function
selectPageList
(
query
)
{
return
request
({
...
...
common/utils.js
View file @
58c2b92
import
CryptoJS
from
'crypto-js'
import
config
from
'@/config.js'
export
function
szToHz
(
num
)
{
const
hzArr
=
[
'〇'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
,
'七'
,
'八'
,
'九'
,
'十'
]
return
hzArr
[
parseInt
(
num
)]
...
...
@@ -52,3 +53,24 @@ export function reLaunchHomeByRole() {
url
:
isDaoGuanRole
()
?
'/pages/index/daoGuanPerson'
:
'/pages/index/home'
})
}
export
function
fillImgUrl
(
url
,
prefix
)
{
if
(
!
url
)
return
''
const
trimmedUrl
=
String
(
url
).
trim
()
if
(
!
trimmedUrl
)
return
''
if
(
trimmedUrl
.
startsWith
(
'msr:'
))
{
return
`
${
trimBaseUrl
(
config
.
baseUrl_api
)}
/fileServer/download?file=
${
encodeURIComponent
(
trimmedUrl
)}
&downFlag=0`
}
if
(
/^
(
data:|https
?
:
\/\/)
/
.
test
(
trimmedUrl
))
{
return
trimmedUrl
}
const
baseUrl
=
prefix
?
`
${
trimBaseUrl
(
config
.
baseUrl_api
)}
/
${
String
(
prefix
).
replace
(
/^
\/
+|
\/
+$/g
,
''
)}
`
:
trimBaseUrl
(
config
.
baseUrl_api
)
const
path
=
trimmedUrl
.
startsWith
(
'/'
)
?
trimmedUrl
:
`/
${
trimmedUrl
}
`
return
baseUrl
+
path
}
function
trimBaseUrl
(
url
)
{
return
String
(
url
||
''
).
replace
(
/
\/
+$/
,
''
)
}
...
...
config.js
View file @
58c2b92
// dev
// const baseUrl_api = 'http://192.168.1.222
:8787'
const
baseUrl_api
=
'http://192.168.1.159
:8787'
// const baseUrl_api = 'http://47.98.186.233:8787'
const
baseUrl_api
=
'https://tk001.wxjylt.com/stage-api/'
//
const baseUrl_api = 'https://tk001.wxjylt.com/stage-api/'
const
loginImage_api
=
'https://tk001.wxjylt.com/stage-api'
const
payUrl
=
'https://wxpay.cmbc.com.cn/mobilePlatform/appserver/lcbpPay.do'
...
...
personal/home.vue
View file @
58c2b92
...
...
@@ -23,12 +23,8 @@
</view>
<view
class=
"user-top"
>
<view
class=
"avatar-wrap"
@
click=
"showLogoutConfirm"
>
<!--
<image
class=
"avatar"
v-if=
"perInfo.photo"
:src=
"config.baseUrl_api + perInfo.photo"
mode=
"aspectFill"
>
</image>
-->
<image
:src=
"config.baseUrl_api + '/fs/static/tx@2x.png'"
class=
"avatar"
mode=
"aspectFill"
>
<view
class=
"avatar-wrap"
@
click=
"handleAvatarUpload"
>
<image
:src=
"avatarUrl"
class=
"avatar"
mode=
"aspectFill"
>
</image>
</view>
<!--
<view
class=
"member-id"
>
{{
userInfo
?.
userName
}}
</view>
-->
...
...
@@ -219,9 +215,13 @@ import to from 'await-to-js'
import
{
bindUser
,
unbindUser
,
downStuCertSingle
downStuCertSingle
,
uploadImgCorpPhoto
,
getInfo
,
updateInfo
}
from
'@/common/api.js'
import
{
onShow
}
from
"@dcloudio/uni-app"
;
import
{
fillImgUrl
}
from
'@/common/utils.js'
const
userStore
=
useUserStore
()
const
userInfo
=
computed
(()
=>
userStore
.
user
??
{})
...
...
@@ -229,6 +229,21 @@ const perInfo = computed(() => userStore.perInfo ?? {})
console
.
log
(
222
,
userInfo
.
value
)
console
.
log
(
333
,
perInfo
.
value
)
const
isValidPhotoValue
=
(
value
)
=>
{
if
(
value
===
undefined
||
value
===
null
)
return
false
const
photo
=
String
(
value
).
trim
()
return
photo
!==
''
&&
photo
!==
'null'
&&
photo
!==
'undefined'
}
const
getAvatarPhoto
=
(
info
=
{})
=>
{
return
[
info
.
photo2
,
info
.
perPhoto2
,
info
.
photo
,
info
.
perPhoto
].
find
(
isValidPhotoValue
)
||
''
}
const
avatarUrl
=
computed
(()
=>
{
const
photo
=
getAvatarPhoto
(
perInfo
.
value
)
return
photo
?
fillImgUrl
(
photo
)
:
config
.
baseUrl_api
+
'/fs/static/tx@2x.png'
})
// 是否已绑定学员:绑定非会员时只有姓名,没有会员卡号,也应视为已绑定,避免反复弹绑定框。
const
isBound
=
computed
(()
=>
{
const
perName
=
perInfo
.
value
?.
perName
...
...
@@ -538,6 +553,89 @@ const goToPay = () => {
});
};
const
handleAvatarUpload
=
()
=>
{
if
(
!
isBound
.
value
)
{
uni
.
showToast
({
title
:
'请先绑定学员'
,
icon
:
'none'
})
return
}
uni
.
chooseImage
({
count
:
1
,
sizeType
:
[
'compressed'
],
sourceType
:
[
'album'
,
'camera'
],
success
:
(
res
)
=>
{
const
imgUrl
=
res
.
tempFilePaths
?.[
0
]
if
(
!
imgUrl
)
{
uni
.
showToast
({
title
:
'未获取到图片地址,请重新选择图片'
,
icon
:
'none'
})
return
}
if
(
typeof
wx
===
'undefined'
||
typeof
wx
.
cropImage
!==
'function'
)
{
uploadAvatarPhoto
(
imgUrl
)
return
}
wx
.
cropImage
({
src
:
imgUrl
,
cropScale
:
'4:5'
,
success
:
(
cropRes
)
=>
{
uploadAvatarPhoto
(
cropRes
.
tempFilePath
||
imgUrl
)
},
fail
:
()
=>
{
uploadAvatarPhoto
(
imgUrl
)
}
})
}
})
}
const
uploadAvatarPhoto
=
async
(
path
)
=>
{
uni
.
showLoading
({
title
:
'上传中...'
,
mask
:
true
})
const
[
uploadErr
,
uploadRes
]
=
await
to
(
uploadImgCorpPhoto
(
path
))
if
(
uploadErr
||
uploadRes
?.
code
!==
200
||
!
uploadRes
?.
data
)
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
uploadRes
?.
msg
||
'头像上传失败,请重新上传'
,
icon
:
'none'
})
return
}
const
photo
=
uploadRes
.
data
.
fang
||
''
const
photo2
=
uploadRes
.
data
.
yuan
||
''
if
(
!
photo
||
!
photo2
)
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'头像上传返回数据异常'
,
icon
:
'none'
})
return
}
const
currentPerInfo
=
userStore
.
perInfo
||
{}
const
nextPerInfo
=
{
...
currentPerInfo
,
photo
,
photo2
}
const
perId
=
userInfo
.
value
?.
perId
||
currentPerInfo
.
perId
if
(
!
perId
)
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'未获取到人员信息,请重新登录后再试'
,
icon
:
'none'
})
return
}
const
[
detailErr
,
detailRes
]
=
await
to
(
getInfo
(
perId
))
const
saveParams
=
{
...(
detailErr
?
currentPerInfo
:
(
detailRes
?.
data
||
currentPerInfo
)),
perId
,
photo
,
photo2
}
const
[
saveErr
]
=
await
to
(
updateInfo
(
saveParams
))
uni
.
hideLoading
()
if
(
saveErr
)
{
uni
.
showToast
({
title
:
'头像已上传,保存失败请稍后重试'
,
icon
:
'none'
})
return
}
userStore
.
setPerInfo
(
nextPerInfo
)
uni
.
showToast
({
title
:
'头像上传成功'
,
icon
:
'success'
})
await
getWebInfo
().
catch
(()
=>
{})
}
// 下载电子会员证
const
downCert
=
async
()
=>
{
if
(
!
isBound
.
value
)
{
...
...
@@ -547,6 +645,11 @@ const downCert = async () => {
const
perId
=
userInfo
.
value
?.
perId
if
(
!
perId
)
return
if
(
!
perInfo
.
value
.
perPhoto
||
!
perInfo
.
value
.
perPhoto2
)
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'请先上传头像照片'
,
icon
:
'none'
})
return
}
uni
.
showLoading
({
title
:
'加载中...'
,
mask
:
true
})
const
[
err
,
res
]
=
await
to
(
downStuCertSingle
(
perId
))
uni
.
hideLoading
()
...
...
personalVip/addVip.vue
View file @
58c2b92
...
...
@@ -111,6 +111,7 @@
}
from
'@dcloudio/uni-app'
import
config
from
'@/config.js'
import
*
as
aes2
from
'@/common/utils.js'
import
{
fillImgUrl
}
from
'@/common/utils.js'
const
current
=
ref
(
0
)
const
agree
=
ref
(
false
)
const
perId
=
ref
()
...
...
@@ -333,10 +334,11 @@
});
api
.
uploadImgCorpPhoto
(
path
).
then
(
data
=>
{
console
.
log
(
data
)
baseFormData
.
value
.
photo
=
data
.
data
.
fang
;
baseFormData
.
value
.
photo2
=
data
.
data
.
yuan
;
const
photoData
=
data
.
data
||
{}
baseFormData
.
value
.
photo
=
photoData
.
fang
||
''
;
baseFormData
.
value
.
photo2
=
photoData
.
yuan
||
''
;
photoArr
.
value
=
{
url
:
config
.
baseUrl_api
+
baseFormData
.
value
.
photo
,
url
:
fillImgUrl
(
baseFormData
.
value
.
photo
),
name
:
'头像'
,
extname
:
'jpg'
}
...
...
@@ -421,23 +423,13 @@
baseFormData
.
value
.
validityDate
=
res
.
data
.
validityDate
?.
slice
(
0
,
10
)
//去掉时分秒
if
(
res
.
data
.
photo
)
{
console
.
log
(
res
.
data
.
photo
)
if
(
res
.
data
.
photo
.
indexOf
(
'http'
)
==
-
1
)
{
baseFormData
.
value
.
photo
=
res
.
data
.
photo
let
obj
=
{
url
:
config
.
baseUrl_api
+
res
.
data
.
photo
,
url
:
fillImgUrl
(
res
.
data
.
photo
),
name
:
'头像'
,
extname
:
'jpg'
}
photoArr
.
value
=
obj
}
else
{
baseFormData
.
value
.
photo
=
res
.
data
.
photo
let
obj
=
{
url
:
res
.
data
.
photo
,
name
:
'头像'
,
extname
:
'jpg'
}
photoArr
.
value
=
obj
}
}
// baseFormData.value.name = res.data.name
...
...
@@ -494,7 +486,6 @@
// }
}
function
changeIdcType
(
e
)
{
console
.
log
(
e
)
// 切换证件照类型把当前页面数据清空
...
...
personalVip/list.vue
View file @
58c2b92
...
...
@@ -56,7 +56,7 @@
<
script
setup
>
import
*
as
api
from
'@/common/api.js'
import
config
from
'@/config.js'
import
{
fillImgUrl
}
from
'@/common/utils.js'
import
{
onMounted
,
ref
...
...
@@ -92,13 +92,9 @@
query
.
value
.
showMyPersonFlag
=
1
}
api
.
selectPageList
(
query
.
value
).
then
(
res
=>
{
for
(
var
l
of
res
.
rows
)
{
if
(
l
.
photo
&&
l
.
photo
.
indexOf
(
'http'
)
==
-
1
)
{
l
.
photo
=
config
.
baseUrl_api
+
l
.
photo
}
}
list
.
value
=
res
.
rows
paging
.
value
.
complete
(
res
.
rows
)
const
rows
=
formatRows
(
res
.
rows
||
[])
list
.
value
=
rows
paging
.
value
.
complete
(
rows
)
total
.
value
=
res
.
total
})
}
...
...
@@ -112,18 +108,21 @@
query
.
value
.
showMyPersonFlag
=
1
}
api
.
selectPageList
(
query
.
value
).
then
(
res
=>
{
for
(
var
l
of
res
.
rows
)
{
if
(
l
.
photo
&&
l
.
photo
.
indexOf
(
'http'
)
==
-
1
)
{
l
.
photo
=
config
.
baseUrl_api
+
l
.
photo
}
}
list
.
value
=
res
.
rows
paging
.
value
.
complete
(
res
.
rows
)
const
rows
=
formatRows
(
res
.
rows
||
[])
list
.
value
=
rows
paging
.
value
.
complete
(
rows
)
total
.
value
=
res
.
total
uni
.
hideLoading
()
})
}
function
formatRows
(
rows
)
{
return
rows
.
map
(
item
=>
({
...
item
,
photo
:
fillImgUrl
(
item
.
photo
)
}))
}
function
handleDelete
(
item
)
{
uni
.
showModal
({
content
:
`是否确认删除
${
item
.
name
}
`
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment