index.js
3.35 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
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';
import router from '../../router/index.js'
export default class category extends Component {
constructor(props) {
super(props);
this.state = {};
}
static defaultProps = {
floor: {}
}
goToList(floor) {
router.goUrl(floor.more_url);
}
goToDetail(product) {
router.go('productDetail', { id: product.product_id });
}
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>
<View className="more" hover-class="none" onClick={this.goToList.bind(this, floor)}>
MORE
<Image src={arrowIcon} className="arrow-right-icon"/>
</View>
</View>
{
newList.length > 0 &&
<ScrollView
className='scrollview'
scrollX
scrollWithAnimation
scrollLeft='0'
lowerThreshold='20'
upperThreshold='20'
>
{
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}>
<View className="item-navigator" onClick={this.goToDetail.bind(this, item)} hover-class="none">
<View className="item-img">
<Image className="img" src={getImgUrl(item.image_url, 140, 140)} mode="aspectFit"/>
</View>
<View className="product-dec">
<Text className="item-name">{item.product_name}</Text>
<View className="item-code">货号 {item.product_code}</View>
</View>
</View>
</View>
)
})
}
</View>
)
})
}
</ScrollView>
}
</View>
)
}
}