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

edit-take-page

parent c9401807
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
// photo.currentItem. // photo.currentItem.
// 当前项的图片显示 // 当前项的图片显示
// 拍照项张数目增加 等于10张 // 拍照项张数目增加 等于10张
let timer = setTimeout(()=>{
if(photo.currentItemLength<10){ if(photo.currentItemLength<10){
uni.navigateBack({ uni.navigateBack({
delta:1 delta:1
...@@ -146,6 +147,7 @@ ...@@ -146,6 +147,7 @@
url:"pages/photo/list" url:"pages/photo/list"
}) })
} }
},2000)
} else { } else {
uni.showToast({ uni.showToast({
title:'图片上传失败' title:'图片上传失败'
......
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
<camera class="camera-box" v-if="cameraChange&&!standardShow" :device-position="cameraInfo.devicePosition" <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 + 'rpx'}" @error="cameraError">
<cover-view class="mark-box"> <cover-view class="mark-box">
<cover-view class="txt u-m-t-30">经度:{{waterInfo.longitude || '正在获取中...'}}</cover-view> <cover-view class="txt big u-m-t-20" >{{titleTxt}}</cover-view>
<cover-view class="txt u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view> <cover-view class="txt u-m-t-20" 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> <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 class="txt u-m-t-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view> -->
</cover-view> </cover-view>
<cover-image class="mark-water" mode="aspectFit" :src="waterInfo.markImage"></cover-image> <cover-image class="mark-water" mode="aspectFit" :src="waterInfo.markImage"></cover-image>
</camera> </camera>
...@@ -95,13 +96,48 @@ ...@@ -95,13 +96,48 @@
this.getMarkPath() this.getMarkPath()
this.currentItem = photo.currentItem this.currentItem = photo.currentItem
}, },
compute: { computed: {
waterSetting() { waterSetting() {
// photo.waterSetting // photo.waterSetting
const photo = getApp().globalData.photo const photo = getApp().globalData.photo
console.log(photo.waterSetting,'photo.waterSetting') console.log(photo.waterSetting, 'photo.waterSetting')
return photo.waterSetting || null return photo.waterSetting || null
},
titleTxt(){
const waterSetting = this.waterSetting
let txt = ''
txt = waterSetting.lower_right && waterSetting.lower_right.title_text || ''
console.log(txt,'title_text','waterSetting',waterSetting)
return txt
},
settingTxtArr(){
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度: ' + waterInfo.longitude, '纬度: ' + waterInfo.latitude, '地址: ' + waterInfo.address, '时间: ' +
waterInfo.date
]
let settingTxtArr = []
const typeArr = ['经度', '纬度', '地址', '时间']
const waterSetting = this.waterSetting
if (!waterSetting || !waterSetting.lower_right || !waterSetting.lower_right.body) {
return arr
} }
const settingArr = waterSetting.lower_right.body
settingArr.map(item => {
const idx = typeArr.indexOf(item.watemark_type)
if (item.enable && (idx > -1 || (item.watemark_value && item.watemark_text))) {
if (idx > -1) {
settingTxtArr.push(arr[idx])
} else {
settingTxtArr.push(item.watemark_text + ': ' + item.watemark_value)
}
}
})
console.log(settingTxtArr,'settingTxtArr')
return settingTxtArr
}
}, },
watch: { watch: {
'authSetting.camera'(val) { 'authSetting.camera'(val) {
...@@ -126,7 +162,7 @@ ...@@ -126,7 +162,7 @@
methods: { methods: {
goBack() { goBack() {
uni.navigateBack({ uni.navigateBack({
delta:2 delta: 2
}) })
// uni.redirectTo({ // uni.redirectTo({
// url: '/pages/photo/list' // url: '/pages/photo/list'
...@@ -141,10 +177,10 @@ ...@@ -141,10 +177,10 @@
}, },
updateTime() { updateTime() {
this.waterInfo.date = this.getTime() this.waterInfo.date = this.getTime()
let timer = setTimeout(() => { // let timer = setTimeout(() => {
clearTimeout(timer); // clearTimeout(timer);
this.updateTime() // this.updateTime()
}, 1000) // }, 1000)
}, },
setCameraInfo(type) { setCameraInfo(type) {
// 设置相机前置后置、闪关灯等 // 设置相机前置后置、闪关灯等
...@@ -291,16 +327,6 @@ ...@@ -291,16 +327,6 @@
}) })
}, },
getDrawTxtArr() {
// 获取绘制数组
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度: ' + waterInfo.longitude, '维度: ' + waterInfo.latitude, '地址: ' + waterInfo.address, '时间: ' +
waterInfo.date
]
return arr
},
/* ---------------------- 拍照流程 ---------------------- */ /* ---------------------- 拍照流程 ---------------------- */
// 第一步:拍照 // 第一步:拍照
takePhoto() { takePhoto() {
...@@ -317,34 +343,42 @@ ...@@ -317,34 +343,42 @@
title: '数据处理中...', title: '数据处理中...',
icon: 'loading' icon: 'loading'
}) })
const waterSetting = this.waterSetting
const globalTempPath = getApp().globalData.photo.tempPath const globalTempPath = getApp().globalData.photo.tempPath
const ratio = this.ratio const ratio = this.ratio
let canvasWidth = this.cameraWidth * ratio let canvasWidth = this.cameraWidth * ratio
let canvasHeight = this.cameraHeight * ratio let canvasHeight = this.cameraHeight * ratio
const waterInfo = this.waterInfo const waterInfo = this.waterInfo
this.showImage = true this.showImage = true
const drawTxtArr = this.getDrawTxtArr() const settingTxtArr = this.settingTxtArr
//将原图画到canvas上面 //将原图画到canvas上面
let canvas = uni.createCanvasContext("canvas", this) let canvas = uni.createCanvasContext("canvas", this)
canvas.rect(0, 0, canvasWidth, canvasHeight) canvas.rect(0, 0, canvasWidth, canvasHeight)
canvas.drawImage(tempPath, 0, 0, canvasWidth, canvasHeight) canvas.drawImage(tempPath, 0, 0, canvasWidth, canvasHeight)
// this.canvas.draw() // this.canvas.draw()
let h = 1
let txtHeight = 20
const title = this.titleTxt
if(title){
canvas.setFontSize(20)
canvas.setFillStyle('#f2f2f2')
canvas.fillText(title, 10, canvasHeight - txtHeight * h++);
}
//加入 水印文字 //加入 水印文字
txtHeight = 18
for (let i = 0; i < settingTxtArr.length; i++) {
canvas.setFontSize(14) canvas.setFontSize(14)
canvas.setFillStyle('#f2f2f2') canvas.setFillStyle('#f2f2f2')
let h = 1
let txtHeight = 18 const txt = settingTxtArr[i]
for (let i = 0; i < drawTxtArr.length; i++) {
const txt = drawTxtArr[i]
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++); canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
} }
// canvas.fillText('经度: ' + waterInfo.longitude, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('维度: ' + waterInfo.latitude, 10, canvasHeight - txtHeight * h++); if(this.waterSetting && this.waterSetting.mid_text){
// canvas.fillText('地址: ' + waterInfo.address, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('时间: ' + waterInfo.date, 10, canvasHeight - txtHeight * h++);
//加入 水印图片 //加入 水印图片
canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50) canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
}
// canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
canvas.draw(false, canvas.draw(false,
setTimeout(() => { setTimeout(() => {
uni.canvasToTempFilePath({ uni.canvasToTempFilePath({
...@@ -455,11 +489,15 @@ ...@@ -455,11 +489,15 @@
.mark-box { .mark-box {
position: absolute; position: absolute;
left: 0; left: 0;
bottom: 20rpx; bottom: 0;
padding: 20rpx; padding: 20rpx;
.txt { .txt {
font-size: 28rpx;
color: #fff; color: #fff;
.big{
font-size: 32rpx;
}
} }
} }
......
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