用工小程序前端代码
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.

102 lines
2.2 KiB

8 months ago
8 months ago
8 months ago
  1. export default {
  2. state: {
  3. token:"",
  4. userInfo : {}, //用户信息
  5. },
  6. mutations: {
  7. onAuth(state){
  8. },
  9. setUserInfo(state,obj){
  10. state.userInfo = obj.userInfo
  11. state.token = obj.token
  12. },
  13. logout(state){
  14. uni.showModal({
  15. title: '确认退出登录吗',
  16. success(r) {
  17. if(r.confirm){
  18. state.userInfo = {}
  19. state.token = ""
  20. uni.removeStorageSync('token')
  21. uni.redirectTo({
  22. url: '/pages/index/index'
  23. })
  24. }
  25. }
  26. })
  27. },
  28. },
  29. actions: {
  30. // 企业身份认证检查
  31. async onEnterpriseAuth({ commit }, config = {
  32. success: () => {},
  33. fail: () => {},
  34. }) {
  35. try {
  36. const { getAuthenticationCompany } = await import('@/common/api.js')
  37. const response = await getAuthenticationCompany({})
  38. const company = response.result
  39. if (company && company.status == 1) {
  40. // 认证审核通过
  41. config.success(company)
  42. } else {
  43. // 认证未通过或未认证
  44. config.fail(company)
  45. }
  46. } catch (error) {
  47. console.error('企业认证检查失败:', error)
  48. config.fail(null)
  49. }
  50. },
  51. // 个人身份认证检查
  52. async onPersonalAuth({ commit }, config = {
  53. success: () => {},
  54. fail: () => {},
  55. }) {
  56. try {
  57. const { getAuthenticationPerson } = await import('@/common/api.js')
  58. const response = await getAuthenticationPerson({})
  59. const person = response.result
  60. if (person && person.status == 1) {
  61. // 认证审核通过
  62. config.success(person)
  63. } else {
  64. // 认证未通过或未认证
  65. config.fail(person)
  66. }
  67. } catch (error) {
  68. console.error('个人认证检查失败:', error)
  69. config.fail(null)
  70. }
  71. },
  72. // 简历完成状态检查
  73. async onResumeComplete({ commit }, config = {
  74. success: () => {},
  75. fail: () => {},
  76. }) {
  77. try {
  78. const { queryResumeById } = await import('@/common/api.js')
  79. const response = await queryResumeById({})
  80. const resume = response.result
  81. if (resume && resume.id) {
  82. // 简历已完成
  83. config.success(resume)
  84. } else {
  85. // 简历未完成
  86. config.fail(resume)
  87. }
  88. } catch (error) {
  89. console.error('简历状态检查失败:', error)
  90. config.fail(null)
  91. }
  92. }
  93. }
  94. }