index.js
3.19 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
import Taro, {Component} from '@tarojs/taro';
import {View, Text, ScrollView, Image} from '@tarojs/components';
import {getImgUrl} from '../../utils';
import arrowIcon from '../../static/images/arrow-right.png';
import './index.scss';
export default class category extends Component {
constructor(props) {
super(props);
this.state = {};
}
static defaultProps = {
floor: {}
}
render() {
let {floor} = this.props;
let list = floor.list || [];
let newList = [];
for(let i = 0; i < list.length; i+=3) {
newList.push(list.slice(i, i + 3));
}
return (
<View className="category">
<View className="floor-header">
<View className="title">{floor.category_name}</View>
<Navigator className="more" url={floor.more_url} hover-class="none">MORE<Image src={arrowIcon} className="arrow-right-icon"/></Navigator>
</View>
{
newList.length > 0 &&
<ScrollView
className='scrollview'
scrollX
scrollWithAnimation
scrollLeft='0'
lowerThreshold='20'
upperThreshold='20'
onScrolltoupper={this.onScrolltoupper}
onScroll={this.onScroll}>
{
newList.map((s, i) => {
return (
<View className="item-group" key={i}>
{
s.map(item => {
return (
<View className="item" key={item.product_id} key={item.product_id}>
<Navigator className="item-navigator" url={`/pages/productDetail/index?id=${item.product_id}`} hover-class="none">
<View className="item-img">
<Image className="img" src={getImgUrl(item.image_url, 140, 140)} mode="aspectFill"/>
</View>
<View className="product-dec">
<Text className="item-name">{item.product_name}</Text>
<View className="item-code">货号 {item.product_code}</View>
</View>
</Navigator>
</View>
)
})
}
</View>
)
})
}
</ScrollView>
}
</View>
)
}
}