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

edit-setting

parent 872b4d15
...@@ -8,26 +8,23 @@ ...@@ -8,26 +8,23 @@
<cover-image bindtap="changeScale" class="icon" mode="aspectFit" src="/static/photo/icon-setting.png"></cover-image> <cover-image bindtap="changeScale" class="icon" mode="aspectFit" src="/static/photo/icon-setting.png"></cover-image>
</cover-view> </cover-view>
</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="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-30">经度:{{waterInfo.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">维度:{{waterInfo.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">地址:{{waterInfo.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-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view>
</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> </camera>
<cover-view class="bottom-box"> <cover-view class="bottom-box">
<cover-image class="icon" :src="icon_arrow_down" mode="" @click="simpleBack"></cover-image> <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 class="txt">拍照要求</cover-view>
</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> </view>
</template> </template>
<script> <script>
...@@ -45,29 +42,40 @@ ...@@ -45,29 +42,40 @@
image: "", image: "",
showImage: false, showImage: false,
canvas: null, canvas: null,
longitude: '正在获取中...', longitude: '正在获取中...',
latitude: '正在获取中...', latitude: '正在获取中...',
address: '正在获取中...', address: '正在获取中...',
date: '正在获取中...', date: '',
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png', // icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
scale: "4_3", // scale: "4_3",
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: '/static/live_mark.png', // liveWaterMarkImage: '/static/live_mark.png',
icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png', // icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png', // icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png',
width: '', width: '',
height: '', height: '',
markPath: '', markPath: '',
canvasWidth: 0, canvasWidth: 0,
canvasHeight: 0, canvasHeight: 0,
restuleImage: '', restuleImage: '',
authSetting: [],
navHeight:0, waterInfo: {
cameraHeight:(4 / 3 * 750), 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) { onLoad(e) {
...@@ -83,10 +91,17 @@ ...@@ -83,10 +91,17 @@
}) })
//this.address = '' //this.address = ''
}, },
compute: {},
watch: {
'authSetting.camera'(val) {
if (val) {
// this.cameraChange = true
}
}
},
onShow() { onShow() {
const globalData = getApp().globalData this.initData()
console.log(globalData,'globalData')
this.navHeight = globalData.navHeight
// this.cameraHeight = globalData.rpxScreenHeight // this.cameraHeight = globalData.rpxScreenHeight
// uni.authorize({ // uni.authorize({
// scope: 'scope.writePhotosAlbum', // scope: 'scope.writePhotosAlbum',
...@@ -97,72 +112,116 @@ ...@@ -97,72 +112,116 @@
// }) // })
}, },
methods: { methods: {
initData() {
const globalData = getApp().globalData
this.navHeight = globalData.navHeight
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() { baiduLocation() {
console.log('baiduLocation') // 百度sdk解析经纬度
let a = this, let a = this,
t = function() { t = function() {
let t = { let t = {
success: function(res) { success: function(res) {
let e = res.wxMarkerData[0]; let e = res.wxMarkerData[0];
console.log(e,e.address,'e.address')
let i = e.address; let i = e.address;
a.address = i a.address = i
// a.setData({
// addressValue: i
// }), o.globalData.addressValue = i, a.initWatermarkBoxHeightAndWidth();
}, },
fail: function(a) { fail: function(a) {
console.log(a, 'a') console.log(a, 'a')
// n.error(a), console.log(a);
} }
}; };
if (a.latitude && a.longitude) { if (a.latitude && a.longitude) {
let e = 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; t.location = e;
} }
h.regeocoding(t); h.regeocoding(t);
}; };
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(){ getLocation() {
const FileSystemManager = wx.getFileSystemManager() let that = this
FileSystemManager.getSavedFileList({ uni.getLocation({
success (res) { type: 'gcj02',
console.log(res,'res-getSavedFileList') success: function(res) {
if (res.fileList.length > 0){ console.log(res, 'res')
wx.removeSavedFile({ that.longitude = parseFloat(res.longitude).toFixed(4)
filePath: res.fileList[0].filePath, that.latitude = parseFloat(res.latitude).toFixed(3)
complete (res) { console.log(that.longitude, 'that.longitude', that.latitude, 'that.latitude')
console.log(res) 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
return uni.showModal({
wx.getSavedFileList({ content: '拒绝授权' + content + ',是否去设置打开?',
success (res) { confirmText: "确认",
console.log(res,'res') cancelText: '取消',
if (res.fileList.length > 0){ success(res) {
wx.removeSavedFile({ if (res.confirm) {
filePath: res.fileList[0].filePath, self.openSetting()
complete (res) {
console.log(res)
} }
},
fail() {}
}) })
},
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() { goBack() {
...@@ -192,39 +251,23 @@ ...@@ -192,39 +251,23 @@
}) })
}, },
//获取位置
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 (){ showLocationAuthModal: function() {
let that = this let that = this
uni.showModal({ uni.showModal({
content:'拒绝授权将无法定位当前位置,是否去设置打开?', content: '拒绝授权将无法定位当前位置,是否去设置打开?',
confirmText: "确认", confirmText: "确认",
cancelText: '取消', cancelText: '取消',
success(res) { success(res) {
if(res.confirm){ if (res.confirm) {
that.openLocationSetting() that.openLocationSetting()
} }
if(res.cancel){ if (res.cancel) {
uni.navigateBack({ uni.navigateBack({
}) })
...@@ -241,34 +284,34 @@ ...@@ -241,34 +284,34 @@
//定位设置界面 //定位设置界面
openLocationSetting() { // openLocationSetting() {
let that = this // let that = this
wx.openSetting({ // wx.openSetting({
success(res) { // 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(res, 'openSetting.res')
console.log('33333location reload page') // console.log(res.authSetting, 'openSetting.res.authSetting')
that.getLocation() // console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
}else{ // console.log(res.authSetting['scope.userLocation'], 'openSetting.res.authSetting.scope.userLocation')
that.showLocationAuthModal()
console.log('444444') // 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({ uni.redirectTo({
url:'/pages/photo/try' url: '/pages/photo/try'
}); });
}, },
...@@ -303,12 +346,10 @@ ...@@ -303,12 +346,10 @@
console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera') console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
console.log(res.authSetting['scope.userInfo'], 'openSetting.res.authSetting.scope.userInfo') console.log(res.authSetting['scope.userInfo'], 'openSetting.res.authSetting.scope.userInfo')
if( res.authSetting['scope.camera'] && res.authSetting['scope.camera'] == true){ if (res.authSetting['scope.camera'] && res.authSetting['scope.camera'] == true) {
console.log('11111camera reload page')
that.reloadPage() that.reloadPage()
}else{ } else {
that.showCameraAuthModal() that.showCameraAuthModal()
console.log('222222')
} }
...@@ -318,20 +359,20 @@ ...@@ -318,20 +359,20 @@
}, },
//相机 再次授权弹窗 //相机 再次授权弹窗
showCameraAuthModal:function (){ showCameraAuthModal: function() {
let that = this let that = this
uni.showModal({ uni.showModal({
content:'拒绝授权将无法拍照,是否去设置打开?', content: '拒绝授权将无法拍照,是否去设置打开?',
confirmText: "确认", confirmText: "确认",
cancelText: '取消', cancelText: '取消',
success(res) { success(res) {
if(res.confirm){ if (res.confirm) {
that.openCameraSetting() that.openCameraSetting()
} }
if(res.cancel){ if (res.cancel) {
uni.navigateBack({ uni.navigateBack({
}) })
...@@ -347,7 +388,7 @@ ...@@ -347,7 +388,7 @@
//相机拒绝授权 //相机拒绝授权
cameraRefuse:function (){ cameraRefuse: function() {
console.log('相机拒绝授权') console.log('相机拒绝授权')
this.showCameraAuthModal() this.showCameraAuthModal()
}, },
...@@ -355,7 +396,7 @@ ...@@ -355,7 +396,7 @@
//第一步: 拍照 //第一步: 拍照
takePhoto() { takePhoto() {
console.log((new Date).getTime(),'开始渲染') console.log((new Date).getTime(), '开始渲染')
this.ctx.takePhoto({ this.ctx.takePhoto({
quality: 'high', quality: 'high',
success: (res) => { success: (res) => {
...@@ -406,10 +447,10 @@ ...@@ -406,10 +447,10 @@
let h = 1 let h = 1
let txtHeight = 36 let txtHeight = 36
this.canvas.fillText( '经度: ' + this.longitude, 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.latitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '地址: ' + this.address, 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.date, 20, canvasHeight - txtHeight * h++);
//加入 水印图片 //加入 水印图片
this.canvas.drawImage(this.markPath, canvasWidth / 2 - 200, canvasHeight / 2 - 50, 400, 100) this.canvas.drawImage(this.markPath, canvasWidth / 2 - 200, canvasHeight / 2 - 50, 400, 100)
...@@ -431,7 +472,7 @@ ...@@ -431,7 +472,7 @@
this.canvas.draw(false, this.canvas.draw(false,
setTimeout(() => { setTimeout(() => {
console.log((new Date).getTime(),'结束渲染') console.log((new Date).getTime(), '结束渲染')
uni.canvasToTempFilePath({ uni.canvasToTempFilePath({
// x: 0, // x: 0,
// y: 0, // y: 0,
...@@ -443,9 +484,9 @@ ...@@ -443,9 +484,9 @@
self.saveToLocal(res.tempFilePath) self.saveToLocal(res.tempFilePath)
const FileSystemManager = wx.getFileSystemManager() const FileSystemManager = wx.getFileSystemManager()
FileSystemManager.saveFile({ FileSystemManager.saveFile({
tempFilePath:res.tempFilePath, tempFilePath: res.tempFilePath,
success (res) { success(res) {
console.log(res,'res-saveFile') console.log(res, 'res-saveFile')
} }
}) })
// this.$emit('canvasImage', res.tempFilePath); // this.$emit('canvasImage', res.tempFilePath);
...@@ -496,7 +537,7 @@ ...@@ -496,7 +537,7 @@
uni.setStorage({ uni.setStorage({
key: 'photo_tempPath', key: 'photo_tempPath',
data: tempImagePath, data: tempImagePath,
success: function () { success: function() {
console.log('tempImagePath save success'); console.log('tempImagePath save success');
let timer = setTimeout(() => { let timer = setTimeout(() => {
...@@ -553,20 +594,20 @@ ...@@ -553,20 +594,20 @@
//相册 再次授权弹窗 //相册 再次授权弹窗
showAlbumAuthModal:function (){ showAlbumAuthModal: function() {
let that = this let that = this
uni.showModal({ uni.showModal({
content:'拒绝授权照片将无法保存到本地相册,是否去设置打开?', content: '拒绝授权照片将无法保存到本地相册,是否去设置打开?',
confirmText: "确认", confirmText: "确认",
cancelText: '取消', cancelText: '取消',
success(res) { success(res) {
if(res.confirm){ if (res.confirm) {
that.openAlbumSetting() that.openAlbumSetting()
} }
if(res.cancel){ if (res.cancel) {
uni.navigateBack({ uni.navigateBack({
}) })
...@@ -591,19 +632,19 @@ ...@@ -591,19 +632,19 @@
console.log(res.authSetting['scope.writePhotosAlbum'], 'openSetting.res.authSetting.scope.writePhotosAlbum') 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') console.log('11111camera reload page')
uni.getStorage({ uni.getStorage({
key:'photo_tempPath', key: 'photo_tempPath',
success: function (res) { success: function(res) {
that.saveToLocal(res.data) that.saveToLocal(res.data)
} }
}) })
//that.reloadPage() //that.reloadPage()
}else{ } else {
that.showAlbumAuthModal() that.showAlbumAuthModal()
console.log('222222') console.log('222222')
} }
...@@ -633,36 +674,40 @@ ...@@ -633,36 +674,40 @@
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.camera-container {
.camera-container{
// padding-top:var(--status-bar-height); // padding-top:var(--status-bar-height);
min-height: 100vh; min-height: 100vh;
background-color: black; background-color: black;
} }
.header-box{
.header-box {
// padding:10rpx 20rpx; // padding:10rpx 20rpx;
position: relative; position: relative;
.inner{ .inner {
display: flex; display: flex;
position: absolute; position: absolute;
left:0;right:0; left: 0;
bottom:0; right: 0;
bottom: 0;
} }
.icon{
margin:20rpx; .icon {
margin: 20rpx;
display: block; display: block;
width:50rpx; width: 50rpx;
height:50rpx; height: 50rpx;
} }
} }
.camera-box{
.camera-box {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100vh; // height: 100vh;
z-index: 1; z-index: 1;
} }
.mark-water{
.mark-water {
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
...@@ -671,37 +716,44 @@ ...@@ -671,37 +716,44 @@
height: 90rpx; height: 90rpx;
z-index: 6; z-index: 6;
} }
.mark-box{
.mark-box {
position: absolute; position: absolute;
left:0; left: 0;
bottom: 20rpx; bottom: 20rpx;
padding:20rpx; padding: 20rpx;
.txt{
.txt {
color: #fff; color: #fff;
} }
} }
.bottom-box{
.bottom-box {
position: absolute; position: absolute;
left:0;right:0; left: 0;
right: 0;
bottom: 0; bottom: 0;
z-index: 5; z-index: 5;
height: 160rpx; height: 160rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding:20rpx; padding: 20rpx;
align-items: center; align-items: center;
background-color: black; background-color: black;
.txt{
line-height:60rpx; .txt {
color:#fff; line-height: 60rpx;
color: #fff;
} }
.icon{
.icon {
display: block; display: block;
width:60rpx; width: 60rpx;
height:60rpx; height: 60rpx;
&.icon-take{
width:150rpx; &.icon-take {
height:150rpx; width: 150rpx;
height: 150rpx;
} }
} }
} }
......
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