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 +
yarn.lock | 100 +++---
manifest.json | 380 ++++++++++++-----------
package.json | 4
common/config.js | 8
common/bluetoothPrinter.js | 42 ++
pages/wareHouse/nuclearScale/nuclearscalerecord.vue | 346 ++------------------
pages/sys/user/index.vue | 2
8 files changed, 358 insertions(+), 550 deletions(-)
diff --git a/common/bluetoothPrinter.js b/common/bluetoothPrinter.js
index dc018e0..2bee9e5 100644
--- a/common/bluetoothPrinter.js
+++ b/common/bluetoothPrinter.js
@@ -1,4 +1,25 @@
-const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
+// 绮捐嚕鎵撳嵃鏈哄師鐢熸彃浠躲�傛彃浠剁敱 DCloud 璐﹀彿缁戝畾锛岃处鍙锋湭璐拱/鏈墦鍏ュ熀搴ф椂涓嶈兘鎶涢敊锛�
+// 鍚﹀垯椤甸潰涓�鍔犺浇灏辩櫧灞忥紝鎵�浠ヨ繖閲屽仛瀹归敊鍔犺浇锛岀己澶辨椂鎵撳嵃鍔熻兘缁欏嚭鎻愮ず鑰屼笉鏄穿婧冦��
+let jcapi = null;
+let pluginMissing = false;
+try {
+ jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
+ if (!jcapi) {
+ pluginMissing = true;
+ }
+} catch (e) {
+ pluginMissing = true;
+}
+
+const PLUGIN_MISSING_MSG = "鏈娴嬪埌绮捐嚕鎵撳嵃鎻掍欢锛岃纭鎵撳寘鏃跺凡璐拱骞跺嬀閫夎鍘熺敓鎻掍欢";
+
+function requirePlugin() {
+ if (pluginMissing || !jcapi) {
+ uni.showToast({ title: PLUGIN_MISSING_MSG, icon: "none", duration: 3000 });
+ return null;
+ }
+ return jcapi;
+}
let state = {
connectedDevice: null,
@@ -25,7 +46,10 @@
/** 鍒濆鍖栵紙鍏ㄥ眬鍙渶涓�娆★級 */
function init() {
- jcapi.initSDK();
+ const api = requirePlugin();
+ if (!api) return;
+
+ api.initSDK();
const saved = uni.getStorageSync("bluetoothConnection");
if (saved) {
@@ -34,7 +58,7 @@
}
// 鏂紑鐩戝惉
- jcapi.didReadPrintErrorInfo((r) => {
+ api.didReadPrintErrorInfo((r) => {
if (r.code === 23) {
state.connectedDevice = null;
state.connectionStatus = "disconnected";
@@ -47,9 +71,13 @@
/** 鎼滅储璁惧 */
function searchDevices() {
return new Promise((resolve, reject) => {
+ const api = requirePlugin();
+ if (!api) {
+ return reject(new Error(PLUGIN_MISSING_MSG));
+ }
uni.openBluetoothAdapter({
success() {
- jcapi.getBluetoothDevices(list => {
+ api.getBluetoothDevices(list => {
resolve(list || []);
});
},
@@ -61,10 +89,14 @@
/** 杩炴帴璁惧 */
function connect(device) {
return new Promise((resolve, reject) => {
+ const api = requirePlugin();
+ if (!api) {
+ return reject(new Error(PLUGIN_MISSING_MSG));
+ }
state.connectionStatus = "connecting";
notify();
- jcapi.openPrinterByDevice({
+ api.openPrinterByDevice({
address: device.address,
name: device.name,
deviceType: 0,
diff --git a/common/config.js b/common/config.js
index 3f42fa4..66d534a 100644
--- a/common/config.js
+++ b/common/config.js
@@ -22,7 +22,13 @@
config.env = "development";
// config.baseUrl = 'https://mes-demo.asun.cloud';
// config.baseUrl = "http://192.168.32.65:9999";
-config.baseUrl = "";
+// 鍚庡彴鏈嶅姟鐪熷疄鍦板潃锛圓pp / 灏忕▼搴� 鎵撳寘鍚庝娇鐢紝蹇呴』鏄甫绔彛鐨勭粷瀵瑰湴鍧�锛�
+config.serverUrl = "http://192.168.22.25:80";
+
+// 娴忚鍣�(H5)閲屽繀椤荤敤鐩稿鍦板潃锛岃姹傛墠浼氳蛋 manifest.json 閲岀殑 devServer 浠g悊锛�
+// 涓�鏃﹀啓鎴愮粷瀵瑰湴鍧�锛岃姹備細鐩磋繛鍚庣锛屾祻瑙堝櫒鎸夎法鍩�(CORS)鎷︽埅銆�
+const isH5 = typeof window !== "undefined" && typeof window.document !== "undefined";
+config.baseUrl = isH5 ? "" : config.serverUrl;
config._api_key = "7a0e8d2d441f8233ef0f3683ca2fc848";
config.appKey = "55e70d3b74c1c8a70481173bf233a5e1";
config.downLoadEnv = "development";
diff --git a/manifest.json b/manifest.json
index 34f0249..ea6c0f0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,195 +1,199 @@
{
- "name": "姹熶笢鍚堥噾MES",
- "appid": "__UNI__2E031D3",
- "description": "pigcloud",
- "versionName": "4.0.2",
- "versionCode": 2,
- "transformPx": false,
- "app-plus": {
- "compilerVersion": 3,
- "optimization": {
- "subPackages": true
- },
- "safearea": {
- "bottom": {
- "offset": "none"
- }
- },
- "splashscreen": {
- "alwaysShowBeforeRender": true,
- "waiting": true,
- "autoclose": true,
- "delay": 0
- },
- "compatible": {
- "ignoreVersion": true
- },
- "usingComponents": true,
- "nvueCompiler": "uni-app",
- "modules": {
- "Bluetooth": {}
- },
- "distribute": {
- "android": {
- "permissions": [
- "<uses-feature android:name=\"android.hardware.camera\"/>",
- "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
- "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
- "<uses-permission android:name=\"android.permission.CAMERA\"/>",
- "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
- "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
- "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
- "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
- "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
- "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
- "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
- "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
- "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
- "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
- "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
- "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
- "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
- "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
- "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
- "<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\"/> ",
- "<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\"/>",
- "<uses-permission android:name=\"android.permission.RECEIVE_SMS\"/>",
- "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
- "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>"
- ],
- "abiFilters": ["armeabi-v7a", "arm64-v8a"]
- },
- "ios": {
- "dSYMs": false
- },
- "sdkConfigs": {
- "ad": {},
- "oauth": {}
- },
- "icons": {
- "android": {
- "hdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png",
- "xhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png",
- "xxhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png",
- "xxxhdpi": "C:/Users/MLL/Desktop/03ae6e42ca681ffd98737b6a20f94d0.png"
+ "name" : "姹熶笢鍚堥噾MES",
+ "appid" : "__UNI__BB8756A",
+ "description" : "pigcloud",
+ "versionName" : "4.0.2",
+ "versionCode" : 3,
+ "transformPx" : false,
+ "app-plus" : {
+ "compilerVersion" : 3,
+ "optimization" : {
+ "subPackages" : true
},
- "ios": {
- "appstore": "",
- "ipad": {
- "app": "",
- "app@2x": "",
- "notification": "",
- "notification@2x": "",
- "proapp@2x": "",
- "settings": "",
- "settings@2x": "",
- "spotlight": "",
- "spotlight@2x": ""
- },
- "iphone": {
- "app@2x": "",
- "app@3x": "",
- "notification@2x": "",
- "notification@3x": "",
- "settings@2x": "",
- "settings@3x": "",
- "spotlight@2x": "",
- "spotlight@3x": ""
- }
- }
- },
- "splashscreen": {
- "androidStyle": "common"
- }
- },
- "nativePlugins": {
- "JCSDK-JCApiModule": {
- "__plugin_info__": {
- "name": "绮捐嚕鎵撳嵃鏈烘帴鍏ユ彃浠�",
- "description": "绮捐嚕绯诲垪鎵撳嵃鏈烘墦鍗版彃浠�",
- "platforms": "Android,iOS",
- "url": "https://ext.dcloud.net.cn/plugin?id=10011",
- "android_package_name": "uni.UNI2E031D3",
- "ios_bundle_id": "",
- "isCloud": true,
- "bought": 1,
- "pid": "10011",
- "parameters": {}
- }
- }
- }
- },
- "quickapp": {},
- "mp-weixin": {
- "appid": "wxf3e5cc7116d23b18",
- "setting": {
- "urlCheck": false,
- "es6": false,
- "minified": true,
- "postcss": true
- },
- "optimization": {
- "subPackages": true
- },
- "usingComponents": true
- },
- "mp-alipay": {
- "usingComponents": true,
- "component2": true
- },
- "mp-qq": {
- "optimization": {
- "subPackages": true
- },
- "appid": ""
- },
- "mp-baidu": {
- "usingComponents": true,
- "appid": ""
- },
- "mp-toutiao": {
- "usingComponents": true,
- "appid": ""
- },
- "h5": {
- "template": "h5.html",
- "router": {
- "mode": "hash",
- "base": "./"
- },
- "optimization": {
- "treeShaking": {
- "enable": false
- }
- },
- "devServer": {
- "port": 8080, //娴忚鍣ㄨ繍琛岀鍙�
- "disableHostCheck": true,
- "proxy": {
- "/auth": {
- "target": "http://192.168.32.65:9999",
- "changeOrigin": true,
- "secure": false
+ "safearea" : {
+ "bottom" : {
+ "offset" : "none"
+ }
},
- "/mes": {
- "target": "http://192.168.32.65:9999",
- "changeOrigin": true,
- "secure": false
+ "splashscreen" : {
+ "alwaysShowBeforeRender" : true,
+ "waiting" : true,
+ "autoclose" : true,
+ "delay" : 0
},
- "/admin": {
- "target": "http://192.168.32.65:9999",
- "changeOrigin": true,
- "secure": false
+ "compatible" : {
+ "ignoreVersion" : true
+ },
+ "usingComponents" : true,
+ "nvueCompiler" : "uni-app",
+ "modules" : {
+ "Bluetooth" : {}
+ },
+ "distribute" : {
+ "android" : {
+ "permissions" : [
+ "<uses-feature android:name=\"android.hardware.camera\"/>",
+ "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
+ "<uses-permission android:name=\"android.permission.CAMERA\"/>",
+ "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+ "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
+ "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
+ "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+ "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
+ "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
+ "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+ "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+ "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
+ "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\"/> ",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\"/>",
+ "<uses-permission android:name=\"android.permission.RECEIVE_SMS\"/>",
+ "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
+ "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>"
+ ],
+ "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
+ },
+ "ios" : {
+ "dSYMs" : false
+ },
+ "sdkConfigs" : {
+ "ad" : {},
+ "oauth" : {}
+ },
+ "icons" : {
+ "android" : {
+ "hdpi" : "unpackage/res/icons/72x72.png",
+ "xhdpi" : "unpackage/res/icons/96x96.png",
+ "xxhdpi" : "unpackage/res/icons/144x144.png",
+ "xxxhdpi" : "unpackage/res/icons/192x192.png"
+ },
+ "ios" : {
+ "appstore" : "unpackage/res/icons/1024x1024.png",
+ "ipad" : {
+ "app" : "unpackage/res/icons/76x76.png",
+ "app@2x" : "unpackage/res/icons/152x152.png",
+ "notification" : "unpackage/res/icons/20x20.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "proapp@2x" : "unpackage/res/icons/167x167.png",
+ "settings" : "unpackage/res/icons/29x29.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "spotlight" : "unpackage/res/icons/40x40.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png"
+ },
+ "iphone" : {
+ "app@2x" : "unpackage/res/icons/120x120.png",
+ "app@3x" : "unpackage/res/icons/180x180.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "notification@3x" : "unpackage/res/icons/60x60.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "settings@3x" : "unpackage/res/icons/87x87.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png",
+ "spotlight@3x" : "unpackage/res/icons/120x120.png"
+ }
+ }
+ },
+ "splashscreen" : {
+ "androidStyle" : "common"
+ }
+ },
+ "nativePlugins" : {
+ "JCSDK-JCApiModule" : {
+ "__plugin_info__" : {
+ "name" : "绮捐嚕鎵撳嵃鏈烘帴鍏ユ彃浠�",
+ "description" : "绮捐嚕绯诲垪鎵撳嵃鏈烘墦鍗版彃浠�",
+ "platforms" : "Android,iOS",
+ "url" : "https://ext.dcloud.net.cn/plugin?id=10011",
+ "android_package_name" : "uni.UNI2E031D3",
+ "ios_bundle_id" : "",
+ "isCloud" : true,
+ "bought" : 1,
+ "pid" : "10011",
+ "parameters" : {}
+ }
+ }
}
- }
},
- "title": "Asun-Mes",
- "domain": "/app"
- },
- "locale": "zh-Hans",
- "fallbackLocale": "zh-Hans"
+ "quickapp" : {},
+ "mp-weixin" : {
+ "appid" : "wxf3e5cc7116d23b18",
+ "setting" : {
+ "urlCheck" : false,
+ "es6" : false,
+ "minified" : true,
+ "postcss" : true
+ },
+ "optimization" : {
+ "subPackages" : true
+ },
+ "usingComponents" : true
+ },
+ "mp-alipay" : {
+ "usingComponents" : true,
+ "component2" : true
+ },
+ "mp-qq" : {
+ "optimization" : {
+ "subPackages" : true
+ },
+ "appid" : ""
+ },
+ "mp-baidu" : {
+ "usingComponents" : true,
+ "appid" : ""
+ },
+ "mp-toutiao" : {
+ "usingComponents" : true,
+ "appid" : ""
+ },
+ "h5" : {
+ "template" : "h5.html",
+ "router" : {
+ "mode" : "hash",
+ "base" : "./"
+ },
+ "optimization" : {
+ "treeShaking" : {
+ "enable" : false
+ }
+ },
+ "devServer" : {
+ "port" : 8080, //娴忚鍣ㄨ繍琛岀鍙�
+ "disableHostCheck" : true,
+ // 浠g悊鍙鐩稿璺緞鐢熸晥锛歝onfig.js 閲� H5 骞冲彴 baseUrl 蹇呴』涓虹┖瀛楃涓�
+ "proxy" : {
+ "/auth" : {
+ "target" : "http://192.168.22.25:80",
+ "changeOrigin" : true,
+ "secure" : false,
+ "logLevel" : "debug"
+ },
+ "/mes" : {
+ "target" : "http://192.168.22.25:80",
+ "changeOrigin" : true,
+ "secure" : false,
+ "logLevel" : "debug"
+ },
+ "/admin" : {
+ "target" : "http://192.168.22.25:80",
+ "changeOrigin" : true,
+ "secure" : false,
+ "logLevel" : "debug"
+ }
+ }
+ },
+ "title" : "Asun-Mes",
+ "domain" : "/app"
+ },
+ "locale" : "zh-Hans",
+ "fallbackLocale" : "zh-Hans"
}
diff --git a/package.json b/package.json
index 38cb8ba..b592cfd 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
},
"dependencies": {
"crypto-js": "^3.3.0",
- "qs": "^6.9.7",
- "vue-i18n": "^8.20.0"
+ "qs": "^6.10.5",
+ "vue-i18n": "^8.27.1"
}
}
diff --git a/pages/sys/user/index.vue b/pages/sys/user/index.vue
index 0dd1554..e7f89ab 100644
--- a/pages/sys/user/index.vue
+++ b/pages/sys/user/index.vue
@@ -66,7 +66,7 @@
loading: false,
refreshLoading: false,
image: undefined,
- currentVersion: "1.0.1",
+ currentVersion: "1.1.3",
};
},
onLoad() {
diff --git a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
index cfd4a57..ed66e15 100644
--- a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
+++ b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -188,11 +188,6 @@
DataMatrix: 33,
AZTEC: 34,
};
-// 绾挎潯绫诲瀷
-const LineType = {
- Solid: 1, // 瀹炵嚎
- Dotted: 2, // 铏氱嚎锛堥粯璁よ櫄瀹�1:1鐩搁棿锛�
-};
// 鎹㈣鏂瑰紡
const LineModeType = {
Justified: 1, // 瀹介珮鍥哄畾锛屽唴瀹硅嚜閫傚簲锛堝瓧鍙�/瀛楅棿璺�/琛岄棿璺濇寜姣斾緥缂╂斁锛�
@@ -480,19 +475,21 @@
}
const ht = item.contractNo;
- const lj = item.partNo;
- const ljms = item.ccontrProModel;
const fh = item.newNetWeight;
- const scdt = item.productionDate;
const scph = item.batchNo;
- const shdw = item.customerName;
- const fhdw = "姹熶笢鍚堥噾鎶�鏈湁闄愬叕鍙�";
- // 鍒濆鍖栫敾鏉�
+ // ===== 鏍囩绾告帓鐗堝弬鏁帮紙鍗曚綅锛歮m锛夛細40*70 鏍囩绾� =====
+ const LABEL_W = 40; // 鏍囩瀹藉害
+ const LABEL_H = 70; // 鏍囩闀垮害锛堣蛋绾告柟鍚戯級
+ const MARGIN = 1; // 鍥涘懆鐣欑櫧锛岄槻姝㈡墦鍗版埅鏂�
+ const QR_SIZE = LABEL_W - MARGIN * 2; // 浜岀淮鐮侀摵婊� 40mm 瀹斤紙38mm锛�
+ const TEXT_FONT_SIZE = 3; // 瀛楁瀛楀彿
+
+ // 鍒濆鍖栫敾鏉匡細瀹� 40銆侀暱 70锛屼笉鍋氭棆杞紙x 涓虹焊瀹芥柟鍚戯紝y 涓鸿蛋绾告柟鍚戯級
jcapi.initDrawingBoard({
- width: 70,
- height: 49,
- rotate: 90,
+ width: LABEL_W,
+ height: LABEL_H,
+ rotate: 0,
});
// 缁樺埗浜岀淮鐮�
@@ -508,290 +505,46 @@
};
jcapi.drawLabelQrCode({
- x: 43.5,
- y: 2,
- width: 24,
- height: 24,
+ x: MARGIN,
+ y: MARGIN,
+ width: QR_SIZE,
+ height: QR_SIZE,
value: qrContent,
rotate: 0,
codeType: QrCodeType.QrCode,
});
- // 缁樺埗妯嚎
- this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid);
- this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid);
- this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid);
+ // 鍏ㄩ儴妗嗙嚎宸插幓鎺夛紱浜岀淮鐮佷笅鏂瑰墿浣欑┖闂存í鍚戝睍绀轰笁涓瓧娈�
+ const textTop = MARGIN + QR_SIZE + MARGIN;
+ const lineHeight = (LABEL_H - MARGIN - textTop) / 3;
+ const fields = [
+ { label: "鍚堝悓鍙�", value: ht },
+ { label: "鍙戣揣/瑁呯鏁�", value: fh },
+ { label: "鐢熶骇鎵瑰彿", value: scph },
+ ];
- //缁樺埗绔栫嚎
- this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid); // 绔栫嚎1
- this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid); // 绔栫嚎2
- this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // 绔栫嚎3
+ fields.forEach((field, index) => {
+ const value =
+ field.value === null || field.value === undefined
+ ? ""
+ : String(field.value);
+ this.getDrawLabelText(
+ MARGIN,
+ textTop + index * lineHeight,
+ LABEL_W - MARGIN * 2,
+ lineHeight,
+ `${field.label}: ${value}`,
+ TEXT_FONT_SIZE,
+ 0,
+ LineModeType.AutoHeight,
+ 0,
+ 0,
+ 0,
+ 1,
+ 1
+ );
+ });
- // 缁樺埗鏂囨湰
- this.getDrawLabelText(
- 3,
- 2.5,
- 40,
- 8,
- "涓ぉ绉戞妧瑁呯娓呭崟",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 1,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 7,
- 25,
- 8,
- "鍚堝悓鍙�:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 12,
- 25,
- 8,
- "闆朵欢鍙�:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 17,
- 25,
- 8,
- "闆朵欢鎻忚堪:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 23.5,
- 25,
- 8,
- "鍙戣揣/瑁呯鏁�:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 28.5,
- 25,
- 8,
- "鐢熶骇鏃ユ湡:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 32.5,
- 25,
- 8,
- "鐢熶骇鎵瑰彿:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 37.5,
- 25,
- 8,
- "鍙戣揣鍗曚綅:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
- this.getDrawLabelText(
- 2,
- 42.5,
- 25,
- 8,
- "鏀惰揣鍗曚綅:",
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 1,
- 1
- );
-
- // 濉厖鍙傛暟鍊�
- this.getDrawLabelText(
- 11,
- 7,
- 30,
- 8,
- ht,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 11,
- 12,
- 32,
- 8,
- lj,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 14,
- 17,
- 30,
- 8,
- ljms,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 17,
- 23.5,
- 27,
- 8,
- fh,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 14,
- 28.5,
- 55,
- 8,
- scdt,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 14,
- 32.7,
- 55,
- 8,
- scph,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 14,
- 37.5,
- 55,
- 8,
- fhdw,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
- this.getDrawLabelText(
- 14,
- 42.5,
- 55,
- 8,
- shdw,
- 2.5,
- 0,
- LineModeType.AutoHeight,
- 0,
- 0,
- 0,
- 0,
- 1
- );
// 鐢熸垚鎵撳嵃鏁版嵁
let imageJsonObj = jcapi.generateLabelJson();
@@ -890,17 +643,6 @@
}
},
- // 缁樺埗妯嚎
- getDrawLabelLine(x, y, width, height, rotate, lineType) {
- jcapi.drawLabelLine({
- x: x,
- y: y,
- width: width,
- height: height,
- rotate: rotate,
- lineType: lineType,
- });
- },
// 濉啿鏂囧瓧鏍囬
getDrawLabelText(
x,
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 => {
diff --git a/yarn.lock b/yarn.lock
index 7faacd8..d1b0a5d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,67 +2,67 @@
# yarn lockfile v1
-"call-bind@^1.0.0":
- "integrity" "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/call-bind/-/call-bind-1.0.2.tgz"
- "version" "1.0.2"
+call-bind@^1.0.0:
+ version "1.0.2"
+ resolved "http://10.1.51.33:8081/repository/group-npm/call-bind/-/call-bind-1.0.2.tgz"
+ integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==
dependencies:
- "function-bind" "^1.1.1"
- "get-intrinsic" "^1.0.2"
+ function-bind "^1.1.1"
+ get-intrinsic "^1.0.2"
-"crypto-js@^3.3.0":
- "integrity" "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
- "resolved" "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.3.0.tgz"
- "version" "3.3.0"
+crypto-js@^3.3.0:
+ version "3.3.0"
+ resolved "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.3.0.tgz"
+ integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==
-"function-bind@^1.1.1":
- "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/function-bind/-/function-bind-1.1.1.tgz"
- "version" "1.1.1"
+function-bind@^1.1.1:
+ version "1.1.1"
+ resolved "http://10.1.51.33:8081/repository/group-npm/function-bind/-/function-bind-1.1.1.tgz"
+ integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
-"get-intrinsic@^1.0.2":
- "integrity" "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz"
- "version" "1.1.1"
+get-intrinsic@^1.0.2:
+ version "1.1.1"
+ resolved "http://10.1.51.33:8081/repository/group-npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz"
+ integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==
dependencies:
- "function-bind" "^1.1.1"
- "has" "^1.0.3"
- "has-symbols" "^1.0.1"
+ function-bind "^1.1.1"
+ has "^1.0.3"
+ has-symbols "^1.0.1"
-"has-symbols@^1.0.1":
- "integrity" "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/has-symbols/-/has-symbols-1.0.3.tgz"
- "version" "1.0.3"
+has-symbols@^1.0.1:
+ version "1.0.3"
+ resolved "http://10.1.51.33:8081/repository/group-npm/has-symbols/-/has-symbols-1.0.3.tgz"
+ integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==
-"has@^1.0.3":
- "integrity" "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/has/-/has-1.0.3.tgz"
- "version" "1.0.3"
+has@^1.0.3:
+ version "1.0.3"
+ resolved "http://10.1.51.33:8081/repository/group-npm/has/-/has-1.0.3.tgz"
+ integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
dependencies:
- "function-bind" "^1.1.1"
+ function-bind "^1.1.1"
-"object-inspect@^1.9.0":
- "integrity" "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/object-inspect/-/object-inspect-1.12.2.tgz"
- "version" "1.12.2"
+object-inspect@^1.9.0:
+ version "1.12.2"
+ resolved "http://10.1.51.33:8081/repository/group-npm/object-inspect/-/object-inspect-1.12.2.tgz"
+ integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==
-"qs@^6.9.7":
- "integrity" "sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/qs/-/qs-6.10.5.tgz"
- "version" "6.10.5"
+qs@^6.10.5:
+ version "6.10.5"
+ resolved "http://10.1.51.33:8081/repository/group-npm/qs/-/qs-6.10.5.tgz"
+ integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ==
dependencies:
- "side-channel" "^1.0.4"
+ side-channel "^1.0.4"
-"side-channel@^1.0.4":
- "integrity" "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/side-channel/-/side-channel-1.0.4.tgz"
- "version" "1.0.4"
+side-channel@^1.0.4:
+ version "1.0.4"
+ resolved "http://10.1.51.33:8081/repository/group-npm/side-channel/-/side-channel-1.0.4.tgz"
+ integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==
dependencies:
- "call-bind" "^1.0.0"
- "get-intrinsic" "^1.0.2"
- "object-inspect" "^1.9.0"
+ call-bind "^1.0.0"
+ get-intrinsic "^1.0.2"
+ object-inspect "^1.9.0"
-"vue-i18n@^8.20.0":
- "integrity" "sha512-lWrGm4F25qReJ7XxSnFVb2h3PfW54ldnM4C+YLBGGJ75+Myt/kj4hHSTKqsyDLamvNYpvINMicSOdW+7yuqgIQ=="
- "resolved" "http://10.1.51.33:8081/repository/group-npm/vue-i18n/-/vue-i18n-8.27.1.tgz"
- "version" "8.27.1"
+vue-i18n@^8.27.1:
+ version "8.27.1"
+ resolved "http://10.1.51.33:8081/repository/group-npm/vue-i18n/-/vue-i18n-8.27.1.tgz"
+ integrity sha512-lWrGm4F25qReJ7XxSnFVb2h3PfW54ldnM4C+YLBGGJ75+Myt/kj4hHSTKqsyDLamvNYpvINMicSOdW+7yuqgIQ==
--
Gitblit v1.9.3