Authored by htoooth

fix needlogin

@@ -25,7 +25,7 @@ const request = async({url, method, reqParams = {}, context}) => { @@ -25,7 +25,7 @@ const request = async({url, method, reqParams = {}, context}) => {
25 }, 25 },
26 sessionKey: user.sessionKey, 26 sessionKey: user.sessionKey,
27 appSessionType: user.appSessionType 27 appSessionType: user.appSessionType
28 - } : 1, 28 + } : null,
29 method: apiInfo.api, 29 method: apiInfo.api,
30 }); 30 });
31 } 31 }
@@ -143,7 +143,7 @@ export default { @@ -143,7 +143,7 @@ export default {
143 143
144 this.toast && this.toast.hide(); 144 this.toast && this.toast.hide();
145 145
146 - if (result.code === 200) { 146 + if (result && result.code === 200) {
147 this.$store.commit('license/form/FETCH_UFO_STATUS_SUCCESS', 0); 147 this.$store.commit('license/form/FETCH_UFO_STATUS_SUCCESS', 0);
148 } else { 148 } else {
149 this.$createToast({ 149 this.$createToast({
@@ -186,11 +186,19 @@ export default { @@ -186,11 +186,19 @@ export default {
186 this.model.certFaceImage.length === 1 && 186 this.model.certFaceImage.length === 1 &&
187 this.model.certReverseImage.length === 1 && 187 this.model.certReverseImage.length === 1 &&
188 (this.model.time.noLimit ? this.model.time.start_time : this.model.time.start_time && this.model.time.expire_time); 188 (this.model.time.noLimit ? this.model.time.start_time : this.model.time.start_time && this.model.time.expire_time);
189 - } 189 + },
  190 + ...mapState(['needLogin'])
190 }, 191 },
191 mounted() { 192 mounted() {
192 this.fetchToken(); 193 this.fetchToken();
193 }, 194 },
  195 + watch: {
  196 + needLogin(newVal) {
  197 + if (newVal) {
  198 + this.$yoho.goLogin({});
  199 + }
  200 + }
  201 + },
194 components: { 202 components: {
195 LayoutApp, 203 LayoutApp,
196 FixedBottom, 204 FixedBottom,
@@ -30,16 +30,23 @@ export default { @@ -30,16 +30,23 @@ export default {
30 }, 30 },
31 31
32 async saveLicense({ commit }, data) { 32 async saveLicense({ commit }, data) {
33 - const result = await this.$api.post( 33 + let result = {};
  34 +
  35 + try {
  36 + result = await this.$api.post(
34 '/api/ufo/license/save', 37 '/api/ufo/license/save',
35 _handleData(data) 38 _handleData(data)
36 ); 39 );
  40 + } catch (e) {
  41 + commit(Types.FETCH_UFO_NEED_LOGIN, true);
  42 + return result;
  43 + }
37 44
38 return result; 45 return result;
39 }, 46 },
40 47
41 async licenseStatus({ commit }) { 48 async licenseStatus({ commit }) {
42 - let result = null; 49 + let result = {};
43 50
44 try { 51 try {
45 result = await this.$api.get('/api/ufo/license/status'); 52 result = await this.$api.get('/api/ufo/license/status');
@@ -58,7 +65,13 @@ export default { @@ -58,7 +65,13 @@ export default {
58 }, 65 },
59 66
60 async getStoreStatus({ commit }) { 67 async getStoreStatus({ commit }) {
61 - const result = await this.$api.get('/api/ufo/store/status'); 68 + let result = {};
  69 +
  70 + try {
  71 + result = await this.$api.get('/api/ufo/store/status');
  72 + } catch (e) {
  73 + return result;
  74 + }
62 75
63 return result; 76 return result;
64 } 77 }
@@ -7,7 +7,8 @@ const qiniu = require('qiniu'); @@ -7,7 +7,8 @@ const qiniu = require('qiniu');
7 const qiniuConfig = global.yoho.config.qiniu; 7 const qiniuConfig = global.yoho.config.qiniu;
8 const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn; 8 const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn;
9 9
10 -function getToken(req, res) { 10 +function getToken(req, res, next) {
  11 + try {
11 let conf = qiniuConfig; 12 let conf = qiniuConfig;
12 let type = req.query.type || ''; 13 let type = req.query.type || '';
13 14
@@ -26,6 +27,9 @@ function getToken(req, res) { @@ -26,6 +27,9 @@ function getToken(req, res) {
26 code: 200, 27 code: 200,
27 uptoken: uploadToken 28 uptoken: uploadToken
28 }); 29 });
  30 + } catch (e) {
  31 + return next(e);
  32 + }
29 } 33 }
30 34
31 module.exports = { 35 module.exports = {
@@ -25,7 +25,7 @@ module.exports = async(req, res, next) => { @@ -25,7 +25,7 @@ module.exports = async(req, res, next) => {
25 }, 25 },
26 sessionKey: req.user.sessionKey, 26 sessionKey: req.user.sessionKey,
27 appSessionType: req.user.appSessionType 27 appSessionType: req.user.appSessionType
28 - } : 0, 28 + } : null,
29 method: apiInfo.api 29 method: apiInfo.api
30 }; 30 };
31 } 31 }