Authored by htoooth

fix needlogin

@@ -27,16 +27,20 @@ export default { @@ -27,16 +27,20 @@ export default {
27 methods: { 27 methods: {
28 }, 28 },
29 computed: { 29 computed: {
30 - ...mapState(['status']) 30 + ...mapState(['status', 'needLogin'])
31 }, 31 },
32 components: { 32 components: {
33 FormPage, 33 FormPage,
34 StatusPage, 34 StatusPage,
35 LayoutApp 35 LayoutApp
  36 + },
  37 + mounted() {
  38 + if (this.needLogin) {
  39 + this.$yoho.goLogin({});
  40 + }
36 } 41 }
37 }; 42 };
38 </script> 43 </script>
39 44
40 <style lang="scss" scoped> 45 <style lang="scss" scoped>
41 -  
42 </style> 46 </style>
@@ -43,12 +43,14 @@ export default { @@ -43,12 +43,14 @@ export default {
43 43
44 if (result.code === 200) { 44 if (result.code === 200) {
45 commit(Types.FETCH_UFO_STATUS_SUCCESS, result.data); 45 commit(Types.FETCH_UFO_STATUS_SUCCESS, result.data);
  46 + } if (result.code === 401) {
  47 + commit(Types.FETCH_UFO_NEED_LOGIN, true);
46 } else { 48 } else {
47 commit(Types.FETCH_UFO_STATUS_SUCCESS, -1); 49 commit(Types.FETCH_UFO_STATUS_SUCCESS, -1);
48 } 50 }
49 }, 51 },
50 52
51 - async getStoreStatus({commit}) { 53 + async getStoreStatus({ commit }) {
52 const result = await this.$api.get('/api/ufo/store/status'); 54 const result = await this.$api.get('/api/ufo/store/status');
53 55
54 return result; 56 return result;
@@ -7,7 +7,8 @@ export default function() { @@ -7,7 +7,8 @@ export default function() {
7 state: { 7 state: {
8 fetching: false, 8 fetching: false,
9 token: false, 9 token: false,
10 - status: -1 10 + status: -1,
  11 + needLogin: false
11 }, 12 },
12 actions, 13 actions,
13 mutations 14 mutations
@@ -7,5 +7,9 @@ export default { @@ -7,5 +7,9 @@ export default {
7 7
8 [Types.FETCH_UFO_STATUS_SUCCESS](state, data) { 8 [Types.FETCH_UFO_STATUS_SUCCESS](state, data) {
9 state.status = data; 9 state.status = data;
  10 + },
  11 +
  12 + [Types.FETCH_UFO_NEED_LOGIN](state, data) {
  13 + state.needLogin = data;
10 } 14 }
11 }; 15 };
@@ -6,3 +6,5 @@ export const FETCH_UFO_SAVE_ERROR = 'FETCH_UFO_SAVE_ERROR'; @@ -6,3 +6,5 @@ export const FETCH_UFO_SAVE_ERROR = 'FETCH_UFO_SAVE_ERROR';
6 export const FETCH_UFO_STATUS_REQUEST = 'FETCH_UFO_STATUS_REQUEST'; 6 export const FETCH_UFO_STATUS_REQUEST = 'FETCH_UFO_STATUS_REQUEST';
7 export const FETCH_UFO_STATUS_SUCCESS = 'FETCH_UFO_STATUS_SUCCESS'; 7 export const FETCH_UFO_STATUS_SUCCESS = 'FETCH_UFO_STATUS_SUCCESS';
8 export const FETCH_UFO_STATUS_ERROR = 'FETCH_UFO_STATUS_ERROR'; 8 export const FETCH_UFO_STATUS_ERROR = 'FETCH_UFO_STATUS_ERROR';
  9 +
  10 +export const FETCH_UFO_NEED_LOGIN = 'FETCH_UFO_NEED_LOGIN';