@cpzxrobot/sdk 1.0.34 → 1.0.36
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 +32 -3
- package/dist/transport_gateway.js +17 -0
- package/index.ts +32 -3
- package/package.json +1 -1
- package/readme.md +1 -0
- package/transport_gateway.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -222,12 +222,41 @@ class Cpzxrobot {
|
|
|
222
222
|
if (token) {
|
|
223
223
|
this.token = token;
|
|
224
224
|
this.initAxios("https://www.cpzxrobot.com/");
|
|
225
|
-
this.
|
|
225
|
+
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
226
|
+
if (res.data.Error) {
|
|
227
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.resolveReady(this.axios);
|
|
231
|
+
});
|
|
226
232
|
return;
|
|
227
233
|
}
|
|
228
234
|
else {
|
|
229
|
-
//
|
|
230
|
-
window.location.href
|
|
235
|
+
//if url has access_token and app_code, use it
|
|
236
|
+
const url = new URL(window.location.href);
|
|
237
|
+
const access_token = url.searchParams.get("access_token");
|
|
238
|
+
const app_code = url.searchParams.get("app_code");
|
|
239
|
+
if (access_token && app_code) {
|
|
240
|
+
this.initAxios("https://www.cpzxrobot.com/");
|
|
241
|
+
this.axios
|
|
242
|
+
.post("/api/v1/user/auth", {
|
|
243
|
+
appCode: app_code,
|
|
244
|
+
auth: access_token,
|
|
245
|
+
})
|
|
246
|
+
.then((res) => {
|
|
247
|
+
if (res.data.Error) {
|
|
248
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.token = "Bearer " + res.data.token;
|
|
252
|
+
this.resolveReady(this.axios);
|
|
253
|
+
});
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
//jump to miniapp login page
|
|
258
|
+
window.location.href = "/login.html";
|
|
259
|
+
}
|
|
231
260
|
}
|
|
232
261
|
}
|
|
233
262
|
else {
|
|
@@ -33,6 +33,23 @@ class TransportGateway extends Object {
|
|
|
33
33
|
get inputs() {
|
|
34
34
|
return this.getDetail;
|
|
35
35
|
},
|
|
36
|
+
//按料单获得对应的料塔
|
|
37
|
+
getDeviceByFodderld: (id) => {
|
|
38
|
+
return this.context.ready.then(() => {
|
|
39
|
+
return this.context.axios
|
|
40
|
+
.get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderld", {
|
|
41
|
+
params: {
|
|
42
|
+
fodderld: id,
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.then((res) => {
|
|
46
|
+
if (res.data.code != 200) {
|
|
47
|
+
throw res.data.message;
|
|
48
|
+
}
|
|
49
|
+
return res.data.data;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
36
53
|
//获取设备打料数据 deperecated
|
|
37
54
|
getDetail: (ids, date) => {
|
|
38
55
|
return this.context.ready.then(() => {
|
package/index.ts
CHANGED
|
@@ -257,11 +257,40 @@ export class Cpzxrobot {
|
|
|
257
257
|
if (token) {
|
|
258
258
|
this.token = token;
|
|
259
259
|
this.initAxios("https://www.cpzxrobot.com/");
|
|
260
|
-
this.
|
|
260
|
+
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
261
|
+
if (res.data.Error) {
|
|
262
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.resolveReady(this.axios);
|
|
266
|
+
});
|
|
261
267
|
return;
|
|
262
268
|
} else {
|
|
263
|
-
//
|
|
264
|
-
window.location.href
|
|
269
|
+
//if url has access_token and app_code, use it
|
|
270
|
+
const url = new URL(window.location.href);
|
|
271
|
+
const access_token = url.searchParams.get("access_token");
|
|
272
|
+
const app_code = url.searchParams.get("app_code");
|
|
273
|
+
if (access_token && app_code) {
|
|
274
|
+
this.initAxios("https://www.cpzxrobot.com/");
|
|
275
|
+
this.axios
|
|
276
|
+
.post("/api/v1/user/auth", {
|
|
277
|
+
appCode: app_code,
|
|
278
|
+
auth: access_token,
|
|
279
|
+
})
|
|
280
|
+
.then((res) => {
|
|
281
|
+
if (res.data.Error) {
|
|
282
|
+
window.location.href = "/login.html?error=" + res.data.Error;
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.token = "Bearer " + res.data.token;
|
|
286
|
+
this.resolveReady(this.axios);
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}else{
|
|
290
|
+
//jump to miniapp login page
|
|
291
|
+
window.location.href = "/login.html";
|
|
292
|
+
}
|
|
293
|
+
|
|
265
294
|
}
|
|
266
295
|
} else {
|
|
267
296
|
this.initAxios(baseURL);
|
package/package.json
CHANGED
package/readme.md
CHANGED
package/transport_gateway.ts
CHANGED
|
@@ -43,6 +43,23 @@ export class TransportGateway extends Object {
|
|
|
43
43
|
get inputs() {
|
|
44
44
|
return this.getDetail;
|
|
45
45
|
},
|
|
46
|
+
//按料单获得对应的料塔
|
|
47
|
+
getDeviceByFodderld: (id: number): Promise<any> => {
|
|
48
|
+
return this.context.ready.then(() => {
|
|
49
|
+
return this.context.axios
|
|
50
|
+
.get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderld", {
|
|
51
|
+
params: {
|
|
52
|
+
fodderld: id,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
.then((res) => {
|
|
56
|
+
if (res.data.code != 200) {
|
|
57
|
+
throw res.data.message;
|
|
58
|
+
}
|
|
59
|
+
return res.data.data;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
},
|
|
46
63
|
//获取设备打料数据 deperecated
|
|
47
64
|
getDetail: (ids: Array<number>, date: string): Promise<any> => {
|
|
48
65
|
return this.context.ready.then(() => {
|