Commit 2dec7783 authored by 李俊赕's avatar 李俊赕

preview-photo

parent 8134a94e
......@@ -62,6 +62,12 @@
"navigationBarTitleText": "选择品牌"
}
},
{
"path": "pages/photo/take",
"style": {
"navigationBarTitleText": "拍照-ljd"
}
},
......@@ -89,13 +95,13 @@
{
"path": "pages/take/index",
"style": {
"navigationBarTitleText": "接单",
"enablePullDownRefresh": true
}
},
// {
// "path": "pages/take/try",
// "style": {
// "navigationBarTitleText": "接单",
// "enablePullDownRefresh": true
// }
// },
......@@ -180,9 +186,16 @@
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"condition": { //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"list": [{
"name": "拍照小工具", //模式名称
"path": "pages/photo/try", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}]
}
}
<template>
<view>
<image class="pic" :src="images[0]" mode="aspectFill"></image>
</view>
</template>
<script>
......@@ -10,10 +12,20 @@
}
},
onLoad(e) {
console.log(e,'e')
if(e.img){
this.images = [e.img]
}
},
methods: {
showPreviewFn(img) {
uni.previewImage({
current: 0,
urls: this.images
});
},
//拨打客服 点击
phoneCallClick: function (phone) {
uni.makePhoneCall({
......@@ -28,4 +40,9 @@
</script>
<style>
.pic{
display: block;
width:100%;
height:auto;
}
</style>
<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>
<canvas class="photoCanvas" id="photoCanvas" style="height:{{canvasHeight}}rpx;width:{{canvasWidth}}rpx;" type="2d"></canvas>
</template>
<script>
// 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
// },
export default {
data() {
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",
iconColor: "white",
devicePosition: "back",
light: "off",
canvasWidth: 750,
canvasHeight: 1e3,
cameraHeight: 1e3,
watermarkStyle: "bottom:20rpx;left:20rpx;",
direction: "normal",
liveWatermarkValue: "/image/live_mark.png",
baiduLocationTimer: null,
wxLocationTimer: null,
netTimeTimer: null,
localTimeTimer: null,
takePhotoTimer: 0,
originalWeather: !1,
a:'',
t:'',
i:'',
o:'',
n:'',
r:'',
l:'',
s:'',
h:''
icon_take: 'https://qn-static.banshouhui.com/take.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',
liveWaterMarkImage: require('@/static/live_mark.png'),
icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png',
canvas: {
ctx: null,
sWidth: 750,
sHeight: 0,
},
waterMarkerTemp:''
}
},
// var a
// t = require("../../@babel/runtime/helpers/interopRequireDefault"),
// e = t(require("../../@babel/runtime/regenerator")),
// i = t(require("../../@babel/runtime/helpers/asyncToGenerator")),
// o = getApp(), n = wx.getRealtimeLogManager(),
// r = require("../../libs/bmap-wx.min.js"), l = require("../../utils/util.js"),
// s = !0,
// h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
// });
onLoad: function(a) {
this.listeningDeviceMotion(), this.originalWeather = o.globalData.weather, o.globalData.weather && this.baiduWeather(),
setTimeout(function() {
s = !1;
}, 2e3);
this.initabcde()
onLoad(e) {
this.ctx = uni.createCameraContext();
this.date = '时间:' + this.getTime()
this.getLocation()
this.getSystemInfo()
uni.setNavigationBarColor({
frontColor: '#FFFFFF',
backgroundColor: '#333333',
})
this.downloadImageH5(this.liveWaterMarkImage)
//this.address = ''
},
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: {
initabcde: function() {
var a
t = require("../../@babel/runtime/helpers/interopRequireDefault"),
e = t(require("../../@babel/runtime/regenerator")),
i = t(require("../../@babel/runtime/helpers/asyncToGenerator")),
o = getApp(),
n = wx.getRealtimeLogManager(),
r = require("../../libs/bmap-wx.min.js"),
l = require("../../utils/util.js"),
s = !0,
h = new r.BMapWX({
ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
//切换前后
switchClick() {
},
//返回 点击
backClick: function() {
uni.navigateBack({
})
},
//获取位置
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() {
var a = this;
wx.nextTick(function() {
wx.createSelectorQuery().select(".watermark-box").boundingClientRect(function(t) {
a.watermarkBoxHeight = t.height, a.watermarkBoxWidth = t.width, a.changeWatermark();
}).exec();
});
},
listeningDeviceMotion: function() {
var a = this;
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";
a.direction != a.lastDirection && (a.setData({
direction: a.direction
}), a.changeCanvas(), a.changeWatermark()), a.lastDirection = a.direction;
});
},
changeCanvas: function() {
var a = this, t = this.direction, e = this.data.canvasWidth, i = this.data.canvasHeight;
"normal" == t ? this.setData({
canvasHeight: Math.max(i, e),
canvasWidth: Math.min(i, e)
}) : this.setData({
canvasHeight: Math.min(i, e),
canvasWidth: Math.max(i, e)
}), wx.createSelectorQuery().select("#photoCanvas").fields({
node: !0,
size: !0
}).exec(function(t) {
a.canvas = t[0].node;
var e = t[0].width, i = t[0].height, n = o.globalData.pixelRatio;
a.canvas.width = e * n, a.canvas.height = i * n, a.canvas.getContext("2d").scale(n, n);
});
},
changeScale: function() {
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",
iconColor: "white",
cameraHeight: 16 / 9 * 750
}), a = 16 / 9 * 750) : "16_9" == e ? (this.setData({
scale: "full",
iconColor: "white",
cameraHeight: o.globalData.rpxScreenHeight
}), a = o.globalData.rpxScreenHeight) : (this.setData({
scale: "4_3",
iconColor: "white",
cameraHeight: 1e3
}), a = 1e3), "normal" == i ? this.setData({
canvasHeight: a,
canvasWidth: Math.min(r, n)
}) : this.setData({
canvasWidth: a,
canvasHeight: Math.min(r, n)
}), wx.nextTick(function() {
t.changeCanvas(), setTimeout(function() {
t.changeWatermark();
}, 500);
});
},
changeWatermark: function() {
var a, t = this.data.direction, e = Math.min(this.watermarkBoxWidth, this.watermarkBoxHeight), i = Math.max(this.watermarkBoxWidth, this.watermarkBoxHeight);
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(";"),
this.setData({
watermarkStyle: a
});
},
formatRemark: function(a) {
for (var t = [], e = 0, i = 15; i < a.length; i += 15) t.push(a.substring(15 * e, i)),
e++;
return a.length % 15 != 0 && t.push(a.substring(15 * e, 15 * e + a.length % 15)),
t;
},
changeDevicePosition: function() {
"back" == this.data.devicePosition ? this.setData({
devicePosition: "front"
}) : this.setData({
devicePosition: "back"
});
},
changeLight: function() {
var a = this.data.light;
"torch" == a ? this.setData({
light: "off"
}) : "off" == a ? this.setData({
light: "on"
}) : "on" == a ? this.setData({
light: "auto"
}) : this.setData({
light: "torch"
});
},
bindPhotoalbum: function(a) {
wx.navigateTo({
url: "/pages/photoalbum/photoalbum?photoPath=" + this.data.tempImagePath
});
},
bindSetting: function() {
wx.navigateTo({
url: "/pages/settings/settings"
});
},
bindTakePhoto: function() {
var a = this;
if (!s && 0 == this.takePhotoTimer) {
this.takePhotoTimer = 1, setTimeout(function() {
a.takePhotoTimer = 0;
}, 1500), this.takePhotoAnimate();
wx.createCameraContext().takePhoto({
quality: "high"
}).then(function(t) {
a.drawPhoto(t.tempImagePath);
}).catch(function(a) {
n.error(a), console.log(a);
});
}
},
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) {
for (;;) switch (a.prev = a.next) {
case 0:
return i = this.canvas.getContext("2d"), n = o.globalData.screenHeight / o.globalData.rpxScreenHeight,
r = this.data.canvasWidth * n, l = this.data.canvasHeight * n, a.next = 6, new Promise(function(a) {
var e = m.canvas.createImage();
e.onload = function() {
var t = r, o = l, n = m.data.direction;
"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),
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),
console.log("已画照片"), a("已画照片");
}, e.onerror = function() {
console.log("照片加载失败"), a();
}, e.src = t;
});
case 6:
if (!this.data.liveWatermark || !this.data.liveWatermarkValue || "" == this.data.liveWatermarkValue) {
a.next = 9;
break;
}
return a.next = 9, new Promise(function(a) {
var t = m.canvas.createImage();
t.onload = function() {
var e = 360 * n, o = 90 * n, s = r / 2 - e / 2, h = l / 2 - o / 2;
i.drawImage(t, s, h, e, o), console.log("已画现场水印"), a("已画现场水印");
}, t.onerror = function() {
console.log("现场水印加载失败"), a();
}, t.src = m.data.liveWatermarkValue;
});
case 9:
if (!this.data.handWriting || "" == this.data.handWriting) {
a.next = 12;
break;
}
return a.next = 12, new Promise(function(a) {
var t = m.canvas.createImage();
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),
i.translate(-s, -h), console.log("已画手写签名水印"), a("已画手写签名水印");
}, t.onerror = function() {
console.log("手写签名水印加载失败"), a();
}, t.src = m.data.handWriting;
});
case 12:
if (!this.data.logoEnable || !this.data.logo || "" == this.data.logo) {
a.next = 16;
break;
}
return console.log("画水印LOGO"), a.next = 16, new Promise(function(a) {
var t = m.canvas.createImage();
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;
});
case 16:
if (console.log("画水印信息"), i.font = "14px", i.fillStyle = this.data.watermarkFontColor,
s = l - 14, h = 0, (c = this.data.remarkArr) && c.length > 0) {
for (g = c.length - 1; g >= 1; g--) u = c[g], i.fillText(u, 52, s - 18 * h++);
d = c[0], i.fillText("备注:" + d, 10, s - 18 * h++);
}
this.data.weather && this.data.weatherValue && i.fillText("天气:" + this.data.weatherValue, 10, s - 18 * h++),
this.data.altitude && this.data.altitudeValue && i.fillText("海拔:" + this.data.altitudeValue, 10, s - 18 * h++),
this.data.time && this.data.timeValue && i.fillText("时间:" + this.data.timeValue, 10, s - 18 * h++),
this.data.address && this.data.addressValue && i.fillText("地址:" + this.data.addressValue, 10, s - 18 * h++),
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);
}
downloadImageH5(image) {
let self = this
console.log('downloadImageH5',image)
// 图片下载本地
uni.downloadFile({
url: image, //仅为示例,并非真实的资源
success: (res) => {
console.log(res,'res-水印图片')
if (res.statusCode === 200) {
self.waterMarkerTemp = res.tempFilePath
}
}
});
},
canvasImage() {
let self = this
this.canvas.ctx.draw(false, setTimeout(() => {
setTimeout(() => {
uni.canvasToTempFilePath({
x: 0,
y: 0,
width: Number(this.canvas.sWidth),
height: Number(this.canvas.sHeight),
canvasId: 'photoCanvas',
success: (res) => {
// 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]
});
},
//照片处理
imageChange(options) {
let self = this
// let ctx = uni.createCanvasContext("photoCanvas") // canvas绘制对象
let ctx = uni.createCanvasContext('photoCanvas', this);
let sWidth = this.canvas.sWidth //绘图宽度
let sHeight = this.canvas.sHeight // 绘图高度
this.canvas.ctx = ctx
ctx.setStrokeStyle("#00ff00")
ctx.setLineWidth(5)
ctx.rect(0, 0, sWidth, sHeight)
ctx.drawImage(options.tempImagePath, 0, 0, sWidth, sHeight)
ctx.setFontSize(20)
ctx.fillText('Hello', 20, 20)
ctx.fillText('MINA', 100, 100)
// if(this.waterMarkerTemp){
// ctx.drawImage(this.waterMarkerTemp, sWidth/2 - 100, sHeight/2 - 20, 200, 40)
// }
ctx.drawImage(options.tempImagePath, sWidth/2 - 100, sHeight/2 - 20, 200, 40);
self.canvasImage()
// self.path = options.tempImagePath
return
// uni.getImageInfo({
// src: that.path,
// success: function(res) {
// }
// })
var that = this
//原图片信息
var _width = options.width
var _height = options.height
that.path = options.tempImagePath
console.log('原照片信息')
console.log('宽:' + options.width)
console.log('高:' + options.height)
console.log('路径:' + options.tempImagePath)
//需要的图片信息
var image_x = parseInt(_width * 0.1);
var image_y = parseInt(_height * 0.09);
var image_width = parseInt(_width * 0.8);
var image_height = parseInt(_height * 0.87);
console.log('需要的图片信息')
console.log('x:' + image_x)
console.log('y:' + image_y)
console.log('宽:' + image_width)
console.log('高:' + image_height)
uni.getImageInfo({
src: that.path,
success: function(res) {
that.showImage = true
//将原图画到canvas上面
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)
/*
//-----------------------------
// let ctx = uni.createCanvasContext('firstCanvas'); // 创建画布
// //将图片src放到cancas内,宽高为图片大小
// ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width / 3, ress.height / 3)
that.canvas.setFontSize(18)
// that.canvas.setFillStyle('#8a2929')
// that.canvas.rotate(-Math.PI / 2);
let textToWidth = res.width / 3 * 0.5;
let textToHeight = res.height / 3 * 0.3;
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)
//-----------------------------
*/
that.canvas.draw()
uni.showLoading({
title: '数据处理中...',
icon: 'loading',
duration: 10000
})
that.canvas.draw()
setTimeout(function() {
//导出自己需要的图片
uni.canvasToTempFilePath({
canvasId: "canvas",
x: image_x,
y: image_y,
width: image_width,
height: image_height,
destWidth: image_width,
destHeight: image_height,
success: function(ress) {
that.image = ress.tempFilePath //处理好的图片
uni.hideLoading()
console.log('处理图片 成功:')
console.log(ress.tempFilePath)
uni.showToast({
icon: 'none',
title: '处理成功'
})
setTimeout(function() {
that.saveToLocal(ress.tempFilePath)
uni.previewImage({
urls: [ress.tempFilePath],
current: 0
});
// uni.navigateTo({
// url:'/pages/photo/preview'+'?path=' + res.tempFilePath
// })
}, 1000);
//TODO........
},
fail: function(e) {
uni.hideLoading()
uni.showToast({
title: '出错啦...',
icon: 'loading'
})
console.log('处理图片 失败:')
console.log(e)
}
});
}, 1000);
}
})
},
//获取当前时间
getTime: function() {
var date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = "0" + day) : "";
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
},
}
}
</script>
<style>
.hidden {
display: none;
}
.camera {
width: 100%;
height: 100vh;
z-index: 1;
position: absolute;
}
.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;
.bottomView {
background-color: #000000;
z-index: 5;
width: 100%;
height: 200rpx;
position: absolute;
bottom: 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.camera-takeIcon {
z-index: 5;
width: 150rpx;
height: 150rpx;
position: absolute;
bottom: 25rpx;
left: 50%;
margin-left: -75rpx;
.switchIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
}
.camera-settingIcon {
z-index: 5;
width: 80rpx;
height: 80rpx;
position: absolute;
bottom: 60rpx;
left: 75%;
.takeIcon {
background-color: #000000;
width: 150rpx;
height: 150rpx;
}
.photoCanvas {
z-index: -1;
position: absolute;
left: 9999px;
.flashIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
margin-left: 100rpx;
}
.watermark-box {
z-index: 4;
position: absolute;
font-size: 14px;
line-height: 18px;
color: #fff;
.locationView {
/* z-index: 5;
width: 300rpx;
position: absolute;
left: 0;
bottom: 200rpx;
display: flex;
flex-direction: column;
padding-bottom: 20rpx;
padding-right: 20rpx; */
bottom: 200rpx;
padding-bottom: 20rpx;
padding-right: 20rpx;
z-index: 4;
position: absolute;
font-size: 14px;
line-height: 18px;
color: #fff;
}
.watermark-box__item {
margin: 2px 0;
.locationText {
/* font-size: 24rpx;
color: #999999;
width: 260rpx; */
margin: 2px 0;
}
.liveWatermarkNormal {
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 360rpx;
height: 90rpx;
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;
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.handWritingLeft,.handWritingNormal {
z-index: 3;
position: absolute;
width: 150rpx;
height: 150rpx;
bottom: 20rpx;
}
.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;
.backIcon {
background-color: #FFFFFF;
width: 54rpx;
height: 54rpx;
border-radius: 27rpx;
position: fixed;
left: 60rpx;
bottom: 50rpx;
}
.logoLeft,.logoRight {
z-index: 3;
position: absolute;
width: 150rpx;
height: 150rpx;
.container {
position: relative;
}
.logoRight {
transform-origin: 50% 50%;
transform: rotate(-90deg);
top: 20rpx;
left: 20rpx;
.showCanvas {
position: absolute;
left: 0;
/* top: 0; */
z-index: -1;
opacity: 0;
background-color: #007AFF;
}
</style>
<template>
<view class="">
<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>
<view class="">
<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" 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-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 v-show='showImage' canvas-id="canvas" :style="{'width':width,'height': height}"></canvas>
</view>
<canvas v-show='showImage' canvas-id="canvas" :style="{'width':canvasWidth+'px','height': canvasHeight + 'px'}"></canvas>
</view>
</template>
<script>
......@@ -33,22 +33,25 @@
path: "",
image: "",
showImage: false,
canvas:null,
longitude:'经度:正在获取中...',
latitude:'纬度:正在获取中...',
address:'地址:正在获取中...',
date:'时间:正在获取中...',
icon_location:'https://qn-static.banshouhui.com/take_order/icon/location.png',
canvas: null,
longitude: '经度:正在获取中...',
latitude: '纬度:正在获取中...',
address: '地址:正在获取中...',
date: '时间:正在获取中...',
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
scale: "4_3",
icon_take:'https://qn-static.banshouhui.com/take.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',
liveWaterMarkImage:'/static/live_mark.png',
icon_arrow_down:'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark:'https://qn-static.banshouhui.com/live_mark.png',
width:'',
height:'',
markPath:'',
icon_take: 'https://qn-static.banshouhui.com/take.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',
liveWaterMarkImage: '/static/live_mark.png',
icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png',
width: '',
height: '',
markPath: '',
canvasWidth:0,
canvasHeight:0,
restuleImage:'',
}
},
onLoad(e) {
......@@ -56,180 +59,236 @@
this.date = '时间:' + this.getTime()
this.getLocation()
this.getMarkPath()
this.getSystemInfo()
uni.setNavigationBarColor({
frontColor:'#FFFFFF',
backgroundColor:'#333333',
frontColor: '#FFFFFF',
backgroundColor: '#333333',
})
//this.address = ''
},
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({
})
},
//获取位置
getLocation(){
getLocation() {
let that = this
uni.getLocation({
type: 'wgs84',
success: function (res) {
type: 'wgs84',
success: function(res) {
that.longitude = '经度:' + res.longitude
that.latitude = '纬度:' + res.latitude
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
console.log('当前位置的地址:' + res.address);
}
}
});
},
//获取 水印 本地缓存路径
getMarkPath: function (){
getMarkPath: function() {
let that = this
uni.downloadFile({
url: this.icon_live_mark, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
console.log('水印图片 下载成功')
url: this.icon_live_mark, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
console.log('水印图片 下载成功')
that.markPath = res.tempFilePath
console.log('markPath:'+ that.markPath)
}
},
console.log('markPath:' + that.markPath)
}
},
fail() {
console.log('水印图片 下载失败')
}
})
},
//第一步: 拍照
takePhoto(){
takePhoto() {
let that = this
this.ctx.takePhoto({
quality: 'high',
success: (res) => {
console.log('拍照成功')
console.log(res)
//this.imageChange(res)
this.getImageInfo(res.tempImagePath)
this.restultImage = res.tempImagePath
//this.saveToLocal(res.tempImagePath)
}
});
},
//第二步: 获取图片信息
getImageInfo(tempImagePath) {
let that = this
uni.getImageInfo({
src:tempImagePath,
src: tempImagePath,
success(res) {
console.log('获取图片信息成功')
//that.saveToLocal(res.)
that.width = res.width+'px';
that.height = res.height+'px';
that.drawCanvas(tempImagePath,res)
that.width = res.width + 'px';
that.height = res.height + 'px';
that.drawCanvas(tempImagePath, res)
}
})
},
//第三步: 绘制画布
drawCanvas: function (tempImagePath,res){
drawCanvas: function(tempImagePath, res) {
console.log('绘制画布')
let canvasWidth = this.canvasWidth
let canvasHeight = this.canvasHeight
console.log(canvasWidth,'canvasWidth',canvasHeight,'canvasHeight')
this.showImage = true
//将原图画到canvas上面
this.canvas = uni.createCanvasContext("canvas", this)
this.canvas.drawImage(tempImagePath, 0, 0, res.width , res.height)
this.canvas.draw()
this.canvas.rect(0, 0, canvasWidth, canvasHeight)
this.canvas.drawImage(tempImagePath, 0, 0, canvasWidth, canvasHeight)
// this.canvas.draw()
//加入 水印文字
this.canvas.setFontSize(18)
this.canvas.setFillStyle('#8a2929')
this.canvas.setFontSize(28)
this.canvas.setFillStyle('#f2f2f2')
//this.canvas.rotate(30 * Math.PI / 180);
let textToWidth = res.width * 0.5;
let textToHeight = res.height * 0.3;
this.canvas.fillText('我是水印', 100, 100)
// let textToWidth = res.width * 0.5;
// let textToHeight = res.height * 0.3;
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.draw()
this.canvas.drawImage(this.markPath, canvasWidth/2-200, canvasHeight/2 - 50, 400, 100)
uni.showLoading({
title: '数据处理中...',
icon: 'loading'
title: '数据处理中...',
icon: 'loading'
})
this.exportCanvasTempFilePath(res.width,res.height)
this.canvasImage()
// 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('width:' + width)
console.log('height:' + height)
let that = this
//导出自己需要的图片
uni.canvasToTempFilePath({
canvasId: "canvas",
success: function(ress) {
that.image = ress.tempFilePath //处理好的图片
uni.hideLoading()
console.log('处理图片 成功:')
console.log(ress.tempFilePath)
uni.showToast({
icon:'none',
title:'处理成功'
})
setTimeout(function() {
that.saveToLocal(ress.tempFilePath)
uni.previewImage({
urls: [ress.tempFilePath],
current:0
});
}, 1000);
//TODO........
},
fail: function(e) {
uni.hideLoading()
uni.showToast({
title: '出错啦...',
icon: 'loading'
})
console.log('处理图片 失败:')
console.log(e)
}
uni.canvasToTempFilePath({
canvasId: "canvas",
success: function(ress) {
that.image = ress.tempFilePath //处理好的图片
uni.hideLoading()
console.log('处理图片 成功:')
console.log(ress.tempFilePath)
uni.showToast({
icon: 'none',
title: '处理成功'
})
setTimeout(function() {
that.saveToLocal(ress.tempFilePath)
uni.previewImage({
urls: [ress.tempFilePath],
current: 0
});
}, 1000);
//TODO........
},
fail: function(e) {
uni.hideLoading()
uni.showToast({
title: '出错啦...',
icon: 'loading'
})
console.log('处理图片 失败:')
console.log(e)
}
});
},
//第五步: 保存到本地相册
saveToLocal(tempImagePath) {
uni.saveImageToPhotosAlbum({
filePath:tempImagePath,
filePath: tempImagePath,
success() {
console.log('保存本地相册 成功')
},
......@@ -238,48 +297,45 @@
}
})
},
//第六步 返回上层界面
goBack: function(){
goBack: function() {
},
//获取当前时间
getTime:function(){
var date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = "0" + day) : "";
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
getTime: function() {
var date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = "0" + day) : "";
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
},
}
}
</script>
<style>
.bottomView{
.bottomView {
background-color: #000000;
z-index: 5;
width: 100%;
......@@ -290,29 +346,29 @@
flex-direction: row;
align-items: center;
justify-content: center;
}
.switchIcon{
.switchIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
}
.takeIcon{
.takeIcon {
background-color: #000000;
width: 150rpx;
height: 150rpx;
}
.flashIcon{
.flashIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
margin-left: 100rpx;
}
.locationView{
.locationView {
/* z-index: 5;
width: 300rpx;
position: absolute;
......@@ -331,26 +387,26 @@
line-height: 18px;
color: #fff;
}
.locationText{
.locationText {
/* font-size: 24rpx;
color: #999999;
width: 260rpx; */
margin: 2px 0;
margin: 2px 0;
}
.liveWatermarkNormal {
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.backIcon{
.backIcon {
background-color: #FFFFFF;
width: 54rpx;
height: 54rpx;
......@@ -359,11 +415,10 @@
left: 60rpx;
bottom: 50rpx;
}
.showCanvas{
.showCanvas {
background-color: #007AFF;
width: 100%;
height: 100%;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment