【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.

122 lines
2.3 KiB

7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 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. teamList : [],//团队列表
  11. authInfo : {},//实名认证信息
  12. },
  13. getters: {
  14. },
  15. mutations: {
  16. // 初始化配置
  17. initConfig(state){
  18. // api('getConfig', res => {
  19. // if(res.code == 200){
  20. // state.configList = res.result
  21. // }
  22. // })
  23. let config = ['getPrivacyPolicy', 'getUserAgreement']
  24. config.forEach(k => {
  25. api(k, res => {
  26. if (res.code == 200) {
  27. state.configList[k] = res.result
  28. }
  29. })
  30. })
  31. },
  32. login(state){
  33. uni.showLoading({
  34. title: '登录中...'
  35. })
  36. let self = this
  37. uni.login({
  38. success(res) {
  39. if(res.errMsg != "login:ok"){
  40. return
  41. }
  42. api('wxLogin', {
  43. code : res.code
  44. }, res => {
  45. uni.hideLoading()
  46. if(res.code != 200){
  47. return
  48. }
  49. state.userInfo = res.result.userInfo
  50. uni.setStorageSync('token', res.result.token)
  51. if(!state.userInfo.nickName || !state.userInfo.headImage){
  52. uni.navigateTo({
  53. url: '/pages/login/wxUserInfo'
  54. })
  55. }else{
  56. self.commit('getUserInfo')
  57. uni.navigateBack(-1)
  58. }
  59. })
  60. }
  61. })
  62. },
  63. logout(state){
  64. uni.showModal({
  65. title: '确认退出登录吗',
  66. success(r) {
  67. if(r.confirm){
  68. state.userInfo = {}
  69. state.role = false
  70. uni.removeStorageSync('token')
  71. uni.reLaunch({
  72. url: '/pages/index/index'
  73. })
  74. }
  75. }
  76. })
  77. },
  78. getUserInfo(state){
  79. api('getInfo', res => {
  80. if(res.code == 200){
  81. state.userInfo = res.result
  82. if(!state.userInfo.nickName || !state.userInfo.headImage){
  83. uni.navigateTo({
  84. url: '/pages/login/wxUserInfo'
  85. })
  86. }else if(!state.userInfo.team){
  87. uni.navigateTo({
  88. url: "/pages/subPack/team/team"
  89. })
  90. }else if(!state.userInfo.auth){
  91. uni.navigateTo({
  92. url: "/pages/subPack/autonym/autonym"
  93. })
  94. }
  95. }
  96. })
  97. },
  98. getTeam(state){
  99. api('teamList', res => {
  100. if(res.code == 200){
  101. state.teamList = res.result
  102. }
  103. })
  104. },
  105. setAuthInfo(state, data){
  106. state.authInfo = data
  107. },
  108. },
  109. actions: {},
  110. })
  111. export default store