diff --git a/common/js/request.js b/common/js/request.js
index 98c9d9f..098723f 100644
--- a/common/js/request.js
+++ b/common/js/request.js
@@ -659,6 +659,43 @@ export default {
})
return res[1].data;
},
+ async checkAuth(authScope, callbackName, callbackSuccessKey) {
+ let _this = this;
+ // 通过 wx.getSetting 先查询一下用户是否授权了authScope
+ let res1 = await wx.getSetting();
+ if (res1) {
+ if (!res1.authSetting[authScope]) {
+ let res = _this[callbackName]();
+ if (res && res[callbackSuccessKey]) {
+ return res;
+ }
+ // 用户授权
+ uni.showToast({
+ title: '请先授权',
+ icon: 'none',
+ duration: 1500
+ })
+ return 'rejected';
+ } else {
+ return _this[callbackName]();
+ }
+ }
+ },
+ async openAndAuthSetting(authScope) {
+ wx.openSetting({
+ success(res) {
+ if (res[authScope]) {
+ return true;
+ }
+ }
+ })
+ uni.showToast({
+ icon: 'error',
+ duration: 1500,
+ title: '授权失败'
+ })
+ return false;
+ },
async wxGetLocation() {
let res = await wx.getLocation({
type: 'gcj02'
diff --git a/pages/area-proxy/my-team.vue b/pages/area-proxy/my-team.vue
index 279be0f..0c60325 100644
--- a/pages/area-proxy/my-team.vue
+++ b/pages/area-proxy/my-team.vue
@@ -65,7 +65,7 @@
-
+
diff --git a/pages/order-manage/order-manage.vue b/pages/order-manage/order-manage.vue
index 1467278..2df6617 100644
--- a/pages/order-manage/order-manage.vue
+++ b/pages/order-manage/order-manage.vue
@@ -210,7 +210,8 @@
-
+
+
@@ -503,7 +504,8 @@
picModalImgList: [],
curDate: '',
curUserInfo: {},
- orderStatistics: {}
+ orderStatistics: {},
+ hasAuthLocation: true
}
},
onLoad(option) {
@@ -1170,8 +1172,17 @@
current: e.currentTarget.dataset.url
});
},
+ async authLocationCallback(res) {
+ if (res.detail.authSetting['scope.userLocation']) {
+ this.hasAuthLocation = true;
+ }
+ },
async recordClockInLocation(order) {
- let res = await this.$request.wxGetLocation();
+ let res = await this.$request.checkAuth('scope.userLocation', 'wxGetLocation', 'latitude');
+ if (res && res === 'rejected') {
+ this.hasAuthLocation = false;
+ return;
+ }
if (!res || !res.latitude) {
uni.showToast({
title: '定位获取失败,打卡失败,请稍后重试',