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

235 lines
5.1 KiB

4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 months ago
4 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. UserExtensionInfo : {},//用户扩展信息,包含认证信息、统计信息
  17. },
  18. getters: {
  19. },
  20. mutations: {
  21. // 初始化配置
  22. initConfig(state){
  23. api('getConfig', res => {
  24. if(res.code == 200){
  25. res.result.forEach(n => {
  26. state.configList[n.paramCode] = n.paramValueText ||
  27. n.paramValue ||
  28. n.paramValueImage
  29. // state.configList[n.keyName + '_keyValue'] = n.keyValue
  30. })
  31. }
  32. })
  33. // let config = ['getPrivacyPolicy', 'getUserAgreement']
  34. // config.forEach(k => {
  35. // api(k, res => {
  36. // if (res.code == 200) {
  37. // state.configList[k] = res.result
  38. // }
  39. // })
  40. // })
  41. },
  42. login(state){
  43. uni.showLoading({
  44. title: '登录中...'
  45. })
  46. uni.login({
  47. success(res) {
  48. if(res.errMsg != "login:ok"){
  49. return
  50. }
  51. api('wxLogin', {
  52. code : res.code
  53. }, res => {
  54. uni.hideLoading()
  55. if(res.code != 200){
  56. return
  57. }
  58. state.userInfo = res.result.userInfo
  59. uni.setStorageSync('token', res.result.token)
  60. if(!state.userInfo.nickName || !state.userInfo.headImage
  61. || !state.userInfo.phone){
  62. uni.navigateTo({
  63. url: '/pages_order/auth/wxUserInfo'
  64. })
  65. }else{
  66. uni.navigateBack(-1)
  67. }
  68. })
  69. }
  70. })
  71. },
  72. getUserInfo(state){
  73. api('getInfo', res => {
  74. if(res.code == 200){
  75. state.userInfo = res.result
  76. if(!state.userInfo.nickName || !state.userInfo.headImage
  77. || !state.userInfo.phone){
  78. uni.navigateTo({
  79. url: '/pages_order/auth/wxUserInfo'
  80. })
  81. }
  82. }
  83. })
  84. },
  85. // 获取工种列表
  86. getJobTypeList(state){
  87. api('commonQueryJobTypeList', {
  88. pageNo : 1,
  89. pageSize : 99999,
  90. }, res => {
  91. if(res.code != 200){
  92. return
  93. }
  94. state.jobTypeList = res.result.records
  95. })
  96. },
  97. // 获取开放地址
  98. getAddressList(state){
  99. api('commonQueryAddressList', {
  100. pageNo : 1,
  101. pageSize : 99999,
  102. }, res => {
  103. if(res.code != 200){
  104. return
  105. }
  106. state.addressList = res.result.records
  107. })
  108. },
  109. // 获取轮播图
  110. getBanner(state){
  111. api('commonQueryBannerList', {
  112. pageNo : 1,
  113. pageSize : 99999,
  114. }, res => {
  115. if(res.code != 200){
  116. return
  117. }
  118. state.banner = res.result.records
  119. })
  120. },
  121. // 获取工作性质列表
  122. getNatureList(state){
  123. api('commonQueryJobNatureList', {
  124. pageNo : 1,
  125. pageSize : 99999,
  126. }, res => {
  127. if(res.code != 200){
  128. return
  129. }
  130. state.natureList = res.result.records
  131. })
  132. },
  133. logout(state){
  134. uni.showModal({
  135. title: '确认退出登录吗',
  136. success(r) {
  137. if(r.confirm){
  138. state.userInfo = {}
  139. state.role = false
  140. uni.removeStorageSync('token')
  141. uni.redirectTo({
  142. url: '/pages/index/index'
  143. })
  144. }
  145. }
  146. })
  147. },
  148. setRole(state, role){
  149. state.role = role
  150. },
  151. // 在完成实名认证的情况下执行
  152. isAuthCertification(state, fn){
  153. this.commit('getUserExtensionInfo')
  154. if(!state.UserExtensionInfo.personAuthenticationStatus) return
  155. if(['-1', '2'].includes(state.UserExtensionInfo.personAuthenticationStatus)){
  156. uni.showModal({
  157. title: `实名认证`,
  158. content: '实名认证未完成 或 实名认证审核未通过,请先完成!',
  159. confirmText: '去完成',
  160. success : e => {
  161. if(e.confirm){
  162. uni.navigateTo({
  163. url: '/pages_order/auth/certification'
  164. })
  165. }
  166. }
  167. })
  168. return
  169. }
  170. if(state.UserExtensionInfo.personAuthenticationStatus == '0'){
  171. uni.showToast({
  172. title: '实名认证审核中,请耐心等待!',
  173. icon: 'none'
  174. })
  175. return
  176. }
  177. fn && fn(state)
  178. },
  179. // 在完成企业认证的情况下执行
  180. isAuthCertificationEnterprise(state, fn){
  181. this.commit('getUserExtensionInfo')
  182. if(!state.UserExtensionInfo.companyAuthenticationStatus) return
  183. if(['-1', '2'].includes(state.UserExtensionInfo.companyAuthenticationStatus)){
  184. uni.showModal({
  185. title: `企业认证`,
  186. content: '企业认证未完成 或 企业认证审核未通过,请先完成!',
  187. confirmText: '去完成',
  188. success : e => {
  189. if(e.confirm){
  190. uni.navigateTo({
  191. url: '/pages_order/auth/certificationEnterprise'
  192. })
  193. }
  194. }
  195. })
  196. return
  197. }
  198. if(state.UserExtensionInfo.companyAuthenticationStatus == '0'){
  199. uni.showToast({
  200. title: '企业认证审核中,请耐心等待!',
  201. icon: 'none'
  202. })
  203. return
  204. }
  205. fn && fn(state)
  206. },
  207. //获取用户扩展信息的接口
  208. getUserExtensionInfo(state){
  209. api('getUserCenterData', res =>{
  210. if(res.code == 200){
  211. state.UserExtensionInfo = res.result
  212. }
  213. })
  214. },
  215. },
  216. actions: {},
  217. })
  218. export default store