|
|
'use strict';
|
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import {Platform} from 'react-native';
|
|
|
import BrandService from '../../services/BrandService';
|
|
|
import {Record, List, Map} from 'immutable';
|
|
|
import Pinyin from '../../../common/utils/pinyin';
|
...
|
...
|
@@ -414,9 +415,12 @@ export function searchHistory() { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function insertSearchHistory(keyword) {
|
|
|
export function insertSearchHistory(data) {
|
|
|
return (dispatch, getState) => {
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.insertSearchHistory(keyword)
|
|
|
//兼容IOS只需要搜索关键字,android需要整个data数据
|
|
|
if (Platform.OS === 'ios') {
|
|
|
let brandName = data.brand_name ? data.brand_name : '';
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.insertSearchHistory(brandName)
|
|
|
.then(data => {
|
|
|
dispatch({
|
|
|
type: INSERT_BRAND_SEARCH_HISTORY,
|
...
|
...
|
@@ -426,6 +430,19 @@ export function insertSearchHistory(keyword) { |
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
}
|
|
|
else{
|
|
|
ReactNative.NativeModules.YH_ClassifyHelper.insertSearchHistory(data)
|
|
|
.then(data => {
|
|
|
dispatch({
|
|
|
type: INSERT_BRAND_SEARCH_HISTORY,
|
|
|
payload: parseSearchHistory(data)
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -447,7 +464,13 @@ export function clearSearchHistory() { |
|
|
function parseSearchHistory(data) {
|
|
|
let list = [];
|
|
|
data.map((item, i) => {
|
|
|
//兼容IOS只需要搜索关键字,android需要整个data数据
|
|
|
if (Platform.OS === 'ios') {
|
|
|
list.push({keyword: item});
|
|
|
}
|
|
|
else{
|
|
|
list.push({keyword: item.brand_name, androiddata: item});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return list;
|
...
|
...
|
|