@cpzxrobot/sdk 1.0.17 → 1.0.19

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/device_gateway.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DeviceTypeGateway } from "./device_type_gateway";
2
2
  import { DeviceFilter } from "./device_filter";
3
- import type { ElectricMeter, Cpzxrobot } from ".";
3
+ import type { ElectricMeter, Cpzxrobot } from ".";
4
4
  import { FeedTowerGateway } from "./device_types/feedtower";
5
5
  import { ElectricMeterGateway } from "./device_types/electricmeter";
6
6
  import { NormalGateway } from "./device_types/normal_type";
@@ -63,12 +63,29 @@ export class DeviceGateway extends Object {
63
63
  // }
64
64
 
65
65
  //获取设备列表,注意特殊类型,比如electricMeter和feedTower,需要通过属性访问
66
- get list() {
67
- return this.normalFilter.list;
66
+ list(
67
+ options:
68
+ | undefined
69
+ | {
70
+ id?: Number | null | undefined;
71
+ data?:
72
+ | "diffPerDay"
73
+ | "sumPerDay"
74
+ | "latest"
75
+ | "weekoverweek"
76
+ | "last"
77
+ | "rangeToday"
78
+ | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
79
+ status?: string;
80
+ unit?: Number;
81
+ detail?: boolean;
82
+ supplier?: string; //供应商,可用于过滤设备
83
+ } = undefined
84
+ ) {
85
+ return this.normalFilter.list(options);
68
86
  }
69
87
 
70
88
  get getHistoryDatas() {
71
89
  return this.normalFilter.getHistoryDatas;
72
90
  }
73
-
74
91
  }
@@ -47,8 +47,8 @@ class DeviceGateway extends Object {
47
47
  // return this.devices
48
48
  // }
49
49
  //获取设备列表,注意特殊类型,比如electricMeter和feedTower,需要通过属性访问
50
- get list() {
51
- return this.normalFilter.list;
50
+ list(options = undefined) {
51
+ return this.normalFilter.list(options);
52
52
  }
53
53
  get getHistoryDatas() {
54
54
  return this.normalFilter.getHistoryDatas;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -2,21 +2,21 @@
2
2
 
3
3
  这是提供给上海正芯数智APP第三方H5应用使用的SDK模块,包含相关物联网设备的获取方式和接口功能
4
4
 
5
- ## 使用方式
5
+ ## 1、使用方式
6
6
 
7
7
  ```
8
8
  npm i @cpzxrobot/sdk
9
9
  ```
10
10
 
11
- ## 开发指南
11
+ ## 2、开发指南
12
12
 
13
- ### 引入包
13
+ ### 2.1、引入包
14
14
 
15
15
  ```
16
16
  import cpzxrobot from "@cpzxrobot/sdk"
17
17
  ```
18
18
 
19
- ### 配置开发信息
19
+ ### 2.2、配置开发信息
20
20
  ```
21
21
  cpzxrobot({
22
22
  devAuth: "从上海正芯获得的开发临时token",
@@ -37,7 +37,7 @@ cpzxrobot({
37
37
 
38
38
  使用上述模板进行sdk初始化
39
39
 
40
- #### 开发时的CORS问题
40
+ #### 2.2.1、开发时的CORS问题
41
41
 
42
42
  如果上述配置后,出现调用接口CORS问题,请在初始化增加参数:
43
43
  ```
@@ -55,6 +55,18 @@ baseURL: "/"
55
55
  },
56
56
  ```
57
57
 
58
+ ### 2.3、使用方法
59
+
60
+ #### 2.3.1、Vue使用方法
61
+
62
+ 在App.vue中调用2.1所示初始化程序,即可完成SDK初始化。
63
+
64
+ 在其他文件中需要使用sdk时,需要
65
+
66
+ * 引用库 `import cpzxrobot from "@cpzxrobot/sdk"`
67
+ * 调用对应的接口方法,例如`cpzxrobot().factory.workshops(factory_id)`
68
+
69
+
58
70
  ### 调用接口
59
71
 
60
72
  主要包入口:
@@ -62,6 +74,9 @@ baseURL: "/"
62
74
  | 调用入口 | 功能说明 |
63
75
  | ----------------------- | -------------------- |
64
76
  | cpzxrobot().factory.xxx | 获得工厂的相关信息 |
77
+ | cpzxrobot().device.normalFilter.list | 获得常见设备的列表(当没有特殊类型需求时调用) |
78
+ | cpzxrobot().device.normalFilter.getData | 获得设备的数据 |
79
+ | cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
65
80
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
66
81
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
67
82
 
package/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import { FactoryGateway } from "@cpzxrobot/sdk/factory_gateway";
3
3
  import { TransportGateway } from "@cpzxrobot/sdk/transport_gateway";
4
4
  import { UserGateway } from "@cpzxrobot/sdk/user_gateway";
5
5
  import { CameraGateway } from "@cpzxrobot/sdk/camera_gateway";
6
+ import { PigfarmGateway } from "@cpzxrobot/sdk/pigfarm_gateway";
6
7
 
7
8
  type Device = {
8
9
  id: number;
@@ -132,8 +133,11 @@ export class Cpzxrobot {
132
133
  mode: string;
133
134
  axios: MyAxiosInstance;
134
135
  camera: CameraGateway;
136
+ pigfarm: PigfarmGateway;
135
137
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
136
138
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;
139
+ openMiniApp: (url: string) => void;
140
+ on: (event: string, callback: (data: any) => void) => void;
137
141
  setTitle: (title: string) => void;
138
142
  saveBase64: (base64: string, filename: string) => void;
139
143
  saveBlob: (blob: Blob, filename: string) => void;