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.
53 lines
1.2 KiB
53 lines
1.2 KiB
import { http } from 'plugins/request/index';
|
|
import { showLoading, hideLoading, showToast, showModal } from 'utils/ui';
|
|
import { SITES_INFO, SCAN_SIGN } from 'api/api';
|
|
|
|
const actions = {
|
|
/**
|
|
* 获取所有场所信息
|
|
* @param {*} commit
|
|
*/
|
|
getSites({ commit }) {
|
|
return new Promise((resolve, reject) => {
|
|
showLoading();
|
|
http
|
|
.post(SITES_INFO)
|
|
.then(res => {
|
|
hideLoading();
|
|
const { data } = res.data;
|
|
commit('setSites', data);
|
|
resolve(data);
|
|
})
|
|
.catch(data => {
|
|
hideLoading();
|
|
showToast(data.msg || '获取场所信息失败');
|
|
reject(data);
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 扫码打卡 提交打卡记录
|
|
* @param {*} commit
|
|
* @param {object} params 提交服务端的数据
|
|
*/
|
|
sign({ commit }, params) {
|
|
return new Promise((resolve, reject) => {
|
|
showLoading();
|
|
http
|
|
.post(SCAN_SIGN, params)
|
|
.then(res => {
|
|
hideLoading();
|
|
const { data } = res.data;
|
|
resolve(data);
|
|
})
|
|
.catch(data => {
|
|
hideLoading();
|
|
showToast(data.msg || '打卡失败');
|
|
reject(data);
|
|
});
|
|
});
|
|
},
|
|
};
|
|
|
|
export default actions;
|
|
|