Authored by 肖亚东

首页banner和热门品类组件提交 — review by 黄敬囿

1 Component({ 1 Component({
2 properties: { 2 properties: {
3 - 3 + bannerList: {
  4 + type: Array,
  5 + value: []
  6 + }
4 }, 7 },
5 data: { 8 data: {
6 9
1 -<swiper class="swiper" indicator-dots="true" autoplay="true"  
2 -interval="3500" circular='true' indicator-color='rgba(255,255,255,0.2)' indicator-active-color="rgba(255,255,255,1)">  
3 - <block wx:for="{{data}}" wx:key="{{index}}"> 1 +<swiper class="banner" indicator-dots="true" autoplay="true"
  2 +interval="3500" circular="true" indicator-color='rgba(255,255,255,0.2)'
  3 + indicator-active-color="rgba(255,255,255,1)">
  4 + <block wx:for="{{ bannerList }}" wx:key="{{index}}">
4 <swiper-item> 5 <swiper-item>
5 - <image src="{{item.src}}" class="new-focus-img-1" mode=' scaleToFill 'data-url="{{item.url}}" data-src='{{item._src}}  
6 - 'data-type="go.list" data-title='{{item.title}} 'data-jump_rule="{{item.url}}" data-f_id="{{f_id}}" data-f_index='{{f_index}}  
7 - ' bindtap="jumpByRule" data-f_inindex='{{index}} ' data-f_name='{{f_name}} '/> 6 + <image src="{{item.src}}" class="new-focus-img"
  7 + mode="aspectFill "data-url="{{item.url}}"
  8 + data-src="{{item._src}}" data-type="go.list"
  9 + data-title="{{item.title}}" data-jump_rule="{{item.url}}"
  10 + data-f_id="{{f_id}}" data-f_index="{{f_index}}"
  11 + bindtap="jumpByRule" data-f_inindex="{{index}}"
  12 + data-f_name="{{f_name}}"/>
8 </swiper-item> 13 </swiper-item>
9 </block> 14 </block>
10 - </swiper>  
  15 +</swiper>
  1 +.banner {
  2 + width: 750rpx;
  3 + height: 562rpx;
  4 +}
  5 +
  6 +.banner .wx-swiper-dots.wx-swiper-dots-horizontal{
  7 + margin-bottom: -8rpx;
  8 + padding-left: 15rpx;
  9 + padding-right: 10rpx;
  10 + padding-top: 5rpx;
  11 + padding-bottom: 5rpx;
  12 + border-radius: 40rpx;
  13 + background: rgba(0,0,0,0.2);
  14 +}
  15 +
  16 +.banner .wx-swiper-dot{
  17 + width:10rpx;
  18 + display: inline-flex;
  19 + height: 10rpx;
  20 + margin-left: -5rpx;
  21 + justify-content:space-between;
  22 +}
  23 +
  24 +.new-focus-img {
  25 + width: 100%;
  26 + height: 100%;
  27 +}
  1 +Component({
  2 + properties: {
  3 + categoryList: {
  4 + type: Array,
  5 + value: []
  6 + }
  7 + },
  8 + data: {
  9 + windowWidth: 750
  10 + },
  11 + methods: {
  12 +
  13 + }
  14 +})
  1 +{
  2 + "component": true
  3 +}
  1 + <view class="catgoryContainer">
  2 + <block wx:for="{{categoryList}}" wx:key="{{index}}">
  3 + <view class="category" bindtap="jumpByRule" style="width: {{(750 - 3)/4}}rpx;border-right:{{index % 4 == 3 ? '0rpx' : '1rpx #dddddd solid;'}}"
  4 + data-jump_rule="{{item.url}}" data-url="{{item.url}}"
  5 + data-index="{{index}}"data-f_id="{{f_id}}"
  6 + data-f_index='{{f_index}}' data-f_inindex='{{index}}'
  7 + data-f_name='{{f_name}}'>
  8 + <image class="categoryImage" src="{{item.src}}"
  9 + style="height: {{(windowWidth-3)/4 + 10}}rpx;" mode="aspectFill"/>
  10 + </view>
  11 + </block>
  12 + </view>
  1 +
  2 +.catgoryContainer {
  3 + display: flex;
  4 + flex-direction: row;
  5 + flex-wrap: wrap;
  6 + background-color: white;
  7 + border-top: 1rpx solid #dddddd;
  8 +}
  9 +.category {
  10 + display: flex;
  11 + flex-direction: column;
  12 + align-items: center;
  13 + border-bottom: 1rpx solid #dddddd;
  14 +}
  15 +.categoryImage {
  16 + width: 100%;
  17 +}
@@ -2,9 +2,27 @@ const app = getApp() @@ -2,9 +2,27 @@ const app = getApp()
2 2
3 Page({ 3 Page({
4 data: { 4 data: {
5 - 5 + 'bannerList': [
  6 + {'src': 'http://img10.static.yhbimg.com/yhb-img01/2018/11/16/09/0159de652b1e164b2166e7665a0c329e4d.jpg'},
  7 + {'src': 'http://img10.static.yhbimg.com/yhb-img01/2018/11/16/09/0159de652b1e164b2166e7665a0c329e4d.jpg'},
  8 + {'src': 'http://img10.static.yhbimg.com/yhb-img01/2018/11/16/09/0159de652b1e164b2166e7665a0c329e4d.jpg'}
  9 + ],
  10 + 'categoryList': [
  11 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  12 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  13 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  14 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  15 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  16 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  17 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  18 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  19 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  20 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  21 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'},
  22 + {'src': 'http://img11.static.yhbimg.com/yhb-img01/2018/11/19/10/016b55c411c314f020b943e3cd663299a7.jpg'}
  23 + ]
6 }, 24 },
7 onLoad: function () { 25 onLoad: function () {
8 - console.log('头条小程序代码片段,可点击以下链接查看代码片段的详细文档') 26 +
9 }, 27 },
10 }) 28 })
  1 +{
  2 + "usingComponents": {
  3 + "home-banner": "../../components/home-banner/home-banner",
  4 + "home-hot-category": "../../components/home-hot-category/home-hot-category"
  5 + }
  6 +}
1 -<view class="intro">欢迎使用代码片段,可在控制台查看代码片段的说明和文档</view>  
  1 +<home-banner banner-list="{{bannerList}}"></home-banner>
  2 +<home-hot-category category-list="{{categoryList}}"></home-hot-category>