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

140 lines
2.8 KiB

4 months ago
4 months ago
3 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
3 months ago
2 months ago
3 months ago
4 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. position : {
  13. status : 0,//0正在定位中 1定位成功 2定位失败
  14. latitude: 39.909,
  15. longitude: 116.39742,
  16. },//定位信息
  17. },
  18. getters: {
  19. },
  20. mutations: {
  21. // 初始化配置
  22. initConfig(state){
  23. // api('getConfig', res => {
  24. // if(res.code == 200){
  25. // state.configList = res.result
  26. // }
  27. // })
  28. let config = ['getPrivacyPolicy', 'getUserAgreement']
  29. config.forEach(k => {
  30. api(k, res => {
  31. if (res.code == 200) {
  32. state.configList[k] = res.result
  33. }
  34. })
  35. })
  36. },
  37. login(state){
  38. uni.showLoading({
  39. title: '登录中...'
  40. })
  41. let self = this
  42. uni.login({
  43. success(res) {
  44. if(res.errMsg != "login:ok"){
  45. return
  46. }
  47. api('wxLogin', {
  48. code : res.code
  49. }, res => {
  50. uni.hideLoading()
  51. if(res.code != 200){
  52. return
  53. }
  54. state.userInfo = res.result.userInfo
  55. uni.setStorageSync('token', res.result.token)
  56. if(!state.userInfo.nickName || !state.userInfo.headImage){
  57. uni.navigateTo({
  58. url: '/pages/login/wxUserInfo'
  59. })
  60. }else{
  61. self.commit('getUserInfo')
  62. uni.navigateBack(-1)
  63. }
  64. })
  65. }
  66. })
  67. },
  68. logout(state){
  69. uni.showModal({
  70. title: '确认退出登录吗',
  71. success(r) {
  72. if(r.confirm){
  73. state.userInfo = {}
  74. state.role = false
  75. uni.removeStorageSync('token')
  76. uni.reLaunch({
  77. url: '/pages/index/index'
  78. })
  79. }
  80. }
  81. })
  82. },
  83. getUserInfo(state){
  84. api('getInfo', res => {
  85. if(res.code == 200){
  86. state.userInfo = res.result
  87. if(!state.userInfo.nickName || !state.userInfo.headImage){
  88. uni.navigateTo({
  89. url: '/pages/login/wxUserInfo'
  90. })
  91. }else if(!state.userInfo.team){
  92. uni.navigateTo({
  93. url: "/pages/subPack/team/team"
  94. })
  95. }else if(!state.userInfo.auth){
  96. uni.navigateTo({
  97. url: "/pages/subPack/autonym/autonym"
  98. })
  99. }
  100. }
  101. })
  102. },
  103. getTeam(state){
  104. api('teamList', res => {
  105. if(res.code == 200){
  106. state.teamList = res.result
  107. }
  108. })
  109. },
  110. setAuthInfo(state, data){
  111. state.authInfo = data
  112. },
  113. getLocation(state){
  114. uni.getLocation({
  115. type: 'gcj02',
  116. success: function(res) {
  117. state.position.status = 1;
  118. state.position.longitude = res.longitude;
  119. state.position.latitude = res.latitude;
  120. },
  121. fail() {
  122. state.position.status = 2;
  123. }
  124. });
  125. },
  126. },
  127. actions: {},
  128. })
  129. export default store