|
|
|
@ -1744,6 +1744,184 @@ module.exports = { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 登录成功后请求位置授权 - 已在登录页面手机号授权时同时请求,避免重复授权
|
|
|
|
// console.log('登录成功后请求位置授权');
|
|
|
|
// wx.authorize({
|
|
|
|
// scope: 'scope.userLocation',
|
|
|
|
// success() {
|
|
|
|
// // 授权成功,获取用户位置
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// // 授权失败,弹出模态框引导用户重新授权
|
|
|
|
// wx.showModal({
|
|
|
|
// title: '需要位置授权',
|
|
|
|
// content: '请在设置中开启位置授权,以便我们为您提供相关服务',
|
|
|
|
// showCancel: true,
|
|
|
|
// cancelText: '取消',
|
|
|
|
// confirmText: '去授权',
|
|
|
|
// success: (res) => {
|
|
|
|
// if (res.confirm) {
|
|
|
|
// // 打开设置页面让用户手动开启授权
|
|
|
|
// wx.openSetting({
|
|
|
|
// success: (settingRes) => {
|
|
|
|
// if (settingRes.authSetting['scope.userLocation']) {
|
|
|
|
// // 用户在设置中开启了位置授权
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// fail: () => {
|
|
|
|
// console.error('打开设置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// 登录成功后请求位置授权 - 已在登录页面手机号授权时同时请求,避免重复授权
|
|
|
|
// console.log('登录成功后请求位置授权');
|
|
|
|
// wx.authorize({
|
|
|
|
// scope: 'scope.userLocation',
|
|
|
|
// success() {
|
|
|
|
// // 授权成功,获取用户位置
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// // 授权失败,弹出模态框引导用户重新授权
|
|
|
|
// wx.showModal({
|
|
|
|
// title: '需要位置授权',
|
|
|
|
// content: '请在设置中开启位置授权,以便我们为您提供相关服务',
|
|
|
|
// showCancel: true,
|
|
|
|
// cancelText: '取消',
|
|
|
|
// confirmText: '去授权',
|
|
|
|
// success: (res) => {
|
|
|
|
// if (res.confirm) {
|
|
|
|
// // 打开设置页面让用户手动开启授权
|
|
|
|
// wx.openSetting({
|
|
|
|
// success: (settingRes) => {
|
|
|
|
// if (settingRes.authSetting['scope.userLocation']) {
|
|
|
|
// // 用户在设置中开启了位置授权
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// fail: () => {
|
|
|
|
// console.error('打开设置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// 以下位置授权代码已在登录页面实现,此处注释掉
|
|
|
|
// wx.authorize({
|
|
|
|
// scope: 'scope.userLocation',
|
|
|
|
// success() {
|
|
|
|
// // 授权成功,获取用户位置
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// // 授权失败,弹出模态框引导用户重新授权
|
|
|
|
// wx.showModal({
|
|
|
|
// title: '需要位置授权',
|
|
|
|
// content: '请在设置中开启位置授权,以便我们为您提供相关服务',
|
|
|
|
// showCancel: true,
|
|
|
|
// cancelText: '取消',
|
|
|
|
// confirmText: '去授权',
|
|
|
|
// success: (res) => {
|
|
|
|
// if (res.confirm) {
|
|
|
|
// // 打开设置页面让用户手动开启授权
|
|
|
|
// wx.openSetting({
|
|
|
|
// success: (settingRes) => {
|
|
|
|
// if (settingRes.authSetting['scope.userLocation']) {
|
|
|
|
// // 用户在设置中开启了位置授权
|
|
|
|
// wx.getLocation({
|
|
|
|
// type: 'gcj02',
|
|
|
|
// success(res) {
|
|
|
|
// const latitude = res.latitude;
|
|
|
|
// const longitude = res.longitude;
|
|
|
|
// console.log('获取位置成功:', { latitude, longitude });
|
|
|
|
// // 可以将位置信息存储到本地
|
|
|
|
// wx.setStorageSync('userLocation', { latitude, longitude });
|
|
|
|
// },
|
|
|
|
// fail() {
|
|
|
|
// console.error('获取位置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// fail: () => {
|
|
|
|
// console.error('打开设置失败');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, phoneRes, userInfo, userType, phoneNumber } |
|
|
|
@ -1752,6 +1930,127 @@ module.exports = { |
|
|
|
console.error('检查客服身份失败:', checkErr); |
|
|
|
// 检查失败时默认为空类型
|
|
|
|
wx.setStorageSync('userType', ''); |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, phoneRes, userInfo, userType: '', phoneNumber } |
|
|
|
@ -1826,6 +2125,66 @@ module.exports = { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, phoneRes, userType, phoneNumber } |
|
|
|
@ -1833,6 +2192,66 @@ module.exports = { |
|
|
|
}).catch(() => { |
|
|
|
// 如果检查也失败,默认为空类型
|
|
|
|
wx.setStorageSync('userType', ''); |
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, phoneRes, userType: '', phoneNumber } |
|
|
|
@ -1907,6 +2326,66 @@ module.exports = { |
|
|
|
getApp().globalData.userType = userType; |
|
|
|
} |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, userInfo, userType, phoneNumber } |
|
|
|
@ -1914,6 +2393,66 @@ module.exports = { |
|
|
|
}).catch(() => { |
|
|
|
// 检查失败时默认为普通用户
|
|
|
|
wx.setStorageSync('userType', 'customer'); |
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, userInfo, userType: 'customer', phoneNumber } |
|
|
|
@ -1929,6 +2468,66 @@ module.exports = { |
|
|
|
getApp().globalData.userType = userType; |
|
|
|
} |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, userInfo, userType } |
|
|
|
@ -1944,6 +2543,66 @@ module.exports = { |
|
|
|
getApp().globalData.userType = 'customer'; |
|
|
|
} |
|
|
|
|
|
|
|
// 登录成功后请求位置授权
|
|
|
|
console.log('登录成功后请求位置授权'); |
|
|
|
wx.authorize({ |
|
|
|
scope: 'scope.userLocation', |
|
|
|
success() { |
|
|
|
// 授权成功,获取用户位置
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
// 授权失败,弹出模态框引导用户重新授权
|
|
|
|
wx.showModal({ |
|
|
|
title: '需要位置授权', |
|
|
|
content: '请在设置中开启位置授权,以便我们为您提供相关服务', |
|
|
|
showCancel: true, |
|
|
|
cancelText: '取消', |
|
|
|
confirmText: '去授权', |
|
|
|
success: (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
// 打开设置页面让用户手动开启授权
|
|
|
|
wx.openSetting({ |
|
|
|
success: (settingRes) => { |
|
|
|
if (settingRes.authSetting['scope.userLocation']) { |
|
|
|
// 用户在设置中开启了位置授权
|
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success(res) { |
|
|
|
const latitude = res.latitude; |
|
|
|
const longitude = res.longitude; |
|
|
|
console.log('获取位置成功:', { latitude, longitude }); |
|
|
|
// 可以将位置信息存储到本地
|
|
|
|
wx.setStorageSync('userLocation', { latitude, longitude }); |
|
|
|
}, |
|
|
|
fail() { |
|
|
|
console.error('获取位置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
console.error('打开设置失败'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolve({ |
|
|
|
success: true, |
|
|
|
data: { openid, userId, sessionKey, userType: 'customer' } |
|
|
|
|