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

158 lines
3.0 KiB

11 months ago
11 months ago
9 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 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 : true,
  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. || !state.userInfo.phone){
  56. uni.navigateTo({
  57. url: '/pages_order/auth/wxUserInfo'
  58. })
  59. }else{
  60. uni.navigateBack(-1)
  61. }
  62. })
  63. }
  64. })
  65. },
  66. getUserInfo(state){
  67. api('getInfo', res => {
  68. if(res.code == 200){
  69. state.userInfo = res.result
  70. if(!state.userInfo.nickName || !state.userInfo.headImage
  71. || !state.userInfo.phone){
  72. uni.navigateTo({
  73. url: '/pages_order/auth/wxUserInfo'
  74. })
  75. }
  76. }
  77. })
  78. },
  79. // 获取工种列表
  80. getJobTypeList(state){
  81. api('commonQueryJobTypeList', {
  82. pageNo : 1,
  83. pageSize : 99999,
  84. }, res => {
  85. if(res.code != 200){
  86. return
  87. }
  88. state.jobTypeList = res.result.records
  89. })
  90. },
  91. // 获取开放地址
  92. getAddressList(state){
  93. api('commonQueryAddressList', {
  94. pageNo : 1,
  95. pageSize : 99999,
  96. }, res => {
  97. if(res.code != 200){
  98. return
  99. }
  100. state.addressList = res.result.records
  101. })
  102. },
  103. // 获取轮播图
  104. getBanner(state){
  105. api('commonQueryBannerList', {
  106. pageNo : 1,
  107. pageSize : 99999,
  108. }, res => {
  109. if(res.code != 200){
  110. return
  111. }
  112. state.banner = res.result.records
  113. })
  114. },
  115. // 获取工作性质列表
  116. getNatureList(state){
  117. api('commonQueryJobNatureList', {
  118. pageNo : 1,
  119. pageSize : 99999,
  120. }, res => {
  121. if(res.code != 200){
  122. return
  123. }
  124. state.natureList = res.result.records
  125. })
  126. },
  127. logout(state){
  128. uni.showModal({
  129. title: '确认退出登录吗',
  130. success(r) {
  131. if(r.confirm){
  132. state.userInfo = {}
  133. state.role = false
  134. uni.removeStorageSync('token')
  135. uni.redirectTo({
  136. url: '/pages/index/index'
  137. })
  138. }
  139. }
  140. })
  141. },
  142. setRole(state, role){
  143. state.role = role
  144. },
  145. },
  146. actions: {},
  147. })
  148. export default store