41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
|
|
const { ipAddress } = require('../http');
|
|||
|
|
|
|||
|
|
function request(url, method, data) {
|
|||
|
|
return new Promise((resolve, reject) => {
|
|||
|
|
const token = wx.getStorageSync('token');
|
|||
|
|
wx.request({
|
|||
|
|
url,
|
|||
|
|
method,
|
|||
|
|
data,
|
|||
|
|
timeout: 45000,
|
|||
|
|
header: {
|
|||
|
|
'content-type': 'application/json',
|
|||
|
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|||
|
|
},
|
|||
|
|
success(res) {
|
|||
|
|
const body = res.data || {};
|
|||
|
|
if (res.statusCode < 200 || res.statusCode >= 300 || body.success === false) {
|
|||
|
|
reject(new Error(body.errorMsg || body.message || body.errorInfo || `请求失败(${res.statusCode})`));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
resolve(body);
|
|||
|
|
},
|
|||
|
|
fail(err) {
|
|||
|
|
reject(new Error(err.errMsg || '网络请求失败'));
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function generatePostureReport(studentNo, input) {
|
|||
|
|
return request(`${ipAddress}Teacher/GeneratePostureReport`, 'POST', { studentNo, input });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function getTeacherPostureReport(studentNo) {
|
|||
|
|
return request(`${ipAddress}Teacher/GetPostureReport?studentNo=${encodeURIComponent(studentNo)}`, 'GET', null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function getTraineePostureReport() {
|
|||
|
|
return request(`${ipAddress}Patriarch/GetPostureReport`, 'GET', null);
|
|||
|
|
}
|