wxLogin.js 856 B

1234567891011121314151617181920212223
  1. import store from '@/store/index.js'
  2. import authorize from '@/common/config/authorize.js'
  3. import { userInfoLogin } from "@/api/use.js"
  4. // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  5. const wxLoginAuthorize = function(){
  6. authorize.getCode('weixin').then(wechatcode =>{
  7. userInfoLogin({code:wechatcode}).then(response =>{
  8. store.commit('updateStatus',response.data)
  9. store.commit('login',response.data);
  10. uni.setStorageSync('token',response.data.token)
  11. uni.removeStorageSync('sessionid')
  12. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  13. }).catch(response =>{
  14. uni.removeStorageSync('sessionid')
  15. uni.setStorageSync('sessionid','JSESSIONID='+response.data)
  16. store.commit('logout',response.data)
  17. store.commit('updateStatus',response.data)
  18. })
  19. })
  20. }
  21. export default{
  22. wxLoginAuthorize
  23. }