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

277 lines
6.1 KiB

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