Commit 205a9191 authored by Damon's avatar Damon

相机-请求位置缓存

parent 6a939c3d
......@@ -113,7 +113,17 @@
photo.currentItemLength = 0
// this.ctx = uni.createCameraContext();
this.updateTime()
this.getLocation()
const locationData = uni.getStorageSync('locationData')
const validityTime = 60000
if (Date.now() - locationData.locationTime < validityTime) { // 1分钟内不重复请求位置信息
this.waterInfo.latitude = locationData.waterInfo.latitude
this.waterInfo.longitude = locationData.waterInfo.longitude
this.baiduLocation()
} else {
this.getLocation()
}
this.getMarkPath()
this.initData()
......@@ -266,6 +276,17 @@
success: function(res) {
waterInfo.longitude = parseFloat(res.longitude).toFixed(4)
waterInfo.latitude = parseFloat(res.latitude).toFixed(3)
const data = {
waterInfo: {
latitude: waterInfo.latitude,
longitude: waterInfo.longitude
},
locationTime: Date.now()
}
uni.setStorage({
key: 'locationData',
data: data,
})
that.baiduLocation()
},
fail(err) {
......
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