parseUtils.js
936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'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,
};