Commit 868c0af5 authored by 和慭琛's avatar 和慭琛

拍照界面

parent f281f92e
...@@ -6,6 +6,13 @@ ...@@ -6,6 +6,13 @@
*/ */
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/photo/try",
"style": {
"navigationBarTitleText": "拍照"
}
},
{ {
"path": "pages/photo/product", "path": "pages/photo/product",
"style": { "style": {
...@@ -49,34 +56,6 @@ ...@@ -49,34 +56,6 @@
}, },
{
"path": "pages/photo/try",
"style": {
"navigationBarTitleText": "拍照"
}
},
{ {
"path": "pages/photo/brand", "path": "pages/photo/brand",
"style": { "style": {
......
<template> <template>
<view class=""> <view class="">
<!--cover-view class="nav__scale-4-3" style="height:64rpx;">
<cover-image @click="changeScale" class="nav-scaleIcon" mode="aspectFit" :src="icon_location"></cover-image>
<cover-image @click="changeDevicePosition" class="nav-switchIcon" mode="aspectFit" :src="icon_location"></cover-image>
<cover-image @click="changeLight" class="nav-lightIcon" mode="aspectFit" :src="icon_location"></cover-image>
</cover-view-->
<camera device-position="back" flash="off" style='width:100%; height:100vh;'> <camera device-position="back" flash="off" style='width:100%; height:100vh;'>
<cover-view class="locationView"> <cover-view class="locationView">
<cover-view class="locationText u-m-l-20 u-m-t-30">{{longitude}}</cover-view> <cover-view class="locationText u-m-l-20 u-m-t-30">{{longitude}}</cover-view>
...@@ -13,15 +8,16 @@ ...@@ -13,15 +8,16 @@
<cover-view class="locationText u-m-l-20 u-m-t-10">{{address}}</cover-view> <cover-view class="locationText u-m-l-20 u-m-t-10">{{address}}</cover-view>
<cover-view class="locationText u-m-l-20 u-m-t-10">{{date}}</cover-view> <cover-view class="locationText u-m-l-20 u-m-t-10">{{date}}</cover-view>
</cover-view> </cover-view>
<cover-image class="liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image> <cover-image class="liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image>
</camera> </camera>
<cover-view class="bottomView"> <cover-view class="bottomView">
<cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()"> </cover-image> <!--cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()"> </cover-image-->
<cover-image class='takeIcon' :src='icon_take' @click="takePhoto()"> </cover-image> <cover-image class='takeIcon' :src='icon_take' @click="takePhoto()"> </cover-image>
<cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image> <cover-image class="backIcon" :src="icon_arrow_down" mode="" @click="backClick"></cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image-->
</cover-view> </cover-view>
<canvas v-show='showImage' canvas-id="canvas" style='width:1000px; height:1500px;'></canvas> <!--canvas class="showCanvas" v-show='showImage' canvas-id="canvas"></canvas-->
</view> </view>
...@@ -47,13 +43,20 @@ ...@@ -47,13 +43,20 @@
icon_take:'https://qn-static.banshouhui.com/take.png', icon_take:'https://qn-static.banshouhui.com/take.png',
icon_switch_white:'https://qn-static.banshouhui.com/switch_white.png', icon_switch_white:'https://qn-static.banshouhui.com/switch_white.png',
icon_light_on_white:'https://qn-static.banshouhui.com/light_on_white.png', icon_light_on_white:'https://qn-static.banshouhui.com/light_on_white.png',
liveWaterMarkImage:require('@/static/live_mark.png') liveWaterMarkImage:'/static/live_mark.png',
icon_arrow_down:'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark:'https://qn-static.banshouhui.com/live_mark.png',
} }
}, },
onLoad(e) { onLoad(e) {
this.ctx = uni.createCameraContext(); this.ctx = uni.createCameraContext();
this.date = '时间:' + this.getTime() this.date = '时间:' + this.getTime()
this.getLocation() this.getLocation()
uni.setNavigationBarColor({
frontColor:'#FFFFFF',
backgroundColor:'#333333',
})
//this.address = '' //this.address = ''
}, },
methods: { methods: {
...@@ -63,6 +66,13 @@ ...@@ -63,6 +66,13 @@
}, },
//返回 点击
backClick: function () {
uni.navigateBack({
})
},
//获取位置 //获取位置
getLocation(){ getLocation(){
let that = this let that = this
...@@ -86,9 +96,37 @@ ...@@ -86,9 +96,37 @@
console.log('拍照成功') console.log('拍照成功')
console.log(res) console.log(res)
this.imageChange(res) this.imageChange(res)
//this.getImageInfo(res.tempImagePath)
//this.saveToLocal(res.tempImagePath)
} }
}); });
}, },
//获取图片信息
getImageInfo(tempImagePath) {
let that = this
uni.getImageInfo({
src:tempImagePath,
success(res) {
//that.saveToLocal(res.)
}
})
},
//保存到本地相册
saveToLocal(tempImagePath) {
uni.saveImageToPhotosAlbum({
filePath:tempImagePath,
success() {
console.log('保存本地相册 成功')
},
fail() {
console.log('保存本地相册 失败')
}
})
},
//照片处理 //照片处理
imageChange(options) { imageChange(options) {
var that = this var that = this
...@@ -119,10 +157,12 @@ ...@@ -119,10 +157,12 @@
that.showImage = true that.showImage = true
//将原图画到canvas上面 //将原图画到canvas上面
that.canvas = uni.createCanvasContext("canvas", that) that.canvas = uni.createCanvasContext("canvas", that)
that.canvas.drawImage(that.path, 0, 0, _width, _height) //that.canvas.drawImage(that.path, 0, 0, _width, _height)
that.canvas.drawImage(that.path, 0, 0, res.width * 3 , res.height * 3)
/*
//----------------------------- //-----------------------------
// let ctx = uni.createCanvasContext('firstCanvas'); /** 创建画布 */ // let ctx = uni.createCanvasContext('firstCanvas'); // 创建画布
// //将图片src放到cancas内,宽高为图片大小 // //将图片src放到cancas内,宽高为图片大小
// ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width / 3, ress.height / 3) // ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width / 3, ress.height / 3)
that.canvas.setFontSize(18) that.canvas.setFontSize(18)
...@@ -131,11 +171,11 @@ ...@@ -131,11 +171,11 @@
let textToWidth = res.width / 3 * 0.5; let textToWidth = res.width / 3 * 0.5;
let textToHeight = res.height / 3 * 0.3; let textToHeight = res.height / 3 * 0.3;
that.canvas.fillText('我是水印', 10, 90) that.canvas.fillText('我是水印', 10, 90)
/** 除了上面的文字水印,这里也可以加入图片水印 */ //. 除了上面的文字水印,这里也可以加入图片水印
// ctx.drawImage('/static/watermark.png', 0, 0, res.width / 3, ress.height / 3) // ctx.drawImage('/static/watermark.png', 0, 0, res.width / 3, ress.height / 3)
ctx.drawImage(this.liveWaterMarkImage, 0, 0, 200, 200) that.canvas.drawImage('/static/live_mark.png', 0, 0, 200, 200)
//----------------------------- //-----------------------------
*/
that.canvas.draw() that.canvas.draw()
uni.showLoading({ uni.showLoading({
title: '数据处理中...', title: '数据处理中...',
...@@ -165,6 +205,8 @@ ...@@ -165,6 +205,8 @@
}) })
setTimeout(function() { setTimeout(function() {
that.saveToLocal(ress.tempFilePath)
uni.previewImage({ uni.previewImage({
urls: [ress.tempFilePath], urls: [ress.tempFilePath],
current:0 current:0
...@@ -249,7 +291,6 @@ ...@@ -249,7 +291,6 @@
background-color: #000000; background-color: #000000;
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
margin-left: 100rpx;
} }
.flashIcon{ .flashIcon{
...@@ -297,4 +338,20 @@ ...@@ -297,4 +338,20 @@
z-index: 6; z-index: 6;
} }
.backIcon{
background-color: #FFFFFF;
width: 54rpx;
height: 54rpx;
border-radius: 27rpx;
position: fixed;
left: 60rpx;
bottom: 50rpx;
}
.showCanvas{
background-color: #007AFF;
width: 100%;
height: 100%;
}
</style> </style>
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