You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
import { http } from 'plugins/request/index';
|
|
import { showLoading, hideLoading, showToast } from 'utils/ui';
|
|
import { USER_SIGNS, SCHOOL_SIGNS, HEALTH_TYPE_STATISTICS } from 'api/api';
|
|
|
|
const actions = {
|
|
/**
|
|
* 获取用户的打卡记录
|
|
* @param {*} commit
|
|
* @param {object} params 提交给后台的完整参数
|
|
*/
|
|
getUserSigns({ commit }, params) {
|
|
return new Promise((resolve, reject) => {
|
|
showLoading();
|
|
http
|
|
.post(USER_SIGNS, params)
|
|
.then(res => {
|
|
hideLoading();
|
|
const { data } = res.data;
|
|
commit('setUserSigns', data);
|
|
resolve(data);
|
|
})
|
|
.catch(data => {
|
|
hideLoading();
|
|
showToast(data.msg || '查询数据失败');
|
|
reject(data);
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 获取校园打卡记录 展示热力图
|
|
* @param {*} commit
|
|
* @param {object} params 提交服务端的完整参数
|
|
*/
|
|
getSchoolSigns({ commit }, params) {
|
|
return new Promise((resolve, reject) => {
|
|
showLoading();
|
|
console.log('SCHOOL_SIGNS: ', SCHOOL_SIGNS);
|
|
|
|
http
|
|
.post(SCHOOL_SIGNS, params)
|
|
.then(res => {
|
|
hideLoading();
|
|
const { data } = res.data;
|
|
commit('setSchoolSigns', data);
|
|
resolve(data);
|
|
})
|
|
.catch(data => {
|
|
hideLoading();
|
|
showToast(data.msg || '获取数据失败');
|
|
reject(data);
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 获取校园健康上报的 数据数目
|
|
* @param {*} commit
|
|
* @param {object} params 提交给服务端的完整数据
|
|
*/
|
|
getSchoolSignsNumber({ commit }, params) {
|
|
return new Promise((resolve, reject) => {
|
|
showLoading();
|
|
http
|
|
.post(HEALTH_TYPE_STATISTICS, params)
|
|
.then(res => {
|
|
hideLoading();
|
|
const { data } = res.data;
|
|
commit('setShoolSignNumber', data);
|
|
resolve(data);
|
|
})
|
|
.catch(data => {
|
|
hideLoading();
|
|
showToast(data.msg || '获取健康上报数据失败');
|
|
reject(data);
|
|
});
|
|
});
|
|
},
|
|
};
|
|
|
|
export default actions;
|
|
|