Authored by 于良

更新配置 侧边栏选择店铺 请求数据 review by 盖剑秋

... ... @@ -2,14 +2,16 @@ module.exports = {
dev: {
// baseUrl: 'http://testapi.yoho.cn:28077',
baseUrl: 'http://172.16.6.190:8081',
privateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
iosPrivateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
httpTimeout: 30000, //毫秒
},
prd: {
baseUrl: 'http://172.16.6.190:8081',
privateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
httpTimeout: 30000, //毫秒
iosPrivateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
HTTPTimeout: 30000, //毫秒
},
storeKey: {
... ...
... ... @@ -75,9 +75,6 @@ class App extends Component {
componentDidMount() {
this.props.actions.getStoredUserInfo();
this.props.actions.getGuideDisplayState();
// let brand = this.props.user.get('brands');
// this.props.actions.switchBrand(brand.get('shopId'), brand.get('shopName'));
}
render() {
... ...
... ... @@ -55,6 +55,8 @@ class DrawerContainer extends Component {
//选择店铺
this.drawer.close();
this.props.actions.switchBrand(brand.get('shopId'), brand.get('shopName'));
this.props.actions.overview(brand.get('shopId'));
this.props.actions.brandRank(brand.get('shopId'));
}
render() {
... ...
... ... @@ -99,9 +99,14 @@ class HomeContainer extends Component {
}
componentDidMount() {
// this.props.actions.overview(this.props.home.shopId);
// this.props.actions.overview(1200);
// this.props.actions.brandRank(1200);
if (!this.props.home.brandId) {
let brands = this.props.user.get('brands');
this.props.actions.switchBrand(brands.get(0).get('shopId'), brands.get(0).get('shopName'));
}
console.log(this.props.home.brandId);
this.props.actions.overview(this.props.home.brandId);
this.props.actions.brandRank(this.props.home.brandId);
}
_onPressCategory(id) {
... ...
... ... @@ -214,10 +214,8 @@ export function login(account, password) {
dispatch(loginRequest());
return userService.login(account,password)
.then(function (json) {
console.log(json);
return userService.storeUserInfo(json)
.then(() => {
console.log(json);
dispatch(loginSuccess(json));
Actions.Drawer();
});
... ...
... ... @@ -13,8 +13,9 @@ export default class UserService {
async overview(brandId) {
let dateId = moment().format('YYYYMMDD'); //20160524
return await this.api.get({
url: '/operations/api/v6/category/getCategory',
url: '/gateway',
body: {
method: 'app.shops.shopbusinessoverview',
brandId,
dateId
}
... ... @@ -30,8 +31,9 @@ export default class UserService {
async brandRank(brandId) {
let dateId = moment().format('YYYYMMDD'); //20160524
return await this.api.get({
url: '/operations/api/v6/category/getCategory',
url: '/gateway',
body: {
method: 'app.shops.shopbrandrank',
brandId,
dateId
}
... ...
... ... @@ -14,8 +14,15 @@ export default class Request {
this.config = process.env.NODE_ENV === `development` ? CONFIG.dev : CONFIG.prd;
this.baseUrl= this.config.baseUrl;
this.privateKey = this.config.privateKey;
this.timeout = this.config.httpTimeout;
this.privateKey = '';
if (React.Platform.OS === 'ios') {
this.privateKey = this.config.iosPrivateKey;
} else {
this.privateKey = this.config.androidPrivateKey;
}
this.timeout = this.config.HTTPTimeout;
}
... ... @@ -133,6 +140,8 @@ export default class Request {
reqOpts.body = queryStrigPair;
}
__DEV__ && console.log(this.baseUrl + opts.url);
if (opts.timeout && opts.timeout > 0) {
return await timeoutPromise(opts.timeout, fetch(this.baseUrl + opts.url, reqOpts));
}
... ...