fix scan routing and zip download errors

This commit is contained in:
汤学会
2026-07-10 10:12:03 +08:00
parent 28b8dc3773
commit be55bd44fe
5 changed files with 190 additions and 30 deletions
+8 -3
View File
@@ -381,9 +381,14 @@ Page({
await this.shareZipFile(filePath, fileName)
} catch (error) {
wx.hideLoading()
const message = error && error.errMsg && error.errMsg.includes('cancel')
? '已取消转发'
: (error.message || '转发失败')
let message = error.message || '转发失败'
if (error && error.errMsg && error.errMsg.includes('cancel')) {
message = '已取消转发'
} else if (error && error.statusCode === 404) {
message = 'ZIP文件不存在或已过期,请重新生成'
} else if (error && error.statusCode === 409) {
message = 'ZIP还未生成完成,请刷新后重试'
}
wx.showToast({ title: message, icon: 'none' })
}
},
+20 -25
View File
@@ -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)}`,