store.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. Vue.use(Vuex);
  5. const api = {
  6. fairs: '/api/jobs/fairs',
  7. faircorps: '/api/jobs/faircorps',
  8. talks: '/api/jobs/talks',
  9. infos: '/api/jobs/infos',
  10. posts: '/api/jobs/posts',
  11. postsInfo: '/api/jobs/posts/{id}',
  12. resumesAdd: '/api/jobs/resumes',
  13. resumes: '/api/jobs/resumes/{id}',
  14. letters: '/api/jobs/letters',
  15. lettersInfo: '/api/jobs/letters/{id}',
  16. userReg: '/api/stud/registers/{id}',
  17. corpInfo: '/api/corp/corps/{corpid}/info',
  18. corpBase: '/api/corp/corps/{corpid}',
  19. corpIdentity: '/api/corp/corps/{corpid}/identity',
  20. //微信部分
  21. connection: '/weixin/qrcode/create',
  22. wxtoken: '/weixin/qrcode/{qrcode}/token',
  23. studBind: '/api/stud/bind', //post=>query;corpid;body:mobile,wxtoken
  24. studLogin: '/api/stud/login', //query:type:0=>用户名+密码 account(学号@学校id)+passwd;1-微信(wxtoken)
  25. dictionary: '/api/code/{type}/items', //type === xzqh:query:level(1/2);parent(无/code)
  26. findOne: '/api/code/xzqh/findOne', //query:name
  27. //验证码
  28. verify: '/adminapi/verify/verify',
  29. checkVerify: '/adminapi/verify/check_verify',
  30. };
  31. export default new Vuex.Store({
  32. state: {
  33. user: {},
  34. },
  35. mutations: {
  36. setUser(state, payload) {
  37. if (payload) {
  38. state.user = payload;
  39. sessionStorage.setItem('user', JSON.stringify(payload));
  40. } else {
  41. let user = sessionStorage.getItem('user');
  42. if (user) state.user = JSON.parse(user);
  43. else return false;
  44. }
  45. },
  46. },
  47. actions: {
  48. // 招聘会
  49. async fairsOperation({ state }, { type, data }) {
  50. let { skip, limit } = data;
  51. let result;
  52. if (type === 'list') {
  53. data = this.$toUndefined(data);
  54. let { corpid } = data;
  55. result = await this.$axios.$get(api.fairs, {}, { corpid: corpid, skip: skip, limit: limit });
  56. }
  57. if (type === 'mylist') {
  58. let { schid, fairid, corpid, status } = data;
  59. result = await this.$axios.$get(api.faircorps, {}, { schid: schid, fairid: fairid, corpid: corpid, status: status });
  60. }
  61. return result;
  62. },
  63. //宣讲会
  64. async talksOperation({ state }, { type, data }) {
  65. let { skip, limit } = data;
  66. let result;
  67. if (type === 'list') {
  68. data = this.$toUndefined(data);
  69. let { corpname, schid } = data;
  70. result = await this.$axios.$get(api.talks, {}, { schid: schid, corpname: corpname, skip: skip, limit: limit });
  71. }
  72. return result;
  73. },
  74. //在线招聘
  75. async jobinfoOperation({ state }, { type, data }) {
  76. let { skip, limit } = data;
  77. let result;
  78. if (type === 'list') {
  79. data = this.$toUndefined(data);
  80. let { corpid, is_practice, corpname } = data;
  81. result = await this.$axios.$get(api.infos, {}, { corpid: corpid, is_practice: is_practice, corpname: corpname, skip: skip, limit: limit });
  82. }
  83. return result;
  84. },
  85. //职位管理
  86. async postOperation({ state }, { type, data }) {
  87. let { skip, limit } = data;
  88. let result;
  89. if (type === 'list') {
  90. data = this.$toUndefined(data);
  91. let { corpid, state, corpname, is_practice } = data;
  92. result = await this.$axios.$get(
  93. api.posts,
  94. {},
  95. { corpid: corpid, state: state, corpname: corpname, is_practice: is_practice, skip: skip, limit: limit }
  96. );
  97. }
  98. if (type === 'search') {
  99. data = this.$toUndefined(data);
  100. let { id } = data;
  101. result = await this.$axios.$get(api.postsInfo, { id: id });
  102. }
  103. return result;
  104. },
  105. // 简历管理
  106. async resumesOperation({ state }, { type, data }) {
  107. let result;
  108. if (type === 'add') {
  109. let { info, schid, studid } = data;
  110. result = await this.$axios.$post(api.resumesAdd, info, {}, { schid: schid, studid: studid });
  111. }
  112. if (type === 'search') {
  113. let { id } = data;
  114. result = await this.$axios.$get(api.resumes, { id: id });
  115. }
  116. if (type === 'update') {
  117. let { id, info } = data;
  118. result = await this.$axios.$post(api.resumes, info, { id: id });
  119. }
  120. return result;
  121. },
  122. //求职信
  123. async lettersOperation({ state }, { type, data }) {
  124. let result;
  125. let { skip, limit } = data;
  126. if (type === 'list') {
  127. let { resume_id, status, corpname, studname, post_id } = data;
  128. result = await this.$axios.$get(
  129. api.letters,
  130. {},
  131. { post_id: post_id, resume_id: resume_id, status: status, corpname: corpname, studname: studname, skip: skip, limit: limit }
  132. );
  133. }
  134. if (type === 'search') {
  135. let { id } = data;
  136. result = await this.$axios.$get(api.lettersInfo, { id: id });
  137. }
  138. return result;
  139. },
  140. //用户信息
  141. async userOperation({ state }, { type, data }) {
  142. let result;
  143. if (type === 'search') {
  144. let { id } = data;
  145. result = await this.$axios.$get(api.userReg, { id: id });
  146. }
  147. if (type === 'passwd') {
  148. let { id, info } = data;
  149. result = await this.$axios.$post(api.userReg, info, { id: id });
  150. }
  151. if (type === 'login') {
  152. let { loginType, info } = data;
  153. result = this.$axios.$post(api.studLogin, info, {}, { type: loginType });
  154. }
  155. return result;
  156. },
  157. //企业基本信息
  158. async corpOperation({ state }, { type, data }) {
  159. let result;
  160. if (type === 'search') {
  161. let { corpid } = data;
  162. let info = await this.$axios.$get(`${api.corpInfo}`, { corpid: corpid });
  163. let base = await this.$axios.$get(api.corpBase, { corpid: corpid });
  164. let identity = await this.$axios.$get(api.corpIdentity, { corpid: corpid });
  165. return { info: info.data, base: base.data, identity: identity.data };
  166. }
  167. return result;
  168. },
  169. //微信部分
  170. async createConnection() {
  171. let result = await this.$axios.$post(api.connection);
  172. if (result.errcode != undefined && result.errcode === 0) {
  173. console.log('create qrcode success', result.data);
  174. return result.data;
  175. }
  176. console.error('create qrcode fail', result);
  177. },
  178. async getWxtoken({ state }, qrcode) {
  179. let result = await this.$axios.$post(api.wxtoken, {}, { qrcode: qrcode });
  180. if (result.errcode != undefined && result.errcode === 0) {
  181. console.log('qrcode login success', result);
  182. return result.token;
  183. }
  184. console.error('create qrcode fail', result);
  185. },
  186. async bindOperation({ state }, { type, data }) {
  187. let { userid, ...info } = data;
  188. let result = await this.$axios.$post(api.studBind, info, {}, { userid: userid });
  189. return result;
  190. },
  191. // 字典表
  192. async dicOperation({ state }, type) {
  193. let result;
  194. if (!_.isObject(type)) {
  195. result = await this.$axios.$get(api.dictionary, { type: type });
  196. } else {
  197. let { level, parent, name } = type;
  198. if (name) {
  199. result = await this.$axios.$get(api.findOne, {}, { name: name });
  200. } else {
  201. result = await this.$axios.$get(api.dictionary, { type: 'xzqh' }, { level: level, parent: parent });
  202. }
  203. }
  204. return result;
  205. },
  206. //原登录
  207. async studLogin({ state }, { type, data }) {
  208. let result = this.$axios.$post(api.studLogin, data, {}, { type: type });
  209. return result;
  210. },
  211. //验证码
  212. async verifyOperation({ state }, { type, data }) {
  213. let result;
  214. if (type === 'verify') {
  215. result = await this.$axios.$get(api.verify, {}, data);
  216. }
  217. if (type === 'checkVerify') {
  218. result = await this.$axios.$post(api.checkVerify, data);
  219. }
  220. if (type === 'message') {
  221. result = await this.$axios.$get(api.message, {}, data);
  222. }
  223. if (type === 'checkMessage') {
  224. result = await this.$axios.$post(api.checkMessage, data);
  225. }
  226. return result;
  227. },
  228. },
  229. });
  230. const data = {
  231. testItem: {
  232. id: Math.random(),
  233. name: 'name',
  234. age: 'age',
  235. tel: '13099876544',
  236. },
  237. };