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

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