Commit dee29850 authored by 李俊赕's avatar 李俊赕

拍照优化

parent de223b82
......@@ -101,6 +101,7 @@ export default {
settleRecommend: '',
navHeight: 0, //导航栏高度
rpxScreenHeight: 0,// 照相视框高度
safeHeight:0, // 安全高度
//拍照相关数据
photo: {
product: {
......@@ -165,6 +166,8 @@ export default {
this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90
this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750
this.globalData.screenHeight = a.screenHeight
this.globalData.safeHeight = a.safeArea.bottom
console.log(a,'a')
} catch (a) {
}
},
......
<template>
<view class="camera-container">
<cover-view class="header-box" :style="{'height':navHeight + 'rpx'}">
<cover-view class="header-box" :style="{'height':navHeight/2 + 'px'}">
<cover-view class="inner">
<cover-image @click="setCameraInfo('devicePosition')" class="icon" mode="aspectFit"
src="/static/photo/icon-switch.png"></cover-image>
......@@ -11,9 +11,10 @@
</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">
:flash="cameraInfo.flash" :style="{'height':cameraHeight/2 + 'px','top':parseInt(navHeight/2) + 'px'}"
@error="cameraError">
<cover-view class="mark-box">
<cover-view class="txt big" >{{titleTxt}}</cover-view>
<cover-view class="txt big" v-if="titleTxt">{{titleTxt}}</cover-view>
<cover-view class="txt" v-for="(txt,index) in settingTxtArr" :key="index">{{txt || '获取中'}}</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>
......@@ -58,7 +59,7 @@
'https://qn-static.banshouhui.com/live_mark.png'
],
},
standardShow: false,
standardShow: true,
cameraInfo: {
devicePosition: 'back',
flash: 'auto'
......@@ -83,9 +84,9 @@
cameraWidth: 750,
cameraHeight: 1000, // (4 / 3 * 750) 图片比例4:3
ratio: 0,
cameraChange: true,
waterSetting:null,
shadowInitShow:true, // 第一次进入页面需显示弹窗
cameraChange: false,
waterSetting: null,
shadowInitShow: true, // 第一次进入页面需显示弹窗
}
},
onLoad(e) {
......@@ -96,19 +97,21 @@
this.updateTime()
this.getLocation()
this.getMarkPath()
this.initData()
this.currentItem = photo.currentItem
},
computed: {
titleTxt(){
titleTxt() {
const waterSetting = this.waterSetting
let txt = ''
if(!waterSetting || !waterSetting.lower_right){
if (!waterSetting || !waterSetting.lower_right) {
return ''
}
txt = waterSetting.lower_right && waterSetting.lower_right.title_text || ''
return txt
},
settingTxtArr(){
settingTxtArr() {
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
......@@ -134,24 +137,16 @@
})
return settingTxtArr
}
},
watch: {},
onShow() {
this.initData()
// this.standardShow = true
// this.cameraHeight = globalData.rpxScreenHeight
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success() {
// console.log('userLocation')
// // uni.getLocation()
// }
// })
// 默认开启弹窗
this.standardShow = this.shadowInitShow
// this.initData()
},
methods: {
closeShadow(){
closeShadow() {
this.shadowInitShow = false
this.standardShow = false
},
......@@ -195,13 +190,15 @@
},
initData() {
const globalData = getApp().globalData
// this.navHeight = parseInt(globalData.navHeight)
this.navHeight = globalData.navHeight
this.cameraHeight = parseInt(globalData.safeHeight*2 - globalData.navHeight - 200) ;
console.log(globalData.safeHeight,'globalData.safeHeight')
console.log(this.cameraHeight,'this.cameraHeight')
console.log(globalData.navHeight,'globalData.navHeight')
this.ratio = globalData.screenHeight / globalData.rpxScreenHeight
console.log(globalData.screenHeight,globalData.rpxScreenHeight,this.ratio)
this.cameraChange = true
this.waterSetting = globalData.photo.waterSetting
if(this.shadowInitShow){
this.standardShow = true
}
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() {
......@@ -342,6 +339,8 @@
const waterSetting = this.waterSetting
const globalTempPath = getApp().globalData.photo.tempPath
const ratio = this.ratio
console.log(this.ratio,'this.ratio')
// const ratio = 0.5
let canvasWidth = this.cameraWidth * ratio
let canvasHeight = this.cameraHeight * ratio
const waterInfo = this.waterInfo
......@@ -356,7 +355,7 @@
let h = 1
//加入 水印文字
for (let i = settingTxtArr.length-1; i >=0; i--) {
for (let i = settingTxtArr.length - 1; i >= 0; i--) {
txtHeight = 20
canvas.setFontSize(16)
canvas.setFillStyle('#f2f2f2')
......@@ -371,21 +370,22 @@
// canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
const title = this.titleTxt
if(title){
if (title) {
canvas.save()
let titleHeight = title.length>14 ? 60 : 30
let titleHeight = title.length > 14 ? 60 : 30
let rectWidth = title.length > 14 ? 215 : title.length*10
canvas.setFillStyle('rgba(34, 114, 255, 0.6)')
canvas.fillRect(10, canvasHeight - txtHeight * h - titleHeight,215, titleHeight)
canvas.fillRect(10, canvasHeight - txtHeight * h - titleHeight, 215, titleHeight)
canvas.restore()
canvas.setFontSize(20)
canvas.setFillStyle('#f2f2f2')
// canvas.setTextAlign('center')
if(title.length>14){
canvas.fillText(title.substr(14,14), 10, canvasHeight - txtHeight * h++ + 20);
if (title.length > 14) {
canvas.fillText(title.substr(14, 14), 10, canvasHeight - txtHeight * h++ + 20);
}
canvas.fillText(title.substr(0,14), 10, canvasHeight - txtHeight * h++ - titleHeight/2 + 10);
canvas.fillText(title.substr(0, 14), 10, canvasHeight - txtHeight * h++ - titleHeight / 2 + 10);
}
if(this.waterSetting && this.waterSetting.mid_text){
if (this.waterSetting && this.waterSetting.mid_text) {
//加入 水印图片
canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
}
......@@ -445,7 +445,7 @@
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 ;
let now = year + "年" + month + "月" + date + "日 " + hour + ":" + min + ":" + sec;
return now
},
......@@ -480,7 +480,8 @@
}
.camera-box {
position: relative;
position: absolute;
left:0;
width: 100%;
// height: 100vh;
z-index: 1;
......@@ -503,15 +504,16 @@
padding: 20rpx;
.txt {
margin-top:5rpx;
margin-top: 5rpx;
line-height: 40rpx;
white-space: normal;
font-size: 28rpx;
color: #fff;
&.big{
padding:10rpx;
&.big {
padding: 10rpx;
margin-bottom: 10rpx;
width:430rpx;
width: 430rpx;
line-height: 40rpx;
font-size: 32rpx;
background-color: rgba(34, 114, 255, 0.6);
......@@ -523,9 +525,11 @@
position: absolute;
left: 0;
right: 0;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
z-index: 5;
height: 160rpx;
box-sizing: border-box;
height: 200rpx;
display: flex;
justify-content: space-between;
padding: 20rpx 78rpx;
......@@ -559,6 +563,8 @@
.page-mask {
position: fixed;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
z-index: 1000;
width: 750rpx;
height: 100vh;
......@@ -574,6 +580,8 @@
.btn-close {
position: absolute;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
left: 0;
right: 0;
height: 200rpx;
......
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