|
|
'use strict';
|
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import PlustarService from '../../services/DetailService';
|
|
|
import DetailService from '../../services/DetailService';
|
|
|
|
|
|
const {
|
|
|
BRAND_INFO_REQUEST,
|
|
|
BRAND_INFO_SUCCESS,
|
|
|
BRAND_INFO_FAILURE,
|
|
|
|
|
|
JUMP_WITH_URL
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
...
|
...
|
@@ -19,3 +23,53 @@ export function jumpWithUrl(url) { |
|
|
payload: url
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function brandInfoRequest(key) {
|
|
|
return {
|
|
|
type: BRAND_INFO_REQUEST,
|
|
|
payload: key
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function brandInfoSuccess(json) {
|
|
|
return {
|
|
|
type: BRAND_INFO_SUCCESS,
|
|
|
payload: json
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function brandInfoFailure(error) {
|
|
|
return {
|
|
|
type: BRAND_INFO_FAILURE,
|
|
|
payload: error
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* index number 请求数据的index
|
|
|
* reload bool 是否需要强制重新请求数据,
|
|
|
*/
|
|
|
export function getBrandInfo(brandId, reload = false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, detail} = getState();
|
|
|
let item = detail.get('brandInfo');
|
|
|
if (reload) {
|
|
|
// 强制刷新数据
|
|
|
} else {
|
|
|
if (item.isFetching) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dispatch(brandInfoRequest());
|
|
|
return new DetailService().getBrandInfo(brandId)
|
|
|
.then(json => {
|
|
|
console.log('----->>>>');
|
|
|
console.log(json);
|
|
|
dispatch(brandInfoSuccess(json));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(brandInfoFailure(error));
|
|
|
});
|
|
|
};
|
|
|
} |
...
|
...
|
|