123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- const util = require('../../../../util/util.js')
- const formatLocation = util.formatLocation
- Page({
- onShareAppMessage() {
- return {
- title: '获取位置',
- path: 'packageAPI/pages/location/get-location/get-location'
- }
- },
- data: {
- theme: 'light',
- hasLocation: false,
- },
- getLocation() {
- const that = this
- wx.getLocation({
- success(res) {
- console.log(res)
- that.setData({
- hasLocation: true,
- location: formatLocation(res.longitude, res.latitude)
- })
- }
- })
- },
- clear() {
- this.setData({
- hasLocation: false
- })
- },
- onLoad() {
- this.setData({
- theme: wx.getSystemInfoSync().theme || 'light'
- })
- if (wx.onThemeChange) {
- wx.onThemeChange(({theme}) => {
- this.setData({theme})
- })
- }
- }
- })
|