-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
1.检测是否授权定位与引导授权
checkLocation(){
var that = this;
wx.getSetting({
success: (res) => {
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {//非初始化进入该页面,且未授权
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
success: function (res) {
if (res.cancel) {
console.log("1授权失败返回数据");
} else if (res.confirm) {
wx.setStorageSync('isChecked','yes')
//village_LBS(that);
wx.openSetting({
success: function (data) {
console.log(data);
if (data.authSetting["scope.userLocation"] == true) {
//再次授权,调用getLocationt的API
that.setLocation();
}else{
}
}
})
}
}
})
} else if (res.authSetting['scope.userLocation'] == undefined) {//初始化进入
that.setLocation();
}
}
})
}
2.设置定位
setLocation(){
wx.getLocation({
type: 'wgs84',
success: function(res) {
console.log(res,'我的经纬度')
wx.setStorageSync("latitude",res.latitude)
wx.setStorageSync("longitude",res.longitude)
}
})
}
3.点击分享按钮分享
<button class='box newBtn' id="btn1" open-type='share' plain='true' >
<text>分享</text>
</button>
onShareAppMessage(res) {
if (res.from === 'button') {
let target_id = res.target.id;
//id为btn1的button触发
if (target_id === "btn1") {
return {
title: 'btn1转发一',
path: 'pages/list/detail?id=35',
success: function(res) {
// 转发成功
},
fail: function(res) {
// 转发失败
}
}
//id为btn2的button触发
}
return {
title: '美食地图',
path: 'pages/list/detail?id='+this.shopId
}
}
},
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels