This commit is contained in:
Mr.jiang 2024-06-25 11:32:16 +08:00
parent 43f2d0ed9d
commit 148e9b7fd8
2 changed files with 46 additions and 48 deletions

View File

@ -322,36 +322,9 @@
},
onLoad() {
let that = this
uni.getLocation({
type: 'gcj02',
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log(res, '地理位置-----------------------》')
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
if (that.amap) {
that.amap.setCenter(new AMap.LngLat(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
// that.getTypeList();
},
fail: function(e) {
console.log('获取地址失败1', e)
// #ifdef APP-PLUS
that.checkPermission();
// #endif
}
})
that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
that.getBannerList()
that.getHomeArtificerList()
that.getKTCityList();
// that.getKTCityList();
that.remen()
},
onShow() {
@ -360,27 +333,24 @@
that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
that.token = uni.getStorageSync('token');
that.getKTCityList();
// if (uni.getStorageSync('token')) {
if (that.latitude && that.longitude) {
// that.getlist()
} else {
if (uni.getStorageSync('token')) {
uni.getLocation({
type: 'gcj02',
highAccuracyExpireTime: 500,
geocode: true, //true
// geocode: true, //true
success: function(res) {
console.log(res, '地理位置')
console.log('地理位置',res)
that.city=res.address.city
that.latitude = res.latitude
that.longitude = res.longitude
// that.getTypeList();
// that.getlist()
that.getBannerList()
that.getHomeArtificerList()
},
fail: function() {
console.log('获取地址失败2')
}
})
}
// }
// that.myId = uni.getStorageSync('userId')
},
methods: {
@ -565,8 +535,8 @@
isStart: 1,
status: 1,
city: this.city,
longitude:'125.281198',
latitude:'43.883036',
longitude:this.longitude,
latitude:this.latitude,
page: 1,
limit: 3
}

View File

@ -536,20 +536,21 @@
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log(res, '地理位置')
console.log( '地理位置',res)
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
// if (that.cmap) {
// that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude));
// }
// if (that.infoWindow) {
// that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
// }
// if(that.amap){
if (that.cmap) {
that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
if(that.amap){
// }
}
that.page = 1
that.getlist()
},
@ -589,6 +590,33 @@
that.getTpCount();
that.getTpMy();
if (uni.getStorageSync('token')) {
uni.getLocation({
type: 'gcj02',
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log( '地理位置',res)
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
if (that.cmap) {
that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
if(that.amap){
}
that.page = 1
that.getlist()
},
fail: function(e) {
console.log('获取地址失败', e)
}
})
that.getIsVip()
}
that.myId = uni.getStorageSync('userId')