From ce259180a1a76db6a7e89d651dc3eb1f49932202 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期六, 10 十月 2026 19:48:50 +0800
Subject: [PATCH] 修改装箱清单打印样式
---
utils/index.js | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/utils/index.js b/utils/index.js
index 2c386eb..59f8361 100644
--- a/utils/index.js
+++ b/utils/index.js
@@ -1,6 +1,30 @@
import * as CryptoJS from "crypto-js";
/**
+ * Base64 缂栫爜锛堟寜 UTF-8 澶勭悊锛�
+ * 娉ㄦ剰锛歜toa 鍙湪娴忚鍣�(H5)瀛樺湪锛孉pp 鍜屽皬绋嬪簭閲屾病鏈夛紝鐩存帴璋冪敤浼氭姤 btoa is not defined銆�
+ * 杩欓噷鍦ㄩ潪 H5 鐜鐢ㄧ函 JS 瀹炵幇锛屼笉渚濊禆浠讳綍骞冲彴 API銆�
+ */
+const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+function base64Encode(str) {
+ const text = String(str);
+ // UTF-8 瀛楄妭搴忓垪
+ const utf8 = unescape(encodeURIComponent(text));
+ let out = "";
+ for (let i = 0; i < utf8.length; i += 3) {
+ const c1 = utf8.charCodeAt(i);
+ const c2 = utf8.charCodeAt(i + 1);
+ const c3 = utf8.charCodeAt(i + 2);
+ out += B64_CHARS[c1 >> 2];
+ out += B64_CHARS[((c1 & 3) << 4) | (isNaN(c2) ? 0 : c2 >> 4)];
+ out += isNaN(c2) ? "=" : B64_CHARS[((c2 & 15) << 2) | (isNaN(c3) ? 0 : c3 >> 6)];
+ out += isNaN(c3) ? "=" : B64_CHARS[c3 & 63];
+ }
+ return out;
+}
+
+/**
*鍔犲瘑澶勭悊
*/
export const encryption = params => {
@@ -8,7 +32,7 @@
const result = JSON.parse(JSON.stringify(data));
if (type === "Base64") {
param.forEach(ele => {
- result[ele] = btoa(result[ele]);
+ result[ele] = base64Encode(result[ele]);
});
} else {
param.forEach(ele => {
--
Gitblit v1.9.3