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

163 lines
3.2 KiB

11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
11 months ago
8 months ago
8 months ago
11 months ago
11 months ago
10 months ago
10 months ago
10 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 : 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. res.result.forEach(n => {
  25. state.configList[n.paramCode] = n.paramValueText ||
  26. n.paramValue ||
  27. n.paramValueImage
  28. // state.configList[n.keyName + '_keyValue'] = n.keyValue
  29. })
  30. }
  31. })
  32. // let config = ['getPrivacyPolicy', 'getUserAgreement']
  33. // config.forEach(k => {
  34. // api(k, res => {
  35. // if (res.code == 200) {
  36. // state.configList[k] = res.result
  37. // }
  38. // })
  39. // })
  40. },
  41. login(state){
  42. uni.showLoading({
  43. title: '登录中...'
  44. })
  45. uni.login({
  46. success(res) {
  47. if(res.errMsg != "login:ok"){
  48. return
  49. }
  50. api('wxLogin', {
  51. code : res.code
  52. }, res => {
  53. uni.hideLoading()
  54. if(res.code != 200){
  55. return
  56. }
  57. state.userInfo = res.result.userInfo
  58. uni.setStorageSync('token', res.result.token)
  59. if(!state.userInfo.nickName || !state.userInfo.headImage
  60. || !state.userInfo.phone){
  61. uni.navigateTo({
  62. url: '/pages_order/auth/wxUserInfo'
  63. })
  64. }else{
  65. uni.navigateBack(-1)
  66. }
  67. })
  68. }
  69. })
  70. },
  71. getUserInfo(state){
  72. api('getInfo', res => {
  73. if(res.code == 200){
  74. state.userInfo = res.result
  75. // if(!state.userInfo.nickName || !state.userInfo.headImage
  76. // || !state.userInfo.phone){
  77. // uni.navigateTo({
  78. // url: '/pages_order/auth/wxUserInfo'
  79. // })
  80. // }
  81. }
  82. })
  83. },
  84. // 获取工种列表
  85. getJobTypeList(state){
  86. api('commonQueryJobTypeList', {
  87. pageNo : 1,
  88. pageSize : 99999,
  89. }, res => {
  90. if(res.code != 200){
  91. return
  92. }
  93. state.jobTypeList = res.result.records
  94. })
  95. },
  96. // 获取开放地址
  97. getAddressList(state){
  98. api('commonQueryAddressList', {
  99. pageNo : 1,
  100. pageSize : 99999,
  101. }, res => {
  102. if(res.code != 200){
  103. return
  104. }
  105. state.addressList = res.result.records
  106. })
  107. },
  108. // 获取轮播图
  109. getBanner(state){
  110. api('commonQueryBannerList', {
  111. pageNo : 1,
  112. pageSize : 99999,
  113. }, res => {
  114. if(res.code != 200){
  115. return
  116. }
  117. state.banner = res.result.records
  118. })
  119. },
  120. // 获取工作性质列表
  121. getNatureList(state){
  122. api('commonQueryJobNatureList', {
  123. pageNo : 1,
  124. pageSize : 99999,
  125. }, res => {
  126. if(res.code != 200){
  127. return
  128. }
  129. state.natureList = res.result.records
  130. })
  131. },
  132. logout(state){
  133. uni.showModal({
  134. title: '确认退出登录吗',
  135. success(r) {
  136. if(r.confirm){
  137. state.userInfo = {}
  138. state.role = false
  139. uni.removeStorageSync('token')
  140. uni.redirectTo({
  141. url: '/pages/index/index'
  142. })
  143. }
  144. }
  145. })
  146. },
  147. setRole(state, role){
  148. state.role = role
  149. },
  150. },
  151. actions: {},
  152. })
  153. export default store