9 changed files with 193 additions and 25 deletions
@ -1,10 +1,11 @@ |
|||||
import Vue from 'vue'; |
import Vue from 'vue'; |
||||
import Vuex from 'vuex'; |
import Vuex from 'vuex'; |
||||
import user from './modules/user/index'; |
import user from './modules/user/index'; |
||||
|
import statistics from './modules/statistics/index'; |
||||
|
|
||||
Vue.use(Vuex); |
Vue.use(Vuex); |
||||
const store = new Vuex.Store({ |
const store = new Vuex.Store({ |
||||
modules: { user }, |
modules: { user, statistics }, |
||||
}); |
}); |
||||
|
|
||||
export default store; |
export default store; |
||||
|
@ -0,0 +1,79 @@ |
|||||
|
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('setUserSign', 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 => { |
||||
|
const { data } = res.data; |
||||
|
commit('setShoolSignNumber', data); |
||||
|
resolve(data); |
||||
|
}) |
||||
|
.catch(data => { |
||||
|
showToast(data.msg || '获取健康上报数据失败'); |
||||
|
reject(data); |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
export default actions; |
@ -0,0 +1,5 @@ |
|||||
|
import state from './state'; |
||||
|
import mutations from './mutations'; |
||||
|
import actions from './actions.js'; |
||||
|
|
||||
|
export default { namespaced: true, state, actions, mutations }; |
@ -0,0 +1,30 @@ |
|||||
|
const mutations = { |
||||
|
/** |
||||
|
* 设置userSigns 自己的打卡记录数据 |
||||
|
* @param {*} state |
||||
|
* @param {array} data |
||||
|
*/ |
||||
|
setUserSigns(state, data) { |
||||
|
state.userSigns = data || []; |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 设置shoolSigns 校园的打卡记录 |
||||
|
* @param {*} state |
||||
|
* @param {array} data |
||||
|
*/ |
||||
|
setSchoolSigns(state, data) { |
||||
|
state.shoolSigns = data || []; |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 设置校园健康统计数目 shoolSignNumbers |
||||
|
* @param {*} state |
||||
|
* @param {array} data |
||||
|
*/ |
||||
|
setShoolSignNumber(state, data) { |
||||
|
state.shoolSignNumber = data || []; |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
export default mutations; |
@ -0,0 +1,7 @@ |
|||||
|
const state = { |
||||
|
userSigns: [], // 用户个人打卡记录
|
||||
|
shoolSigns: [], // 校园的打卡记录
|
||||
|
shoolSignNumber: [], // 健康上报数目统计
|
||||
|
}; |
||||
|
|
||||
|
export default state; |
Loading…
Reference in new issue