使用uniapp寫微信小程式 獲取定位

2021-10-02 23:14:33 字數 455 閱讀 5433

獲取定位並存入快取

// 第一步 獲取定位

uni.getlocation()

uni.setstorage()

// that.$store.state.vipinfo.longitude = that.longitude;

// that.$store.state.vipinfo.latitude = that.latitude;

}});

在需要使用的地方讀取快取

給data中定義的值賦值時,需使用同步獲取快取

this.longitude = uni.getstoragesync('longitude');

this.latitude = uni.getstoragesync('latitude');

最後便可用這個座標資訊進行業務操作了。。。

uni app微信小程式登入授權

首先是需要用到乙個授權按鈕來觸發獲取使用者資訊授權 關鍵在於 open type 為 getuserinfo 然後有個 getuserinfo的事件,把獲取授權介面寫到該事件裡面去 方法如下 ifdef mp weixin uni.getprovider fail fail else endif 在...

使用uni app開發微信小程式之登入模組

1.當使用者未授權過,呼叫該介面將直接報錯 2.當使用者授權過,可以使用該介面獲取使用者資訊 但在實際開發中我們可能需要彈出授權詢問框,因此需要我們自己來寫模擬授權彈框 主要是對 open type getuserinfo 的包裹 使用者是否是第一次授權判斷來顯示該頁面 如下 1.頁面結構 temp...

uniapp發布微信小程式適應頭部

uni.getsysteminfo safeareainsets screenheight 667 螢幕高度 screenwidth 375 螢幕寬度 statusbarheight 20 狀態列高度 system ios 10.0.1 作業系統版本 version 7.0.4 版本號 window...