forked from alibaba/weex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brand.we
53 lines (52 loc) · 1.26 KB
/
brand.we
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
<template>
<container class="container">
<image if={{ds.floorTitle}} class="title" src="{{ds.floorTitle}}"></image>
<container style="margin-left:4;margin-right:4">
<banners ds="{{bannerItems}}" direction="column" width="{{NUMBER_742}}" height="{{NUMBER_230}}"
space="{{NUMBER_4}}"></banners>
</container>
</container>
</template>
<style>
.title {
width: 750;
height: 100;
}
.container {
margin-bottom: 4;
background-color:#C0BABC;
}
</style>
<script>
module.exports = {
data: {
NUMBER_742: 742,
NUMBER_230: 230,
NUMBER_4: 4
},
methods: {
ready: function () {
var self = this;
self._randomBrand();
},
_randomBrand: function () {
var self = this;
var bannerItems = self.ds.bannerItems;
bannerItems = bannerItems.sort(function(){
return Math.random()-0.5;
});
self.bannerItems = bannerItems.slice(0,8);
for(var i=0;i<bannerItems.length;i++){
var item = bannerItems[i];
if(i%2===0){
item.img = item.leftImg;
item.url = item.rightUrl;
}else{
item.img = item.rightImg;
item.url = item.rightUrl;
}
}
}
}
}
</script>