store.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. Vue.use(Vuex);
  5. const api = {
  6. corpInfo: '/api/corp/corps/{corpid}/info',
  7. corpBase: '/api/corp/corps/{corpid}',
  8. hr: '/api/corp/corps/{corpid}/users', //list,add
  9. hrImp: '/api/corp/users/{id}', //查询:id:手机号,用户肯定不知道id啊!那就手机号呗;修改:用id
  10. corpIdentity: '/api/corp/corps/{corpid}/identity',
  11. corpSchInfo: '/api/corp/corps/{corpid}/schs',
  12. schs: '/api/corp/schs', //get:按学校查询入驻企业列表;post:申请入驻学校
  13. profiles: '/api/jobs/profiles', //get查询招生简章列表;post创建招生简章
  14. posts: '/api/jobs/posts',
  15. postsinfo: '/api/jobs/posts/{id}',
  16. // posts: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/posts`,
  17. // postsinfo: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/posts/{id}`,
  18. profilesinfo: '/api/jobs/profiles/{id}',
  19. infos: '/api/jobs/infos',
  20. fairs: '/api/jobs/fairs',
  21. fairsinfo: '/api/jobs/fairs/{id}',
  22. faircorps: '/api/jobs/faircorps',
  23. faircorpsInfo: '/api/jobs/faircorps/{id}',
  24. infoss: '/api/jobs/infos/{id}',
  25. talks: '/api/jobs/talks',
  26. talksinfo: '/api/jobs/talks/{id}',
  27. resumes: '/api/jobs/resumes',
  28. resumesInfo: '/api/jobs/resumes/{id}',
  29. letters: '/api/jobs/letters',
  30. lettersinfo: '/api/jobs/letters/{id}',
  31. userReg: '/api/corp/users/{id}',
  32. connection: '/weixin/qrcode/create',
  33. wxtoken: '/weixin/qrcode/{qrcode}/token',
  34. corpBind: '/api/corp/bind', //post=>query;corpid;body:mobile,wxtoken
  35. corpLogin: '/api/corp/login',
  36. dictionary: '/api/code/{type}/items', //type === xzqh:query:level(1/2);parent(无/code)
  37. corpReg: '/api/corp/corps', //query:type:0=>用户名+密码 account(学号@学校id)+passwd;1-微信(wxtoken)
  38. //验证码
  39. verify: '/api/cms/verify/verify',
  40. checkVerify: '/api/cms/verify/check_verify',
  41. //短信验证码
  42. message: '/api/cms/verify/sendmessage',
  43. checkMessage: '/api/cms/verify/check_message',
  44. // 关注数
  45. stucorp: `/api/jobs/studentcorp`,
  46. stucorpsearch: `/api/jobs/studentcorp`,
  47. stucorplist: `/api/jobs/studentcorp`,
  48. stucorpupdate: `/api/jobs/studentcorp`,
  49. stucorpdelete: `/api/jobs/studentcorp/{id}`,
  50. //待办事项
  51. notice: `/api/msg/message`, //${process.env.NODE_ENV === 'development' ? '/napi' : '/api'}
  52. noticeDelete: `/api/msg/message/{id}`,
  53. };
  54. export default new Vuex.Store({
  55. state: {
  56. user: {},
  57. },
  58. mutations: {
  59. setUser(state, payload) {
  60. if (payload) {
  61. state.user = payload;
  62. sessionStorage.setItem('user', JSON.stringify(payload));
  63. } else {
  64. let user = sessionStorage.getItem('user');
  65. if (user) state.user = JSON.parse(user);
  66. else return false;
  67. }
  68. },
  69. },
  70. actions: {
  71. //用户信息
  72. async userOperation({ state }, { type, data }) {
  73. let result;
  74. if (type === 'passwd') {
  75. let { id, info } = data;
  76. result = await this.$axios.$post(api.userReg, info, { id: id });
  77. }
  78. if (type === 'login') {
  79. let { loginType, info } = data;
  80. result = this.$axios.$post(api.corpLogin, info, {}, { type: loginType });
  81. }
  82. return result;
  83. },
  84. async corpSchInfo({ state, commit }, { type, data }) {
  85. let result;
  86. if (type === 'list') {
  87. let { corpid, skip, limit } = data;
  88. result = await this.$axios.$get(`${api.corpSchInfo}`, { corpid: corpid }, { skip: skip, limit: limit, status: '已审核' });
  89. let newArr = result.data.filter(fil => `${fil.schid}` !== `999991`);
  90. result.data = newArr;
  91. }
  92. return result;
  93. },
  94. //宣讲会
  95. async postTalksInfo({ state }, { type, data }) {
  96. let { skip, limit } = data;
  97. let result;
  98. if (type === 'add') {
  99. let { info, corpid, corpname, schid, schname } = data;
  100. result = await this.$axios.$post(api.talks, info, {}, { schid: schid, corpid: corpid, corpname: corpname, schname: schname });
  101. }
  102. if (type === 'list') {
  103. let { corpid, status } = data;
  104. result = await this.$axios.$get(api.talks, {}, { corpid: corpid, status: status, skip: skip, limit: limit });
  105. }
  106. if (type === 'search') {
  107. let { id } = data;
  108. result = await this.$axios.$get(api.talksinfo, { id: id });
  109. }
  110. if (type === 'update') {
  111. let { info, id } = data;
  112. result = await this.$axios.$post(api.talksinfo, info, { id: id });
  113. }
  114. if (type === 'delete') {
  115. let { id } = data;
  116. result = await this.$axios.$delete(api.talksinfo, {}, { id: id });
  117. }
  118. return result;
  119. },
  120. //在线招聘
  121. async jobinfoOperation({ state }, { type, data }) {
  122. let { skip, limit } = data;
  123. let result;
  124. if (type === 'add') {
  125. let { info, corpid, corpname, schid, schname } = data;
  126. result = await this.$axios.$post(api.infos, info, {}, { schid: schid, corpid: corpid, corpname: corpname, schname: schname });
  127. }
  128. if (type === 'list') {
  129. let { corpid, is_practice, status } = data;
  130. result = await this.$axios.$get(api.infos, {}, { corpid: corpid, skip: skip, limit: limit, is_practice: is_practice, status: status });
  131. }
  132. if (type === 'search') {
  133. let { id } = data;
  134. result = await this.$axios.$get(api.infoss, { id: id });
  135. }
  136. if (type === 'update') {
  137. let { info, id } = data;
  138. result = await this.$axios.$post(api.infoss, info, { id: id });
  139. }
  140. if (type === 'delete') {
  141. let { id } = data;
  142. result = await this.$axios.$delete(api.infoss, {}, { id: id });
  143. }
  144. return result;
  145. },
  146. //职位管理
  147. async postOperation({ state }, { type, data }) {
  148. let { skip, limit } = data;
  149. let result;
  150. if (type === 'add') {
  151. let { info, corpid, corpname } = data;
  152. result = await this.$axios.$post(api.posts, info, {}, { corpid: corpid, corpname: corpname });
  153. }
  154. if (type === 'list') {
  155. let { corpid, is_practice } = data;
  156. result = await this.$axios.$get(`${api.posts}`, {}, { corpid: corpid, skip: skip, limit: limit, is_practice: is_practice });
  157. }
  158. if (type === 'search') {
  159. let { id } = data;
  160. result = await this.$axios.$get(api.postsinfo, { id: id });
  161. }
  162. if (type === 'update') {
  163. let { info, id } = data;
  164. result = await this.$axios.$post(api.postsinfo, info, { id: id });
  165. }
  166. if (type === 'delete') {
  167. let { id } = data;
  168. result = await this.$axios.$delete(api.postsinfo, {}, { id: id });
  169. }
  170. return result;
  171. },
  172. //hr一系列操作
  173. async hrOperation({ state }, { type, data }) {
  174. let result;
  175. if (type === `delete`) {
  176. let { id } = data;
  177. result = await this.$axios.$delete(api.hrImp, {}, { id: id });
  178. } else if (type === `add`) {
  179. let { corpid, info } = data;
  180. result = await this.$axios.$post(api.hr, info, { corpid: corpid });
  181. } else if (type === 'search') {
  182. let { tel } = data;
  183. result = await this.$axios.$get(api.hrImp, { id: tel });
  184. } else if (type === 'update') {
  185. let { info } = data;
  186. let { passwd, id } = info;
  187. result = await this.$axios.$post(api.hrImp, { passwd: passwd }, { id: id });
  188. } else {
  189. result = await this.$axios.$get(api.hr, { corpid: data });
  190. }
  191. return result;
  192. },
  193. //招聘简章
  194. async profilesOperation({ state }, { type, data }) {
  195. let { skip, limit } = data;
  196. let result;
  197. if (type === 'add') {
  198. let { info, corpid, corpname } = data;
  199. result = await this.$axios.$post(api.profiles, info, {}, { corpid: corpid, corpname: corpname });
  200. }
  201. if (type === 'list') {
  202. let { corpid } = data;
  203. result = await this.$axios.$get(api.profiles, {}, { corpid: corpid, skip: skip, limit: limit });
  204. }
  205. if (type === 'search') {
  206. let { id } = data;
  207. result = await this.$axios.$get(api.profilesinfo, { id: id });
  208. }
  209. if (type === 'update') {
  210. let { info, id } = data;
  211. result = await this.$axios.$post(api.profilesinfo, info, { id: id });
  212. }
  213. if (type === 'delete') {
  214. let { id } = data;
  215. result = await this.$axios.$delete(api.profilesinfo, {}, { id: id });
  216. }
  217. return result;
  218. },
  219. //企业基本信息
  220. async corpOperation({ state }, { type, data }) {
  221. let result;
  222. if (type === 'search') {
  223. let { corpid } = data;
  224. let info = await this.$axios.$get(`${api.corpInfo}`, { corpid: corpid });
  225. let base = await this.$axios.$get(api.corpBase, { corpid: corpid });
  226. let identity = await this.$axios.$get(api.corpIdentity, { corpid: corpid });
  227. return { info: info.data, base: base.data, identity: identity.data };
  228. }
  229. if (type === 'info') {
  230. let { corpid, info } = data;
  231. result = await this.$axios.$post(api.corpInfo, info, { corpid: corpid });
  232. }
  233. if (type === 'identity') {
  234. let { corpid, info } = data;
  235. result = await this.$axios.$post(api.corpIdentity, info, { corpid: corpid });
  236. }
  237. return result;
  238. },
  239. //入驻学校
  240. async joinSch({ state }, { schid, corpid }) {
  241. let result = await this.$axios.$post(api.schs, { schid: schid, corpid: corpid });
  242. return result;
  243. },
  244. // 简历管理
  245. async resumesOperation({ state }, { type, data }) {
  246. let result;
  247. if (type === 'list') {
  248. let { schid, year } = data;
  249. result = await this.$axios.$get(api.resumes, {}, { schid: schid, year: year });
  250. }
  251. if (type === 'search') {
  252. let { id } = data;
  253. result = await this.$axios.$get(api.resumesInfo, { id: id });
  254. }
  255. return result;
  256. },
  257. //求职信
  258. async lettersOperation({ state }, { type, data }) {
  259. let result;
  260. let { skip, limit } = data;
  261. if (type === 'list') {
  262. let { resume_id, status, corpname, studname, post_id } = data;
  263. result = await this.$axios.$get(
  264. api.letters,
  265. {},
  266. { post_id: post_id, resume_id: resume_id, status: status, corpname: corpname, studname: studname, skip: skip, limit: limit }
  267. );
  268. }
  269. if (type === 'search') {
  270. let { id } = data;
  271. result = await this.$axios.$get(api.lettersinfo, { id: id });
  272. }
  273. if (type === 'update') {
  274. let { id, status } = data;
  275. result = await this.$axios.$post(api.lettersinfo, { status: status }, { id: id });
  276. }
  277. return result;
  278. },
  279. // 招聘会
  280. async jobfairOperation({ state }, { type, data }) {
  281. let { skip, limit } = data;
  282. let result;
  283. if (type === 'add') {
  284. let { info, corpid, corpname } = data;
  285. result = await this.$axios.$post(api.fairs, info, {}, { corpid: corpid, corpname: corpname });
  286. }
  287. if (type === 'list') {
  288. let { schid, status } = data;
  289. result = await this.$axios.$get(api.fairs, {}, { schid: schid, status: status, skip: skip, limit: limit });
  290. }
  291. if (type === 'myList') {
  292. let { schid, fairid, corpid, status } = data;
  293. result = await this.$axios.$get(api.faircorps, {}, { schid: schid, fairid: fairid, corpid: corpid, status: status, skip: skip, limit: limit });
  294. }
  295. if (type === 'search') {
  296. let { id } = data;
  297. result = await this.$axios.$get(api.fairsinfo, { id: id });
  298. }
  299. if (type === 'update') {
  300. let { info, id } = data;
  301. result = await this.$axios.$post(api.faircorps, info, { id: id });
  302. }
  303. if (type === 'delete') {
  304. let { id } = data;
  305. result = await this.$axios.$delete(api.fairsinfo, {}, { id: id });
  306. }
  307. if (type === 'apply') {
  308. let { schname, fairid, corpid, corpname, info } = data;
  309. result = await this.$axios.$post(api.faircorps, info, {}, { schname: schname, fairid: fairid, corpid: corpid, corpname: corpname, schid: 999991 });
  310. }
  311. if (type === 'searchApply') {
  312. let { id } = data;
  313. result = await this.$axios.$get(api.faircorpsInfo, { id: id });
  314. }
  315. if (type === 'applyUpdate') {
  316. let { id, info } = data;
  317. result = await this.$axios.$post(api.faircorpsInfo, info, { id: id });
  318. }
  319. return result;
  320. },
  321. //微信部分
  322. async createConnection() {
  323. let result = await this.$axios.$post(api.connection);
  324. if (result.errcode != undefined && result.errcode === 0) {
  325. console.log('create qrcode success', result.data);
  326. return result.data;
  327. }
  328. console.error('create qrcode fail', result);
  329. },
  330. async getWxtoken({ state }, qrcode) {
  331. let result = await this.$axios.$post(api.wxtoken, {}, { qrcode: qrcode });
  332. if (result.errcode != undefined && result.errcode === 0) {
  333. console.log('qrcode login success', result);
  334. return result.token;
  335. }
  336. console.error('create qrcode fail', result);
  337. },
  338. async bindOperation({ state }, { type, data }) {
  339. let { corpid, ...info } = data;
  340. let result = await this.$axios.$post(api.corpBind, info, {}, { corpid: corpid });
  341. return result;
  342. },
  343. // 字典表
  344. async dicOperation({ state }, type) {
  345. let result;
  346. if (!_.isObject(type)) {
  347. result = await this.$axios.$get(api.dictionary, { type: type });
  348. } else {
  349. let { level, parent } = type;
  350. result = await this.$axios.$get(api.dictionary, { type: 'xzqh' }, { level: level, parent: parent });
  351. }
  352. return result;
  353. },
  354. //登录与注册
  355. async corpReg({ state, commit }, { data, schid, schname }) {
  356. let result = await this.$axios.$post(api.corpReg, data, {}, { schid: schid, schname: schname });
  357. return result;
  358. },
  359. async corpLogin({ state }, { type, data }) {
  360. let result = this.$axios.$post(api.corpLogin, data, {}, { type: type });
  361. return result;
  362. },
  363. //验证码
  364. async verifyOperation({ state }, { type, data }) {
  365. let result;
  366. if (type === 'verify') {
  367. result = await this.$axios.$get(api.verify, {}, data);
  368. }
  369. if (type === 'checkVerify') {
  370. result = await this.$axios.$post(api.checkVerify, data);
  371. }
  372. if (type === 'message') {
  373. result = await this.$axios.$get(api.message, {}, data);
  374. }
  375. if (type === 'checkMessage') {
  376. result = await this.$axios.$post(api.checkMessage, data);
  377. }
  378. return result;
  379. },
  380. // 学生关注企业
  381. async stucorpOperation({ state }, { type, data }) {
  382. let result;
  383. let { skip, limit } = data;
  384. if (type === 'add') {
  385. let { query, body } = data;
  386. result = await this.$axios.$post(api.stucorp, body, {}, query);
  387. }
  388. if (type === 'list') {
  389. let { corpid } = data;
  390. result = await this.$axios.$get(api.stucorplist, {}, { corpid: corpid, skip: skip, limit: limit });
  391. }
  392. if (type === 'search') {
  393. let { id, studid, corpid } = data;
  394. result = await this.$axios.$get(api.stucorpsearch, {}, { studid: studid, corpid: corpid });
  395. }
  396. if (type === 'update') {
  397. let { info, id } = data;
  398. result = await this.$axios.$post(api.stucorpupdate, info, { id: id });
  399. }
  400. if (type === 'delete') {
  401. let { id } = data;
  402. result = await this.$axios.$delete(api.stucorpdelete, {}, { id: id });
  403. }
  404. return result;
  405. },
  406. //待办事项
  407. async noticeOperation({ state }, { type, data }) {
  408. let result;
  409. let { skip, limit } = data;
  410. if (type === 'list') {
  411. let { userid, type } = data;
  412. result = await this.$axios.$get(api.notice, {}, { userid: userid, type: type, skip: skip, limit: limit });
  413. }
  414. if (type === 'delete') {
  415. let { id } = data;
  416. result = await this.$axios.$delete(api.noticeDelete, {}, { id: id });
  417. }
  418. return result;
  419. },
  420. },
  421. });
  422. const data = {
  423. testItem: {
  424. id: Math.random(),
  425. name: 'name',
  426. age: 'age',
  427. tel: '13099876544',
  428. },
  429. };