123456789101112131415161718192021222324252627 |
- import store from '@/store/index.js'
- import authorize from '@/common/config/authorize.js'
- import { userInfoLogin } from "@/api/use.js"
- // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- const wxLoginAuthorize = function(){
- authorize.getCode('weixin').then(wechatcode =>{
- authorize.getUserInfo('weixin').then(wxResponse =>{
- userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
- store.commit('updateStatus',response.data)
- store.commit('login',response.data);
- store.commit('wxLogin',wxResponse.userInfo);
- uni.setStorageSync('token',response.data.token)
- uni.removeStorageSync('sessionid')
- uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
- }).catch(response =>{
- uni.removeStorageSync('sessionid')
- uni.setStorageSync('sessionid','JSESSIONID='+response.data)
- store.commit('logout',response.data)
- store.commit('updateStatus',response.data)
- store.commit('wxLogin',wxResponse.userInfo);
- })
- })
- })
- }
- export default{
- wxLoginAuthorize
- }
|