...
|
...
|
@@ -41,6 +41,13 @@ const { |
|
|
GET_BRAND_RESOURCE_FOR_LIFESTYLE_SUCCESS,
|
|
|
GET_BRAND_RESOURCE_FOR_LIFESTYLE_FAILURE,
|
|
|
|
|
|
BRAND_SHOW_SEARCH,
|
|
|
FETCH_BRAND_SEARCH_HISTORY,
|
|
|
INSERT_BRAND_SEARCH_HISTORY,
|
|
|
CLEAR_BRAND_SEARCH_HISTORY,
|
|
|
BRAND_HOT_KEYWORD_REQUEST,
|
|
|
BRAND_HOT_KEYWORD_SUCCESS,
|
|
|
BRAND_HOT_KEYWORD_FAILURE,
|
|
|
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
...
|
...
|
@@ -59,6 +66,13 @@ export function setChannelFilter(filter) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function setShowSearch(show) {
|
|
|
return {
|
|
|
type: BRAND_SHOW_SEARCH,
|
|
|
payload: show
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getBrandListForBoyRequest() {
|
|
|
return {
|
|
|
type: GET_BRAND_LIST_FOR_BOY_REQUEST,
|
...
|
...
|
@@ -331,3 +345,130 @@ export function parseResourceResources(json) { |
|
|
brandsText,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function searchHistory() {
|
|
|
return (dispatch, getState) => {
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.fetchSearchHistory()
|
|
|
.then(data => {
|
|
|
dispatch({
|
|
|
type: FETCH_BRAND_SEARCH_HISTORY,
|
|
|
payload: parseSearchHistory(data)
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function insertSearchHistory(keyword) {
|
|
|
return (dispatch, getState) => {
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.insertSearchHistory(keyword)
|
|
|
.then(data => {
|
|
|
dispatch({
|
|
|
type: INSERT_BRAND_SEARCH_HISTORY,
|
|
|
payload: parseSearchHistory(data)
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function clearSearchHistory() {
|
|
|
return (dispatch, getState) => {
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.clearSearchHistory()
|
|
|
.then(data => {
|
|
|
dispatch({
|
|
|
type: CLEAR_BRAND_SEARCH_HISTORY,
|
|
|
payload: parseSearchHistory(data)
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseSearchHistory(data) {
|
|
|
let list = [];
|
|
|
data.map((item, i) => {
|
|
|
list.push({keyword: item});
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
export function hotKeywordRequest() {
|
|
|
return {
|
|
|
type: BRAND_HOT_KEYWORD_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function hotKeywordSuccess(json) {
|
|
|
return {
|
|
|
type: BRAND_HOT_KEYWORD_SUCCESS,
|
|
|
payload: json
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function hotKeywordFailure(error) {
|
|
|
return {
|
|
|
type: BRAND_HOT_KEYWORD_FAILURE,
|
|
|
payload: error
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function hotKeyword(reload=false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, brand} = getState();
|
|
|
let {search} = brand;
|
|
|
let {isFetching} = search;
|
|
|
if (reload) {
|
|
|
// 强制刷新数据
|
|
|
|
|
|
} else {
|
|
|
if (isFetching) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let fetchHotKeyword = (uid) => {
|
|
|
dispatch(hotKeywordRequest());
|
|
|
return new BrandService(app.host).fetchHotKeyword(uid)
|
|
|
.then(json => {
|
|
|
let payload = parseHotKeyword(json);
|
|
|
dispatch(hotKeywordSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(hotKeywordFailure(error));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
fetchHotKeyword(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
fetchHotKeyword(0);
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseHotKeyword(json) {
|
|
|
let list = [];
|
|
|
Array.isArray(json) && json.map((item, i) => {
|
|
|
let brandName = item.brandName ? item.brandName : '';
|
|
|
let keyword = brandName;
|
|
|
let brandDomain = item.brandDomain ? item.brandDomain : '';
|
|
|
let brandId = item.brandId ? item.brandId : '';
|
|
|
list.push({keyword, brandName, brandDomain, brandId});
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
list,
|
|
|
};
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|