定位打卡提示完善
This commit is contained in:
parent
95d649f32a
commit
c92a2d1557
|
|
@ -665,7 +665,7 @@ export default {
|
||||||
let res1 = await wx.getSetting();
|
let res1 = await wx.getSetting();
|
||||||
if (res1) {
|
if (res1) {
|
||||||
if (!res1.authSetting[authScope]) {
|
if (!res1.authSetting[authScope]) {
|
||||||
let res = _this[callbackName]();
|
let res = await _this[callbackName]();
|
||||||
if (res && res[callbackSuccessKey]) {
|
if (res && res[callbackSuccessKey]) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -677,7 +677,7 @@ export default {
|
||||||
})
|
})
|
||||||
return 'rejected';
|
return 'rejected';
|
||||||
} else {
|
} else {
|
||||||
return _this[callbackName]();
|
return await _this[callbackName]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -697,10 +697,25 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
async wxGetLocation() {
|
async wxGetLocation() {
|
||||||
|
let errCode = null;
|
||||||
let res = await wx.getLocation({
|
let res = await wx.getLocation({
|
||||||
type: 'gcj02'
|
type: 'gcj02',
|
||||||
|
fail: async (result) => {
|
||||||
|
if (result.errCode === 2) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '定位获取失败,请确认是否开启定位',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: async (result) => {
|
||||||
|
console.log("success");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// res.latitude, res.longitude
|
// res.latitude, res.longitude
|
||||||
|
console.log(res)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1178,31 +1178,75 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async recordClockInLocation(order) {
|
async recordClockInLocation(order) {
|
||||||
let res = await this.$request.checkAuth('scope.userLocation', 'wxGetLocation', 'latitude');
|
let _this = this;
|
||||||
if (res && res === 'rejected') {
|
// 通过 wx.getSetting 先查询一下用户是否授权了authScope
|
||||||
this.hasAuthLocation = false;
|
let res1 = await wx.getSetting();
|
||||||
return;
|
if (res1) {
|
||||||
}
|
if (!res1.authSetting['scope.userLocation']) {
|
||||||
if (!res || !res.latitude) {
|
let res2 = await wx.getLocation({
|
||||||
uni.showToast({
|
type: 'gcj02',
|
||||||
title: '定位获取失败,打卡失败,请稍后重试',
|
fail: async (result) => {
|
||||||
icon: 'none',
|
console.log(result)
|
||||||
duration: 2500
|
if (result.errno === 103) {
|
||||||
})
|
this.hasAuthLocation = false;
|
||||||
} else {
|
// 用户授权
|
||||||
let params = {
|
uni.showToast({
|
||||||
id: order.orderDetailId,
|
title: '请先授权',
|
||||||
clockInLocation: res.longitude + "," + res.latitude
|
icon: 'none',
|
||||||
}
|
duration: 1500
|
||||||
let updateOrderRes = await this.$request.updateDetailOrder(params);
|
})
|
||||||
if (updateOrderRes && updateOrderRes.code === 0) {
|
} else {
|
||||||
this.reloadMasterOrderPage();
|
// 用户授权
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'success',
|
title: '请确认是否开启定位',
|
||||||
duration: 1000
|
icon: 'none',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: async (result) => {
|
||||||
|
_this.persistClockInLocation(order, result);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
wx.getLocation({
|
||||||
|
type: 'gcj02',
|
||||||
|
fail: async (result) => {
|
||||||
|
console.log(result)
|
||||||
|
if (result.errCode === 2 || result.errCode === 404) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '定位获取失败,请确认是否开启定位',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2500
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '定位获取失败,请稍后重试',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: async (result) => {
|
||||||
|
_this.persistClockInLocation(order, result);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async persistClockInLocation(order, res) {
|
||||||
|
let params = {
|
||||||
|
id: order.orderDetailId,
|
||||||
|
clockInLocation: res.longitude + "," + res.latitude
|
||||||
|
}
|
||||||
|
let updateOrderRes = await this.$request.updateDetailOrder(params);
|
||||||
|
if (updateOrderRes && updateOrderRes.code === 0) {
|
||||||
|
this.reloadMasterOrderPage();
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue