Commit aee78d69 authored by Facius's avatar Facius

代码冲突

parents da5ff8fc 614e27d5
......@@ -130,14 +130,17 @@
this.checkUpdate()
var that=this
uni.getStorage({
key: 'token',
success: function (res) {
that.globalData.token = res.data
that.initAPIneedToken()
that.globalData.token = util.getToken()
console.log(that.globalData.token,'that.globalData.token')
that.initAPIneedToken()
// uni.getStorage({
// key: 'token',
// success: function (res) {
// that.globalData.token = res.data
// that.initAPIneedToken()
}
})
// }
// })
this.getProtocolContent()
......
......@@ -137,15 +137,17 @@
// photo.currentItem.
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.redirectTo({
url:"pages/photo/list"
})
}
let timer = setTimeout(()=>{
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.redirectTo({
url:"pages/photo/list"
})
}
},2000)
} else {
uni.showToast({
title:'图片上传失败'
......
......@@ -132,11 +132,12 @@
'token': getApp().globalData.token,
'watermark': this.result
}).then(res => {
console.log(res)
if (res.result == true) {
console.log(res)
if (res.result == true) {
const photo = getApp().globalData.photo
photo.waterSetting = this.result
}
console.log(this.result,'this.result')
photo.waterSetting = this.result
}
this.$nextTick(function() {
uni.hideLoading();
......
......@@ -13,10 +13,11 @@
<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-t-30">经度:{{waterInfo.longitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view>
<cover-view class="txt big u-m-t-20" >{{titleTxt}}</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.date || '正在获取中...'}}</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>
......@@ -83,6 +84,7 @@
cameraHeight: 1000, // (4 / 3 * 750) 图片比例4:3
ratio: 0,
cameraChange: true,
waterSetting:null,
}
},
onLoad(e) {
......@@ -95,13 +97,45 @@
this.getMarkPath()
this.currentItem = photo.currentItem
},
compute: {
waterSetting() {
// photo.waterSetting
const photo = getApp().globalData.photo
console.log(photo.waterSetting,'photo.waterSetting')
return photo.waterSetting || null
computed: {
titleTxt(){
const waterSetting = this.waterSetting
let txt = ''
if(!waterSetting || !waterSetting.lower_right){
return ''
}
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: {
'authSetting.camera'(val) {
......@@ -126,7 +160,7 @@
methods: {
goBack() {
uni.navigateBack({
delta:2
delta: 2
})
// uni.redirectTo({
// url: '/pages/photo/list'
......@@ -141,10 +175,10 @@
},
updateTime() {
this.waterInfo.date = this.getTime()
let timer = setTimeout(() => {
clearTimeout(timer);
this.updateTime()
}, 1000)
// let timer = setTimeout(() => {
// clearTimeout(timer);
// this.updateTime()
// }, 1000)
},
setCameraInfo(type) {
// 设置相机前置后置、闪关灯等
......@@ -168,6 +202,7 @@
const globalData = getApp().globalData
this.navHeight = globalData.navHeight
this.ratio = globalData.screenHeight / globalData.rpxScreenHeight
this.waterSetting = getApp().globalData.photo.waterSetting
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() {
......@@ -291,16 +326,6 @@
})
},
getDrawTxtArr() {
// 获取绘制数组
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度: ' + waterInfo.longitude, '维度: ' + waterInfo.latitude, '地址: ' + waterInfo.address, '时间: ' +
waterInfo.date
]
return arr
},
/* ---------------------- 拍照流程 ---------------------- */
// 第一步:拍照
takePhoto() {
......@@ -317,34 +342,42 @@
title: '数据处理中...',
icon: 'loading'
})
const waterSetting = this.waterSetting
const globalTempPath = getApp().globalData.photo.tempPath
const ratio = this.ratio
let canvasWidth = this.cameraWidth * ratio
let canvasHeight = this.cameraHeight * ratio
const waterInfo = this.waterInfo
this.showImage = true
const drawTxtArr = this.getDrawTxtArr()
const settingTxtArr = this.settingTxtArr
//将原图画到canvas上面
let canvas = uni.createCanvasContext("canvas", this)
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++) {
const txt = drawTxtArr[i]
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.setFillStyle('#f2f2f2')
const txt = settingTxtArr[i]
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
// canvas.fillText('经度: ' + waterInfo.longitude, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('维度: ' + waterInfo.latitude, 10, canvasHeight - txtHeight * h++);
// 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)
if(this.waterSetting && this.waterSetting.mid_text){
//加入 水印图片
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,
setTimeout(() => {
uni.canvasToTempFilePath({
......@@ -455,11 +488,15 @@
.mark-box {
position: absolute;
left: 0;
bottom: 20rpx;
bottom: 0;
padding: 20rpx;
.txt {
font-size: 28rpx;
color: #fff;
.big{
font-size: 32rpx;
}
}
}
......
......@@ -3,6 +3,6 @@
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "666666666666"
"token": "fdsadfsafsafsadfdsa",
"system_id": "79550af260555cc20afb34156c94b32c"
}
......@@ -15,9 +15,9 @@ exports.main = async (event, context) => {
system_id: watermark.system_id
}).get()
if (res.data && res.data.length > 0) {
collection.doc(res.data[0]._id).update(watermark)
await collection.doc(res.data[0]._id).update(watermark)
} else {
collection.add(watermark)
await collection.add(watermark)
}
}
//返回数据给客户端
......
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "666666666666",
"token": "fdsadfsafsafsadfdsa",
"watermark": {
"has_origin": true,
"lower_right": {
"body": [{
"enable": true,
"watemark_text": "时间",
"watemark_type": "时间",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "地址",
"watemark_type": "地址",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "经度",
"watemark_type": "经度",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "纬度",
"watemark_type": "纬度",
"watemark_value": ""
}],
"title_text": "OR000000001111"
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"watemark_value": "蓝天工程队3",
"enable": true,
"watemark_text": "工程队名称3",
"watemark_type": "备注"
}, {
"enable": true,
"watemark_text": "10000",
"watemark_type": "备注",
"watemark_value": "111111"
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}]
},
"mid_text": "现场拍照",
"system_id": "79550af260555cc20afb34156c94b32c",
"user_id": ""
"user_id": "fdsadfsafsafsadfdsa"
}
}
}
\ No newline at end of file
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