123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- // pages/camera/camera.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- async onShow() {
- const { authSetting } = await wx.getSetting();
- console.log('authSetting', authSetting['scope.userLocation'])
- if (authSetting['scope.userLocation']) {
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy:true,
- success(res) {
- const latitude = res.latitude
- const longitude = res.longitude
- const speed = res.speed
- const accuracy = res.accuracy
- console.log('第一次-getLocation', res)
- }
- })
- wx.startLocationUpdate({
- type:'gcj02',
- isHighAccuracy:true,
- altitude:true,
- highAccuracyExpireTime:4000,
- success:(res)=>{
- console.log('startLocationUpdate',res)
- }
- })
- wx.onLocationChange((res)=>{
- console.log('移动获取',res)
- })
-
-
- } else {
- wx.getLocation({
- type: 'wgs84',
- success(res) {
- const latitude = res.latitude
- const longitude = res.longitude
- const speed = res.speed
- const accuracy = res.accuracy
- console.log('res', res)
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- wx.offLocationChange()
- wx.stopLocationUpdate({
- success:(res)=>{
- console.log('stopLocationUpdate',res)
- }
- })
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- handleGetLocation(){
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy:true,
- altitude:true,
- success(res) {
- const latitude = res.latitude
- const longitude = res.longitude
- const speed = res.speed
- const accuracy = res.accuracy
- console.log('手动getLocation', res)
- wx.showModal({
- title: '提示',
- content: JSON.stringify(res),
- success (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
-
- }
- })
- }
- })
|