123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { Vue, Component } from 'vue-property-decorator';
- import {namespace} from 'vuex-class';
- import { types } from '@/common/store/index';
- const baseModule = namespace('base');
- @Component({})
- export default class LoginMixin extends Vue {
- @baseModule.Getter('_userInfo') _userInfo: any;
- @baseModule.Getter('_token') token: any;
- @baseModule.Mutation(types.SET_USERINFO) _setUserInfo: any;
-
- isAuthorization(){
- if(!this.token){
- this.$Router.push('/pages/login/login');
- return true;
- }
- }
-
-
- /**
- * 获取用户信息
- * GET
- * */
- getUserInfo () {
- // uni.showLoading({
- // title: '加载中',
- // });
- return this.$http.get({
- url:this.$api.getUserInfo
- })
- .then((res:any) => {
- // uni.hideLoading();
- if (res) {
- // let {info, ...extra } = res;
- this._setUserInfo(res.info)
- }
- })
- .catch((err:any) => {
- // uni.hideLoading();
- console.log(err)
- })
- }
- }
|