Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a5ecd425
authored
Jul 18, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:图片跨域导致下载空白问题
1 parent
3dacb62c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
11 deletions
src/views/financeManage/account/offlineAccountList.vue
src/views/financeManage/account/onlineAccountList.vue
src/views/systemConfig/images/test.png
src/views/systemConfig/qRcodeDialog.vue
src/views/financeManage/account/offlineAccountList.vue
View file @
a5ecd42
...
@@ -256,6 +256,10 @@ export default {
...
@@ -256,6 +256,10 @@ export default {
this
.
getOptionsList
()
this
.
getOptionsList
()
})
})
getPlatformMerchantList
({}).
then
(
res
=>
{
getPlatformMerchantList
({}).
then
(
res
=>
{
res
.
unshift
({
merchantId
:
-
1
,
merchantName
:
'嘀加智慧云'
})
this
.
baseData
.
PlatformMerchantList
=
res
this
.
baseData
.
PlatformMerchantList
=
res
this
.
getOptionsList
()
this
.
getOptionsList
()
})
})
...
...
src/views/financeManage/account/onlineAccountList.vue
View file @
a5ecd42
...
@@ -145,7 +145,8 @@
...
@@ -145,7 +145,8 @@
<span
v-if=
"scope.row.divisionStatus"
<span
v-if=
"scope.row.divisionStatus"
:style=
"
{ 'color': [4, 5].includes(+scope.row.divisionStatus) ? 'red' : '#606266' }">
{{
baseData
.
divisionStatusList
.
find
(
item
=>
+
item
.
confId
===
scope
.
row
.
divisionStatus
).
confLabel
}}
</span>
:style=
"
{ 'color': [4, 5].includes(+scope.row.divisionStatus) ? 'red' : '#606266' }">
{{
baseData
.
divisionStatusList
.
find
(
item
=>
+
item
.
confId
===
scope
.
row
.
divisionStatus
).
confLabel
}}
</span>
<span
v-else
>
-
</span>
<span
v-else
>
-
</span>
</
template
></el-table-column>
</
template
>
</el-table-column>
<el-table-column
label=
"分账时间"
<el-table-column
label=
"分账时间"
prop=
"divisionDateStr"
prop=
"divisionDateStr"
align=
"center"
align=
"center"
...
@@ -304,6 +305,10 @@ export default {
...
@@ -304,6 +305,10 @@ export default {
this
.
getOptionsList
()
this
.
getOptionsList
()
})
})
getPlatformMerchantList
({}).
then
(
res
=>
{
getPlatformMerchantList
({}).
then
(
res
=>
{
res
.
unshift
({
merchantId
:
-
1
,
merchantName
:
'嘀加智慧云'
})
this
.
baseData
.
PlatformMerchantList
=
res
this
.
baseData
.
PlatformMerchantList
=
res
this
.
getOptionsList
()
this
.
getOptionsList
()
})
})
...
...
src/views/systemConfig/images/test.png
0 → 100644
View file @
a5ecd42
51.8 KB
src/views/systemConfig/qRcodeDialog.vue
View file @
a5ecd42
...
@@ -11,13 +11,15 @@
...
@@ -11,13 +11,15 @@
id=
"view"
>
id=
"view"
>
<img
style=
"width:100%;height:100%"
<img
style=
"width:100%;height:100%"
src=
"./images/code3.png"
>
src=
"./images/code3.png"
>
<
div
class=
"imgDiv"
>
<
!-- v-if="qrCodeURL"
<div
class=
"imgDiv"
>
--
>
<img
v-if=
"qrCodeURL"
<img
v-if=
"qrCodeURL"
style=
"width:100%;height:100%"
class=
"qrImg"
id=
"img1"
crossorigin=
"anonymous"
:src=
"qrCodeURL"
>
:src=
"qrCodeURL"
>
<div
v-else
<div
v-if=
"!qrCodeURL"
class=
"el-icon-loading loadingIcon"
></div>
class=
"el-icon-loading loadingIcon"
></div>
<
/div
>
<
!--
</div>
--
>
<div
class=
"merchantNameDiv"
>
{{
info
.
yqMerchantName
}}
</div>
<div
class=
"merchantNameDiv"
>
{{
info
.
yqMerchantName
}}
</div>
</div>
</div>
</d2-dialog>
</d2-dialog>
...
@@ -69,7 +71,31 @@ export default {
...
@@ -69,7 +71,31 @@ export default {
},
},
methods
:
{
methods
:
{
/**
* @description: 图片转base64
* @param {String} url 需要转换的图片原链接(http://....jpg)
* @param {String} outputFormat 转换出来的图片的类型(canvas支持jpg/png格式)
* @return: 返回图片对应的base64编码
*/
getBas64
(
url
,
outputFormat
=
'image/png'
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
canvas
=
document
.
createElement
(
'CANVAS'
)
const
ctx
=
canvas
.
getContext
(
'2d'
)
const
img
=
new
Image
()
img
.
crossOrigin
=
'Anonymous'
// 重点!设置image对象可跨域请求
img
.
onload
=
function
()
{
canvas
.
height
=
img
.
height
canvas
.
width
=
img
.
width
ctx
.
drawImage
(
img
,
0
,
0
)
const
dataURL
=
canvas
.
toDataURL
(
outputFormat
)
canvas
=
null
resolve
(
dataURL
)
}
// img.src = url; // 旧的方式
img
.
src
=
url
+
'?t='
+
new
Date
().
valueOf
()
// 防止oss的缓存问题
})
},
createQrcodeImage
()
{
createQrcodeImage
()
{
const
oParams
=
{}
const
oParams
=
{}
oParams
.
channelType
=
1
oParams
.
channelType
=
1
...
@@ -81,16 +107,47 @@ export default {
...
@@ -81,16 +107,47 @@ export default {
createWeappQrcode
(
oParams
).
then
(
res
=>
{
createWeappQrcode
(
oParams
).
then
(
res
=>
{
this
.
qrCodeURL
=
res
this
.
qrCodeURL
=
res
// function getBase64(imgUrl) {
// window.URL = window.URL || window.webkitURL
// var xhr = new XMLHttpRequest()
// xhr.open('get', imgUrl, true)
// xhr.responseType = 'blob'
// xhr.onload = function () {
// if (this.status == 200) {
// // 得到一个blob对象
// var blob = this.response
// console.log('blob', blob)
// // 至关重要
// const oFileReader = new FileReader()
// oFileReader.onloadend = function (e) {
// // 此处拿到的已经是base64的图片了,可以赋值做相应的处理
// console.log(e.target.result)
// }
// oFileReader.readAsDataURL(blob)
// }
// }
// xhr.send()
// }
// console.log(getBase64(res))
// getBase64('需要转成base64的图片url')
})
})
},
},
// 下载保存图片
// 下载保存图片
takeScreenshot
()
{
takeScreenshot
()
{
html2canvas
(
document
.
getElementById
(
'view'
)).
then
(
canvas
=>
{
// const opts = {
// useCORS: true
// }
html2canvas
(
document
.
getElementById
(
'view'
),
{
backgroundColor
:
null
,
allowTaint
:
true
,
// 允许污染
taintTest
:
true
,
// 在渲染前测试图片(没整明白有啥用)
useCORS
:
true
// 使用跨域(当allowTaint为true时这段代码没什么用,下面解释)
}).
then
(
canvas
=>
{
this
.
convertCanvasToImg
(
canvas
)
this
.
convertCanvasToImg
(
canvas
)
})
})
},
},
// 转换图片格式
// 转换图片格式
convertCanvasToImg
(
canvas
)
{
convertCanvasToImg
(
canvas
)
{
// canvas base64 转 blob
// canvas base64 转 blob
...
@@ -148,22 +205,29 @@ export default {
...
@@ -148,22 +205,29 @@ export default {
position
:
relative
;
position
:
relative
;
/* background-image: url('./images/code3.png'); */
/* background-image: url('./images/code3.png'); */
}
}
.
imgDiv
{
.
qrImg
{
width
:
150px
;
width
:
150px
;
height
:
150px
;
height
:
150px
;
position
:
absolute
;
position
:
absolute
;
left
:
50%
;
left
:
50%
;
top
:
42%
;
top
:
42%
;
transform
:
translate
(
-50%
,
-50%
);
transform
:
translate
(
-50%
,
-50%
);
background-color
:
#d8d8d8
;
/* background-color: #d8d8d8; */
z-index
:
2
;
}
}
.loadingIcon
{
.loadingIcon
{
position
:
absolute
;
position
:
absolute
;
/* width: 44px;
/* width: 44px;
height: 44px; */
height: 44px; */
font-size
:
30px
;
font-size
:
30px
;
top
:
60px
;
/* top: 60px;
left
:
60px
;
left: 60px; */
/* transform: translate(-50%, -50%); */
/* width: 150px;
height: 150px; */
position
:
absolute
;
left
:
46%
;
top
:
40%
;
transform
:
translate
(
-50%
,
-50%
);
transform
:
translate
(
-50%
,
-50%
);
}
}
.merchantNameDiv
{
.merchantNameDiv
{
...
...
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