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

334 lines
7.7 KiB

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