|
@@ -14,6 +14,8 @@ Page({
|
|
|
avatarUrl: defaultAvatarUrl,
|
|
avatarUrl: defaultAvatarUrl,
|
|
|
nickName: "用户登录",
|
|
nickName: "用户登录",
|
|
|
phoneNumber: "",
|
|
phoneNumber: "",
|
|
|
|
|
+ latitude: null,
|
|
|
|
|
+ longitude: null,
|
|
|
menuCardList: [{
|
|
menuCardList: [{
|
|
|
icon: "../../static/index/icon/ic_fjkz.png",
|
|
icon: "../../static/index/icon/ic_fjkz.png",
|
|
|
bgIcon: "../../static/index/bg/bg_fjkz.png",
|
|
bgIcon: "../../static/index/bg/bg_fjkz.png",
|
|
@@ -87,10 +89,79 @@ Page({
|
|
|
}]
|
|
}]
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
- onCloseTipsDialog() {
|
|
|
|
|
|
|
+ getLocation() {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ var hasAuth = wx.getStorageSync("hasAuth");
|
|
|
|
|
+ if (!hasAuth) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ wx.getSetting({
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ if (res.authSetting['scope.userLocation']) {
|
|
|
|
|
+ // 用户已经授权
|
|
|
|
|
+ wx.getLocation({
|
|
|
|
|
+ type: 'gcj02', // 返回可以用于wx.openLocation的经纬度
|
|
|
|
|
+ success(locationRes) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ latitude: locationRes.latitude,
|
|
|
|
|
+ longitude: locationRes.longitude,
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('纬度:', locationRes.latitude);
|
|
|
|
|
+ console.log('经度:', locationRes.longitude);
|
|
|
|
|
+ that.savehotelnew();
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(err) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ latitude: null,
|
|
|
|
|
+ longitude: null,
|
|
|
|
|
+ error: err.message
|
|
|
|
|
+ });
|
|
|
|
|
+ console.error('获取位置失败:', err.message);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 用户未授权
|
|
|
|
|
+ // wx.authorize({
|
|
|
|
|
+ // scope: 'scope.userLocation',
|
|
|
|
|
+ // success() {
|
|
|
|
|
+ // // 用户同意授权后再次获取位置
|
|
|
|
|
+ // that.savehotelnew();
|
|
|
|
|
+ // },
|
|
|
|
|
+ // fail() {
|
|
|
|
|
+ // // 用户拒绝授权
|
|
|
|
|
+ // that.setData({
|
|
|
|
|
+ // latitude: null,
|
|
|
|
|
+ // longitude: null,
|
|
|
|
|
+ // error: '用户拒绝授权获取地理位置'
|
|
|
|
|
+ // });
|
|
|
|
|
+ // console.error('用户拒绝授权获取地理位置');
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ savehotelnew() {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ wx.request({
|
|
|
|
|
+ url: 'https://aipush.aidsleep.cn/savehotelnew',
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
|
|
|
|
|
+ unionid: wx.getStorageSync('unionid'),
|
|
|
|
|
+ longandlat: that.data.longitude + "|" + that.data.latitude
|
|
|
|
|
+ },
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: () => {
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ onCloseTipsDialog() {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
showTipsA: false,
|
|
showTipsA: false,
|
|
|
- showTipsB:false
|
|
|
|
|
|
|
+ showTipsB: false
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
onMenuClick(e) {
|
|
onMenuClick(e) {
|
|
@@ -156,7 +227,7 @@ Page({
|
|
|
var hasHotelAuth = wx.getStorageSync("hasHotelAuth");
|
|
var hasHotelAuth = wx.getStorageSync("hasHotelAuth");
|
|
|
if (!hasHotelAuth) {
|
|
if (!hasHotelAuth) {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- showTipsB:true
|
|
|
|
|
|
|
+ showTipsB: true
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -230,8 +301,8 @@ Page({
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
*/
|
|
|
onReady() {
|
|
onReady() {
|
|
|
-
|
|
|
|
|
wx.hideTabBar()
|
|
wx.hideTabBar()
|
|
|
|
|
+ this.getLocation();
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|