|
@@ -6,7 +6,7 @@
|
|
|
<view class="back-btn" @click="handleBack">
|
|
<view class="back-btn" @click="handleBack">
|
|
|
<text class="back-icon">‹</text>
|
|
<text class="back-icon">‹</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <text class="header-title">小程序扫描</text>
|
|
|
|
|
|
|
+ <text class="header-title">{{ t('scan.title') }}</text>
|
|
|
<view class="placeholder"></view>
|
|
<view class="placeholder"></view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -29,14 +29,14 @@
|
|
|
:class="{ active: scanMode === 'single' }"
|
|
:class="{ active: scanMode === 'single' }"
|
|
|
@click="switchToSingle"
|
|
@click="switchToSingle"
|
|
|
>
|
|
>
|
|
|
- <text class="mode-text">单页</text>
|
|
|
|
|
|
|
+ <text class="mode-text">{{ t('scan.singlePage') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
<view
|
|
<view
|
|
|
class="mode-btn"
|
|
class="mode-btn"
|
|
|
:class="{ active: scanMode === 'multiple' }"
|
|
:class="{ active: scanMode === 'multiple' }"
|
|
|
@click="switchToMultiple"
|
|
@click="switchToMultiple"
|
|
|
>
|
|
>
|
|
|
- <text class="mode-text">多页</text>
|
|
|
|
|
|
|
+ <text class="mode-text">{{ t('scan.multiplePage') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -69,7 +69,7 @@
|
|
|
class="upload-btn"
|
|
class="upload-btn"
|
|
|
@click="handleMultipleUpload"
|
|
@click="handleMultipleUpload"
|
|
|
>
|
|
>
|
|
|
- <text class="upload-text">上传</text>
|
|
|
|
|
|
|
+ <text class="upload-text">{{ t('scan.upload') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- PDF缩略图预览(右下角) -->
|
|
<!-- PDF缩略图预览(右下角) -->
|
|
@@ -85,7 +85,7 @@
|
|
|
<view class="action-buttons">
|
|
<view class="action-buttons">
|
|
|
<view class="action-btn" @click="handleSelectImage">
|
|
<view class="action-btn" @click="handleSelectImage">
|
|
|
<image class="btn-icon" src="/static/pages/scan/import-pic.svg" mode="aspectFit" />
|
|
<image class="btn-icon" src="/static/pages/scan/import-pic.svg" mode="aspectFit" />
|
|
|
- <text class="btn-text">导入图片</text>
|
|
|
|
|
|
|
+ <text class="btn-text">{{ t('scan.importImage') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<view class="capture-btn" @click="handleCapture">
|
|
<view class="capture-btn" @click="handleCapture">
|
|
@@ -94,7 +94,7 @@
|
|
|
|
|
|
|
|
<view class="action-btn" @click="handleSelectFile">
|
|
<view class="action-btn" @click="handleSelectFile">
|
|
|
<image class="btn-icon" src="/static/pages/scan/import-doc.svg" mode="aspectFit" />
|
|
<image class="btn-icon" src="/static/pages/scan/import-doc.svg" mode="aspectFit" />
|
|
|
- <text class="btn-text">导入文档</text>
|
|
|
|
|
|
|
+ <text class="btn-text">{{ t('scan.importDocument') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -176,7 +176,7 @@ const switchToSingle = () => {
|
|
|
scanMode.value = 'single'
|
|
scanMode.value = 'single'
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '已切换到单页模式',
|
|
|
|
|
|
|
+ title: t('scan.switchToSingle'),
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
@@ -188,7 +188,7 @@ const switchToMultiple = () => {
|
|
|
scanMode.value = 'multiple'
|
|
scanMode.value = 'multiple'
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '已切换到多页模式',
|
|
|
|
|
|
|
+ title: t('scan.switchToMultiple'),
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
@@ -198,7 +198,7 @@ const switchToMultiple = () => {
|
|
|
const handleCameraError = (e) => {
|
|
const handleCameraError = (e) => {
|
|
|
console.error('相机错误:', e)
|
|
console.error('相机错误:', e)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '相机启动失败',
|
|
|
|
|
|
|
+ title: t('scan.cameraError'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -212,7 +212,7 @@ const handleCapture = () => {
|
|
|
success: async (res) => {
|
|
success: async (res) => {
|
|
|
try {
|
|
try {
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
- title: '处理中..',
|
|
|
|
|
|
|
+ title: t('scan.processing'),
|
|
|
mask: true
|
|
mask: true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -230,7 +230,7 @@ const handleCapture = () => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('处理图片失败:', error)
|
|
console.error('处理图片失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '处理失败',
|
|
|
|
|
|
|
+ title: t('scan.processFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -238,7 +238,7 @@ const handleCapture = () => {
|
|
|
fail: (err) => {
|
|
fail: (err) => {
|
|
|
console.error('拍照失败:', err)
|
|
console.error('拍照失败:', err)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '拍照失败',
|
|
|
|
|
|
|
+ title: t('scan.captureFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -254,7 +254,7 @@ const handleSelectImage = async () => {
|
|
|
success: async (res) => {
|
|
success: async (res) => {
|
|
|
try {
|
|
try {
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
- title: '处理�?..',
|
|
|
|
|
|
|
+ title: t('scan.processing'),
|
|
|
mask: true
|
|
mask: true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -272,7 +272,7 @@ const handleSelectImage = async () => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('处理图片失败:', error)
|
|
console.error('处理图片失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '处理失败',
|
|
|
|
|
|
|
+ title: t('scan.processFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -289,7 +289,7 @@ const handleSelectFile = () => {
|
|
|
success: async (res) => {
|
|
success: async (res) => {
|
|
|
try {
|
|
try {
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
- title: '处理中...',
|
|
|
|
|
|
|
+ title: t('scan.processing'),
|
|
|
mask: true
|
|
mask: true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -309,7 +309,7 @@ const handleSelectFile = () => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('处理文档失败:', error)
|
|
console.error('处理文档失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '处理失败',
|
|
|
|
|
|
|
+ title: t('scan.processFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -317,7 +317,7 @@ const handleSelectFile = () => {
|
|
|
fail: (err) => {
|
|
fail: (err) => {
|
|
|
console.error('选择文档失败:', err)
|
|
console.error('选择文档失败:', err)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '选择文档失败',
|
|
|
|
|
|
|
+ title: t('scan.selectDocumentFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -349,7 +349,7 @@ const handleDocumentUpload = async (base64Data) => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '文档导入成功',
|
|
|
|
|
|
|
+ title: t('scan.documentImportSuccess'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
@@ -364,7 +364,7 @@ const handleDocumentUpload = async (base64Data) => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('处理文档失败:', error)
|
|
console.error('处理文档失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: error.message || '处理失败',
|
|
|
|
|
|
|
+ title: error.message || t('scan.processFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -386,7 +386,7 @@ const handleDocumentInMultipleMode = async (base64Data, fileName) => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: `已添加第${pdfDataList.value.length}个文档`,
|
|
|
|
|
|
|
+ title: t('scan.added', { count: pdfDataList.value.length }),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
@@ -394,7 +394,7 @@ const handleDocumentInMultipleMode = async (base64Data, fileName) => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('处理文档失败:', error)
|
|
console.error('处理文档失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: error.message || '处理失败',
|
|
|
|
|
|
|
+ title: error.message || t('scan.processFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -443,19 +443,19 @@ const uploadSingleImage = async (base64Data) => {
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '上传成功',
|
|
|
|
|
|
|
+ title: t('scan.uploadSuccess'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 2000
|
|
duration: 2000
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- throw new Error(response.msg || '上传失败')
|
|
|
|
|
|
|
+ throw new Error(response.msg || t('scan.uploadFailed'))
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('上传失败:', error)
|
|
console.error('上传失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: error.message || '上传失败',
|
|
|
|
|
|
|
+ title: error.message || t('scan.uploadFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -465,7 +465,7 @@ const uploadSingleImage = async (base64Data) => {
|
|
|
const handleMultipleUpload = async () => {
|
|
const handleMultipleUpload = async () => {
|
|
|
if (imageBase64List.value.length === 0) {
|
|
if (imageBase64List.value.length === 0) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '请先添加图片',
|
|
|
|
|
|
|
+ title: t('scan.addImage'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
@@ -473,7 +473,7 @@ const handleMultipleUpload = async () => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
- title: '上传中...',
|
|
|
|
|
|
|
+ title: t('scan.uploading'),
|
|
|
mask: true
|
|
mask: true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -497,19 +497,19 @@ const handleMultipleUpload = async () => {
|
|
|
await handlePdfPreview(response.data.fileBase64)
|
|
await handlePdfPreview(response.data.fileBase64)
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '上传成功',
|
|
|
|
|
|
|
+ title: t('scan.uploadSuccess'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 2000
|
|
duration: 2000
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- throw new Error(response.msg || '上传失败')
|
|
|
|
|
|
|
+ throw new Error(response.msg || t('scan.uploadFailed'))
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('上传失败:', error)
|
|
console.error('上传失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: error.message || '上传失败',
|
|
|
|
|
|
|
+ title: error.message || t('scan.uploadFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -540,7 +540,7 @@ const uploadAndScanImage = async (base64Data) => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: `已扫描第${pdfDataList.value.length}页`,
|
|
|
|
|
|
|
+ title: t('scan.scanned', { count: pdfDataList.value.length }),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 1500
|
|
duration: 1500
|
|
|
})
|
|
})
|
|
@@ -551,7 +551,7 @@ const uploadAndScanImage = async (base64Data) => {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
console.error('扫描失败:', error)
|
|
console.error('扫描失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: error.message || '扫描失败',
|
|
|
|
|
|
|
+ title: t('scan.scanFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -563,7 +563,7 @@ const handleDeleteImage = (index) => {
|
|
|
imageTempPaths.value.splice(index, 1)
|
|
imageTempPaths.value.splice(index, 1)
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '已删除',
|
|
|
|
|
|
|
+ title: t('scan.deleted'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 1000
|
|
duration: 1000
|
|
|
})
|
|
})
|
|
@@ -574,7 +574,7 @@ const handleDeletePdf = (index) => {
|
|
|
pdfDataList.value.splice(index, 1)
|
|
pdfDataList.value.splice(index, 1)
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '已删除',
|
|
|
|
|
|
|
+ title: t('scan.deleted'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 1000
|
|
duration: 1000
|
|
|
})
|
|
})
|
|
@@ -584,7 +584,7 @@ const handleDeletePdf = (index) => {
|
|
|
const handleViewAllPdf = () => {
|
|
const handleViewAllPdf = () => {
|
|
|
if (pdfDataList.value.length === 0) {
|
|
if (pdfDataList.value.length === 0) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '暂无PDF',
|
|
|
|
|
|
|
+ title: t('scan.noPdf'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
@@ -607,14 +607,14 @@ const handlePdfPreview = async (base64Data) => {
|
|
|
showPdfThumbnail.value = true
|
|
showPdfThumbnail.value = true
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '上传成功',
|
|
|
|
|
|
|
+ title: t('scan.uploadSuccess'),
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
duration: 2000
|
|
duration: 2000
|
|
|
})
|
|
})
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('处理PDF失败:', error)
|
|
console.error('处理PDF失败:', error)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '处理PDF失败',
|
|
|
|
|
|
|
+ title: t('scan.processPdfFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -655,7 +655,7 @@ const handleOpenPdf = () => {
|
|
|
fail: (err) => {
|
|
fail: (err) => {
|
|
|
console.error('打开文档失败:', err)
|
|
console.error('打开文档失败:', err)
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '打开文档失败',
|
|
|
|
|
|
|
+ title: t('scan.openDocumentFailed'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|