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
2dec7783
Commit
2dec7783
authored
Dec 31, 2020
by
李俊赕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preview-photo
parent
8134a94e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
712 additions
and
903 deletions
+712
-903
pages.json
take-order/pages.json
+21
-8
preview.vue
take-order/pages/photo/preview.vue
+18
-1
take.vue
take-order/pages/photo/take.vue
+419
-695
try.vue
take-order/pages/photo/try.vue
+254
-199
No files found.
take-order/pages.json
View file @
2dec7783
...
@@ -62,6 +62,12 @@
...
@@ -62,6 +62,12 @@
"navigationBarTitleText"
:
"选择品牌"
"navigationBarTitleText"
:
"选择品牌"
}
}
},
},
{
"path"
:
"pages/photo/take"
,
"style"
:
{
"navigationBarTitleText"
:
"拍照-ljd"
}
},
...
@@ -89,13 +95,13 @@
...
@@ -89,13 +95,13 @@
{
//
{
"path"
:
"pages/take/index
"
,
//
"path"
:
"pages/take/try
"
,
"style"
:
{
//
"style"
:
{
"navigationBarTitleText"
:
"接单"
,
//
"navigationBarTitleText"
:
"接单"
,
"enablePullDownRefresh"
:
true
//
"enablePullDownRefresh"
:
true
}
//
}
},
//
},
...
@@ -180,9 +186,16 @@
...
@@ -180,9 +186,16 @@
"navigationBarTitleText"
:
"uni-app"
,
"navigationBarTitleText"
:
"uni-app"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"backgroundColor"
:
"#F8F8F8"
"backgroundColor"
:
"#F8F8F8"
},
"condition"
:
{
//模式配置,仅开发期间生效
"current"
:
0
,
//当前激活的模式(list
的索引项)
"list"
:
[{
"name"
:
"拍照小工具"
,
//模式名称
"path"
:
"pages/photo/try"
,
//启动页面,必选
"query"
:
""
//启动参数,在页面的onLoad函数里面得到
}]
}
}
}
}
take-order/pages/photo/preview.vue
View file @
2dec7783
<
template
>
<
template
>
<view>
<image
class=
"pic"
:src=
"images[0]"
mode=
"aspectFill"
></image>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -10,10 +12,20 @@
...
@@ -10,10 +12,20 @@
}
}
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
console
.
log
(
e
,
'e'
)
if
(
e
.
img
){
this
.
images
=
[
e
.
img
]
}
},
},
methods
:
{
methods
:
{
showPreviewFn
(
img
)
{
uni
.
previewImage
({
current
:
0
,
urls
:
this
.
images
});
},
//拨打客服 点击
//拨打客服 点击
phoneCallClick
:
function
(
phone
)
{
phoneCallClick
:
function
(
phone
)
{
uni
.
makePhoneCall
({
uni
.
makePhoneCall
({
...
@@ -28,4 +40,9 @@
...
@@ -28,4 +40,9 @@
</
script
>
</
script
>
<
style
>
<
style
>
.pic
{
display
:
block
;
width
:
100%
;
height
:
auto
;
}
</
style
>
</
style
>
take-order/pages/photo/take.vue
View file @
2dec7783
<
template
>
<view
class=
"container"
>
<camera
device-position=
"back"
flash=
"off"
style=
'width:100%; height:100vh;'
>
<cover-view
class=
"locationView"
>
<cover-view
class=
"locationText u-m-l-20 u-m-t-30"
>
{{
longitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
latitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
address
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
date
}}
</cover-view>
</cover-view>
<cover-image
class=
"liveWatermarkNormal"
mode=
"aspectFit"
:src=
"liveWaterMarkImage"
></cover-image>
</camera>
<cover-view
class=
"bottomView"
>
<!--cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()">
</cover-image-->
<cover-image
class=
'takeIcon'
:src=
'icon_take'
@
click=
"takePhoto()"
>
</cover-image>
<cover-image
class=
"backIcon"
:src=
"icon_arrow_down"
mode=
""
@
click=
"backClick"
></cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()">
</cover-image-->
</cover-view>
<canvas
class=
"showCanvas"
canvas-id=
"photoCanvas"
id=
"photoCanvas"
:style=
"
{width:canvas.sWidth + 'px',height:canvas.sHeight+ 'px'}">
</canvas>
<!--template>
<view>
<cover-view class="{{scale=='4_3'?'nav__scale-4-3':scale=='16_9'?'nav__scale-16-9':'nav__scale-full'}}" style="height:{{navHeight}}rpx;">
<cover-image @click="changeScale" class="nav-scaleIcon" mode="aspectFit" src="/image/{{scale}}_{{iconColor}}.png"></cover-image>
<cover-image @click="changeDevicePosition" class="nav-switchIcon" mode="aspectFit" src="/image/switch_{{iconColor}}.png"></cover-image>
<cover-image @click="changeLight" class="nav-lightIcon" mode="aspectFit" src="/image/light_{{light}}_{{iconColor}}.png"></cover-image>
</cover-view>
<camera binderror="binderror" bindinitdone="bindinitdone" bindstop="bindstop" class="camera" devicePosition="{{devicePosition}}" flash="{{light}}" resolution="high" style="height:{{cameraHeight}}rpx;top:{{scale=='4_3'?navHeight:0}}rpx">
<cover-view class="watermark-box" style="color:{{watermarkFontColor}}; {{watermarkStyle}}">
<cover-view class="watermark-box__item" v-if="{{lonLat}}">经度:{{longitudeValue?longitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{lonLat}}">纬度:{{latitudeValue?latitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{address}}">地址:{{addressValue?addressValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{time}}">时间:{{timeValue?timeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{altitude}}">海拔:{{altitudeValue?altitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{weather}}">天气:{{weatherValue?weatherValue:'正在获取...'}}</cover-view>
<cover-view class="weui-flex" v-if="{{remarkArr.length>0}}">
<cover-view>备注:</cover-view>
<cover-view class="weui-flex__item" style="margin-top:1rpx;">
<cover-view v-for="{{remarkArr}}">{{item}}</cover-view>
</cover-view>
</cover-view>
</cover-view>
<cover-image class="{{direction=='normal'?'logoNormal':direction=='left'?'logoLeft':'logoRight'}}" mode="heightFix" src="{{logo}}" style="opacity:{{1-logoTransparency*5/100}};" v-if="{{logoEnable}}"></cover-image>
<cover-image class="{{direction=='normal'?'liveWatermarkNormal':direction=='left'?'liveWatermarkLeft':'liveWatermarkRight'}}" mode="aspectFit" src="{{liveWatermarkValue}}" v-if="{{liveWatermark}}"></cover-image>
<cover-image class="{{direction=='normal'?'handWritingNormal':direction=='left'?'handWritingLeft':'handWritingRight'}}" mode="aspectFit" src="{{handWriting}}"></cover-image>
</camera>
<cover-view class="camera-photoalbumIconBox {{tempImagePath?'':'1hidden'}}">
<cover-image @click="bindPhotoalbum" class="camera-photoalbumIcon" mode="aspectFill" src="{{tempImagePath}}"></cover-image>
</cover-view>
<cover-image @click="bindTakePhoto" class="camera-takeIcon" id="take" mode="aspectFit" src="/image/take.png"></cover-image>
<cover-image @click="bindSetting" class="camera-settingIcon" mode="aspectFit" src="/image/setting_white.png"></cover-image>
</view>
</view>
<canvas class="photoCanvas" id="photoCanvas" style="height:{{canvasHeight}}rpx;width:{{canvasWidth}}rpx;" type="2d"></canvas>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
// import mp_dialog from '/miniprogram_npm/weui-miniprogram/dialog/dialog';
// import mp_con from '/miniprogram_npm/weui-miniprogram/icon/icon';
// import mp_form_page from '/miniprogram_npm/weui-miniprogram/form-page/form-page';
// import mp_form from '/miniprogram_npm/weui-miniprogram/form/form';
// import mp_cell from '/miniprogram_npm/weui-miniprogram/cell/cell';
// import mp_cells from '/miniprogram_npm/weui-miniprogram/cells/cells';
// import mp_slideview from '/miniprogram_npm/weui-miniprogram/slideview/slideview';
// import mp_toptips from '/miniprogram_npm/weui-miniprogram/toptips/toptips';
// import mp_actionSheet from '/miniprogram_npm/weui-miniprogram/actionsheet/actionsheet';
// import mp_halfScreenDialog from '/miniprogram_npm/weui-miniprogram/half-screen-dialog/half-screen-dialog';
// import mp_msg from '/miniprogram_npm/weui-miniprogram/msg/msg';
// import color_picker from '/miniprogram_npm/mini-color-picker/color-picker';
// export default {
// components: {
// "mp-dialog":mp_dialog,
// "mp-icon":mp_con,
// "mp-form-page":mp_form_page,
// "mp-form":mp_form,
// "mp-cell":mp_cell,
// "mp-cells":mp_cells,
// "mp-slideview":mp_slideview,
// "mp-toptips":mp_toptips,
// "mp-actionSheet":mp_actionSheet,
// "mp-halfScreenDialog":mp_halfScreenDialog,
// "mp-msg":mp_msg,
// "color-picker":color_picker
// },
data
()
{
data
()
{
return
{
return
{
navHeight: o.globalData.navHeight,
title
:
''
,
ctx
:
null
,
path
:
""
,
image
:
""
,
showImage
:
false
,
canvas
:
null
,
longitude
:
'经度:正在获取中...'
,
latitude
:
'纬度:正在获取中...'
,
address
:
'地址:正在获取中...'
,
date
:
'时间:正在获取中...'
,
icon_location
:
'https://qn-static.banshouhui.com/take_order/icon/location.png'
,
scale
:
"4_3"
,
scale
:
"4_3"
,
iconColor: "white",
icon_take
:
'https://qn-static.banshouhui.com/take.png'
,
devicePosition: "back",
icon_switch_white
:
'https://qn-static.banshouhui.com/switch_white.png'
,
light: "off",
icon_light_on_white
:
'https://qn-static.banshouhui.com/light_on_white.png'
,
canvasWidth: 750,
liveWaterMarkImage
:
require
(
'@/static/live_mark.png'
),
canvasHeight: 1e3,
icon_arrow_down
:
'https://qn-static.banshouhui.com/arrow_down.png'
,
cameraHeight: 1e3,
icon_live_mark
:
'https://qn-static.banshouhui.com/live_mark.png'
,
watermarkStyle: "bottom:20rpx;left:20rpx;",
canvas
:
{
direction: "normal",
ctx
:
null
,
liveWatermarkValue: "/image/live_mark.png",
sWidth
:
750
,
baiduLocationTimer: null,
sHeight
:
0
,
wxLocationTimer: null,
},
netTimeTimer: null,
waterMarkerTemp
:
''
localTimeTimer: null,
takePhotoTimer: 0,
originalWeather: !1,
a:'',
t:'',
i:'',
o:'',
n:'',
r:'',
l:'',
s:'',
h:''
}
}
},
},
// var a
onLoad
(
e
)
{
// t = require("../../@babel/runtime/helpers/interopRequireDefault"),
this
.
ctx
=
uni
.
createCameraContext
();
// e = t(require("../../@babel/runtime/regenerator")),
this
.
date
=
'时间:'
+
this
.
getTime
()
// i = t(require("../../@babel/runtime/helpers/asyncToGenerator")),
this
.
getLocation
()
// o = getApp(), n = wx.getRealtimeLogManager(),
this
.
getSystemInfo
()
// r = require("../../libs/bmap-wx.min.js"), l = require("../../utils/util.js"),
uni
.
setNavigationBarColor
({
// s = !0,
frontColor
:
'#FFFFFF'
,
// h = new r.BMapWX({
backgroundColor
:
'#333333'
,
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
})
// });
this
.
downloadImageH5
(
this
.
liveWaterMarkImage
)
//this.address = ''
onLoad: function(a) {
this.listeningDeviceMotion(), this.originalWeather = o.globalData.weather, o.globalData.weather && this.baiduWeather(),
setTimeout(function() {
s = !1;
}, 2e3);
this.initabcde()
},
},
onReady: function() {},
onShow: function() {
wx.startDeviceMotionListening();
var a = o.globalData.remark, t = this.formatRemark(a);
o.globalData.remarkArr = t, this.setData({
lonLat: o.globalData.lonLat,
address: o.globalData.address,
time: o.globalData.time,
altitude: o.globalData.altitude,
weather: o.globalData.weather,
liveWatermark: o.globalData.liveWatermark,
remarkArr: o.globalData.remarkArr,
handWriting: o.globalData.handWriting,
logoEnable: o.globalData.logoEnable,
logo: o.globalData.logo,
latLonFormat: o.globalData.latLonFormat,
watermarkFont: o.globalData.watermarkFont,
watermarkFontColor: o.globalData.watermarkFontColor,
logoTransparency: o.globalData.logoTransparency
}), (o.globalData.lonLat || o.globalData.altitude) && (this.wxLocation(), wx.startLocationUpdate()),
o.globalData.address && this.baiduLocation(), o.globalData.time && this.netTime(),
o.globalData.weather && this.originalWeather != o.globalData.weather && this.baiduWeather(),
this.initWatermarkBoxHeightAndWidth();
},
onHide: function() {
wx.stopDeviceMotionListening().catch(function(a) {
console.log(a);
}), (o.globalData.lonLat || o.globalData.altitude) && wx.stopLocationUpdate().catch(function(a) {
console.log(a);
}), clearInterval(this.baiduLocationTimer), clearInterval(this.wxLocationTimer),
clearInterval(this.netTimeTimer), clearInterval(this.localTimeTimer);
},
onUnload: function() {
wx.stopDeviceMotionListening();
},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {},
bindinitdone: function(a) {},
bindstop: function(a) {},
binderror: function(a) {},
methods
:
{
methods
:
{
initabcde: function() {
//切换前后
var a
switchClick
()
{
t = require("../../@babel/runtime/helpers/interopRequireDefault"),
e = t(require("../../@babel/runtime/regenerator")),
},
i = t(require("../../@babel/runtime/helpers/asyncToGenerator")),
o = getApp(),
//返回 点击
n = wx.getRealtimeLogManager(),
backClick
:
function
()
{
r = require("../../libs/bmap-wx.min.js"),
uni
.
navigateBack
({
l = require("../../utils/util.js"),
s = !0,
})
h = new r.BMapWX({
},
ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
//获取位置
getLocation
()
{
let
that
=
this
uni
.
getLocation
({
type
:
'wgs84'
,
success
:
function
(
res
)
{
that
.
longitude
=
'经度:'
+
res
.
longitude
that
.
latitude
=
'纬度:'
+
res
.
latitude
console
.
log
(
'当前位置的经度:'
+
res
.
longitude
);
console
.
log
(
'当前位置的纬度:'
+
res
.
latitude
);
console
.
log
(
'当前位置的地址:'
+
res
.
address
);
}
});
});
},
},
//拍照
takePhoto
()
{
this
.
ctx
.
takePhoto
({
quality
:
'high'
,
success
:
(
res
)
=>
{
console
.
log
(
'拍照成功'
)
console
.
log
(
res
)
this
.
imageChange
(
res
)
//this.getImageInfo(res.tempImagePath)
//this.saveToLocal(res.tempImagePath)
}
});
},
//获取图片信息
getImageInfo
(
tempImagePath
)
{
let
that
=
this
uni
.
getImageInfo
({
src
:
tempImagePath
,
success
(
res
)
{
//that.saveToLocal(res.)
}
})
},
//保存到本地相册
saveToLocal
(
tempImagePath
)
{
uni
.
saveImageToPhotosAlbum
({
filePath
:
tempImagePath
,
success
()
{
console
.
log
(
'保存本地相册 成功'
)
},
fail
()
{
console
.
log
(
'保存本地相册 失败'
)
}
})
},
getSystemInfo
()
{
// 获取设备信息
try
{
const
res
=
uni
.
getSystemInfoSync
();
this
.
canvas
.
sWidth
=
res
.
windowWidth
this
.
canvas
.
sHeight
=
res
.
windowHeight
console
.
log
(
res
.
windowWidth
,
'res.windowWidth'
,
res
.
windowHeight
,
'res.windowHeight'
)
}
catch
(
e
)
{
// error
}
},
initWatermarkBoxHeightAndWidth: function() {
downloadImageH5
(
image
)
{
var a = this;
let
self
=
this
wx.nextTick(function() {
console
.
log
(
'downloadImageH5'
,
image
)
wx.createSelectorQuery().select(".watermark-box").boundingClientRect(function(t) {
// 图片下载本地
a.watermarkBoxHeight = t.height, a.watermarkBoxWidth = t.width, a.changeWatermark();
uni
.
downloadFile
({
}).exec();
url
:
image
,
//仅为示例,并非真实的资源
});
success
:
(
res
)
=>
{
},
console
.
log
(
res
,
'res-水印图片'
)
listeningDeviceMotion: function() {
if
(
res
.
statusCode
===
200
)
{
var a = this;
self
.
waterMarkerTemp
=
res
.
tempFilePath
wx.onDeviceMotionChange(function(t) {
}
if ("ios" == o.globalData.platform) {
}
var e = parseFloat(t.alpha);
});
a.direction = e > 45 && e < 136 ? "left" : e > 225 && e < 316 ? "right" : "normal";
},
} else t.gamma < -40 && t.gamma > -130 ? a.direction = "right" : t.gamma > 40 && t.gamma < 130 ? a.direction = "left" : a.direction = "normal";
canvasImage
()
{
a.direction != a.lastDirection && (a.setData({
let
self
=
this
direction: a.direction
this
.
canvas
.
ctx
.
draw
(
false
,
setTimeout
(()
=>
{
}), a.changeCanvas(), a.changeWatermark()), a.lastDirection = a.direction;
setTimeout
(()
=>
{
});
uni
.
canvasToTempFilePath
({
},
x
:
0
,
changeCanvas: function() {
y
:
0
,
var a = this, t = this.direction, e = this.data.canvasWidth, i = this.data.canvasHeight;
width
:
Number
(
this
.
canvas
.
sWidth
),
"normal" == t ? this.setData({
height
:
Number
(
this
.
canvas
.
sHeight
),
canvasHeight: Math.max(i, e),
canvasId
:
'photoCanvas'
,
canvasWidth: Math.min(i, e)
success
:
(
res
)
=>
{
}) : this.setData({
// this.$emit('canvasImage', res.tempFilePath);
canvasHeight: Math.min(i, e),
// if (this.showPreview) {
canvasWidth: Math.max(i, e)
self
.
showPreviewFn
(
res
.
tempFilePath
);
}), wx.createSelectorQuery().select("#photoCanvas").fields({
// }
node: !0,
},
size: !0
fail
:
(
res
)
=>
{
}).exec(function(t) {
console
.
log
(
res
);
a.canvas = t[0].node;
},
var e = t[0].width, i = t[0].height, n = o.globalData.pixelRatio;
complete
:
()
=>
{
a.canvas.width = e * n, a.canvas.height = i * n, a.canvas.getContext("2d").scale(n, n);
uni
.
hideLoading
();
});
}
},
},
this
);
changeScale: function() {
},
500
);
var a, t = this, e = this.data.scale, i = this.direction, n = this.data.canvasWidth, r = this.data.canvasHeight;
}));
"4_3" == e ? (this.setData({
},
scale: "16_9",
showPreviewFn
(
img
)
{
iconColor: "white",
uni
.
previewImage
({
cameraHeight: 16 / 9 * 750
current
:
0
,
}), a = 16 / 9 * 750) : "16_9" == e ? (this.setData({
urls
:
[
img
]
scale: "full",
});
iconColor: "white",
},
cameraHeight: o.globalData.rpxScreenHeight
//照片处理
}), a = o.globalData.rpxScreenHeight) : (this.setData({
imageChange
(
options
)
{
scale: "4_3",
let
self
=
this
iconColor: "white",
// let ctx = uni.createCanvasContext("photoCanvas") // canvas绘制对象
cameraHeight: 1e3
let
ctx
=
uni
.
createCanvasContext
(
'photoCanvas'
,
this
);
}), a = 1e3), "normal" == i ? this.setData({
let
sWidth
=
this
.
canvas
.
sWidth
//绘图宽度
canvasHeight: a,
let
sHeight
=
this
.
canvas
.
sHeight
// 绘图高度
canvasWidth: Math.min(r, n)
this
.
canvas
.
ctx
=
ctx
}) : this.setData({
ctx
.
setStrokeStyle
(
"#00ff00"
)
canvasWidth: a,
ctx
.
setLineWidth
(
5
)
canvasHeight: Math.min(r, n)
ctx
.
rect
(
0
,
0
,
sWidth
,
sHeight
)
}), wx.nextTick(function() {
ctx
.
drawImage
(
options
.
tempImagePath
,
0
,
0
,
sWidth
,
sHeight
)
t.changeCanvas(), setTimeout(function() {
ctx
.
setFontSize
(
20
)
t.changeWatermark();
ctx
.
fillText
(
'Hello'
,
20
,
20
)
}, 500);
ctx
.
fillText
(
'MINA'
,
100
,
100
)
});
// if(this.waterMarkerTemp){
},
// ctx.drawImage(this.waterMarkerTemp, sWidth/2 - 100, sHeight/2 - 20, 200, 40)
changeWatermark: function() {
// }
var a, t = this.data.direction, e = Math.min(this.watermarkBoxWidth, this.watermarkBoxHeight), i = Math.max(this.watermarkBoxWidth, this.watermarkBoxHeight);
ctx
.
drawImage
(
options
.
tempImagePath
,
sWidth
/
2
-
100
,
sHeight
/
2
-
20
,
200
,
40
);
a = "left" == t ? [ "top:" + (20 - 2 * e + 10) + "rpx", "left:20rpx", "transform-origin: left bottom", "transform: rotate(90deg)" ].join(";") : "right" == t ? [ "bottom:" + 2 * i + "rpx", "right:20rpx", "transform-origin: right bottom", "transform: rotate(-90deg)" ].join(";") : [ "bottom:20rpx", "left:20rpx" ].join(";"),
self
.
canvasImage
()
this.setData({
// self.path = options.tempImagePath
watermarkStyle: a
});
},
return
formatRemark: function(a) {
// uni.getImageInfo({
for (var t = [], e = 0, i = 15; i < a.length; i += 15) t.push(a.substring(15 * e, i)),
// src: that.path,
e++;
// success: function(res) {
return a.length % 15 != 0 && t.push(a.substring(15 * e, 15 * e + a.length % 15)),
// }
t;
// })
},
var
that
=
this
changeDevicePosition: function() {
//原图片信息
"back" == this.data.devicePosition ? this.setData({
var
_width
=
options
.
width
devicePosition: "front"
var
_height
=
options
.
height
}) : this.setData({
that
.
path
=
options
.
tempImagePath
devicePosition: "back"
console
.
log
(
'原照片信息'
)
});
console
.
log
(
'宽:'
+
options
.
width
)
},
console
.
log
(
'高:'
+
options
.
height
)
changeLight: function() {
console
.
log
(
'路径:'
+
options
.
tempImagePath
)
var a = this.data.light;
"torch" == a ? this.setData({
//需要的图片信息
light: "off"
var
image_x
=
parseInt
(
_width
*
0.1
);
}) : "off" == a ? this.setData({
var
image_y
=
parseInt
(
_height
*
0.09
);
light: "on"
var
image_width
=
parseInt
(
_width
*
0.8
);
}) : "on" == a ? this.setData({
var
image_height
=
parseInt
(
_height
*
0.87
);
light: "auto"
console
.
log
(
'需要的图片信息'
)
}) : this.setData({
console
.
log
(
'x:'
+
image_x
)
light: "torch"
console
.
log
(
'y:'
+
image_y
)
});
console
.
log
(
'宽:'
+
image_width
)
},
console
.
log
(
'高:'
+
image_height
)
bindPhotoalbum: function(a) {
wx.navigateTo({
url: "/pages/photoalbum/photoalbum?photoPath=" + this.data.tempImagePath
uni
.
getImageInfo
({
});
src
:
that
.
path
,
},
success
:
function
(
res
)
{
bindSetting: function() {
that
.
showImage
=
true
wx.navigateTo({
//将原图画到canvas上面
url: "/pages/settings/settings"
that
.
canvas
=
uni
.
createCanvasContext
(
"canvas"
,
that
)
});
//that.canvas.drawImage(that.path, 0, 0, _width, _height)
},
that
.
canvas
.
drawImage
(
that
.
path
,
0
,
0
,
res
.
width
*
3
,
res
.
height
*
3
)
bindTakePhoto: function() {
var a = this;
/*
if (!s && 0 == this.takePhotoTimer) {
//-----------------------------
this.takePhotoTimer = 1, setTimeout(function() {
// let ctx = uni.createCanvasContext('firstCanvas'); // 创建画布
a.takePhotoTimer = 0;
// //将图片src放到cancas内,宽高为图片大小
}, 1500), this.takePhotoAnimate();
// ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width / 3, ress.height / 3)
wx.createCameraContext().takePhoto({
that.canvas.setFontSize(18)
quality: "high"
// that.canvas.setFillStyle('#8a2929')
}).then(function(t) {
// that.canvas.rotate(-Math.PI / 2);
a.drawPhoto(t.tempImagePath);
let textToWidth = res.width / 3 * 0.5;
}).catch(function(a) {
let textToHeight = res.height / 3 * 0.3;
n.error(a), console.log(a);
that.canvas.fillText('我是水印', 10, 90)
});
//. 除了上面的文字水印,这里也可以加入图片水印
}
// ctx.drawImage('/static/watermark.png', 0, 0, res.width / 3, ress.height / 3)
},
that.canvas.drawImage('/static/live_mark.png', 0, 0, 200, 200)
drawPhoto: (a = (0, i.default)(e.default.mark(function a(t) {
//-----------------------------
var i, n, r, l, s, h, c, g, u, d, m = this;
*/
return e.default.wrap(function(a) {
that
.
canvas
.
draw
()
for (;;) switch (a.prev = a.next) {
uni
.
showLoading
({
case 0:
title
:
'数据处理中...'
,
return i = this.canvas.getContext("2d"), n = o.globalData.screenHeight / o.globalData.rpxScreenHeight,
icon
:
'loading'
,
r = this.data.canvasWidth * n, l = this.data.canvasHeight * n, a.next = 6, new Promise(function(a) {
duration
:
10000
var e = m.canvas.createImage();
})
e.onload = function() {
that
.
canvas
.
draw
()
var t = r, o = l, n = m.data.direction;
setTimeout
(
function
()
{
"left" == n ? (i.translate(0, o), i.rotate(-Math.PI / 2), i.drawImage(e, 0, 0, o, t),
//导出自己需要的图片
i.rotate(Math.PI / 2), i.translate(0, -o)) : "right" == n ? (i.translate(t, 0),
uni
.
canvasToTempFilePath
({
i.rotate(Math.PI / 2), i.drawImage(e, 0, 0, o, t), i.rotate(-Math.PI / 2), i.translate(-t, 0)) : i.drawImage(e, 0, 0, t, o),
canvasId
:
"canvas"
,
console.log("已画照片"), a("已画照片");
x
:
image_x
,
}, e.onerror = function() {
y
:
image_y
,
console.log("照片加载失败"), a();
width
:
image_width
,
}, e.src = t;
height
:
image_height
,
});
destWidth
:
image_width
,
destHeight
:
image_height
,
case 6:
success
:
function
(
ress
)
{
if (!this.data.liveWatermark || !this.data.liveWatermarkValue || "" == this.data.liveWatermarkValue) {
that
.
image
=
ress
.
tempFilePath
//处理好的图片
a.next = 9;
uni
.
hideLoading
()
break;
console
.
log
(
'处理图片 成功:'
)
}
console
.
log
(
ress
.
tempFilePath
)
return a.next = 9, new Promise(function(a) {
var t = m.canvas.createImage();
uni
.
showToast
({
t.onload = function() {
icon
:
'none'
,
var e = 360 * n, o = 90 * n, s = r / 2 - e / 2, h = l / 2 - o / 2;
title
:
'处理成功'
i.drawImage(t, s, h, e, o), console.log("已画现场水印"), a("已画现场水印");
})
}, t.onerror = function() {
console.log("现场水印加载失败"), a();
setTimeout
(
function
()
{
}, t.src = m.data.liveWatermarkValue;
});
that
.
saveToLocal
(
ress
.
tempFilePath
)
uni
.
previewImage
({
case 9:
urls
:
[
ress
.
tempFilePath
],
if (!this.data.handWriting || "" == this.data.handWriting) {
current
:
0
a.next = 12;
});
break;
// uni.navigateTo({
}
// url:'/pages/photo/preview'+'?path=' + res.tempFilePath
return a.next = 12, new Promise(function(a) {
// })
var t = m.canvas.createImage();
},
1000
);
t.onload = function() {
var e = 150 * n, o = 150 * n, s = r - e - 10, h = l - 10;
i.translate(s, h), i.rotate(-Math.PI / 2), i.drawImage(t, 0, 0, e, o), i.rotate(Math.PI / 2),
//TODO........
i.translate(-s, -h), console.log("已画手写签名水印"), a("已画手写签名水印");
}, t.onerror = function() {
},
console.log("手写签名水印加载失败"), a();
fail
:
function
(
e
)
{
}, t.src = m.data.handWriting;
uni
.
hideLoading
()
});
uni
.
showToast
({
title
:
'出错啦...'
,
case 12:
icon
:
'loading'
if (!this.data.logoEnable || !this.data.logo || "" == this.data.logo) {
})
a.next = 16;
console
.
log
(
'处理图片 失败:'
)
break;
console
.
log
(
e
)
}
}
return console.log("画水印LOGO"), a.next = 16, new Promise(function(a) {
});
var t = m.canvas.createImage();
},
1000
);
t.onload = function() {
}
var e = 150 * n, l = 150 * n, s = r - e - 10, h = 1 - 5 * o.globalData.logoTransparency / 100;
})
i.globalAlpha = h, i.drawImage(t, s, 10, e, l), i.globalAlpha = 1, console.log("已画水印LOGO"),
},
a("已画水印LOGO");
}, t.onerror = function() {
console.log("水印LOGO加载失败"), a();
//获取当前时间
}, t.src = m.data.logo;
getTime
:
function
()
{
});
var
date
=
new
Date
(),
case 16:
year
=
date
.
getFullYear
(),
if (console.log("画水印信息"), i.font = "14px", i.fillStyle = this.data.watermarkFontColor,
month
=
date
.
getMonth
()
+
1
,
s = l - 14, h = 0, (c = this.data.remarkArr) && c.length > 0) {
day
=
date
.
getDate
(),
for (g = c.length - 1; g >= 1; g--) u = c[g], i.fillText(u, 52, s - 18 * h++);
hour
=
date
.
getHours
()
<
10
?
"0"
+
date
.
getHours
()
:
date
.
getHours
(),
d = c[0], i.fillText("备注:" + d, 10, s - 18 * h++);
minute
=
date
.
getMinutes
()
<
10
?
"0"
+
date
.
getMinutes
()
:
date
.
getMinutes
(),
}
second
=
date
.
getSeconds
()
<
10
?
"0"
+
date
.
getSeconds
()
:
date
.
getSeconds
();
this.data.weather && this.data.weatherValue && i.fillText("天气:" + this.data.weatherValue, 10, s - 18 * h++),
month
>=
1
&&
month
<=
9
?
(
month
=
"0"
+
month
)
:
""
;
this.data.altitude && this.data.altitudeValue && i.fillText("海拔:" + this.data.altitudeValue, 10, s - 18 * h++),
day
>=
0
&&
day
<=
9
?
(
day
=
"0"
+
day
)
:
""
;
this.data.time && this.data.timeValue && i.fillText("时间:" + this.data.timeValue, 10, s - 18 * h++),
var
timer
=
year
+
'/'
+
month
+
'/'
+
day
+
' '
+
hour
+
':'
+
minute
+
':'
+
second
;
this.data.address && this.data.addressValue && i.fillText("地址:" + this.data.addressValue, 10, s - 18 * h++),
return
timer
;
this.data.lonLat && this.data.latitudeValue && this.data.longitudeValue && (i.fillText("纬度:" + this.data.latitudeValue, 10, s - 18 * h++),
},
i.fillText("经度:" + this.data.longitudeValue, 10, s - 18 * h++)), this.savaToTempFile();
case 31:
case "end":
return a.stop();
}
}, a, this);
})), function(t) {
return a.apply(this, arguments);
}),
savaToTempFile: function() {
var a = this;
wx.canvasToTempFilePath({
canvas: this.canvas
}).then(function(t) {
console.log(t), a.setData({
tempImagePath: t.tempFilePath
}), a.saveToPhotosAlbum(t.tempFilePath);
}).catch(function(a) {
n.error(a), console.log(a);
});
},
saveToPhotosAlbum: function(a) {
wx.getSetting({
success: function(t) {
t.authSetting["scope.writePhotosAlbum"] ? wx.saveImageToPhotosAlbum({
filePath: a
}) : wx.authorize({
scope: "scope.writePhotosAlbum",
success: function() {
wx.saveImageToPhotosAlbum({
filePath: a
});
},
fail: function() {
n.error("已拒绝保存照片到本地相册授权"), console.log("已拒绝保存照片到本地相册授权");
}
});
}
});
},
takePhotoAnimate: function() {
this.animate("#take", [ {
scale: [ 1, 1 ]
}, {
scale: [ .95, .95 ]
}, {
scale: [ 1, 1 ]
} ], 300, function() {
this.clearAnimation("#take");
}.bind(this));
},
baiduWeather: function() {
var a = this;
h.weather({
success: function(t) {
var e = t.currentWeather[0];
console.log("当前天气", e);
var i = e.temperature + " " + e.weatherDesc + " " + e.wind;
a.setData({
weatherValue: i
}), a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
n.error(a), console.log(a);
}
});
},
baiduLocation: function() {
var a = this, t = function() {
var t = {
success: function(t) {
var e = t.wxMarkerData[0];
console.log("当前定位", e);
var i = e.address;
a.setData({
addressValue: i
}), o.globalData.addressValue = i, a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
n.error(a), console.log(a);
}
};
if ((o.globalData.lonLat || o.globalData.altitude) && a.latitude && a.longitude) {
var e = a.latitude + "," + a.longitude;
t.location = e;
}
h.regeocoding(t);
};
t(), clearInterval(this.baiduLocationTimer), this.baiduLocationTimer = setInterval(t, 6e4);
},
wxLocation: function() {
var a = this;
wx.onLocationChange(function(t) {
a.latitude = t.latitude, a.longitude = t.longitude;
var e = l.formatLonLat(t.latitude, o.globalData.latLonFormat), i = l.formatLonLat(t.longitude, o.globalData.latLonFormat), n = "0米";
t.altitude && (n = t.altitude.toFixed(2) + "米"), a.setData({
latitudeValue: e,
longitudeValue: i,
altitudeValue: n
}), o.globalData.latitudeValue = e, o.globalData.longitudeValue = i, o.globalData.altitudeValue = n;
});
},
netTime: function() {
var a = this, t = function() {
wx.request({
url: "https://www.baidu.com",
success: function(t) {
var e = new Date(t.header.Date);
o.globalData.timestampValue = e.getTime();
var i = l.formatTime(e);
a.setData({
timeValue: i
}), o.globalData.timeValue = i, a.initWatermarkBoxHeightAndWidth();
}
});
};
t(), clearInterval(this.netTimeTimer), clearInterval(this.localTimeTimer), this.netTimeTimer = setInterval(t, 6e4),
this.localTimeTimer = setInterval(function() {
if (o.globalData.timestampValue) {
o.globalData.timestampValue += 1e3;
var t = l.formatTime(new Date(o.globalData.timestampValue));
a.setData({
timeValue: t
}), o.globalData.timeValue = t;
}
}, 1e3);
}
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
>
.hidden {
.bottomView
{
display: none;
background-color
:
#000000
;
}
z-index
:
5
;
width
:
100%
;
.camera {
height
:
200
rpx
;
width: 100%;
position
:
absolute
;
height: 100vh;
bottom
:
0
;
z-index: 1;
display
:
flex
;
position: absolute;
flex-direction
:
row
;
}
align-items
:
center
;
justify-content
:
center
;
.nav__scale-4-3 {
background-color: #000;
}
.nav__scale-4-3,.nav__scale-16-9 {
z-index: 5;
position: fixed;
top: 0;
left: 0;
right: 0;
}
.nav__scale-16-9 {
background-color: transparent;
}
.nav__scale-full {
z-index: 5;
position: fixed;
top: 0;
left: 0;
right: 0;
}
.nav-scaleIcon {
left: 5rpx;
}
.nav-scaleIcon,.nav-switchIcon {
z-index: 5;
width: 50rpx;
height: 50rpx;
position: absolute;
bottom: 0;
margin: 20rpx;
}
.nav-switchIcon {
left: 120rpx;
}
.nav-lightIcon {
left: 220rpx;
}
.nav-lightIcon,.nav-moreIcon {
z-index: 5;
width: 50rpx;
height: 50rpx;
position: absolute;
bottom: 0;
margin: 20rpx;
}
.nav-moreIcon {
left: 320rpx;
}
.camera-photoalbumIconBox {
z-index: 5;
width: 80rpx;
height: 80rpx;
position: absolute;
bottom: 60rpx;
left: 25%;
margin-left: -80rpx;
background-color: hsla(0,0%,100%,0);
border: 1rpx solid #fff;
border-radius: 50%;
}
.camera-photoalbumIcon {
z-index: 5;
}
}
.camera-takeIcon {
.switchIcon
{
z-index: 5;
background-color
:
#000000
;
width: 150rpx;
width
:
50
rpx
;
height: 150rpx;
height
:
50
rpx
;
position: absolute;
bottom: 25rpx;
left: 50%;
margin-left: -75rpx;
}
}
.camera-settingIcon {
.takeIcon
{
z-index: 5;
background-color
:
#000000
;
width: 80rpx;
width
:
150
rpx
;
height: 80rpx;
height
:
150
rpx
;
position: absolute;
bottom: 60rpx;
left: 75%;
}
}
.photoCanvas {
.flashIcon
{
z-index: -1;
background-color
:
#000000
;
position: absolute;
width
:
50
rpx
;
left: 9999px;
height
:
50
rpx
;
margin-left
:
100
rpx
;
}
}
.watermark-box {
.locationView
{
z-index: 4;
/* z-index: 5;
position: absolute;
width: 300rpx;
font-size: 14px;
position: absolute;
line-height: 18px;
left: 0;
color: #fff;
bottom: 200rpx;
display: flex;
flex-direction: column;
padding-bottom: 20rpx;
padding-right: 20rpx; */
bottom
:
200
rpx
;
padding-bottom
:
20
rpx
;
padding-right
:
20
rpx
;
z-index
:
4
;
position
:
absolute
;
font-size
:
14px
;
line-height
:
18px
;
color
:
#fff
;
}
}
.watermark-box__item {
.locationText
{
margin: 2px 0;
/* font-size: 24rpx;
color: #999999;
width: 260rpx; */
margin
:
2px
0
;
}
}
.liveWatermarkNormal
{
.liveWatermarkNormal
{
z-index: 3;
z-index
:
3
;
position: absolute;
position
:
absolute
;
left: 50%;
left
:
50%
;
top: 50%;
top
:
50%
;
transform: translate(-50%,-50%);
transform
:
translate
(
-50%
,
-50%
);
width: 360rpx;
width
:
360
rpx
;
height: 90rpx;
height
:
90
rpx
;
z-index: 6;
z-index
:
6
;
}
.liveWatermarkRight {
transform-origin: 50% 50%;
transform: rotate(-90deg);
}
.liveWatermarkLeft,.liveWatermarkRight {
z-index: 3;
position: absolute;
left: 25%;
top: calc(50% - 45rpx);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.liveWatermarkLeft {
transform-origin: 50% 50%;
transform: rotate(90deg);
}
.handWritingNormal {
transform-origin: 50% 50%;
transform: rotate(-90deg);
right: 20rpx;
}
}
.handWritingLeft,.handWritingNormal {
.backIcon
{
z-index: 3;
background-color
:
#FFFFFF
;
position: absolute;
width
:
54
rpx
;
width: 150rpx;
height
:
54
rpx
;
height: 150rpx;
border-radius
:
27
rpx
;
bottom: 20rpx;
position
:
fixed
;
}
left
:
60
rpx
;
bottom
:
50
rpx
;
.handWritingLeft {
transform-origin: 50% 50%;
left: 20rpx;
}
.handWritingRight {
transform-origin: 50% 50%;
transform: rotate(180deg);
}
.handWritingRight,.logoNormal {
z-index: 3;
position: absolute;
width: 150rpx;
height: 150rpx;
top: 20rpx;
right: 20rpx;
}
.logoNormal {
transform-origin: 50% 50%;
}
.logoLeft {
transform-origin: 50% 50%;
transform: rotate(90deg);
bottom: 20rpx;
right: 20rpx;
}
}
.logoLeft,.logoRight {
.container
{
z-index: 3;
position
:
relative
;
position: absolute;
width: 150rpx;
height: 150rpx;
}
}
.logoRight {
.showCanvas
{
transform-origin: 50% 50%;
position
:
absolute
;
transform: rotate(-90deg);
left
:
0
;
top: 20rpx;
/* top: 0; */
left: 20rpx;
z-index
:
-1
;
opacity
:
0
;
background-color
:
#007AFF
;
}
}
</
style
>
</
style
>
take-order/pages/photo/try.vue
View file @
2dec7783
<
template
>
<
template
>
<view
class=
""
>
<view
class=
""
>
<camera
device-position=
"back"
flash=
"off"
style=
'width:100%; height:100vh;'
>
<camera
device-position=
"back"
flash=
"off"
style=
'width:100%; height:100vh;'
>
<cover-view
class=
"locationView"
>
<cover-view
class=
"locationView"
>
<cover-view
class=
"locationText u-m-l-20 u-m-t-30"
>
{{
longitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-30"
>
{{
longitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
latitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
latitude
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
address
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
address
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
date
}}
</cover-view>
<cover-view
class=
"locationText u-m-l-20 u-m-t-10"
>
{{
date
}}
</cover-view>
</cover-view>
<cover-image
class=
"liveWatermarkNormal"
mode=
"aspectFit"
:src=
"liveWaterMarkImage"
></cover-image>
</camera>
<cover-view
class=
"bottomView"
>
<!--cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()">
</cover-image-->
<cover-image
class=
'takeIcon'
:src=
'icon_take'
@
click=
"takePhoto()"
>
</cover-image>
<cover-image
class=
"backIcon"
v-if=
"restultImage"
:src=
"restultImage"
mode=
""
@
click=
"goPage"
></cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()">
</cover-image-->
</cover-view>
</cover-view>
<cover-image
class=
"liveWatermarkNormal"
mode=
"aspectFit"
:src=
"liveWaterMarkImage"
></cover-image>
<canvas
v-show=
'showImage'
canvas-id=
"canvas"
:style=
"
{'width':canvasWidth+'px','height': canvasHeight + 'px'}">
</canvas>
</camera>
<cover-view
class=
"bottomView"
>
</view>
<!--cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()">
</cover-image-->
<cover-image
class=
'takeIcon'
:src=
'icon_take'
@
click=
"takePhoto()"
>
</cover-image>
<cover-image
class=
"backIcon"
:src=
"icon_arrow_down"
mode=
""
@
click=
"backClick"
></cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()">
</cover-image-->
</cover-view>
<canvas
v-show=
'showImage'
canvas-id=
"canvas"
:style=
"
{'width':width,'height': height}">
</canvas>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -33,22 +33,25 @@
...
@@ -33,22 +33,25 @@
path
:
""
,
path
:
""
,
image
:
""
,
image
:
""
,
showImage
:
false
,
showImage
:
false
,
canvas
:
null
,
canvas
:
null
,
longitude
:
'经度:正在获取中...'
,
longitude
:
'经度:正在获取中...'
,
latitude
:
'纬度:正在获取中...'
,
latitude
:
'纬度:正在获取中...'
,
address
:
'地址:正在获取中...'
,
address
:
'地址:正在获取中...'
,
date
:
'时间:正在获取中...'
,
date
:
'时间:正在获取中...'
,
icon_location
:
'https://qn-static.banshouhui.com/take_order/icon/location.png'
,
icon_location
:
'https://qn-static.banshouhui.com/take_order/icon/location.png'
,
scale
:
"4_3"
,
scale
:
"4_3"
,
icon_take
:
'https://qn-static.banshouhui.com/take.png'
,
icon_take
:
'https://qn-static.banshouhui.com/take.png'
,
icon_switch_white
:
'https://qn-static.banshouhui.com/switch_white.png'
,
icon_switch_white
:
'https://qn-static.banshouhui.com/switch_white.png'
,
icon_light_on_white
:
'https://qn-static.banshouhui.com/light_on_white.png'
,
icon_light_on_white
:
'https://qn-static.banshouhui.com/light_on_white.png'
,
liveWaterMarkImage
:
'/static/live_mark.png'
,
liveWaterMarkImage
:
'/static/live_mark.png'
,
icon_arrow_down
:
'https://qn-static.banshouhui.com/arrow_down.png'
,
icon_arrow_down
:
'https://qn-static.banshouhui.com/arrow_down.png'
,
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
:
''
,
markPath
:
''
,
canvasWidth
:
0
,
canvasHeight
:
0
,
restuleImage
:
''
,
}
}
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
...
@@ -56,180 +59,236 @@
...
@@ -56,180 +59,236 @@
this
.
date
=
'时间:'
+
this
.
getTime
()
this
.
date
=
'时间:'
+
this
.
getTime
()
this
.
getLocation
()
this
.
getLocation
()
this
.
getMarkPath
()
this
.
getMarkPath
()
this
.
getSystemInfo
()
uni
.
setNavigationBarColor
({
uni
.
setNavigationBarColor
({
frontColor
:
'#FFFFFF'
,
frontColor
:
'#FFFFFF'
,
backgroundColor
:
'#333333'
,
backgroundColor
:
'#333333'
,
})
})
//this.address = ''
//this.address = ''
},
},
methods
:
{
methods
:
{
goPage
(){
// 进入图片预览页
},
getSystemInfo
()
{
// 获取设备信息
try
{
const
res
=
uni
.
getSystemInfoSync
();
this
.
canvasWidth
=
res
.
windowWidth
*
2
this
.
canvasHeight
=
res
.
windowHeight
*
2
console
.
log
(
res
.
windowWidth
,
'res.windowWidth'
,
res
.
windowHeight
,
'res.windowHeight'
)
}
catch
(
e
)
{
// error
}
},
//返回 点击
//返回 点击
backClick
:
function
()
{
backClick
:
function
()
{
uni
.
navigateBack
({
uni
.
navigateBack
({
})
})
},
},
//获取位置
//获取位置
getLocation
(){
getLocation
()
{
let
that
=
this
let
that
=
this
uni
.
getLocation
({
uni
.
getLocation
({
type
:
'wgs84'
,
type
:
'wgs84'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
that
.
longitude
=
'经度:'
+
res
.
longitude
that
.
longitude
=
'经度:'
+
res
.
longitude
that
.
latitude
=
'纬度:'
+
res
.
latitude
that
.
latitude
=
'纬度:'
+
res
.
latitude
console
.
log
(
'当前位置的经度:'
+
res
.
longitude
);
console
.
log
(
'当前位置的经度:'
+
res
.
longitude
);
console
.
log
(
'当前位置的纬度:'
+
res
.
latitude
);
console
.
log
(
'当前位置的纬度:'
+
res
.
latitude
);
console
.
log
(
'当前位置的地址:'
+
res
.
address
);
console
.
log
(
'当前位置的地址:'
+
res
.
address
);
}
}
});
});
},
},
//获取 水印 本地缓存路径
//获取 水印 本地缓存路径
getMarkPath
:
function
()
{
getMarkPath
:
function
()
{
let
that
=
this
let
that
=
this
uni
.
downloadFile
({
uni
.
downloadFile
({
url
:
this
.
icon_live_mark
,
//仅为示例,并非真实的资源
url
:
this
.
icon_live_mark
,
//仅为示例,并非真实的资源
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
if
(
res
.
statusCode
===
200
)
{
console
.
log
(
'水印图片 下载成功'
)
console
.
log
(
'水印图片 下载成功'
)
that
.
markPath
=
res
.
tempFilePath
that
.
markPath
=
res
.
tempFilePath
console
.
log
(
'markPath:'
+
that
.
markPath
)
console
.
log
(
'markPath:'
+
that
.
markPath
)
}
}
},
},
fail
()
{
fail
()
{
console
.
log
(
'水印图片 下载失败'
)
console
.
log
(
'水印图片 下载失败'
)
}
}
})
})
},
},
//第一步: 拍照
//第一步: 拍照
takePhoto
(){
takePhoto
()
{
let
that
=
this
let
that
=
this
this
.
ctx
.
takePhoto
({
this
.
ctx
.
takePhoto
({
quality
:
'high'
,
quality
:
'high'
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
console
.
log
(
'拍照成功'
)
console
.
log
(
'拍照成功'
)
console
.
log
(
res
)
console
.
log
(
res
)
//this.imageChange(res)
//this.imageChange(res)
this
.
getImageInfo
(
res
.
tempImagePath
)
this
.
getImageInfo
(
res
.
tempImagePath
)
this
.
restultImage
=
res
.
tempImagePath
//this.saveToLocal(res.tempImagePath)
//this.saveToLocal(res.tempImagePath)
}
}
});
});
},
},
//第二步: 获取图片信息
//第二步: 获取图片信息
getImageInfo
(
tempImagePath
)
{
getImageInfo
(
tempImagePath
)
{
let
that
=
this
let
that
=
this
uni
.
getImageInfo
({
uni
.
getImageInfo
({
src
:
tempImagePath
,
src
:
tempImagePath
,
success
(
res
)
{
success
(
res
)
{
console
.
log
(
'获取图片信息成功'
)
console
.
log
(
'获取图片信息成功'
)
//that.saveToLocal(res.)
that
.
width
=
res
.
width
+
'px'
;
that
.
width
=
res
.
width
+
'px'
;
that
.
height
=
res
.
height
+
'px'
;
that
.
height
=
res
.
height
+
'px'
;
that
.
drawCanvas
(
tempImagePath
,
res
)
that
.
drawCanvas
(
tempImagePath
,
res
)
}
}
})
})
},
},
//第三步: 绘制画布
//第三步: 绘制画布
drawCanvas
:
function
(
tempImagePath
,
res
)
{
drawCanvas
:
function
(
tempImagePath
,
res
)
{
console
.
log
(
'绘制画布'
)
console
.
log
(
'绘制画布'
)
let
canvasWidth
=
this
.
canvasWidth
let
canvasHeight
=
this
.
canvasHeight
console
.
log
(
canvasWidth
,
'canvasWidth'
,
canvasHeight
,
'canvasHeight'
)
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
,
res
.
height
)
this
.
canvas
.
rect
(
0
,
0
,
canvasWidth
,
canvasHeight
)
this
.
canvas
.
draw
()
this
.
canvas
.
drawImage
(
tempImagePath
,
0
,
0
,
canvasWidth
,
canvasHeight
)
// this.canvas.draw()
//加入 水印文字
//加入 水印文字
this
.
canvas
.
setFontSize
(
1
8
)
this
.
canvas
.
setFontSize
(
2
8
)
this
.
canvas
.
setFillStyle
(
'#
8a2929
'
)
this
.
canvas
.
setFillStyle
(
'#
f2f2f2
'
)
//this.canvas.rotate(30 * Math.PI / 180);
//this.canvas.rotate(30 * Math.PI / 180);
let
textToWidth
=
res
.
width
*
0.5
;
// let textToWidth = res.width * 0.5;
let
textToHeight
=
res
.
height
*
0.3
;
// let textToHeight = res.height * 0.3;
this
.
canvas
.
fillText
(
'我是水印'
,
100
,
100
)
let
h
=
1
let
txtHeight
=
36
this
.
canvas
.
fillText
(
'经度'
+
this
.
longitude
,
20
,
canvasHeight
-
txtHeight
*
h
++
);
this
.
canvas
.
fillText
(
'维度'
+
this
.
latitude
,
20
,
canvasHeight
-
txtHeight
*
h
++
);
this
.
canvas
.
fillText
(
'地址'
+
this
.
address
,
20
,
canvasHeight
-
txtHeight
*
h
++
);
this
.
canvas
.
fillText
(
'时间'
+
this
.
date
,
20
,
canvasHeight
-
txtHeight
*
h
++
);
//加入 水印图片
//加入 水印图片
this
.
canvas
.
drawImage
(
this
.
markPath
,
0
,
0
,
res
.
width
/
3
,
res
.
height
/
3
)
this
.
canvas
.
drawImage
(
this
.
markPath
,
canvasWidth
/
2
-
200
,
canvasHeight
/
2
-
50
,
400
,
100
)
this
.
canvas
.
draw
()
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'数据处理中...'
,
title
:
'数据处理中...'
,
icon
:
'loading'
icon
:
'loading'
})
})
this
.
canvasImage
()
this
.
exportCanvasTempFilePath
(
res
.
width
,
res
.
height
)
// this.canvas.draw()
// uni.showLoading({
// title: '数据处理中...',
// icon: 'loading'
// })
// this.exportCanvasTempFilePath(res.width,res.height)
},
canvasImage
()
{
let
self
=
this
this
.
canvas
.
draw
(
false
,
setTimeout
(()
=>
{
setTimeout
(()
=>
{
uni
.
canvasToTempFilePath
({
// x: 0,
// y: 0,
width
:
Number
(
this
.
canvasWidth
),
height
:
Number
(
this
.
canvasHeight
),
canvasId
:
'canvas'
,
success
:
(
res
)
=>
{
that
.
saveToLocal
(
res
.
tempFilePath
)
console
.
log
(
res
.
tempFilePath
,
'res.tempFilePath-canvasImage'
)
// this.$emit('canvasImage', res.tempFilePath);
// if (this.showPreview) {
self
.
showPreviewFn
(
res
.
tempFilePath
);
// }
},
fail
:
(
res
)
=>
{
console
.
log
(
res
);
},
complete
:
()
=>
{
uni
.
hideLoading
();
}
},
this
);
},
500
);
}));
},
showPreviewFn
(
img
)
{
uni
.
previewImage
({
current
:
0
,
urls
:
[
img
]
});
},
},
//第四步: 导出画布
//第四步: 导出画布
exportCanvasTempFilePath
:
function
(
width
,
height
)
{
exportCanvasTempFilePath
:
function
(
width
,
height
)
{
console
.
log
(
'导出画布'
)
console
.
log
(
'导出画布'
)
console
.
log
(
'width:'
+
width
)
console
.
log
(
'width:'
+
width
)
console
.
log
(
'height:'
+
height
)
console
.
log
(
'height:'
+
height
)
let
that
=
this
let
that
=
this
//导出自己需要的图片
//导出自己需要的图片
uni
.
canvasToTempFilePath
({
uni
.
canvasToTempFilePath
({
canvasId
:
"canvas"
,
canvasId
:
"canvas"
,
success
:
function
(
ress
)
{
success
:
function
(
ress
)
{
that
.
image
=
ress
.
tempFilePath
//处理好的图片
that
.
image
=
ress
.
tempFilePath
//处理好的图片
uni
.
hideLoading
()
uni
.
hideLoading
()
console
.
log
(
'处理图片 成功:'
)
console
.
log
(
'处理图片 成功:'
)
console
.
log
(
ress
.
tempFilePath
)
console
.
log
(
ress
.
tempFilePath
)
uni
.
showToast
({
uni
.
showToast
({
icon
:
'none'
,
icon
:
'none'
,
title
:
'处理成功'
title
:
'处理成功'
})
})
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
saveToLocal
(
ress
.
tempFilePath
)
that
.
saveToLocal
(
ress
.
tempFilePath
)
uni
.
previewImage
({
uni
.
previewImage
({
urls
:
[
ress
.
tempFilePath
],
urls
:
[
ress
.
tempFilePath
],
current
:
0
current
:
0
});
});
},
1000
);
},
1000
);
//TODO........
//TODO........
},
},
fail
:
function
(
e
)
{
fail
:
function
(
e
)
{
uni
.
hideLoading
()
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
title
:
'出错啦...'
,
title
:
'出错啦...'
,
icon
:
'loading'
icon
:
'loading'
})
})
console
.
log
(
'处理图片 失败:'
)
console
.
log
(
'处理图片 失败:'
)
console
.
log
(
e
)
console
.
log
(
e
)
}
}
});
});
},
},
//第五步: 保存到本地相册
//第五步: 保存到本地相册
saveToLocal
(
tempImagePath
)
{
saveToLocal
(
tempImagePath
)
{
uni
.
saveImageToPhotosAlbum
({
uni
.
saveImageToPhotosAlbum
({
filePath
:
tempImagePath
,
filePath
:
tempImagePath
,
success
()
{
success
()
{
console
.
log
(
'保存本地相册 成功'
)
console
.
log
(
'保存本地相册 成功'
)
},
},
...
@@ -238,48 +297,45 @@
...
@@ -238,48 +297,45 @@
}
}
})
})
},
},
//第六步 返回上层界面
//第六步 返回上层界面
goBack
:
function
(){
goBack
:
function
()
{
},
},
//获取当前时间
//获取当前时间
getTime
:
function
()
{
getTime
:
function
()
{
var
date
=
new
Date
(),
var
date
=
new
Date
(),
year
=
date
.
getFullYear
(),
year
=
date
.
getFullYear
(),
month
=
date
.
getMonth
()
+
1
,
month
=
date
.
getMonth
()
+
1
,
day
=
date
.
getDate
(),
day
=
date
.
getDate
(),
hour
=
date
.
getHours
()
<
10
?
"0"
+
date
.
getHours
()
:
date
.
getHours
(),
hour
=
date
.
getHours
()
<
10
?
"0"
+
date
.
getHours
()
:
date
.
getHours
(),
minute
=
date
.
getMinutes
()
<
10
?
"0"
+
date
.
getMinutes
()
:
date
.
getMinutes
(),
minute
=
date
.
getMinutes
()
<
10
?
"0"
+
date
.
getMinutes
()
:
date
.
getMinutes
(),
second
=
date
.
getSeconds
()
<
10
?
"0"
+
date
.
getSeconds
()
:
date
.
getSeconds
();
second
=
date
.
getSeconds
()
<
10
?
"0"
+
date
.
getSeconds
()
:
date
.
getSeconds
();
month
>=
1
&&
month
<=
9
?
(
month
=
"0"
+
month
)
:
""
;
month
>=
1
&&
month
<=
9
?
(
month
=
"0"
+
month
)
:
""
;
day
>=
0
&&
day
<=
9
?
(
day
=
"0"
+
day
)
:
""
;
day
>=
0
&&
day
<=
9
?
(
day
=
"0"
+
day
)
:
""
;
var
timer
=
year
+
'/'
+
month
+
'/'
+
day
+
' '
+
hour
+
':'
+
minute
+
':'
+
second
;
var
timer
=
year
+
'/'
+
month
+
'/'
+
day
+
' '
+
hour
+
':'
+
minute
+
':'
+
second
;
return
timer
;
return
timer
;
},
},
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
>
.bottomView
{
.bottomView
{
background-color
:
#000000
;
background-color
:
#000000
;
z-index
:
5
;
z-index
:
5
;
width
:
100%
;
width
:
100%
;
...
@@ -290,29 +346,29 @@
...
@@ -290,29 +346,29 @@
flex-direction
:
row
;
flex-direction
:
row
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
}
}
.switchIcon
{
.switchIcon
{
background-color
:
#000000
;
background-color
:
#000000
;
width
:
50
rpx
;
width
:
50
rpx
;
height
:
50
rpx
;
height
:
50
rpx
;
}
}
.takeIcon
{
.takeIcon
{
background-color
:
#000000
;
background-color
:
#000000
;
width
:
150
rpx
;
width
:
150
rpx
;
height
:
150
rpx
;
height
:
150
rpx
;
}
}
.flashIcon
{
.flashIcon
{
background-color
:
#000000
;
background-color
:
#000000
;
width
:
50
rpx
;
width
:
50
rpx
;
height
:
50
rpx
;
height
:
50
rpx
;
margin-left
:
100
rpx
;
margin-left
:
100
rpx
;
}
}
.locationView
{
.locationView
{
/* z-index: 5;
/* z-index: 5;
width: 300rpx;
width: 300rpx;
position: absolute;
position: absolute;
...
@@ -331,26 +387,26 @@
...
@@ -331,26 +387,26 @@
line-height
:
18px
;
line-height
:
18px
;
color
:
#fff
;
color
:
#fff
;
}
}
.locationText
{
.locationText
{
/* font-size: 24rpx;
/* font-size: 24rpx;
color: #999999;
color: #999999;
width: 260rpx; */
width: 260rpx; */
margin
:
2px
0
;
margin
:
2px
0
;
}
}
.liveWatermarkNormal
{
.liveWatermarkNormal
{
z-index
:
3
;
z-index
:
3
;
position
:
absolute
;
position
:
absolute
;
left
:
50%
;
left
:
50%
;
top
:
50%
;
top
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
transform
:
translate
(
-50%
,
-50%
);
width
:
360
rpx
;
width
:
360
rpx
;
height
:
90
rpx
;
height
:
90
rpx
;
z-index
:
6
;
z-index
:
6
;
}
}
.backIcon
{
.backIcon
{
background-color
:
#FFFFFF
;
background-color
:
#FFFFFF
;
width
:
54
rpx
;
width
:
54
rpx
;
height
:
54
rpx
;
height
:
54
rpx
;
...
@@ -359,11 +415,10 @@
...
@@ -359,11 +415,10 @@
left
:
60
rpx
;
left
:
60
rpx
;
bottom
:
50
rpx
;
bottom
:
50
rpx
;
}
}
.showCanvas
{
.showCanvas
{
background-color
:
#007AFF
;
background-color
:
#007AFF
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
}
}
</
style
>
</
style
>
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