Title.js
3.76 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import DeviceInfo from 'react-native-device-info';
const {
View,
Image,
Text,
TouchableOpacity,
Dimensions,
StyleSheet,
Platform,
} = ReactNative;
export default class Title extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps,nextState){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let {resource} = this.props;
if (!resource) {
return null;
}
let yh_exposureData = this.props.yh_exposureData?this.props.yh_exposureData:null;
let fontFamilyStyle = {};
if (Platform.OS === 'ios') {
let systemVersion = DeviceInfo.getSystemVersion();
systemVersion = parseFloat(systemVersion);
if (systemVersion >= 9.0) {
fontFamilyStyle = {fontFamily: 'PingFang SC'};
}
}
let list = resource.get('module_data').get('data').toJS();
let data = list?list[0]:null;
let linkType = data.linkType;
let linkReource = data.resource;
let title = data.text;
let hasMoreButton = linkType==''?false:true;
let moduleOrder = resource.get('module_order') + 1;
let moduleType = resource.get('module_type');
let properties = resource.get('module_data').get('properties').toJS();
let isModuleMargin = properties.isModuleMargin;
let url = '';
if (linkType == '0') {
url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.poollist","params":{"productPool":"${linkReource}"}}`;
} else if (linkType == '1') {
url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${linkReource}"}}`;
} else if (linkType == '2') {
url = linkReource;
}
if (yh_exposureData) {
yh_exposureData = {
I_INDEX: 0,
ACTION_URL: url,
...yh_exposureData,
};
}
return(
<View style={[styles.container,{height: isModuleMargin=='1'?40+10:40,backgroundColor: '#f0f0f0'}]}>
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5'}}/>
<View style={styles.title}>
<Text style={[styles.text, fontFamilyStyle]}>{title}</Text>
{hasMoreButton?
<TouchableOpacity yh_exposureData={yh_exposureData} activeOpacity={0.5} style={styles.thumbnail} onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(linkType,linkReource,moduleOrder,moduleType,0);
}}>
<Image
source={require('../../../brandStore/image/btn_more_p.png')}
style={{width: 22, height: 4,marginLeft:3}}
resizeMode={'contain'}
/>
</TouchableOpacity>:null}
</View>
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5'}}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
height: 40,
width: width,
},
title: {
alignItems: 'center',
justifyContent: 'center',
height: 39,
width: width,
backgroundColor: '#e5e5e5',
},
text: {
textAlign: 'left',
fontSize: 16,
fontWeight: 'bold',
color: '#444',
},
thumbnail: {
position: 'absolute',
width: 40,
height: 38,
top: 1,
bottom: 1,
marginLeft: width - 40,
backgroundColor: 'transparent',
justifyContent: 'center',
},
});