Showing
6 changed files
with
36 additions
and
3 deletions
@@ -31,6 +31,12 @@ export default { | @@ -31,6 +31,12 @@ export default { | ||
31 | this.updateUser(Vue, user, purviews); | 31 | this.updateUser(Vue, user, purviews); |
32 | }); | 32 | }); |
33 | }, | 33 | }, |
34 | + initConfig(Vue) { | ||
35 | + return this.userService.config().then((data) => { | ||
36 | + Object.assign(Vue.$config, data); | ||
37 | + Vue.prop('config', Vue.$config); | ||
38 | + }); | ||
39 | + }, | ||
34 | install(Vue) { | 40 | install(Vue) { |
35 | this.userService = new UserService(); | 41 | this.userService = new UserService(); |
36 | 42 | ||
@@ -41,7 +47,10 @@ export default { | @@ -41,7 +47,10 @@ export default { | ||
41 | if (isLogin && user) { | 47 | if (isLogin && user) { |
42 | try { | 48 | try { |
43 | user = crypto.aesDecrypt(user, Object); | 49 | user = crypto.aesDecrypt(user, Object); |
44 | - return this.initPurview(Vue, user).then(() => { | 50 | + return Promise.all([ |
51 | + this.initPurview(Vue, user), | ||
52 | + this.initConfig(Vue) | ||
53 | + ]).then(() => { | ||
45 | next(); | 54 | next(); |
46 | }, () => { | 55 | }, () => { |
47 | next(); | 56 | next(); |
@@ -82,7 +91,10 @@ export default { | @@ -82,7 +91,10 @@ export default { | ||
82 | local: (username, password) => { | 91 | local: (username, password) => { |
83 | return this.userService.login(username, password).then((res) => { | 92 | return this.userService.login(username, password).then((res) => { |
84 | if (res.code === 200) { | 93 | if (res.code === 200) { |
85 | - return this.initPurview(Vue, res.data).then(() => { | 94 | + return Promise.all([ |
95 | + this.initPurview(Vue, res.data), | ||
96 | + this.initConfig(Vue) | ||
97 | + ]).then(() => { | ||
86 | return res.data; | 98 | return res.data; |
87 | }); | 99 | }); |
88 | } | 100 | } |
@@ -12,6 +12,9 @@ class UserService extends Service { | @@ -12,6 +12,9 @@ class UserService extends Service { | ||
12 | return {ori: res.data, deep: this.deepList(res.data)}; | 12 | return {ori: res.data, deep: this.deepList(res.data)}; |
13 | }); | 13 | }); |
14 | } | 14 | } |
15 | + config() { | ||
16 | + return this.post('/config'); | ||
17 | + } | ||
15 | deepList(purviews) { | 18 | deepList(purviews) { |
16 | let purs = []; | 19 | let purs = []; |
17 | 20 |
@@ -20,6 +20,7 @@ const path = require('path'); | @@ -20,6 +20,7 @@ const path = require('path'); | ||
20 | global.env = { | 20 | global.env = { |
21 | version: pkg.version, | 21 | version: pkg.version, |
22 | Production: process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'gray', | 22 | Production: process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'gray', |
23 | + Gray: process.env.NODE_ENV === 'gray', | ||
23 | Test: (process.env.NODE_ENV || '').indexOf('test') >= 0 | 24 | Test: (process.env.NODE_ENV || '').indexOf('test') >= 0 |
24 | }; | 25 | }; |
25 | 26 |
@@ -104,7 +104,7 @@ if (global.env.Test) { | @@ -104,7 +104,7 @@ if (global.env.Test) { | ||
104 | if (global.env.Production) { | 104 | if (global.env.Production) { |
105 | domains.erp = 'http://gw.api.yohobuy.com'; | 105 | domains.erp = 'http://gw.api.yohobuy.com'; |
106 | domains.platform = 'http://api.platform.yohoops.org/platform'; | 106 | domains.platform = 'http://api.platform.yohoops.org/platform'; |
107 | - domains.shop = 'http://shops.yohobuy.com'; | 107 | + domains.shop = 'http://127.0.0.1:30012'; |
108 | } | 108 | } |
109 | 109 | ||
110 | _.each(domainApis, (apis, domainName) => { | 110 | _.each(domainApis, (apis, domainName) => { |
@@ -23,5 +23,6 @@ router.post('/switchShop', before, auth, middleware(UserController, 'switchShop' | @@ -23,5 +23,6 @@ router.post('/switchShop', before, auth, middleware(UserController, 'switchShop' | ||
23 | router.post('/upload/image', before, auth, multipartMiddleware, middleware(FileController, 'uploadImage')); | 23 | router.post('/upload/image', before, auth, multipartMiddleware, middleware(FileController, 'uploadImage')); |
24 | router.post('/upload/xlsx', before, auth, multipartMiddleware, middleware(FileController, 'uploadXlsx')); | 24 | router.post('/upload/xlsx', before, auth, multipartMiddleware, middleware(FileController, 'uploadXlsx')); |
25 | router.post('/importSeller', before, auth, multipartMiddleware, middleware(FileController, 'importSeller')); | 25 | router.post('/importSeller', before, auth, multipartMiddleware, middleware(FileController, 'importSeller')); |
26 | +router.post('/config', middleware(UserController, 'config')); | ||
26 | 27 | ||
27 | module.exports = router; | 28 | module.exports = router; |
@@ -72,6 +72,22 @@ class UserController extends Context { | @@ -72,6 +72,22 @@ class UserController extends Context { | ||
72 | data: '登出成功' | 72 | data: '登出成功' |
73 | }); | 73 | }); |
74 | } | 74 | } |
75 | + config(req, res) { | ||
76 | + let config = { | ||
77 | + shopsFeDomain: 'http://shops.yohobuy.com' | ||
78 | + }; | ||
79 | + | ||
80 | + if (global.env.Production) { | ||
81 | + Object.assign(config, { | ||
82 | + shopsFeDomain: 'http://shops.yohobuy.com' | ||
83 | + }); | ||
84 | + } else if (global.env.Gray) { | ||
85 | + Object.assign(config, { | ||
86 | + shopsFeDomain: 'http://shops.yohops.com' | ||
87 | + }); | ||
88 | + } | ||
89 | + res.json(config); | ||
90 | + } | ||
75 | switchShop(req, res) { | 91 | switchShop(req, res) { |
76 | let shopId = req.body.shopId; | 92 | let shopId = req.body.shopId; |
77 | 93 |
-
Please register or login to post a comment