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
2646f639
Commit
2646f639
authored
Mar 27, 2021
by
李俊赕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style-change
parent
022407ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
79 deletions
+104
-79
take.vue
take-order/pages/photo/take.vue
+104
-79
No files found.
take-order/pages/photo/take.vue
View file @
2646f639
<
template
>
<
template
>
<view
class=
"camera-container"
>
<view
class=
"camera-container"
>
<cover-view
class=
"header-box"
:style=
"
{'height':navHeight + 'rpx'}">
<cover-view
class=
"header-box"
:style=
"
{'height':navHeight + 'rpx'}">
<cover-view
class=
"inner"
>
<cover-view
class=
"inner"
>
<cover-image
@
click=
"setCameraInfo('devicePosition')"
class=
"icon"
mode=
"aspectFit"
src=
"/static/photo/icon-switch.png"
></cover-image>
<cover-image
@
click=
"setCameraInfo('devicePosition')"
class=
"icon"
mode=
"aspectFit"
<cover-image
@
click=
"setCameraInfo('flash')"
class=
"icon"
mode=
"aspectFit"
:src=
"'/static/photo/icon-light-' + cameraInfo.flash +'.png'"
></cover-image>
src=
"/static/photo/icon-switch.png"
></cover-image>
<cover-image
@
click=
"goPage('/pages/photo/setting')"
class=
"icon"
mode=
"aspectFit"
src=
"/static/photo/icon-setting.png"
></cover-image>
<cover-image
@
click=
"setCameraInfo('flash')"
class=
"icon"
mode=
"aspectFit"
:src=
"'/static/photo/icon-light-' + cameraInfo.flash +'.png'"
></cover-image>
<cover-image
@
click=
"goPage('/pages/photo/setting')"
class=
"icon"
mode=
"aspectFit"
src=
"/static/photo/icon-setting.png"
></cover-image>
</cover-view>
</cover-view>
</cover-view>
</cover-view>
<camera
class=
"camera-box"
v-if=
"cameraChange&&!standardShow"
:device-position=
"cameraInfo.devicePosition"
:flash=
"cameraInfo.flash"
:style=
"
{'height':cameraHeight + 'rpx'}"
<camera
class=
"camera-box"
v-if=
"cameraChange&&!standardShow"
:device-position=
"cameraInfo.devicePosition"
@error="cameraError">
:flash=
"cameraInfo.flash"
:style=
"
{'height':cameraHeight + 'rpx'}"
@error="cameraError">
<cover-view
class=
"mark-box"
>
<cover-view
class=
"mark-box"
>
<cover-view
class=
"txt u-m-
l-20 u-m-
t-30"
>
经度:
{{
waterInfo
.
longitude
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-t-30"
>
经度:
{{
waterInfo
.
longitude
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-
l-20 u-m-
t-10"
>
维度:
{{
waterInfo
.
latitude
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-t-10"
>
维度:
{{
waterInfo
.
latitude
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-
l-20 u-m-
t-10"
>
地址:
{{
waterInfo
.
address
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-t-10"
>
地址:
{{
waterInfo
.
address
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-
l-20 u-m-
t-10"
>
时间:
{{
waterInfo
.
date
||
'正在获取中...'
}}
</cover-view>
<cover-view
class=
"txt u-m-t-10"
>
时间:
{{
waterInfo
.
date
||
'正在获取中...'
}}
</cover-view>
</cover-view>
</cover-view>
<cover-image
class=
"mark-water"
mode=
"aspectFit"
:src=
"waterInfo.markImage"
></cover-image>
<cover-image
class=
"mark-water"
mode=
"aspectFit"
:src=
"waterInfo.markImage"
></cover-image>
</camera>
</camera>
...
@@ -23,11 +25,13 @@
...
@@ -23,11 +25,13 @@
<cover-image
class=
'icon-take icon'
src=
'/static/photo/icon-take.png'
@
click=
"takePhoto"
>
</cover-image>
<cover-image
class=
'icon-take icon'
src=
'/static/photo/icon-take.png'
@
click=
"takePhoto"
>
</cover-image>
<cover-image
class=
'icon'
src=
'/static/photo/icon-standard.png'
@
click=
"standardShow = true"
>
</cover-image>
<cover-image
class=
'icon'
src=
'/static/photo/icon-standard.png'
@
click=
"standardShow = true"
>
</cover-image>
</cover-view>
</cover-view>
<canvas
canvas-id=
"canvas"
id=
"photoCanvas"
class=
"canvas"
:style=
"
{'width':750 + 'rpx','height': cameraHeight + 'rpx'}">
</canvas>
<canvas
canvas-id=
"canvas"
id=
"photoCanvas"
class=
"canvas"
:style=
"
{'width':750 + 'rpx','height': cameraHeight + 'rpx'}">
</canvas>
<view
v-if=
"standardShow"
class=
"page-mask"
:z-index=
"10000"
>
<view
v-if=
"standardShow"
class=
"page-mask"
:z-index=
"10000"
>
<photo-standard
:currentItem=
"currentItem"
/>
<photo-standard
:currentItem=
"currentItem"
/>
<view
class=
"btn-close"
@
click=
"standardShow = false"
>
<view
class=
"btn-close"
@
click=
"standardShow = false"
>
<image
class=
"icon icon-close"
mode=
"aspectFit"
src=
"/static/photo/icon-close.png"
></cover-image>
<image
class=
"icon icon-close"
mode=
"aspectFit"
src=
"/static/photo/icon-close.png"
>
</cover-image>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -41,19 +45,22 @@
...
@@ -41,19 +45,22 @@
});
});
import
standard
from
'@/components/photo/standard.vue'
import
standard
from
'@/components/photo/standard.vue'
export
default
{
export
default
{
components
:{
components
:
{
'photo-standard'
:
standard
,
'photo-standard'
:
standard
,
},
},
data
()
{
data
()
{
return
{
return
{
currentItem
:{
currentItem
:
{
name
:
'111'
,
name
:
'111'
,
images
:[
'https://qn-static.banshouhui.com/live_mark.png'
,
'https://qn-static.banshouhui.com/live_mark.png'
,
'https://qn-static.banshouhui.com/live_mark.png'
],
images
:
[
'https://qn-static.banshouhui.com/live_mark.png'
,
},
'https://qn-static.banshouhui.com/live_mark.png'
,
standardShow
:
false
,
'https://qn-static.banshouhui.com/live_mark.png'
cameraInfo
:{
],
devicePosition
:
'back'
,
},
flash
:
'auto'
standardShow
:
false
,
cameraInfo
:
{
devicePosition
:
'back'
,
flash
:
'auto'
},
},
waterInfo
:
{
waterInfo
:
{
longitude
:
''
,
// 经度
longitude
:
''
,
// 经度
...
@@ -62,34 +69,34 @@
...
@@ -62,34 +69,34 @@
date
:
''
,
//日期
date
:
''
,
//日期
markImage
:
'https://qn-static.banshouhui.com/live_mark.png'
markImage
:
'https://qn-static.banshouhui.com/live_mark.png'
},
},
tempImgs
:{
tempImgs
:
{
'markImage'
:
''
,
// 拍照水印
'markImage'
:
''
,
// 拍照水印
'origin'
:
''
,
// 无水印照片
'origin'
:
''
,
// 无水印照片
'mixWater'
:
''
,
// 有水印照片
'mixWater'
:
''
,
// 有水印照片
},
},
authSetting
:
{
authSetting
:
{
camera
:
false
,
// 相机授权
camera
:
false
,
// 相机授权
location
:
false
,
// 位置授权
location
:
false
,
// 位置授权
},
},
navHeight
:
0
,
navHeight
:
0
,
cameraWidth
:
750
,
cameraWidth
:
750
,
cameraHeight
:
1000
,
// (4 / 3 * 750) 图片比例4:3
cameraHeight
:
1000
,
// (4 / 3 * 750) 图片比例4:3
ratio
:
0
,
ratio
:
0
,
cameraChange
:
true
,
cameraChange
:
true
,
}
}
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
const
photo
=
getApp
().
globalData
.
photo
const
photo
=
getApp
().
globalData
.
photo
console
.
log
(
photo
,
'global-photo'
)
console
.
log
(
photo
,
'global-photo'
)
getApp
().
trackPage
(
'拍照页'
)
getApp
().
trackPage
(
'拍照页'
)
// this.ctx = uni.createCameraContext();
// this.ctx = uni.createCameraContext();
this
.
waterInfo
.
date
=
this
.
get
Time
()
this
.
update
Time
()
this
.
getLocation
()
this
.
getLocation
()
this
.
getMarkPath
()
this
.
getMarkPath
()
this
.
currentItem
=
photo
.
currentItem
this
.
currentItem
=
photo
.
currentItem
},
},
compute
:
{
compute
:
{
setting
(){
setting
()
{
const
photo
=
getApp
().
globalData
.
photo
const
photo
=
getApp
().
globalData
.
photo
return
photo
.
setting
||
null
return
photo
.
setting
||
null
}
}
...
@@ -115,34 +122,44 @@
...
@@ -115,34 +122,44 @@
// })
// })
},
},
methods
:
{
methods
:
{
goBack
(){
goBack
()
{
uni
.
redirectTo
({
uni
.
navigateBack
({
url
:
'/pages/photo/list'
delta
:
2
})
})
// uni.redirectTo({
// url: '/pages/photo/list'
// })
},
},
goPage
(
url
){
goPage
(
url
)
{
url
=
url
||
'/pages/photo/index'
;
url
=
url
||
'/pages/photo/index'
;
console
.
log
(
url
,
'url'
)
console
.
log
(
url
,
'url'
)
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
url
url
:
url
})
})
},
},
setCameraInfo
(
type
){
updateTime
()
{
this
.
waterInfo
.
date
=
this
.
getTime
()
let
timer
=
setTimeout
(()
=>
{
clearTimeout
(
timer
);
this
.
updateTime
()
},
1000
)
},
setCameraInfo
(
type
)
{
// 设置相机前置后置、闪关灯等
// 设置相机前置后置、闪关灯等
const
cameraInfo
=
this
.
cameraInfo
const
cameraInfo
=
this
.
cameraInfo
let
val
=
cameraInfo
[
type
]
let
val
=
cameraInfo
[
type
]
switch
(
type
)
{
switch
(
type
)
{
case
'devicePosition'
:
case
'devicePosition'
:
val
=
val
===
'back'
?
'front'
:
'back'
val
=
val
===
'back'
?
'front'
:
'back'
break
;
break
;
case
'flash'
:
case
'flash'
:
val
=
val
===
'auto'
?
'on'
:
(
val
===
'on'
?
'off'
:
'auto'
)
val
=
val
===
'auto'
?
'on'
:
(
val
===
'on'
?
'off'
:
'auto'
)
break
;
break
;
defalut
:
defalut
:
break
;
break
;
}
}
console
.
log
(
type
,
'type'
,
val
,
'val'
)
console
.
log
(
type
,
'type'
,
val
,
'val'
)
this
.
cameraInfo
[
type
]
=
val
this
.
cameraInfo
[
type
]
=
val
},
},
initData
()
{
initData
()
{
...
@@ -246,7 +263,7 @@
...
@@ -246,7 +263,7 @@
self
.
authSetting
.
location
=
true
self
.
authSetting
.
location
=
true
self
.
getLocation
()
self
.
getLocation
()
}
}
console
.
log
(
self
.
cameraChange
,
'this.cameraChange'
)
console
.
log
(
self
.
cameraChange
,
'this.cameraChange'
)
if
(
res
.
authSetting
[
'scope.camera'
])
{
if
(
res
.
authSetting
[
'scope.camera'
])
{
self
.
authSetting
.
camera
=
true
self
.
authSetting
.
camera
=
true
}
}
...
@@ -272,12 +289,14 @@
...
@@ -272,12 +289,14 @@
})
})
},
},
getDrawTxtArr
(){
getDrawTxtArr
()
{
// 获取绘制数组
// 获取绘制数组
let
arr
=
[]
let
arr
=
[]
// 包含经纬度
// 包含经纬度
const
waterInfo
=
this
.
waterInfo
const
waterInfo
=
this
.
waterInfo
arr
=
[
'经度: '
+
waterInfo
.
longitude
,
'维度: '
+
waterInfo
.
latitude
,
'地址: '
+
waterInfo
.
address
,
'时间: '
+
waterInfo
.
date
]
arr
=
[
'经度: '
+
waterInfo
.
longitude
,
'维度: '
+
waterInfo
.
latitude
,
'地址: '
+
waterInfo
.
address
,
'时间: '
+
waterInfo
.
date
]
return
arr
return
arr
},
},
/* ---------------------- 拍照流程 ---------------------- */
/* ---------------------- 拍照流程 ---------------------- */
...
@@ -285,7 +304,7 @@
...
@@ -285,7 +304,7 @@
takePhoto
()
{
takePhoto
()
{
wx
.
createCameraContext
().
takePhoto
({
wx
.
createCameraContext
().
takePhoto
({
quality
:
"high"
quality
:
"high"
}).
then
(
res
=>
{
}).
then
(
res
=>
{
this
.
tempImgs
.
origin
=
res
.
tempImagePath
this
.
tempImgs
.
origin
=
res
.
tempImagePath
this
.
drawCanvas
(
res
.
tempImagePath
)
this
.
drawCanvas
(
res
.
tempImagePath
)
})
})
...
@@ -299,7 +318,7 @@
...
@@ -299,7 +318,7 @@
const
globalTempPath
=
getApp
().
globalData
.
photo
.
tempPath
const
globalTempPath
=
getApp
().
globalData
.
photo
.
tempPath
const
ratio
=
this
.
ratio
const
ratio
=
this
.
ratio
let
canvasWidth
=
this
.
cameraWidth
*
ratio
let
canvasWidth
=
this
.
cameraWidth
*
ratio
let
canvasHeight
=
this
.
cameraHeight
*
ratio
let
canvasHeight
=
this
.
cameraHeight
*
ratio
const
waterInfo
=
this
.
waterInfo
const
waterInfo
=
this
.
waterInfo
this
.
showImage
=
true
this
.
showImage
=
true
const
drawTxtArr
=
this
.
getDrawTxtArr
()
const
drawTxtArr
=
this
.
getDrawTxtArr
()
...
@@ -314,7 +333,7 @@
...
@@ -314,7 +333,7 @@
canvas
.
setFillStyle
(
'#f2f2f2'
)
canvas
.
setFillStyle
(
'#f2f2f2'
)
let
h
=
1
let
h
=
1
let
txtHeight
=
18
let
txtHeight
=
18
for
(
let
i
=
0
;
i
<
drawTxtArr
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
drawTxtArr
.
length
;
i
++
)
{
const
txt
=
drawTxtArr
[
i
]
const
txt
=
drawTxtArr
[
i
]
canvas
.
fillText
(
txt
,
10
,
canvasHeight
-
txtHeight
*
h
++
);
canvas
.
fillText
(
txt
,
10
,
canvasHeight
-
txtHeight
*
h
++
);
}
}
...
@@ -328,7 +347,7 @@
...
@@ -328,7 +347,7 @@
setTimeout
(()
=>
{
setTimeout
(()
=>
{
uni
.
canvasToTempFilePath
({
uni
.
canvasToTempFilePath
({
width
:
canvasWidth
,
width
:
canvasWidth
,
height
:
canvasHeight
,
height
:
canvasHeight
,
canvasId
:
'canvas'
,
canvasId
:
'canvas'
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
this
.
tempImgs
.
mixWater
=
res
.
tempFilePath
this
.
tempImgs
.
mixWater
=
res
.
tempFilePath
...
@@ -370,17 +389,19 @@
...
@@ -370,17 +389,19 @@
},
},
//获取当前时间
//获取当前时间
getTime
:
function
()
{
getTime
:
function
()
{
let
date
=
new
Date
(),
let
d
=
new
Date
();
year
=
date
.
getFullYear
(),
let
year
=
d
.
getFullYear
();
month
=
date
.
getMonth
()
+
1
,
let
month
=
d
.
getMonth
()
+
1
;
day
=
date
.
getDate
(),
let
date
=
d
.
getDate
();
hour
=
date
.
getHours
()
<
10
?
"0"
+
date
.
getHours
()
:
date
.
getHours
(),
let
days
=
new
Array
(
"日"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
);
minute
=
date
.
getMinutes
()
<
10
?
"0"
+
date
.
getMinutes
()
:
date
.
getMinutes
(),
let
day
=
d
.
getDay
();
second
=
date
.
getSeconds
()
<
10
?
"0"
+
date
.
getSeconds
()
:
date
.
getSeconds
();
let
hour
=
(
d
.
getHours
()
<
10
)
?
(
"0"
+
d
.
getHours
())
:
d
.
getHours
();
month
>=
1
&&
month
<=
9
?
(
month
=
"0"
+
month
)
:
""
;
let
min
=
(
d
.
getMinutes
()
<
10
)
?
(
"0"
+
d
.
getMinutes
())
:
d
.
getMinutes
();
day
>=
0
&&
day
<=
9
?
(
day
=
"0"
+
day
)
:
""
;
let
sec
=
(
d
.
getSeconds
()
<
10
)
?
(
"0"
+
d
.
getSeconds
())
:
d
.
getSeconds
();
var
timer
=
year
+
'/'
+
month
+
'/'
+
day
+
' '
+
hour
+
':'
+
minute
+
':'
+
second
;
let
now
=
year
+
"年"
+
month
+
"月"
+
date
+
"日 "
+
hour
+
":"
+
min
+
":"
+
sec
+
"(星期"
+
days
[
day
]
+
return
timer
;
")"
;
return
now
},
},
}
}
}
}
...
@@ -469,32 +490,36 @@
...
@@ -469,32 +490,36 @@
}
}
}
}
}
}
.canvas
{
.canvas
{
position
:
fixed
;
position
:
fixed
;
left
:
-750rpx
;
left
:
-750rpx
;
top
:
0
;
top
:
0
;
}
}
// 拍照规范
// 拍照规范
.page-mask
{
.page-mask
{
position
:
fixed
;
position
:
fixed
;
bottom
:
0
;
bottom
:
0
;
z-index
:
1000
;
z-index
:
1000
;
width
:
750rpx
;
width
:
750rpx
;
height
:
100vh
;
height
:
100vh
;
padding
:
0
30rpx
;
padding
:
0
30rpx
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
background-color
:
rgba
(
0
,
0
,
0
,
0
.8
);
background-color
:
rgba
(
0
,
0
,
0
,
0
.8
);
.icon
{
.icon
{
width
:
92rpx
;
width
:
92rpx
;
height
:
92rpx
;
height
:
92rpx
;
}
}
.btn-close
{
.btn-close
{
position
:
absolute
;
position
:
absolute
;
bottom
:
0
;
bottom
:
0
;
left
:
0
;
right
:
0
;
left
:
0
;
height
:
200rpx
;
right
:
0
;
z-index
:
100
;
height
:
200rpx
;
z-index
:
100
;
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
...
...
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