Commit 5097b821 authored by 李俊赕's avatar 李俊赕

page-page-combine

parent d6a89814
...@@ -109,8 +109,15 @@ ...@@ -109,8 +109,15 @@
classifyId:'', // 分类id classifyId:'', // 分类id
systemId:'', // 系统id systemId:'', // 系统id
}, },
currentItemLength:0,//已拍摄照片张数
productList:[], productList:[],
currentItem:null, // 选择的某一项 currentItem:null, // 选择的某一项
setting:null, //自定义设置
waterSetting:null, // 水印设置
tempPath:{
origin:'', // 缓存拍照图片
mixWater:'' // 缓存水印拍照图片
}
}, },
// 用户信息 // 用户信息
tempUserInfo: '', // 临时用户选项 tempUserInfo: '', // 临时用户选项
......
<!-- 拍照规范弹窗 -->
<template> <template>
<view class="standard-box"> <view class="standard-box">
简单了解的了解到了家里的经历的阶段了
<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish"> <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
<swiper-item class="swiper-item" key="swiper1"> <swiper-item class="swiper-item" key="swiper1">
<view class="title"> <view class="title">
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
} }
} }
}, },
}, },
data() { data() {
return { return {
......
...@@ -70,9 +70,6 @@ ...@@ -70,9 +70,6 @@
}, },
{ {
"path": "pages/settle/select", "path": "pages/settle/select",
"style": { "style": {
...@@ -148,7 +145,8 @@ ...@@ -148,7 +145,8 @@
"style": { "style": {
"navigationBarTitleText": "照片预览", "navigationBarTitleText": "照片预览",
"navigationBarBackgroundColor":"#333333", "navigationBarBackgroundColor":"#333333",
"backgroundColor":"#FFFFFF" "backgroundColor":"#FFFFFF",
"navigationBarTextStyle":"white"
} }
}, },
......
<template> <template>
<view> <view>
<view class="contentView"> <view class="contentView">
<image class="pic" :src="images[0]" mode="widthFix" @click="showPreviewFn"></image> <image class="pic" :src="files[0]" mode="aspectFill" @click="showPreviewFn"></image>
</view> </view>
<view class="bottomView"> <view class="bottomView">
<image class="remakeIcon" :src="btn_remake" @click="remakePhoto"></image> <image class="btn" :src="btn_remake" @click="remakePhoto"></image>
<image class="continueIcon" :src="btn_continue" @click="continuePhoto"></image> <image class="btn" :src="btn_continue" @click="continuePhoto"></image>
</view> </view>
</view> </view>
</template> </template>
...@@ -29,21 +29,69 @@ ...@@ -29,21 +29,69 @@
}, },
onLoad(e) { onLoad(e) {
getApp().trackPage('照片预览页') getApp().trackPage('照片预览页')
console.log(e, 'e') const globalTempPath = getApp().globalData.photo.tempPath
if(globalTempPath && globalTempPath.mixWater){
this.files = [globalTempPath.mixWater]
}
if(e.standardId) { if(e.standardId) {
this.standardId = e.standardId this.standardId = e.standardId
} }
if (e.img) { if (e.img) {
this.images = [e.img] this.images = [e.img]
this.downloadImages() // this.downloadImages()
} }
console.log(this.images, 'this.images') console.log(this.images, 'this.images')
this.token = getApp().globalData.token this.token = getApp().globalData.token
}, },
methods: { methods: {
// 保存照片到本地
async saveTempToLocal(tempImagePath) {
//has_origin //是否保存原图
let that = this
const photo = getApp().globalData.photo
if(!photo.tempPath){
return
}
let path = ''
if(photo.tempPath.origin && photo.waterSetting && photo.waterSetting.has_origin){
// 保存原图到本地
path = photo.tempPath.origin
let result = await this.saveLocal(path)
if(result){
uni.showToast({
icon: 'none',
title: '已将照片原图保存到本地相册'
})
}
}
if(photo.tempPath.mixWater){
// 保存水印处理图片到本地
path = photo.tempPath.mixWater
let result1 = await this.saveLocal(path)
if(result1){
uni.showToast({
icon: 'none',
title: '已将水印图片保存到本地相册'
})
}
}
uni.hideLoading()
},
saveLocal(path){
return new Promise((resolve,reject)=>{
uni.saveImageToPhotosAlbum({
filePath: path,
success() {
resolve(true)
},
fail() {
reject('保存失败')
}
})
})
},
showPreviewFn(img) { showPreviewFn(img) {
uni.previewImage({ uni.previewImage({
current: 0, current: 0,
...@@ -59,14 +107,17 @@ ...@@ -59,14 +107,17 @@
// 重拍图片 // 重拍图片
remakePhoto() { remakePhoto() {
uni.navigateTo({ uni.navigateBack({
url: '/pages/photo/take' delta:1
}) })
}, },
// 确认图片 // 确认图片
continuePhoto() { continuePhoto() {
let self = this let self = this
uni.showLoading({
title:'图片保存中……'
})
self.confirmUpload(true) self.confirmUpload(true)
}, },
submitFile() { submitFile() {
...@@ -81,9 +132,21 @@ ...@@ -81,9 +132,21 @@
console.log(res, "云服务保存图片"); console.log(res, "云服务保存图片");
if(res.result) { if(res.result) {
// TODO 参数是否要来回传递 // TODO 参数是否要来回传递
uni.navigateTo({ self.saveTempToLocal()
url: '/pages/photo/list' const photo = getApp().globalData.photo
photo.currentItemLength++
// photo.currentItem.
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.redirectTo({
url:"pages/photo/list"
}) })
}
} else { } else {
uni.showToast({ uni.showToast({
title:'图片上传失败' title:'图片上传失败'
...@@ -115,42 +178,38 @@ ...@@ -115,42 +178,38 @@
} }
</script> </script>
<style> <style lang="scss">
.contentView { .contentView {
background-color: #333333; background-color: #333333;
padding-top: 120rpx; /* padding-top: 120rpx; */
height: 880rpx; padding-bottom:228rpx;
height: 100vh;
display: flex;
flex-direction: column;
} }
.pic { .pic {
flex:1;
width: 100%; width: 100%;
height: 760rpx;
/* height:auto */
/* height: 760rpx; */
} }
.bottomView { .bottomView {
box-shadow: 0 0 1rpx 6rpx rgba(255,255,255,0.05);
background-color: #333333; background-color: #333333;
width: 100%; width: 100%;
height: 326rpx; padding:70rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
display: flex; display: flex;
flex-direction: column-reverse; justify-content: space-around;
align-items: center; align-items: center;
} .btn{
display: block;
.remakeIcon {
width: 200rpx; width: 200rpx;
height: 88rpx; height: 88rpx;
position: fixed;
left: 80rpx;
bottom: 176rpx;
} }
.continueIcon {
width: 200rpx;
height: 88rpx;
position: fixed;
right: 80rpx;
bottom: 176rpx;
} }
</style> </style>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<cover-view class="header-box" :style="{'height':navHeight + 'rpx'}"> <cover-view class="header-box" :style="{'height':navHeight + 'rpx'}">
<cover-view class="inner"> <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('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.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="goPage('/pages/photo/setting')" class="icon" mode="aspectFit" src="/static/photo/icon-setting.png"></cover-image>
</cover-view> </cover-view>
</cover-view> </cover-view>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<cover-image class='icon' src='/static/photo/icon-standard.png' @click="standardShow = true"> </cover-image> <cover-image class='icon' src='/static/photo/icon-standard.png' @click="standardShow = true"> </cover-image>
</cover-view> </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-show="standardShow" class="page-mask" :z-index="10000"> <view v-if="standardShow" class="page-mask" :z-index="10000">
<photo-standard :currentItem="currentItem" /> <photo-standard :currentItem="currentItem" />
<view class="btn-close" @click="standardShow = false"> <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>
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
name:'111', 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'], 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:true, standardShow:false,
cameraInfo:{ cameraInfo:{
devicePosition:'front', devicePosition:'back',
flash:'auto' flash:'auto'
}, },
waterInfo: { waterInfo: {
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
}, },
tempImgs:{ tempImgs:{
'markImage':'', // 拍照水印 'markImage':'', // 拍照水印
'noMarkPhoto':'', // 无水印照片 'origin':'', // 无水印照片
'markPhoto':'', // 有水印照片 'mixWater':'', // 有水印照片
}, },
authSetting: { authSetting: {
camera: false, // 相机授权 camera: false, // 相机授权
...@@ -88,13 +88,18 @@ ...@@ -88,13 +88,18 @@
this.getMarkPath() this.getMarkPath()
this.currentItem = photo.currentItem this.currentItem = photo.currentItem
}, },
compute: {}, compute: {
setting(){
const photo = getApp().globalData.photo
return photo.setting || null
}
},
watch: { watch: {
'authSetting.camera'(val) { 'authSetting.camera'(val) {
if (val) { if (val) {
// this.cameraChange = true // this.cameraChange = true
} }
} },
}, },
onShow() { onShow() {
this.initData() this.initData()
...@@ -131,7 +136,7 @@ ...@@ -131,7 +136,7 @@
val = val==='back' ? 'front' : 'back' val = val==='back' ? 'front' : 'back'
break; break;
case 'flash': case 'flash':
val = val==='auto' ? 'on' : 'auto' val = val==='auto' ? 'on' : (val==='on' ? 'off' : 'auto')
break; break;
defalut: defalut:
...@@ -267,13 +272,21 @@ ...@@ -267,13 +272,21 @@
}) })
}, },
getDrawTxtArr(){
// 获取绘制数组
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度: ' + waterInfo.longitude,'维度: ' + waterInfo.latitude,'地址: ' + waterInfo.address,'时间: ' + waterInfo.date]
return arr
},
/* ---------------------- 拍照流程 ---------------------- */ /* ---------------------- 拍照流程 ---------------------- */
// 第一步:拍照 // 第一步:拍照
takePhoto() { takePhoto() {
wx.createCameraContext().takePhoto({ wx.createCameraContext().takePhoto({
quality: "high" quality: "high"
}).then(res=>{ }).then(res=>{
this.tempImgs.noMarkPhoto = res.tempImagePath this.tempImgs.origin = res.tempImagePath
this.drawCanvas(res.tempImagePath) this.drawCanvas(res.tempImagePath)
}) })
}, },
...@@ -283,11 +296,13 @@ ...@@ -283,11 +296,13 @@
title: '数据处理中...', title: '数据处理中...',
icon: 'loading' icon: 'loading'
}) })
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()
//将原图画到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)
...@@ -299,10 +314,14 @@ ...@@ -299,10 +314,14 @@
canvas.setFillStyle('#f2f2f2') canvas.setFillStyle('#f2f2f2')
let h = 1 let h = 1
let txtHeight = 18 let txtHeight = 18
canvas.fillText('经度: ' + waterInfo.longitude, 20, canvasHeight - txtHeight * h++); for(let i = 0;i<drawTxtArr.length;i++){
canvas.fillText('维度: ' + waterInfo.latitude, 20, canvasHeight - txtHeight * h++); const txt = drawTxtArr[i]
canvas.fillText('地址: ' + waterInfo.address, 20, canvasHeight - txtHeight * h++); canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
canvas.fillText('时间: ' + waterInfo.date, 20, 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) canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
canvas.draw(false, canvas.draw(false,
...@@ -312,8 +331,11 @@ ...@@ -312,8 +331,11 @@
height:canvasHeight, height:canvasHeight,
canvasId: 'canvas', canvasId: 'canvas',
success: (res) => { success: (res) => {
this.tempImgs.markPhoto = res.tempFilePath this.tempImgs.mixWater = res.tempFilePath
this.saveToLocal(res.tempFilePath) globalTempPath.origin = this.tempImgs.origin
globalTempPath.mixWater = res.tempFilePath
this.goPage('/pages/photo/preview')
// this.saveToLocal(res.tempFilePath)
}, },
fail: (res) => { fail: (res) => {
console.log(res); console.log(res);
...@@ -322,10 +344,11 @@ ...@@ -322,10 +344,11 @@
uni.hideLoading(); uni.hideLoading();
} }
}, this); }, this);
}, 500)) }, 50))
}, },
// 第三步:保存到本地 // 第三步:保存到本地
saveToLocal(tempImagePath) { saveToLocal(tempImagePath) {
//has_origin //是否保存原图
let that = this let that = this
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
filePath: tempImagePath, filePath: tempImagePath,
...@@ -345,44 +368,6 @@ ...@@ -345,44 +368,6 @@
urls: [img] urls: [img]
}); });
}, },
//第五步: 保存到本地相册
saveToLocal(tempImagePath) {
let that = this
uni.saveImageToPhotosAlbum({
filePath: tempImagePath,
success() {
uni.showToast({
icon: 'none',
title: '已将照片保存到本地相册'
})
// let timer = setTimeout(() => {
// that.goBack()
// }, 1500)
},
fail() {
uni.showToast({
icon: 'none',
title: '保存本地相册失败'
})
uni.setStorage({
key: 'photo_tempPath',
data: tempImagePath,
success: function() {
console.log('tempImagePath save success');
let timer = setTimeout(() => {
that.showAlbumAuthModal()
}, 1500)
}
});
}
})
},
//获取当前时间 //获取当前时间
getTime: function() { getTime: function() {
let date = new Date(), let date = new Date(),
......
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