parseUtils.js 936 Bytes
'use strict';

import ReactNative from 'react-native';
import md5 from 'md5';


const {
    Dimensions,
} = ReactNative;



function parsePageInfoList(json, rec_id) {
    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 : [];

    //为列表数据添加rec_id,埋点事件需要
    list.map((item, i) => {
        item.rec_id = rec_id;
    });

    return {
        currentPage,
        pageCount,
        total,
        list,
    }
}


/**
 * 客户端40位随机数指纹
 * @return
 */
function getRecId() {
    try {
        let date = new Date();
        let encryptStr = md5(date);
        return encryptStr + encryptStr.substring(0,8);
    } catch (error) {
        return "";
    }
}

module.exports = {
	parsePageInfoList,
    getRecId,
};