Commit 01df1405 authored by 李俊赕's avatar 李俊赕

edit-setting

parent 872b4d15
......@@ -8,26 +8,23 @@
<cover-image bindtap="changeScale" class="icon" mode="aspectFit" src="/static/photo/icon-setting.png"></cover-image>
</cover-view>
</cover-view>
<camera class="camera-box" device-position="front" flash="on" :style="{'height':cameraHeight + 'rpx','line-height':cameraHeight + 'rpx'}" @error="cameraRefuse">
<camera class="camera-box" v-if="cameraChange" device-position="front" flash="on" :style="{'height':cameraHeight + 'rpx'}"
@error="cameraError">
<cover-view class="mark-box">
<cover-view class="txt u-m-l-20 u-m-t-30">经度:{{longitude}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">维度:{{latitude}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">地址:{{address}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">时间:{{date}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-30">经度:{{waterInfo.longitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">地址:{{waterInfo.address || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-l-20 u-m-t-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view>
</cover-view>
<cover-image class="mark-water liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image>
<cover-image class="mark-water liveWatermarkNormal" mode="aspectFit" :src="waterInfo.markImage"></cover-image>
</camera>
<cover-view class="bottom-box">
<cover-image class="icon" :src="icon_arrow_down" mode="" @click="simpleBack"></cover-image>
<cover-image class='icon-take icon' src='/static/photo/icon-take.png' @click="takePhoto()"> </cover-image>
<cover-image class='icon-take icon' src='/static/photo/icon-take.png' @click="takePhoto"> </cover-image>
<cover-view class="txt">拍照要求</cover-view>
</cover-view>
<canvas v-show='showImage' canvas-id="canvas" :style="{'width':canvasWidth+'px','height': canvasHeight + 'px'}"></canvas>
<canvas v-show='showImage' canvas-id="canvas" :style="{'width':750 + 'rpx','height': cameraHeight + 'rpx'}"></canvas>
</view>
</template>
<script>
......@@ -45,29 +42,40 @@
image: "",
showImage: false,
canvas: null,
longitude: '正在获取中...',
latitude: '正在获取中...',
address: '正在获取中...',
date: '正在获取中...',
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
scale: "4_3",
icon_take: 'https://qn-static.banshouhui.com/take.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',
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',
date: '',
// icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
// scale: "4_3",
// icon_take: 'https://qn-static.banshouhui.com/take.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',
// 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',
width: '',
height: '',
markPath: '',
canvasWidth: 0,
canvasHeight: 0,
restuleImage: '',
authSetting: [],
navHeight:0,
cameraHeight:(4 / 3 * 750),
waterInfo: {
longitude: '', // 经度
latitude: '', // 维度
address: '', //地址
date: '', //日期
markImage:'/static/live_mark.png'
},
authSetting: {
camera: false, // 相机授权
location: false, // 位置授权
},
navHeight: 0,
cameraHeight: 1000, // (4 / 3 * 750) 图片比例4:3
cameraChange: true,
}
},
onLoad(e) {
......@@ -83,10 +91,17 @@
})
//this.address = ''
},
compute: {},
watch: {
'authSetting.camera'(val) {
if (val) {
// this.cameraChange = true
}
}
},
onShow() {
const globalData = getApp().globalData
console.log(globalData,'globalData')
this.navHeight = globalData.navHeight
this.initData()
// this.cameraHeight = globalData.rpxScreenHeight
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
......@@ -97,74 +112,118 @@
// })
},
methods: {
initData() {
const globalData = getApp().globalData
this.navHeight = globalData.navHeight
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() {
console.log('baiduLocation')
// 百度sdk解析经纬度
let a = this,
t = function() {
let t = {
success: function(res) {
let e = res.wxMarkerData[0];
console.log(e,e.address,'e.address')
let i = e.address;
a.address = i
// a.setData({
// addressValue: i
// }), o.globalData.addressValue = i, a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
console.log(a, 'a')
// n.error(a), console.log(a);
}
};
if (a.latitude && a.longitude) {
let e = a.latitude + "," + a.longitude;
// let e = "113.88308" + ',' + "22.55329"
// let e = "22.55329" + ',' + "113.88308"
t.location = e;
}
h.regeocoding(t);
};
t()
},
goPage() {
// 进入图片预览页
cameraError: function(e) {
const {
errMsg
} = e.detail
console.log(e.detail, 'e.detail')
if (errMsg !== 'insertCamera:fail auth deny') {
return
}
this.showSettingModal('camera')
},
simpleBack(){
const FileSystemManager = wx.getFileSystemManager()
FileSystemManager.getSavedFileList({
success (res) {
console.log(res,'res-getSavedFileList')
if (res.fileList.length > 0){
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete (res) {
console.log(res)
}
})
}
//获取位置
getLocation() {
let that = this
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log(res, 'res')
that.longitude = parseFloat(res.longitude).toFixed(4)
that.latitude = parseFloat(res.latitude).toFixed(3)
console.log(that.longitude, 'that.longitude', that.latitude, 'that.latitude')
that.baiduLocation()
},
fail(err) {
console.log('err-location', 'err')
that.showSettingModal('location')
// that.showLocationAuthModal('')
}
});
},
showSettingModal(type) {
console.log(type, 'showModal-type')
type = type || 'camera'
const self = this
let authSetting = {
'camera': {
content: '将无法进行拍照',
method: ''
},
'location': {
content: '将无法定位当前位置',
method: ''
},
'writePhotosAlbum': {
content: '将无法保存图片到本地',
method: ''
}
}
let content = authSetting[type].content
uni.showModal({
content: '拒绝授权' + content + ',是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if (res.confirm) {
self.openSetting()
}
},
fail() {}
})
return
wx.getSavedFileList({
success (res) {
console.log(res,'res')
if (res.fileList.length > 0){
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete (res) {
console.log(res)
}
})
}
}
},
openSetting() {
// 打开设置
let self = this
this.cameraChange = false
wx.openSetting({
success(res) {
console.log(res, 'res-setting')
const authSetting = res.authSetting
if (authSetting['scope.userLocation']) {
// 位置授权成功
self.authSetting.location = true
self.getLocation()
}
if (res.authSetting['scope.camera']) {
this.cameraChange = true
self.authSetting.camera = true
}
if (res.authSetting['scope.writePhotosAlbum']) {
self.authSetting.writePhotosAlbum = true
}
}
})
return
uni.navigateBack({
//delta: 2
});
},
goBack() {
let pages = getCurrentPages();
......@@ -192,83 +251,67 @@
})
},
//获取位置
getLocation() {
let that = this
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log(res,'res')
that.longitude = parseFloat(res.longitude).toFixed(4)
that.latitude = parseFloat(res.latitude).toFixed(3)
console.log(that.longitude,'that.longitude',that.latitude,'that.latitude')
that.baiduLocation()
},
fail() {
that.showLocationAuthModal()
}
});
},
//定位 再次授权弹窗
showLocationAuthModal:function (){
let that = this
showLocationAuthModal: function() {
let that = this
uni.showModal({
content:'拒绝授权将无法定位当前位置,是否去设置打开?',
content: '拒绝授权将无法定位当前位置,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
if (res.confirm) {
that.openLocationSetting()
}
if(res.cancel){
if (res.cancel) {
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//定位设置界面
openLocationSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
console.log(res.authSetting['scope.userLocation'], 'openSetting.res.authSetting.scope.userLocation')
if( res.authSetting['scope.userLocation'] && res.authSetting['scope.userLocation'] == true){
console.log('33333location reload page')
that.getLocation()
}else{
that.showLocationAuthModal()
console.log('444444')
}
}
})
},
// openLocationSetting() {
// let that = this
// wx.openSetting({
// success(res) {
// console.log(res, 'openSetting.res')
// console.log(res.authSetting, 'openSetting.res.authSetting')
// console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
// console.log(res.authSetting['scope.userLocation'], 'openSetting.res.authSetting.scope.userLocation')
// if( res.authSetting['scope.userLocation'] && res.authSetting['scope.userLocation'] == true){
// console.log('33333location reload page')
// that.getLocation()
// }else{
// that.showLocationAuthModal()
// console.log('444444')
// }
// }
// })
// },
//刷新当前页
reloadPage:function (){
reloadPage: function() {
uni.redirectTo({
url:'/pages/photo/try'
url: '/pages/photo/try'
});
},
......@@ -291,71 +334,69 @@
callback(res) {
console.log(res, 'res-callback')
},
//相机设置界面
openCameraSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
console.log(res.authSetting['scope.userInfo'], 'openSetting.res.authSetting.scope.userInfo')
if( res.authSetting['scope.camera'] && res.authSetting['scope.camera'] == true){
console.log('11111camera reload page')
if (res.authSetting['scope.camera'] && res.authSetting['scope.camera'] == true) {
that.reloadPage()
}else{
} else {
that.showCameraAuthModal()
console.log('222222')
}
}
})
},
//相机 再次授权弹窗
showCameraAuthModal:function (){
let that = this
showCameraAuthModal: function() {
let that = this
uni.showModal({
content:'拒绝授权将无法拍照,是否去设置打开?',
content: '拒绝授权将无法拍照,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
if (res.confirm) {
that.openCameraSetting()
}
if(res.cancel){
if (res.cancel) {
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//相机拒绝授权
cameraRefuse:function (){
cameraRefuse: function() {
console.log('相机拒绝授权')
this.showCameraAuthModal()
},
//第一步: 拍照
takePhoto() {
console.log((new Date).getTime(),'开始渲染')
console.log((new Date).getTime(), '开始渲染')
this.ctx.takePhoto({
quality: 'high',
success: (res) => {
......@@ -405,11 +446,11 @@
this.canvas.setFillStyle('#f2f2f2')
let h = 1
let txtHeight = 36
this.canvas.fillText( '经度: ' + this.longitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '维度: ' + this.latitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '地址: ' + this.address, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '时间: ' +this.date, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText('经度: ' + this.longitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText('维度: ' + this.latitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText('地址: ' + this.address, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText('时间: ' + this.date, 20, canvasHeight - txtHeight * h++);
//加入 水印图片
this.canvas.drawImage(this.markPath, canvasWidth / 2 - 200, canvasHeight / 2 - 50, 400, 100)
......@@ -430,8 +471,8 @@
let self = this
this.canvas.draw(false,
setTimeout(() => {
console.log((new Date).getTime(),'结束渲染')
console.log((new Date).getTime(), '结束渲染')
uni.canvasToTempFilePath({
// x: 0,
// y: 0,
......@@ -439,13 +480,13 @@
height: Number(this.canvasHeight),
canvasId: 'canvas',
success: (res) => {
self.saveToLocal(res.tempFilePath)
const FileSystemManager = wx.getFileSystemManager()
FileSystemManager.saveFile({
tempFilePath:res.tempFilePath,
success (res) {
console.log(res,'res-saveFile')
tempFilePath: res.tempFilePath,
success(res) {
console.log(res, 'res-saveFile')
}
})
// this.$emit('canvasImage', res.tempFilePath);
......@@ -486,31 +527,31 @@
},
fail() {
// console.log('保存本地相册 失败')
///*
uni.showToast({
icon: 'none',
title: '保存本地相册失败'
})
uni.setStorage({
key: 'photo_tempPath',
data: tempImagePath,
success: function () {
console.log('tempImagePath save success');
key: 'photo_tempPath',
data: tempImagePath,
success: function() {
console.log('tempImagePath save success');
let timer = setTimeout(() => {
that.showAlbumAuthModal()
}, 1500)
}
}
});
//*/
/*
let txt = '保存本地相册失败'
......@@ -550,68 +591,68 @@
}
})
},
//相册 再次授权弹窗
showAlbumAuthModal:function (){
let that = this
showAlbumAuthModal: function() {
let that = this
uni.showModal({
content:'拒绝授权照片将无法保存到本地相册,是否去设置打开?',
content: '拒绝授权照片将无法保存到本地相册,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
if (res.confirm) {
that.openAlbumSetting()
}
if(res.cancel){
if (res.cancel) {
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//相机设置界面
openAlbumSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.writePhotosAlbum'], 'openSetting.res.authSetting.scope.writePhotosAlbum')
if( res.authSetting['scope.writePhotosAlbum'] && res.authSetting['scope.writePhotosAlbum'] == true){
if (res.authSetting['scope.writePhotosAlbum'] && res.authSetting['scope.writePhotosAlbum'] == true) {
console.log('11111camera reload page')
uni.getStorage({
key:'photo_tempPath',
success: function (res) {
that.saveToLocal(res.data)
key: 'photo_tempPath',
success: function(res) {
that.saveToLocal(res.data)
}
})
//that.reloadPage()
}else{
} else {
that.showAlbumAuthModal()
console.log('222222')
}
}
})
},
//获取当前时间
......@@ -633,36 +674,40 @@
}
</script>
<style scoped lang="scss">
.camera-container{
.camera-container {
// padding-top:var(--status-bar-height);
min-height: 100vh;
background-color: black;
}
.header-box{
.header-box {
// padding:10rpx 20rpx;
position: relative;
.inner{
.inner {
display: flex;
position: absolute;
left:0;right:0;
bottom:0;
left: 0;
right: 0;
bottom: 0;
}
.icon{
margin:20rpx;
.icon {
margin: 20rpx;
display: block;
width:50rpx;
height:50rpx;
width: 50rpx;
height: 50rpx;
}
}
.camera-box{
.camera-box {
position: relative;
width: 100%;
height: 100vh;
// height: 100vh;
z-index: 1;
}
.mark-water{
.mark-water {
position: absolute;
left: 50%;
top: 50%;
......@@ -671,41 +716,48 @@
height: 90rpx;
z-index: 6;
}
.mark-box{
.mark-box {
position: absolute;
left:0;
left: 0;
bottom: 20rpx;
padding:20rpx;
.txt{
padding: 20rpx;
.txt {
color: #fff;
}
}
.bottom-box{
.bottom-box {
position: absolute;
left:0;right:0;
left: 0;
right: 0;
bottom: 0;
z-index: 5;
height: 160rpx;
display: flex;
justify-content: space-between;
padding:20rpx;
padding: 20rpx;
align-items: center;
background-color: black;
.txt{
line-height:60rpx;
color:#fff;
.txt {
line-height: 60rpx;
color: #fff;
}
.icon{
.icon {
display: block;
width:60rpx;
height:60rpx;
&.icon-take{
width:150rpx;
height:150rpx;
width: 60rpx;
height: 60rpx;
&.icon-take {
width: 150rpx;
height: 150rpx;
}
}
}
// .blackBackColor {
// background-color: #000000;
// overflow: hidden;
......
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