【PT.SCC实名制管理系统】24.10.01 -30天,考勤打卡小程序
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.

79 lines
1.4 KiB

7 months ago
7 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. userInfo : {}, //用户信息
  10. },
  11. getters: {
  12. },
  13. mutations: {
  14. // 初始化配置
  15. initConfig(state){
  16. // api('getConfig', res => {
  17. // if(res.code == 200){
  18. // state.configList = res.result
  19. // }
  20. // })
  21. let config = ['getPrivacyPolicy', 'getUserAgreement']
  22. config.forEach(k => {
  23. api(k, res => {
  24. if (res.code == 200) {
  25. state.configList[k] = res.result
  26. }
  27. })
  28. })
  29. },
  30. login(state){
  31. uni.showLoading({
  32. title: '登录中...'
  33. })
  34. uni.login({
  35. success(res) {
  36. if(res.errMsg != "login:ok"){
  37. return
  38. }
  39. api('wxLogin', {
  40. code : res.code
  41. }, res => {
  42. uni.hideLoading()
  43. if(res.code != 200){
  44. return
  45. }
  46. state.userInfo = res.result.userInfo
  47. uni.setStorageSync('token', res.result.token)
  48. if(!state.userInfo.nickName || !state.userInfo.headImage){
  49. uni.navigateTo({
  50. url: '/pages_order/auth/wxUserInfo'
  51. })
  52. }else{
  53. uni.navigateBack(-1)
  54. }
  55. })
  56. }
  57. })
  58. },
  59. getUserInfo(state){
  60. api('infoGetInfo', res => {
  61. if(res.code == 200){
  62. state.userInfo = res.result
  63. }
  64. })
  65. },
  66. },
  67. actions: {},
  68. })
  69. export default store