scan-ipp-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
|
-
##
|
|
1
|
+
## ipp SDK
|
|
2
|
+
|
|
2
3
|
|
|
3
|
-
轻量级、零依赖的订单金额计算 & 购物车处理 SDK,支持四舍五入、向上取整、抹零、五舍六入、零元筐、押筐、附加费、反推单价/重量等业务逻辑,即插即用。
|
|
4
4
|
|
|
5
5
|
```shell
|
|
6
|
-
npm i
|
|
6
|
+
npm i scan-ipp-sdk
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```javascript
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import { startDiscovery,stopDiscovery } from 'scan-ipp-sdk'
|
|
11
|
+
|
|
12
|
+
// 开始扫描
|
|
13
|
+
startDiscovery(
|
|
14
|
+
(device) => {
|
|
15
|
+
console.log("Found device:", device);
|
|
16
|
+
|
|
17
|
+
if (!deviceNames.has(device.ip)) {
|
|
18
|
+
console.log(
|
|
19
|
+
"针式打印机-uni结果",
|
|
20
|
+
detail.callBackName,
|
|
21
|
+
this.scannedDevices,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
(err) => {
|
|
27
|
+
console.error("Scan error", err);
|
|
28
|
+
uni.showToast({
|
|
29
|
+
title: "扫描出错: " + err,
|
|
30
|
+
icon: "none",
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
// 扫描完成后,调用stopDiscovery方法停止扫描
|
|
35
|
+
stopDiscovery()
|
|
16
36
|
|
|
17
|
-
const detail = await OrderProcessingSDK.handleShopCar(cart, billing, 0)
|
|
18
|
-
// 0=四舍五入 1=向上取整 2=不处理 3=抹零 4=五舍六入
|
|
19
|
-
console.log(detail.totalCalAmount) // 12
|
|
20
|
-
console.log(detail.totalChangeDiff) // -0.34
|
|
21
37
|
```
|
|
22
38
|
|
|
23
39
|
|
|
24
|
-
|
|
25
|
-
| 方法 | 说明 |
|
|
26
|
-
| ------------------------------------------------ | -------------------- |
|
|
27
|
-
| `handleShopCar(items, billing, roundType)` | 单订单处理(核心) |
|
|
28
|
-
| `batchProcessOrders(orders, billing, roundType)` | 批量处理 |
|
|
29
|
-
| `calculateOrderStats(items)` | 统计:总数/总额/均值/最大/最小 |
|
|
30
|
-
| `syncProductCheckStatus(...)` | 购物车与货品勾选状态同步 |
|
|
31
|
-
| `handleBillingData(row, opts)` | 行级开单计算(金额/重量/附加费/押筐) |
|
|
32
|
-
|
|
33
|
-
|
|
34
40
|
MIT © qinxingxing
|