|
@@ -5,7 +5,7 @@
|
|
|
import Vue from 'vue'
|
|
|
import { mapState,mapMutations} from 'vuex';
|
|
|
import authorize from '@/common/config/authorize.js'
|
|
|
- import { userInfoLogin } from "@/api/use.js"
|
|
|
+ import wxLogin from "@/common/config/wxLogin.js"
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
let self = this
|
|
@@ -57,30 +57,10 @@
|
|
|
this.refresh()
|
|
|
},
|
|
|
methods:{
|
|
|
- ...mapMutations(['login','logout']),
|
|
|
- getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
|
|
|
- authorize.getCode('weixin').then(wechatcode =>{
|
|
|
- // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
|
|
|
- authorize.getUserInfo('weixin').then(wxResponse =>{
|
|
|
- userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
|
|
|
- this.login(response.data)
|
|
|
- uni.setStorageSync('token',response.data.token)
|
|
|
- uni.removeStorageSync('sessionid')
|
|
|
- uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
|
|
|
- this.$store.commit('updateStatus',response.data)
|
|
|
- }).catch(error =>{
|
|
|
- this.logout()
|
|
|
- uni.removeStorageSync('sessionid')
|
|
|
- uni.setStorageSync('sessionid','JSESSIONID='+error.data)
|
|
|
- this.$store.commit('updateStatus',error.data)
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
refresh(){
|
|
|
let TIME = (20*60)*1000;
|
|
|
setInterval(()=>{
|
|
|
- this.getCheekeyCode()
|
|
|
+ wxLogin.wxLoginAuthorize()
|
|
|
},TIME)
|
|
|
}
|
|
|
},
|