Authored by 于良

Merge branch 'local' into develop

Conflicts:
	js/services/HomeService.js
@@ -2,14 +2,16 @@ module.exports = { @@ -2,14 +2,16 @@ module.exports = {
2 dev: { 2 dev: {
3 // baseUrl: 'http://testapi.yoho.cn:28077', 3 // baseUrl: 'http://testapi.yoho.cn:28077',
4 baseUrl: 'http://172.16.6.190:8081', 4 baseUrl: 'http://172.16.6.190:8081',
5 - privateKey: 'a85bb0674e08986c6b115d5e3a4884fa', 5 + iosPrivateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
  6 + androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
6 httpTimeout: 30000, //毫秒 7 httpTimeout: 30000, //毫秒
7 8
8 }, 9 },
9 prd: { 10 prd: {
10 baseUrl: 'http://172.16.6.190:8081', 11 baseUrl: 'http://172.16.6.190:8081',
11 - privateKey: 'a85bb0674e08986c6b115d5e3a4884fa',  
12 - httpTimeout: 30000, //毫秒 12 + iosPrivateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
  13 + androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
  14 + HTTPTimeout: 30000, //毫秒
13 15
14 }, 16 },
15 storeKey: { 17 storeKey: {
@@ -75,9 +75,6 @@ class App extends Component { @@ -75,9 +75,6 @@ class App extends Component {
75 componentDidMount() { 75 componentDidMount() {
76 this.props.actions.getStoredUserInfo(); 76 this.props.actions.getStoredUserInfo();
77 this.props.actions.getGuideDisplayState(); 77 this.props.actions.getGuideDisplayState();
78 -  
79 - // let brand = this.props.user.get('brands');  
80 - // this.props.actions.switchBrand(brand.get('shopId'), brand.get('shopName'));  
81 } 78 }
82 79
83 render() { 80 render() {
@@ -55,6 +55,8 @@ class DrawerContainer extends Component { @@ -55,6 +55,8 @@ class DrawerContainer extends Component {
55 //选择店铺 55 //选择店铺
56 this.drawer.close(); 56 this.drawer.close();
57 this.props.actions.switchBrand(brand.get('shopId'), brand.get('shopName')); 57 this.props.actions.switchBrand(brand.get('shopId'), brand.get('shopName'));
  58 + this.props.actions.overview(brand.get('shopId'));
  59 + this.props.actions.brandRank(brand.get('shopId'));
58 } 60 }
59 61
60 render() { 62 render() {
@@ -99,9 +99,14 @@ class HomeContainer extends Component { @@ -99,9 +99,14 @@ class HomeContainer extends Component {
99 } 99 }
100 100
101 componentDidMount() { 101 componentDidMount() {
102 - // this.props.actions.overview(this.props.home.shopId);  
103 - // this.props.actions.overview(1200);  
104 - // this.props.actions.brandRank(1200); 102 +
  103 + if (!this.props.home.brandId) {
  104 + let brands = this.props.user.get('brands');
  105 + this.props.actions.switchBrand(brands.get(0).get('shopId'), brands.get(0).get('shopName'));
  106 + }
  107 + console.log(this.props.home.brandId);
  108 + this.props.actions.overview(this.props.home.brandId);
  109 + this.props.actions.brandRank(this.props.home.brandId);
105 } 110 }
106 111
107 _onPressCategory(id) { 112 _onPressCategory(id) {
@@ -214,10 +214,8 @@ export function login(account, password) { @@ -214,10 +214,8 @@ export function login(account, password) {
214 dispatch(loginRequest()); 214 dispatch(loginRequest());
215 return userService.login(account,password) 215 return userService.login(account,password)
216 .then(function (json) { 216 .then(function (json) {
217 - console.log(json);  
218 return userService.storeUserInfo(json) 217 return userService.storeUserInfo(json)
219 .then(() => { 218 .then(() => {
220 - console.log(json);  
221 dispatch(loginSuccess(json)); 219 dispatch(loginSuccess(json));
222 Actions.Drawer(); 220 Actions.Drawer();
223 }); 221 });
@@ -9,19 +9,38 @@ export default class UserService { @@ -9,19 +9,38 @@ export default class UserService {
9 this.api = new Request(); 9 this.api = new Request();
10 } 10 }
11 11
12 - async overview(shopId) { 12 + async overview(brandId) {
  13 + let dateId = moment().format('YYYYMMDD'); //20160524
  14 + return await this.api.get({
  15 + url: '/gateway',
  16 + body: {
  17 + method: 'app.shops.shopbusinessoverview',
  18 + brandId,
  19 + dateId
  20 + }
  21 + })
  22 + .then((json) => {
  23 + return json;
  24 + })
  25 + .catch((error) => {
  26 + throw(error);
  27 + });
  28 + }
13 29
  30 + async brandRank(brandId) {
  31 + let dateId = moment().format('YYYYMMDD'); //20160524
14 return await this.api.get({ 32 return await this.api.get({
15 - url: '/operations/api/v6/category/getCategory', 33 + url: '/gateway',
16 body: { 34 body: {
17 - shopId, 35 + method: 'app.shops.shopbrandrank',
  36 + brandId,
  37 + dateId
18 } 38 }
19 }) 39 })
20 .then((json) => { 40 .then((json) => {
21 return json; 41 return json;
22 }) 42 })
23 .catch((error) => { 43 .catch((error) => {
24 - console.error(error);  
25 throw(error); 44 throw(error);
26 }); 45 });
27 } 46 }
@@ -14,8 +14,15 @@ export default class Request { @@ -14,8 +14,15 @@ export default class Request {
14 this.config = process.env.NODE_ENV === `development` ? CONFIG.dev : CONFIG.prd; 14 this.config = process.env.NODE_ENV === `development` ? CONFIG.dev : CONFIG.prd;
15 15
16 this.baseUrl= this.config.baseUrl; 16 this.baseUrl= this.config.baseUrl;
17 - this.privateKey = this.config.privateKey;  
18 - this.timeout = this.config.httpTimeout; 17 +
  18 + this.privateKey = '';
  19 + if (React.Platform.OS === 'ios') {
  20 + this.privateKey = this.config.iosPrivateKey;
  21 + } else {
  22 + this.privateKey = this.config.androidPrivateKey;
  23 + }
  24 +
  25 + this.timeout = this.config.HTTPTimeout;
19 } 26 }
20 27
21 28
@@ -133,6 +140,8 @@ export default class Request { @@ -133,6 +140,8 @@ export default class Request {
133 reqOpts.body = queryStrigPair; 140 reqOpts.body = queryStrigPair;
134 } 141 }
135 142
  143 + __DEV__ && console.log(this.baseUrl + opts.url);
  144 +
136 if (opts.timeout && opts.timeout > 0) { 145 if (opts.timeout && opts.timeout > 0) {
137 return await timeoutPromise(opts.timeout, fetch(this.baseUrl + opts.url, reqOpts)); 146 return await timeoutPromise(opts.timeout, fetch(this.baseUrl + opts.url, reqOpts));
138 } 147 }