123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- import Vue from 'vue';
- import Vuex from 'vuex';
- import _ from 'lodash';
- Vue.use(Vuex);
- const api = {
- fairs: '/api/jobs/fairs',
- fairsInfo: '/api/jobs/fairs/{id}',
- fairsSimple: '/api/jobs/fairs/{id}/simple',
- infos: '/api/jobs/infos',
- infoss: '/api/jobs/infos/{id}',
- talks: '/api/jobs/talks',
- talksinfo: '/api/jobs/talks/{id}',
- posts: '/api/jobs/posts',
- postsinfo: '/api/jobs/posts/{id}',
- corpBase: '/api/corp/corps/{corpid}',
- corpInfo: '/api/corp/corps/{corpid}/info',
- corpIdentity: '/api/corp/corps/{corpid}/identity',
- userReg: '/api/stud/registers/{id}',
- tickets: '/api/jobs/tickets',
- ticketsinfo: '/api/jobs/tickets/{id}',
- resumes: '/api/jobs/resumes',
- resumesInfo: '/api/jobs/resumes/{id}',
- letters: '/api/jobs/letters',
- //微信部分
- connection: '/weixin/qrcode/create',
- wxtoken: '/weixin/qrcode/{qrcode}/token',
- studLogin: '/api/stud/login',
- //双选会企业信息
- fairCorp: '/api/jobs/faircorps',
- fairJobs: '/api/jobs/faircorps/{id}/jobs',
- //分站菜单
- menuQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/menu/list`,
- menuSearch: `/adminapi/menu/fetch/{id}`,
- // 站点管理
- siteQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/query`,
- siteFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/config`,
- siteContent: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/content`,
- // 新闻管理
- newsQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/news/list`,
- newsFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/news/fetch/{id}`,
- bugInfo: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/newscreeper/fetch/{id}`,
- //栏目管理
- columnQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/column/list`,
- columnFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/column/fetch/{id}`,
- bugList: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/newscreeper/list`,
- //模块管理
- moduleQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/modules/list`,
- //合作单位/友情链接
- linkQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/img/list`,
- // 学生关注企业
- // stucorp: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp`,
- // stucorpsearch: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp`,
- // stucorplist: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp`,
- // stucorpupdate: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp`,
- // stucorpdelete: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp/{id}`,
- stucorp: `/api/stud/studentcorp`,
- stucorpsearch: '/api/stud/studentcorp',
- stucorplist: '/api/stud/studentcorp',
- stucorpdelete: '/api/stud/studentcorp/{id}',
- //测试前缀${process.env.NODE_ENV === 'development' ? '/adminapi' : '${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}'}
- //审核过的企业(主站用)
- getCorps: `/api/corp/corps/`,
- };
- export default new Vuex.Store({
- state: {
- user: {},
- },
- mutations: {
- setUser(state, payload) {
- if (payload) {
- state.user = payload;
- sessionStorage.setItem('user', JSON.stringify(payload));
- } else {
- let user = sessionStorage.getItem('user');
- if (user) state.user = JSON.parse(user);
- else return false;
- }
- },
- },
- actions: {
- //招聘会
- async jobfairOperation({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'list') {
- data = this.$toUndefined(data);
- let { schid, date } = data;
- result = await this.$axios.$get(api.fairs, {}, { schid: schid, skip: skip, limit: limit, date: date, status: '1' });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.fairsInfo, { id: id });
- }
- return result;
- },
- //招聘会企业信息
- async fairInfoOperation({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'searchCorp') {
- let { schid, fairid, corpid, status } = data;
- result = this.$axios.$get(api.fairCorp, {}, { schid: schid, fairid: fairid, corpid: corpid, status: status, skip: skip, limit: limit });
- }
- if (type === 'searchJobs') {
- let { id } = data;
- result = this.$axios.$get(api.fairJobs, { id: id }, { skip: skip, limit: limit });
- }
- return result;
- },
- //招聘会简要信息
- async getfairsSimple({ state }, { type, data }) {
- let result;
- if (type === 'list') {
- let { id } = data;
- result = await this.$axios.$get(api.fairsSimple, { id: id });
- }
- return result;
- },
- //在线招聘
- async jobinfoOperation({ state }, { type, data }) {
- let { skip, limit } = data;
- let result;
- if (type === 'list') {
- data = this.$toUndefined(data);
- let { schid, corpname, is_practice } = data;
- result = await this.$axios.$get(api.infos, {}, { corpname: corpname, schid: schid, is_practice: is_practice, skip: skip, limit: limit, status: 1 });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.infoss, { id: id });
- }
- return result;
- },
- //宣讲会
- async postTalksInfo({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'list') {
- data = this.$toUndefined(data);
- let { schid, corpname, date } = data;
- result = await this.$axios.$get(api.talks, {}, { corpname: corpname, schid: schid, date: date, skip: skip, limit: limit, status: 1 });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.talksinfo, { id: id });
- }
- return result;
- },
- //职位管理
- async postOperation({ state }, { type, data }) {
- let { skip, limit } = data;
- let result;
- if (type === 'list') {
- data = this.$toUndefined(data);
- let { schid, corpname, is_practice, corpid, is_publish } = data;
- result = await this.$axios.$get(
- `${api.posts}`,
- {},
- { schid: schid, corpid: corpid, corpname: corpname, is_practice: is_practice, skip: skip, limit: limit, is_publish: is_publish }
- );
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.postsinfo, { id: id });
- }
- return result;
- },
- //企业基本信息
- async corpOperation({ state }, { type, data }) {
- let result;
- if (type === 'search') {
- let { corpid } = data;
- result = await this.$axios.$get(api.corpInfo, { corpid: corpid });
- }
- if (type === 'component') {
- let { corpid } = data;
- let base = await this.$axios.$get(api.corpBase, { corpid: corpid });
- let info = await this.$axios.$get(api.corpInfo, { corpid: corpid });
- let identity = await this.$axios.$get(api.corpIdentity, { corpid: corpid });
- result = {
- data: { ...info.data, ...identity.data, ...base.data },
- errcode: `${info.errcode}` === '0' && `${identity.errcode}` === '0' && `${base.errcode}` === '0' ? '0' : '1',
- };
- }
- return result;
- },
- // 入场券接口
- async ticketsOperation({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'add') {
- let { query, body } = data;
- result = await this.$axios.$post(api.tickets, body, {}, query);
- }
- if (type === 'list') {
- let { schid, fairid, studid } = data;
- result = await this.$axios.$get(api.tickets, {}, { schid: schid, fairid: fairid, studid: studid, skip: skip, limit: limit });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.ticketsinfo, { id: id });
- }
- if (type === 'update') {
- let { info, id } = data;
- result = await this.$axios.$post(api.ticketsinfo, info, { id: id });
- }
- if (type === 'delete') {
- let { id } = data;
- result = await this.$axios.$delete(api.ticketsinfo, {}, { id: id });
- }
- return result;
- },
- //用户
- async userOperation({ stata }, { type, data }) {
- let result;
- if (type === 'search') {
- let { studid } = data;
- result = await this.$axios.$get(api.userReg, { id: studid });
- }
- if (type === 'login') {
- let { loginType, info } = data;
- result = this.$axios.$post(api.studLogin, info, {}, { type: loginType });
- }
- return result;
- },
- //求职信
- async lettersOperation({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'list') {
- let { resume_id, status, corpname, studname, post_id } = data;
- result = await this.$axios.$get(
- api.letters,
- {},
- { post_id: post_id, resume_id: resume_id, status: status, corpname: corpname, studname: studname, skip: skip, limit: limit }
- );
- }
- if (type === 'apply') {
- let { query, body } = data;
- result = await this.$axios.$post(api.letters, body, {}, query);
- }
- return result;
- },
- // 简历管理
- async resumesOperation({ state }, { type, data }) {
- let result;
- if (type === 'add') {
- let { info, schid, studid } = data;
- result = await this.$axios.$post(api.resumes, info, {}, { schid: schid, studid: studid });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.resumesInfo, { id: id });
- }
- if (type === 'update') {
- let { id, info } = data;
- result = await this.$axios.$post(api.resumesInfo, info, { id: id });
- }
- return result;
- },
- //微信部分
- async createConnection() {
- let result = await this.$axios.$post(api.connection);
- if (result.errcode != undefined && result.errcode === 0) {
- console.log('create qrcode success', result.data);
- return result.data;
- }
- console.error('create qrcode fail', result);
- },
- async getWxtoken({ state }, qrcode) {
- let result = await this.$axios.$post(api.wxtoken, {}, { qrcode: qrcode });
- if (result.errcode != undefined && result.errcode === 0) {
- console.log('qrcode login success', result);
- return result.token;
- }
- console.error('create qrcode fail', result);
- },
- //分站菜单
- async menuOperation({ state }, { type, data }) {
- let result;
- if (type === 'list') {
- let { site } = data;
- result = await this.$axios.$get(api.menuQuery, {}, { is_use: '0' });
- }
- if (type === 'search') {
- let { id } = data;
- result = await this.$axios.$get(api.menuSearch, { id: id });
- }
- return result;
- },
- //模块管理
- async moduleOperation({ state }, { type, data }) {
- let result;
- if (type === 'list') {
- result = await this.$axios.$get(api.moduleQuery, {}, { is_use: '0' });
- }
- return result;
- },
- // 站点管理
- async siteOperation({ state }, { type, data }) {
- let result;
- if (type === 'list') {
- let { site, column } = data;
- result = await this.$axios.$get(api.siteQuery, { column: column });
- }
- if (type === 'search') {
- let { site } = data;
- //_tenant
- let content = await this.$axios.$get(api.siteContent, {});
- result = await this.$axios.$get(api.siteFetch, {});
- if (content.data && `${content.errcode}` === '0') {
- console.log('in function:');
- result.data.content = content && content.data ? content.data : '';
- }
- }
- return result;
- },
- // 信息管理
- async newsOperation({ state }, { type, data }) {
- let { skip, limit } = data;
- let result;
- if (type === 'list') {
- let { site, parent_id, news_type } = data;
- if (news_type === '0') {
- result = await this.$axios.$get(api.bugList, {}, { parent_id: parent_id, skip: skip, limit: limit, is_use: '0' });
- } else {
- result = await this.$axios.$get(api.newsQuery, {}, { parent_id: parent_id, skip: skip, limit: limit, is_use: '0' });
- }
- }
- if (type === 'search') {
- let { id, news_type } = data;
- result = await this.$axios.$get(api.bugInfo, { id: id });
- }
- return result;
- },
- //栏目管理
- async columnOperation({ state }, { type, data }) {
- let { skip, limit } = data;
- let result;
- if (type === 'list') {
- //TODO
- let { parent_id, site } = data;
- result = await this.$axios.$get(api.columnQuery, {}, { parent_id: parent_id, is_use: '0' });
- }
- if (type === 'search') {
- let { parent_id } = data;
- result = await this.$axios.$get(api.columnFetch, { id: parent_id });
- }
- return result;
- },
- // 学生关注企业
- async stucorpOperation({ state }, { type, data }) {
- let result;
- let { skip, limit } = data;
- if (type === 'add') {
- let { query, body } = data;
- result = await this.$axios.$post(api.stucorp, body, {}, query);
- }
- if (type === 'list') {
- let { corpid, corpname, studid, studname, studschool } = data;
- result = await this.$axios.$get(
- api.stucorplist,
- {},
- { corpid: corpid, corpname: corpname, studid: studid, studname: studname, studschool: studschool, skip: skip, limit: limit }
- );
- }
- if (type === 'search') {
- let { id, studid, corpid } = data;
- result = await this.$axios.$get(api.stucorpsearch, {}, { studid: studid, corpid: corpid });
- }
- if (type === 'update') {
- let { info, id } = data;
- result = await this.$axios.$post(api.stucorpupdate, info, { id: id });
- }
- if (type === 'delete') {
- let { id } = data;
- result = await this.$axios.$delete(api.stucorpdelete, {}, { id: id });
- }
- return result;
- },
- //合作单位/友情链接
- async linkOperation({ state }, { type, data }) {
- let result;
- if (type === 'list') {
- let { site, type } = data;
- result = await this.$axios.$get(api.linkQuery, {}, { type: type, is_use: `0` });
- }
- return result;
- },
- //查询入驻的企业
- async corpListOperation({ state }) {
- let result = await this.$axios.$get(api.getCorps, {}, { status: '已认证', skip: 0, limit: 8 });
- return result;
- },
- },
- });
- const data = {
- testItem: {
- id: Math.random(),
- name: 'name',
- age: 'age',
- tel: '13099876544',
- },
- };
|