|
|
'use strict';
|
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import ReactNative, {
|
|
|
NativeModules,
|
|
|
} from 'react-native'
|
|
|
import ListService from '../../services/ListService';
|
|
|
|
|
|
import helper from '../../../common/utils/helper';
|
...
|
...
|
@@ -27,7 +29,10 @@ export function getProductList(reload = false) { |
|
|
dispatch(getProductListRequest());
|
|
|
return new ListService(app.host).getProductListData(channel, gender, uid, page, pageSize)
|
|
|
.then(json => {
|
|
|
let payload = parseProductList(json);
|
|
|
let payload = parseProductList(json, products.list.toJS()&&products.list.toJS().length);
|
|
|
|
|
|
NativeModules.YH_CommonHelper.logEvent('YB_FIND_GOOD_GDS_L', payload.logParam);
|
|
|
|
|
|
payload.endReached = payload.currentPage == payload.pageCount;
|
|
|
|
|
|
if (payload.currentPage > 1 && !reload) {
|
...
|
...
|
@@ -61,17 +66,34 @@ export function getProductList(reload = false) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseProductList(json) {
|
|
|
function parseProductList(json, count) {
|
|
|
let currentPage = json && json.page ? json.page : 1;
|
|
|
let pageCount = json && json.page_total ? json.page_total : 0;
|
|
|
let total = json && json.total ? json.total : 0;
|
|
|
let list = json && json.product_list ? json.product_list : [];
|
|
|
|
|
|
let logList = [];
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
let item = list[i];
|
|
|
logList.push({
|
|
|
I_INDEX: count + i + 1,
|
|
|
PRD_SKN: item.product_skn,
|
|
|
})
|
|
|
}
|
|
|
let data = {
|
|
|
F_ID: 1002,
|
|
|
LIST: logList,
|
|
|
}
|
|
|
let logParam = {
|
|
|
AB_TYPE: 'A',
|
|
|
DATA:[data],
|
|
|
}
|
|
|
return {
|
|
|
list,
|
|
|
currentPage,
|
|
|
pageCount,
|
|
|
total,
|
|
|
logParam,
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -106,6 +128,7 @@ export function fetchBanner() { |
|
|
dispatch(fetchBannerRequest());
|
|
|
return new ListService(app.serviceHost).fetchBannerData()
|
|
|
.then(json => {
|
|
|
dispatch(logBanner(json));
|
|
|
dispatch(fetchBannerSuccess(json));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -114,6 +137,36 @@ export function fetchBanner() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
function logBanner(json) {
|
|
|
let bannerData = [];
|
|
|
if (json.data && josn.data.length()) {
|
|
|
let bannerDataArray = json.data;
|
|
|
if (bannerDataArray.length > 0) {
|
|
|
bannerData = bannerDataArray[0].data;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let logList = [];
|
|
|
for (var i = 0; i < bannerData.length; i++) {
|
|
|
let item = bannerData[i];
|
|
|
logList.push({
|
|
|
I_INDEX: i + 1,
|
|
|
F_URL: item.url,
|
|
|
})
|
|
|
}
|
|
|
let data = {
|
|
|
F_ID: 1001,
|
|
|
LIST: logList,
|
|
|
}
|
|
|
let logParam = {
|
|
|
AB_TYPE: 'A',
|
|
|
DATA:[data],
|
|
|
}
|
|
|
|
|
|
NativeModules.YH_CommonHelper.logEvent('YB_FIND_GOOD_GDS_L', logParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
export function fetchBannerRequest() {
|
|
|
return {
|
|
|
type: FETCH_BANNER_REQUEST
|
...
|
...
|
|