html
<view class="cu-form-group item">
<view class="title">
<text class="text-red">*</text>地址</view>
<input placeholder="请输入地址" value='{{addresss}}' name="order_start_addresss" type='text'></input>
<view><image class='sss' src="/images/go.png" bindtap='ding'></image></view>
</view>
js
ding:function(){
var _this = this;
wx.getLocation({
type: 'wgs84',
altitude: true,
success(res) {
const latitude = res.latitude
const longitude = res.longitude
const speed = res.speed
const accuracy = res.accuracy
console.log(res,'aaaaaaaaaaa');
// _this.getDistance(res.latitude, res.longitude, 39.924091, 116.403414);
}
})
wx.chooseLocation({
success: function (e) {
//允许打开定位
console.log("开启了定位", e);
if (e.address!==''){
_this.setData({
addresss:e.address
})
}
},
fail: () => {
//不允许打开定位
wx.getSetting({
success: (res) => {
if (!res.authSetting['scope.userLocation']) {
//打开提示框,提示前往设置页面
that.setData({
showCon: true
})
}
}
})
}
})
},