| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- // 启停接口
- export const control = async (data) => {
- try {
- const response = await uni.$http.post(`/api/v1/items/rt/${data.id}`,data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
- console.log(response);
- if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
- // uni.showToast({
- // title: '数据请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- uni.removeStorageSync('token');
- login();
- return response.data;
- }
- return response.data;
- } catch (error) {
- console.log(error);
- // uni.showToast({
- // title: '网络请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- login();
- return response.data;
- }
- };
- // 二级页面信息
- export const getuidatas = async (data) => {
- try {
- const response = await uni.$http.get('/api/v1/uidatas/rt/uis/3224a3eb-2375-4dfc-99ce-b182edd30996',data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
- console.log(response);
-
- if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
- // uni.showToast({
- // title: '数据请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- uni.removeStorageSync('token');
- login();
-
- return response.data;
- }
- return response.data;
- } catch (error) {
- // console.error('Network request failed:', error);
- console.log(error);
- // uni.showToast({
- // title: '网络请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- login();
- return response.data;
- }
- };
- // 系统故障列表
- export const getfaultsList = async (data) => {
- try {
- // console.log(uni.getStorageSync('token'));
- const response = await uni.$http.get('/api/v1/faults',data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
- console.log(response.data);
- if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
- // uni.showToast({
- // title: '数据请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- uni.removeStorageSync('token');
- login();
- return response.data;
- }
- return response.data;
- } catch (error) {
- console.error('Network request failed:', error);
- console.log(error);
- // uni.showToast({
- // title: '网络请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- uni.removeStorageSync('token');
- login();
- return response.data;
- }
- };
- // 登录接口
- export const login = async (start,count) => {
- try {
- console.log('login request');
- const response = await uni.$http.post('/api/v1/login',
- {name: "dexnui", pwd: "dexn1001"},{'Content-Type': 'application/json;charset=utf-8'});
- console.log(response);
- if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
- // uni.showToast({
- // title: '数据请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- return response.data;
- }
- console.log(response.data);
- uni.setStorageSync('token', response.data.data.token);
- return response.data;
- } catch (error) {
- // console.error('Network request failed:', error);
- // uni.showToast({
- // title: '网络请求失败! ',
- // duration: 1500,
- // icon: 'none',
- // });
- return response.data;
- }
- };
-
-
|