Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1579c641
authored
Jun 20, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit 图片转base64
1 parent
e35a899c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
api/module/systemApi.js
pages/equity/index.vue
api/module/systemApi.js
View file @
1579c64
...
...
@@ -47,18 +47,20 @@ const getMockData = async (immediate = false) => {
};
const
imgToBase64
=
(
list
,
urlKey
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
arr
=
[]
list
.
map
(
e
=>
{
let
arr
=
[],
newList
=
JSON
.
parse
(
JSON
.
stringify
(
list
))
list
.
map
((
e
,
index
)
=>
{
if
(
!
(
urlKey
?
e
[
urlKey
]
:
e
).
startsWith
(
'https'
))
return
resolve
(
list
)
uni
.
request
({
url
:
urlKey
?
e
[
urlKey
]
:
e
,
method
:
'GET'
,
responseType
:
'arraybuffer'
,
success
:
(
res
)
=>
{
const
base64
=
`data:image/png;base64,
${
uni
.
arrayBufferToBase64
(
res
.
data
)}
`
if
(
urlKey
)
e
[
urlKey
]
=
base64
else
e
=
base64
if
(
urlKey
)
newList
[
index
]
[
urlKey
]
=
base64
else
newList
[
index
]
=
base64
arr
.
push
(
e
)
if
(
arr
.
length
===
list
.
length
)
resolve
(
l
ist
)
if
(
arr
.
length
===
list
.
length
)
resolve
(
newL
ist
)
},
fail
:
(
err
)
=>
{
reject
(
err
)
...
...
@@ -70,9 +72,9 @@ const imgToBase64 = (list, urlKey) => {
const
updateMockData
=
(
data
,
key
)
=>
{
const
mockData
=
uni
.
$storage
.
get
(
'mock_data'
)
mockData
[
key
]
=
data
setTimeout
(()
=>
{
setTimeout
(()
=>
{
uni
.
$storage
.
set
(
"mock_data"
,
mockData
)
},
1
e3
)
},
1
e3
)
}
// 图片版本号
const
getImageVersion
=
async
()
=>
{
...
...
pages/equity/index.vue
View file @
1579c64
...
...
@@ -121,13 +121,13 @@ export default {
// 查询素材
async
getSoure
()
{
let
{
moduleList
,
toolList
}
=
await
uni
.
$api
.
systemApi
.
getMockData
();
moduleList
.
map
(
async
e
=>
{
await
moduleList
.
map
(
async
e
=>
{
if
(
e
.
receptionSourceDetailList
)
e
.
receptionSourceDetailList
=
await
uni
.
$api
.
systemApi
.
imgToBase64
(
e
.
receptionSourceDetailList
,
'detailUrl'
)
if
(
e
.
carTypeList
)
e
.
carTypeList
=
await
uni
.
$api
.
systemApi
.
imgToBase64
(
e
.
carTypeList
)
})
this
.
moduleList
=
moduleList
this
.
toolList
=
toolList
uni
.
$api
.
systemApi
.
updateMockData
(
moduleList
,
'moduleList'
)
uni
.
$api
.
systemApi
.
updateMockData
(
moduleList
,
'moduleList'
)
},
errorImg
(
index
)
{
this
.
moduleList
[
index
].
showAlt
=
true
...
...
Write
Preview
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