wx.config({
debug: false,
appId: '${appId}',
timestamp: '${timestamp}',
nonceStr: '${nonceStr}',
signature: '${signature}',
jsApiList: ['checkJsApi','openLocation','getLocation']
});
AMap.plugin('AMap.Geolocation', function () {
var geolocation = new AMap.Geolocation({
enableHighAccuracy: true,
timeout: 10000,
position: 'RB',
extensions: 'all',
convert: true
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: ['getLocation'],
success: function (res) {
if(res.checkResult.getLocation){
wx.getLocation({
success: function (res) {
latitude = res.latitude;
longitude = res.longitude;
layer.closeAll();
},
cancel: function(){
layer.closeAll();
}
});
}
}
});
});
wx.getLocation({
type: 'wgs84',
success: function (res) {
console.log('微信定位成功:', res);
onComplete({
position: [res.longitude, res.latitude],
addressComponent: {
province: '微信省',
city: '微信市',
district: '微信区',
street: '微信路',
streetNumber: '88号'
}
});
},
fail: function () {
console.error('微信定位失败,尝试高德定位...');
geolocation.getCurrentPosition((status, result) => {
if (status === 'complete') {
onComplete(result);
} else {
onError(result);
}
});
}
});
});这是我的代码
后端问题,前端代码没啥看的