Commit af0189e5 authored by 和慭琛's avatar 和慭琛

定位功能添加

parent 51a08d00
...@@ -6,21 +6,24 @@ ...@@ -6,21 +6,24 @@
*/ */
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/photo/try",
"style": { "style": {
"navigationBarTitleText": "下单" "navigationBarTitleText": "拍照"
} }
}, },
{ {
"path": "pages/photo/try", "path": "pages/index/index",
"style": { "style": {
"navigationBarTitleText": "拍照" "navigationBarTitleText": "下单"
} }
}, },
{ {
"path": "pages/photo/preview", "path": "pages/photo/preview",
"style": { "style": {
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
<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='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image>
</cover-view> </cover-view>
<cover-view class="locationView">
<text class="locationText u-m-l-20 u-m-t-30">{{longitude}}</text>
<text class="locationText u-m-l-20 u-m-t-10">{{latitude}}</text>
<text class="locationText u-m-l-20 u-m-t-10">{{address}}</text>
<text class="locationText u-m-l-20 u-m-t-10">{{date}}</text>
</cover-view>
<canvas v-show='showImage' canvas-id="canvas" style='width:1000px; height:1500px;'></canvas> <canvas v-show='showImage' canvas-id="canvas" style='width:1000px; height:1500px;'></canvas>
...@@ -33,6 +39,10 @@ ...@@ -33,6 +39,10 @@
image: "", image: "",
showImage: false, showImage: false,
canvas:null, canvas:null,
longitude:'经度:正在获取中...',
latitude:'纬度:正在获取中...',
address:'地址:正在获取中...',
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',
...@@ -43,7 +53,9 @@ ...@@ -43,7 +53,9 @@
}, },
onLoad(e) { onLoad(e) {
this.ctx = uni.createCameraContext(); this.ctx = uni.createCameraContext();
this.date = '时间:' + this.getTime()
this.getLocation()
//this.address = ''
}, },
methods: { methods: {
...@@ -52,6 +64,21 @@ ...@@ -52,6 +64,21 @@
}, },
//获取位置
getLocation(){
let that = this
uni.getLocation({
type: 'wgs84',
success: function (res) {
that.longitude = '经度:' + res.longitude
that.latitude = '纬度:' + res.latitude
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
console.log('当前位置的地址:' + res.address);
}
});
},
//拍照 //拍照
takePhoto(){ takePhoto(){
this.ctx.takePhoto({ this.ctx.takePhoto({
...@@ -167,7 +194,24 @@ ...@@ -167,7 +194,24 @@
}, 1000); }, 1000);
} }
}) })
} },
//获取当前时间
getTime:function(){
var date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = "0" + day) : "";
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
},
...@@ -218,4 +262,23 @@ ...@@ -218,4 +262,23 @@
margin-left: 100rpx; margin-left: 100rpx;
} }
.locationView{
z-index: 5;
width: 300rpx;
position: absolute;
left: 0;
bottom: 200rpx;
display: flex;
flex-direction: column;
padding-bottom: 20rpx;
padding-right: 20rpx;
}
.locationText{
font-size: 24rpx;
color: #999999;
width: 260rpx;
}
</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