选择前
选择位置
选择后
上代码:
//wxml
<view class="cu-form-group border-bottom">
<view class="title">详细地址</view>
<input class="address-right" disabled='{{true}}' required="{{true}}" name="address" value="{{address}}"
bindtap="AddressInput" />
<text class="cuIcon-locationfill text-green"></text>
</view>
js
AddressInput(e) {
wx.getSetting({
success: function (res) {
var statu = res.authSetting;
if (!statu['scope.userLocation']) {
wx.showModal({
title: '发布需要授权定位功能',
content: '请确认授权,否则地图功能将无法使用',
success: function (tip) {
if (tip.confirm) {
console.log(tip.confirm)
wx.openSetting({
success: function (data) {
if (data.authSetting["scope.userLocation"] === true) {
app.ShowToast("授权成功")
} else {
app.ShowToast("授权失败,请重新点击")
}
},
fail: function (data) {
console.log(data)
}
})
} else {
app.ShowToast("授权失败,请重新点击")
}
},
})
}
}
});
var that = this;
wx.chooseLocation({
success: function (res) {
console.log(res)
that.setData({
address: res.address, //调用成功直接设置地址
resident: res.name,
longitude: res.longitude,
latitude: res.latitude
})
}
})
},