Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jz_Travel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengke
jz_Travel
Commits
06b394af
Commit
06b394af
authored
Jul 25, 2025
by
youjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
3ec2c0c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
QRCode.vue
pages/teamLeader/components/QRCode.vue
+28
-13
No files found.
pages/teamLeader/components/QRCode.vue
View file @
06b394af
...
@@ -189,7 +189,6 @@
...
@@ -189,7 +189,6 @@
// 1. 清理 Base64 前缀(如 data:image/png;base64,)
// 1. 清理 Base64 前缀(如 data:image/png;base64,)
const
base64Data
=
this
.
list
[
this
.
current
].
data
const
base64Data
=
this
.
list
[
this
.
current
].
data
// 2. 解码 Base64 为二进制字符串
// 2. 解码 Base64 为二进制字符串
// 3. 转换为 Uint8Array(二进制数组)
const
arrayBuffer
=
wx
.
base64ToArrayBuffer
(
base64Data
);
const
arrayBuffer
=
wx
.
base64ToArrayBuffer
(
base64Data
);
// 3. 转换为临时文件路径(微信小程序需通过临时文件)
// 3. 转换为临时文件路径(微信小程序需通过临时文件)
const
tempDir
=
wx
.
env
.
USER_DATA_PATH
;
// 临时目录(无需权限)
const
tempDir
=
wx
.
env
.
USER_DATA_PATH
;
// 临时目录(无需权限)
...
@@ -203,8 +202,8 @@
...
@@ -203,8 +202,8 @@
data
:
arrayBuffer
,
// 直接写入 ArrayBuffer
data
:
arrayBuffer
,
// 直接写入 ArrayBuffer
encoding
:
'binary'
,
// 必须指定为 binary
encoding
:
'binary'
,
// 必须指定为 binary
success
:
()
=>
{
success
:
()
=>
{
uni
.
showToast
({
title
:
'临时文件:'
+
filePath
});
//
uni.showToast({ title: '临时文件:' + filePath });
console
.
log
(
filePath
,
'----'
)
// 可选:保存到相册(需授权)
// 可选:保存到相册(需授权)
that
.
saveFileToPhone
(
filePath
);
that
.
saveFileToPhone
(
filePath
);
},
},
...
@@ -215,16 +214,32 @@
...
@@ -215,16 +214,32 @@
});
});
},
},
saveFileToPhone
(
tempFilePath
)
{
saveFileToPhone
(
tempFilePath
)
{
uni
.
saveFile
({
const
platform
=
uni
.
getSystemInfoSync
().
platform
;
tempFilePath
:
tempFilePath
,
if
(
platform
===
'mp-weixin'
||
platform
===
'devtools'
)
{
success
:
(
saveRes
)
=>
{
// 微信小程序:使用 wx.saveImageToPhotosAlbum
uni
.
showToast
({
title
:
'文件已保存至:'
+
saveRes
.
savedFilePath
});
wx
.
saveImageToPhotosAlbum
({
},
filePath
:
tempFilePath
,
fail
:
(
err
)
=>
{
success
:
(
saveRes
)
=>
{
uni
.
showToast
({
title
:
'保存失败'
,
icon
:
'none'
});
uni
.
showToast
({
title
:
'保存成功'
});
console
.
error
(
'保存错误'
,
err
);
console
.
log
(
saveRes
,
'----文件地址'
);
}
},
});
fail
:
(
err
)
=>
{
uni
.
showToast
({
title
:
'保存失败'
,
icon
:
'none'
});
console
.
error
(
'保存错误'
,
err
);
}
});
}
// uni.saveFile({
// tempFilePath: tempFilePath,
// success: (saveRes) => {
// uni.showToast({ title: '文件已保存至:' + saveRes.savedFilePath });
// console.log(saveRes.savedFilePath,'----文件地址');
// },
// fail: (err) => {
// uni.showToast({ title: '保存失败', icon: 'none' });
// console.error('保存错误', err);
// }
// });
},
},
canvasToTempFilePath
(){
canvasToTempFilePath
(){
uni
.
canvasToTempFilePath
({
uni
.
canvasToTempFilePath
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment