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

119 lines
2.2 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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. addressList : [],//开放地址
  15. },
  16. getters: {
  17. },
  18. mutations: {
  19. // 初始化配置
  20. initConfig(state){
  21. // api('getConfig', res => {
  22. // if(res.code == 200){
  23. // state.configList = res.result
  24. // }
  25. // })
  26. let config = ['getPrivacyPolicy', 'getUserAgreement']
  27. config.forEach(k => {
  28. api(k, res => {
  29. if (res.code == 200) {
  30. state.configList[k] = res.result
  31. }
  32. })
  33. })
  34. },
  35. login(state){
  36. uni.showLoading({
  37. title: '登录中...'
  38. })
  39. uni.login({
  40. success(res) {
  41. if(res.errMsg != "login:ok"){
  42. return
  43. }
  44. api('wxLogin', {
  45. code : res.code
  46. }, res => {
  47. uni.hideLoading()
  48. if(res.code != 200){
  49. return
  50. }
  51. state.userInfo = res.result.userInfo
  52. uni.setStorageSync('token', res.result.token)
  53. if(!state.userInfo.nickName || !state.userInfo.headImage){
  54. uni.navigateTo({
  55. url: '/pages_order/auth/wxUserInfo'
  56. })
  57. }else{
  58. uni.navigateBack(-1)
  59. }
  60. })
  61. }
  62. })
  63. },
  64. getUserInfo(state){
  65. api('infoGetInfo', res => {
  66. if(res.code == 200){
  67. state.userInfo = res.result
  68. }
  69. })
  70. },
  71. // 获取工种列表
  72. getJobTypeList(state){
  73. api('commonQueryJobTypeList', {
  74. pageNo : 1,
  75. pageSize : 99999,
  76. }, res => {
  77. if(res.code != 200){
  78. return
  79. }
  80. state.jobTypeList = res.result.records
  81. })
  82. },
  83. // 获取开放地址
  84. getAddressList(state){
  85. api('commonQueryAddressList', {
  86. pageNo : 1,
  87. pageSize : 99999,
  88. }, res => {
  89. if(res.code != 200){
  90. return
  91. }
  92. state.addressList = res.result.records
  93. })
  94. },
  95. // 获取轮播图
  96. getBanner(state){
  97. api('commonQueryBannerList', {
  98. pageNo : 1,
  99. pageSize : 99999,
  100. }, res => {
  101. if(res.code != 200){
  102. return
  103. }
  104. state.banner = res.result.records
  105. })
  106. },
  107. },
  108. actions: {},
  109. })
  110. export default store