Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
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
和慭琛
take_order
Commits
1c343a45
Commit
1c343a45
authored
Dec 30, 2020
by
和慭琛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
水印图片下载
parent
3e6c8074
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
9 deletions
+38
-9
try.vue
take-order/pages/photo/try.vue
+38
-9
No files found.
take-order/pages/photo/try.vue
View file @
1c343a45
...
@@ -48,12 +48,14 @@
...
@@ -48,12 +48,14 @@
icon_live_mark
:
'https://qn-static.banshouhui.com/live_mark.png'
,
icon_live_mark
:
'https://qn-static.banshouhui.com/live_mark.png'
,
width
:
''
,
width
:
''
,
height
:
''
,
height
:
''
,
markPath
:
''
,
}
}
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
this
.
ctx
=
uni
.
createCameraContext
();
this
.
ctx
=
uni
.
createCameraContext
();
this
.
date
=
'时间:'
+
this
.
getTime
()
this
.
date
=
'时间:'
+
this
.
getTime
()
this
.
getLocation
()
this
.
getLocation
()
this
.
getMarkPath
()
uni
.
setNavigationBarColor
({
uni
.
setNavigationBarColor
({
frontColor
:
'#FFFFFF'
,
frontColor
:
'#FFFFFF'
,
...
@@ -63,10 +65,7 @@
...
@@ -63,10 +65,7 @@
},
},
methods
:
{
methods
:
{
//切换前后
switchClick
(){
},
//返回 点击
//返回 点击
backClick
:
function
()
{
backClick
:
function
()
{
...
@@ -90,6 +89,25 @@
...
@@ -90,6 +89,25 @@
});
});
},
},
//获取 水印 本地缓存路径
getMarkPath
:
function
(){
let
that
=
this
uni
.
downloadFile
({
url
:
this
.
icon_live_mark
,
//仅为示例,并非真实的资源
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
console
.
log
(
'水印图片 下载成功'
)
that
.
markPath
=
res
.
tempFilePath
console
.
log
(
'markPath:'
+
that
.
markPath
)
}
},
fail
()
{
console
.
log
(
'水印图片 下载失败'
)
}
})
},
//第一步: 拍照
//第一步: 拍照
takePhoto
(){
takePhoto
(){
let
that
=
this
let
that
=
this
...
@@ -117,8 +135,8 @@
...
@@ -117,8 +135,8 @@
success
(
res
)
{
success
(
res
)
{
console
.
log
(
'获取图片信息成功'
)
console
.
log
(
'获取图片信息成功'
)
//that.saveToLocal(res.)
//that.saveToLocal(res.)
that
.
width
=
res
.
width
/
3
+
'px'
;
that
.
width
=
res
.
width
+
'px'
;
that
.
height
=
res
.
height
/
3
+
'px'
;
that
.
height
=
res
.
height
+
'px'
;
that
.
drawCanvas
(
tempImagePath
,
res
)
that
.
drawCanvas
(
tempImagePath
,
res
)
}
}
...
@@ -131,12 +149,23 @@
...
@@ -131,12 +149,23 @@
this
.
showImage
=
true
this
.
showImage
=
true
//将原图画到canvas上面
//将原图画到canvas上面
this
.
canvas
=
uni
.
createCanvasContext
(
"canvas"
,
this
)
this
.
canvas
=
uni
.
createCanvasContext
(
"canvas"
,
this
)
this
.
canvas
.
drawImage
(
tempImagePath
,
0
,
0
,
res
.
width
/
3
,
res
.
height
/
3
)
this
.
canvas
.
drawImage
(
tempImagePath
,
0
,
0
,
res
.
width
,
res
.
height
)
this
.
canvas
.
draw
()
this
.
canvas
.
draw
()
//加入 水印文字
this
.
canvas
.
setFontSize
(
18
)
this
.
canvas
.
setFillStyle
(
'#8a2929'
)
this
.
canvas
.
rotate
(
30
*
Math
.
PI
/
180
);
let
textToWidth
=
res
.
width
*
0.5
;
let
textToHeight
=
res
.
height
*
0.3
;
this
.
canvas
.
fillText
(
'我是水印'
,
textToWidth
,
textToHeight
)
//加入 水印图片
this
.
canvas
.
drawImage
(
this
.
markPath
,
50
,
50
,
200
,
40
)
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'数据处理中...'
,
title
:
'数据处理中...'
,
icon
:
'loading'
,
icon
:
'loading'
duration
:
10000
})
})
//that.canvas.draw()
//that.canvas.draw()
this
.
exportCanvasTempFilePath
(
res
.
width
,
res
.
height
)
this
.
exportCanvasTempFilePath
(
res
.
width
,
res
.
height
)
...
...
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