使用地图相关api 在数据网络断开的情况下定位错误,不会捕获错误提示错误信息,不会进入失败回调的方法里
wx.getLocation({
type: ‘gcj02’, // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用wx.openLocation 的坐标
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var point = {
latitude: latitude,
longitude: longitude
};
that.setData({
‘point’: point
})
//wx.setStorageSync(‘adrrNumMobile’, latitude + “,” + longitude)
fetch.showAddress(res.latitude, res.longitude);
var strUrl = “signForMobile/updateSignInfo.if”
var loginId = wx.getStorageSync(“loginId”)
var startWorkTime = util.formatNowTime()
var signFlag = ‘am’
var adrrNumMobile = latitude + “,” + longitude
var signAddr = wx.getStorageSync(‘address’)
if (signAddr == null || signAddr == ‘’) {
that.setData({
toastMsg: ‘无网络连接’,
selected: true,
})
setTimeout(that.toastHide, 2000)
return;
}
var key = [“loginId”, “startWorkTime”, “signFlag”, ‘adrrNumMobile’, ‘signAddr’]
var value = [loginId, startWorkTime, signFlag, adrrNumMobile, signAddr]
console.log(“value…” + value)
utilHttpRequest.httpRequest(strUrl, key, value,
function (res) {
console.log(res)
that.setData({
toastMsg: res.data.msg,
selected: true,
})
setTimeout(that.toastHide, 2000)
},
function (res) {
})
},
fail: function (err) {
that.setData({
toastMsg: ‘定位失败’,
selected: true,
})
},
})