@cpzxrobot/sdk 1.0.1 → 1.0.3

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/dist/index.js CHANGED
@@ -48,10 +48,10 @@ class shzx {
48
48
  inApp() {
49
49
  return this.mode === "miniapp_in_app";
50
50
  }
51
- initAxios() {
51
+ initAxios(baseURL) {
52
52
  if (this.mode !== "miniapp_in_app") {
53
53
  const instance = axios_1.default.create({
54
- baseURL: "/",
54
+ baseURL,
55
55
  });
56
56
  instance.interceptors.request.use((config) => {
57
57
  // 在发送请求之前在头部添加token
@@ -126,7 +126,7 @@ class shzx {
126
126
  this.setTitle = function (title) {
127
127
  document.title = title;
128
128
  };
129
- console.log("欢迎使用上海正芯物联网IOT系统,您当前是开发环境,请在平台获取开发用jwt key,并传入devAuth设置");
129
+ console.log("欢迎使用上海正诚物联网IOT系统,您当前是开发环境,请在平台获取开发用jwt key,并传入devAuth设置");
130
130
  }
131
131
  else {
132
132
  this.mode = "miniapp_in_web";
@@ -149,16 +149,16 @@ class shzx {
149
149
  openMiniApp(url) {
150
150
  this._jumpToMiniApp(url);
151
151
  }
152
- setAuth(auth) {
152
+ setAuth(auth, baseURL) {
153
153
  if (this.mode === "miniapp_in_app") {
154
154
  this.platformReady.then(() => {
155
- this.initAxios();
155
+ this.initAxios(baseURL);
156
156
  console.log("shzx is ready");
157
157
  this.resolveReady(this.axios);
158
158
  });
159
159
  return;
160
160
  }
161
- this.initAxios();
161
+ this.initAxios(baseURL);
162
162
  this.auth = auth;
163
163
  this.axios
164
164
  .post("/api/v1/user/auth", {
@@ -190,6 +190,7 @@ let _instance;
190
190
  function default_1(args = {
191
191
  devAuth: "",
192
192
  appCode: "",
193
+ baseURL: "https://www.cpzxrobot.com/",
193
194
  selectedFarm: {
194
195
  id: 0,
195
196
  code: "",
@@ -203,7 +204,7 @@ function default_1(args = {
203
204
  }) {
204
205
  if (!_instance) {
205
206
  _instance = new shzx(args.appCode);
206
- _instance.setAuth(args.devAuth);
207
+ _instance.setAuth(args.devAuth, args.baseURL);
207
208
  if (args.selectedFarm) {
208
209
  _instance.user.selectedFarm = args.selectedFarm;
209
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -65,3 +65,34 @@ baseURL: "/"
65
65
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
66
66
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
67
67
 
68
+ ### 工厂信息接口
69
+
70
+ #### cpzxrobot().factory.workshops(factory_id)
71
+
72
+ 获得工厂的所有车间
73
+
74
+ 入参:
75
+
76
+ factory_id: 工厂id
77
+
78
+ #### cpzxrobot().factory.units(factory_id)
79
+
80
+ 获得工厂的所有单元
81
+
82
+ 入参:
83
+
84
+ factory_id: 工厂id
85
+
86
+ ### 摄像头相关
87
+
88
+ cpzxrobot().camera.search(args)
89
+
90
+ 搜索摄像头
91
+
92
+ 入参:
93
+
94
+ 入参为json object,可接受多种参数中的一个
95
+
96
+ 如果入参为:{unit_id:xxx}则按单元搜索
97
+
98
+ 如果入参为:{factory_id:xxx}则按工厂搜索