fix scan routing and zip download errors
This commit is contained in:
+20
-25
@@ -1,5 +1,6 @@
|
||||
const api = require('../../utils/api')
|
||||
const locationGuard = require('../../utils/locationGuard')
|
||||
const { buildErpLoginConfirmUrlFromScanResult } = require('../../utils/scanRouting')
|
||||
|
||||
const avatarKey = phone => `jh_wrs_avatar_${phone}`
|
||||
|
||||
@@ -373,22 +374,14 @@ Page({
|
||||
return raw
|
||||
},
|
||||
async scanDevice() {
|
||||
wx.showLoading({ title: '定位中' })
|
||||
try {
|
||||
await locationGuard.ensureFactoryLocation()
|
||||
} catch (error) {
|
||||
wx.hideLoading()
|
||||
wx.showModal({
|
||||
title: '无法扫码报工',
|
||||
content: error.message || '当前位置不在允许范围内',
|
||||
showCancel: false,
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.hideLoading()
|
||||
wx.scanCode({
|
||||
onlyFromCamera: false,
|
||||
success: async res => {
|
||||
const erpLoginUrl = buildErpLoginConfirmUrlFromScanResult(res)
|
||||
if (erpLoginUrl) {
|
||||
wx.navigateTo({ url: erpLoginUrl })
|
||||
return
|
||||
}
|
||||
const candidates = [res.path, res.result, res.rawData]
|
||||
const moldName = candidates.reduce((found, item) => (
|
||||
found || this.extractMoldName(item)
|
||||
@@ -398,21 +391,23 @@ Page({
|
||||
return
|
||||
}
|
||||
const paramName = moldName.startsWith('mold=') ? 'scene' : 'moldName'
|
||||
if (paramName === 'scene') {
|
||||
try {
|
||||
wx.showLoading({ title: '校验中' })
|
||||
try {
|
||||
wx.showLoading({ title: paramName === 'scene' ? '校验中' : '定位中' })
|
||||
if (paramName === 'scene') {
|
||||
const resolved = await api.resolveMoldScene(moldName)
|
||||
await locationGuard.ensureFactoryLocation(resolved.attendancePointName)
|
||||
} catch (error) {
|
||||
wx.showModal({
|
||||
title: '无法扫码报工',
|
||||
content: error.message || '当前位置不在该考勤点范围内',
|
||||
showCancel: false,
|
||||
})
|
||||
return
|
||||
} finally {
|
||||
wx.hideLoading()
|
||||
} else {
|
||||
await locationGuard.ensureFactoryLocation()
|
||||
}
|
||||
} catch (error) {
|
||||
wx.showModal({
|
||||
title: '无法扫码报工',
|
||||
content: error.message || '当前位置不在允许范围内',
|
||||
showCancel: false,
|
||||
})
|
||||
return
|
||||
} finally {
|
||||
wx.hideLoading()
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/clock/clock?${paramName}=${encodeURIComponent(moldName)}`,
|
||||
|
||||
Reference in New Issue
Block a user