特易招,招聘小程序
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.

150 lines
2.8 KiB

6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex); //vue的插件机制
  4. import api from '@/api/api.js'
  5. //Vuex.Store 构造器选项
  6. const store = new Vuex.Store({
  7. state: {
  8. configList: [], //配置列表
  9. // 角色 true为老板 false为工人
  10. role : false,
  11. userInfo : {}, //用户信息
  12. banner : [],//轮播图
  13. jobTypeList : [],//工种
  14. natureList : [],//工作性质
  15. addressList : [],//开放地址
  16. },
  17. getters: {
  18. },
  19. mutations: {
  20. // 初始化配置
  21. initConfig(state){
  22. // api('getConfig', res => {
  23. // if(res.code == 200){
  24. // state.configList = res.result
  25. // }
  26. // })
  27. let config = ['getPrivacyPolicy', 'getUserAgreement']
  28. config.forEach(k => {
  29. api(k, res => {
  30. if (res.code == 200) {
  31. state.configList[k] = res.result
  32. }
  33. })
  34. })
  35. },
  36. login(state){
  37. uni.showLoading({
  38. title: '登录中...'
  39. })
  40. uni.login({
  41. success(res) {
  42. if(res.errMsg != "login:ok"){
  43. return
  44. }
  45. api('wxLogin', {
  46. code : res.code
  47. }, res => {
  48. uni.hideLoading()
  49. if(res.code != 200){
  50. return
  51. }
  52. state.userInfo = res.result.userInfo
  53. uni.setStorageSync('token', res.result.token)
  54. // if(!state.userInfo.nickName || !state.userInfo.headImage){
  55. // uni.navigateTo({
  56. // url: '/pages_order/auth/wxUserInfo'
  57. // })
  58. // }else{
  59. uni.navigateBack(-1)
  60. // }
  61. })
  62. }
  63. })
  64. },
  65. getUserInfo(state){
  66. api('infoGetInfo', res => {
  67. if(res.code == 200){
  68. state.userInfo = res.result
  69. }
  70. })
  71. },
  72. // 获取工种列表
  73. getJobTypeList(state){
  74. api('commonQueryJobTypeList', {
  75. pageNo : 1,
  76. pageSize : 99999,
  77. }, res => {
  78. if(res.code != 200){
  79. return
  80. }
  81. state.jobTypeList = res.result.records
  82. })
  83. },
  84. // 获取开放地址
  85. getAddressList(state){
  86. api('commonQueryAddressList', {
  87. pageNo : 1,
  88. pageSize : 99999,
  89. }, res => {
  90. if(res.code != 200){
  91. return
  92. }
  93. state.addressList = res.result.records
  94. })
  95. },
  96. // 获取轮播图
  97. getBanner(state){
  98. api('commonQueryBannerList', {
  99. pageNo : 1,
  100. pageSize : 99999,
  101. }, res => {
  102. if(res.code != 200){
  103. return
  104. }
  105. state.banner = res.result.records
  106. })
  107. },
  108. // 获取工作性质列表
  109. getNatureList(state){
  110. api('commonQueryJobNatureList', {
  111. pageNo : 1,
  112. pageSize : 99999,
  113. }, res => {
  114. if(res.code != 200){
  115. return
  116. }
  117. state.natureList = res.result.records
  118. })
  119. },
  120. logout(state){
  121. uni.showModal({
  122. title: '确认退出登录吗',
  123. success(r) {
  124. if(r.confirm){
  125. state.userInfo = {}
  126. state.role = false
  127. uni.removeStorageSync('token')
  128. uni.redirectTo({
  129. url: '/pages/index/index'
  130. })
  131. }
  132. }
  133. })
  134. },
  135. setRole(state, role){
  136. state.role = role
  137. },
  138. },
  139. actions: {},
  140. })
  141. export default store