Commit 2646f639 authored by 李俊赕's avatar 李俊赕

style-change

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