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

page-page-combine

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