打卡定位

This commit is contained in:
2026-09-24 11:41:39 +08:00
parent bef7f00970
commit 403f7e835f
3 changed files with 65 additions and 24 deletions
+25 -20
View File
@@ -867,32 +867,37 @@ export const store = {
this.emit()
},
punch() {
_locate() {
let type = 'gcj02'
// #ifdef H5
type = 'wgs84'
// #endif
return new Promise((resolve, reject) => {
uni.getLocation({
type: 'gcj02',
isHighAccuracy: true,
success: async (pos) => {
try {
const rec = await api.oaPost('/profile/attendance/punch', {
source: 'mobile',
latitude: pos.latitude,
longitude: pos.longitude,
accuracyM: pos.accuracy
}, this.token)
await this.refreshAttendance()
resolve((rec && rec.title) || '打卡成功')
} catch (e) {
reject(e)
}
},
fail() {
reject(new Error('需要定位权限才能打卡'))
}
type,
isHighAccuracy: false,
timeout: 8000,
success: resolve,
fail: reject
})
})
},
async punch() {
const body = { source: 'mobile' }
try {
const pos = await this._locate()
body.latitude = pos.latitude
body.longitude = pos.longitude
body.accuracyM = pos.accuracy
} catch (_) {
// 桌面浏览器经常没有定位;坐标缺省时仍提交,由服务端决定是否允许
}
const rec = await api.oaPost('/profile/attendance/punch', body, this.token)
await this.refreshAttendance()
return (rec && rec.title) || '打卡成功'
},
async audit(no, action, comment) {
await api.oaPost(`/workflow/requests/${no}/audit`, { action, comment }, this.token)
await this.refreshWorkbench()