Video.js
3.45 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
129
130
131
132
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import {GetQueryString} from '../../utils/Helper';
import YH_Image from '../../../common/components/YH_Image';
const {
View,
Text,
Image,
TouchableOpacity,
Dimensions,
StyleSheet,
Platform,
PixelRatio,
} = ReactNative;
export default class Video extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps,nextState){
if (Immutable.is(nextProps.resource, this.props.resource) && Immutable.is(nextProps.videoCounts, this.props.videoCounts)) {
return false;
} else {
return true;
}
}
render() {
let {resource,videoCounts} = this.props;
if (!resource) {
return null;
}
let counts = videoCounts?videoCounts.toJS():null;
let list = resource.get('module_data').get('data').toJS();
let properties = resource.get('module_data').get('properties').toJS();
let data = list?list[0]:null;
let videoImage = data?data.pic:'a';
let title = data?data.text.title:'';
let detail = data?data.text.content:'';
let num = 0;
let urlForVideo = data?data.video:'';
let isModuleMargin = properties.isModuleMargin;
let heigthW = isModuleMargin?backgroundHeight+10:backgroundHeight;
let room = GetQueryString(urlForVideo,'room');
let bgpic = GetQueryString(urlForVideo,'bgpic');
for(var k in counts) {
if (room == k) {
num = counts[k];
}
}
return(
<View style={{width: backgroundWidth,height:heigthW,backgroundColor: 'white'}}>
<TouchableOpacity activeOpacity={0.5}
style={styles.thumbnail}
onPress={() => {
this.props.onPressVideo && this.props.onPressVideo(room,bgpic);
}}>
<YH_Image
url={videoImage}
style={styles.thumbnail}
></YH_Image>
</TouchableOpacity>
<View style={styles.icon}>
<Image source={require('../../image/see_ic.png')} style={styles.eyeImage}></Image>
<Text style={styles.num} numberOfLines={1}>{num}</Text>
</View>
<Text style={styles.title} numberOfLines={1}>{title}</Text>
<Text style={styles.detail} numberOfLines={2}>{detail}</Text>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let backgroundWidth = width;
let backgroundHeight = Math.ceil(((363+190)/750)*width);
let imageHeigth = Math.ceil((363/750)*width);
let styles = StyleSheet.create({
thumbnail: {
width: backgroundWidth,
height:imageHeigth,
},
title: {
textAlign: 'left',
fontSize: 18,
fontWeight: 'bold',
color: '#444444',
marginTop: 15,
marginLeft: 15,
width: width - 30,
},
detail: {
textAlign: 'left',
fontSize: 14,
color: '#444444',
marginLeft: 15,
marginTop: 5,
width: width - 30,
backgroundColor: 'white',
lineHeight: 20,
},
icon: {
minWidth: 70,
height: 20,
position: 'absolute',
borderRadius: 10,
backgroundColor: 'gray',
top: 10,
right: 15,
flexDirection: 'row',
alignItems: 'center',
},
eyeImage: {
marginLeft: 8,
width: 15,
height: 12,
},
num: {
marginLeft: 8,
color: 'white',
fontSize: 10,
}
});