【微信小程序】仿某品会某菇街商城商品分类

个人觉得商城类小程序某品会和某菇街是做的比较好的,看了一下新电商的商品分类,相对于老的商城那种顶部分类比较新颖,就仿做了一个。

新电商平台商品分类效果图(图片来源蘑菇街,图侵删)


蘑菇街商品分类

相对于传统电商的一行title右滑,感觉是我喜欢的风格,挺简洁好看的。
蘑菇街的商品分类分为两部分,左边为商品的所有分类,右边为每个分类对应的商品细分并加上推荐的一些商品。要注意的是:

  • 左边的商品种类是固定的高度(屏幕高度 - 已用的屏幕高度),在当前页可以看完所有分类,没有遮挡住分类,用户体验好。
  • 右边的就是可滑动的,注意是在给定的高度范围内滑动,用scroll-view,左右不影响。

挺简单的~先上我的效果图


上代码,有时候为了方便修改及看效果,某些样式我写在了页面中,习惯不好大家不要学哈。图标去阿里巴巴矢量图标库找合适的就好了。代码大家自己修改一下使用,左边商品分类我加了点击效果,还要在每次点击时清空右边的数据重新加载更新,因为没有接口有点麻烦就没有做。

【WXML】

<view class='positonNav'>
  <view class='horizontal '>
    <view class='item'>
      <view class='horizontal' style='background:#efefef;padding:4px 8px;'>
        <view style='width:40rpx;height:40rpx;margin:auto;padding-right:8px;'>
          <image src='../../imgs/search.png' style='width:100%;height:100%;'></image>
        </view>
        <view class='item'>
          <input placeholder='原宿风学生上衣' placeholder-style='color:#999;font-size:14px;'></input>
        </view>
      </view>
    </view>
    <view style='width:40rpx;height:40rpx;margin:auto;padding-left:10px;'>
      <image src='../../imgs/message.png' style='width:100%;height:100%;'></image>
    </view>
  </view>
</view>
<view style='width:100%;height:2px;background:#eee;'></view>
<view class='horizontal'>
  <view style='height: {{img_height}}px;width:20%;'>
    <view class='vertical'>
      <view wx:for='{{titlrBar}}' style='height: {{img_height/15}}px;line-height:{{img_height/15}}px;{{item === option ? "background: #fff;border-left:1px solid #f95a70;" : "background: #efefef;"}};text-align:center;' bindtap='clickTitle' data-title='{{item}}'>
        <text style='font-size: 14px;color:#000;{{item === option ? "color: #f95a70;font-weight: bold;" : "color: #333;"}}'>{{item}}</text>
      </view>
    </view>
  </view>
  <view class='item'>
    <scroll-view scroll-y style='height: {{img_height}}px;'>
      <view class='horizontal wrap'>
        <view wx:for='{{menu}}' class='menuView'>
          <view class='vertical'>
            <view class='item'>
              <view class='mune_img_view'>
                <image src='{{item.img}}'/>
              </view>
            </view>
            <view class='menu_text_view'>
              <text>{{item.name}}</text>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</view>

【WXSS】

.positonNav {
  top: 0px;
  position: sticky;
  position: -webkit-sticky;
  background-color: #fff;
  z-index: 9999;
  padding: 10px ;
}
.mune_img_view{
  width: 60px; 
  height: 60px; 
  margin: auto;
}
.mune_img_view > image{
  width: 100%; 
  height: 100%;
}
.menu_text_view{
  text-align: center; 
}
.menu_text_view > text{
  font-size: 14px; 
  color: #666;
}
.menuView{
  width: 33.3%; 
  padding: 5px 0;
}
.horizontal{
  display: flex;
  flex-direction: row;
}
.vertical{
  display: flex;
  flex-direction: column;
}
.item{
  flex: 1; 
}

之前漏了两个样式 ,补上

.nowrap {
  white-space: nowrap;
}

.wrap {
  flex-wrap: wrap;
}

【JS】

  data: {
    titlrBar:[
      '正在流行',
      '女装',
      '套装',
      '裙裤',
      '上衣',
      '家居',
      '女鞋',
      '男士',
      '母婴',
      '内衣',
      '美妆',
      '运动',
      '包包',
      '配饰',
      '食品'
    ],
    img_height:1,
    option:'正在流行',
    menu:[
      { name: '大衣', img: '../../imgs/dress/dayi.png' },
      { name: '牛仔裤', img: '../../imgs/dress/niuzhai.png' },
      { name: '连衣裙', img: '../../imgs/dress/lianyiqun.png' },
      { name: '秋裤', img: '../../imgs/dress/qiuku.png' },
      { name: '衬衫', img: '../../imgs/dress/chenshan.png' },
      { name: '帽子', img: '../../imgs/dress/maozi.png' },
      { name: '毛衣', img: '../../imgs/dress/maoyi.png' },
      { name: '大衣', img: '../../imgs/dress/dayi.png' },
      { name: '牛仔裤', img: '../../imgs/dress/niuzhai.png' },
      { name: '连衣裙', img: '../../imgs/dress/lianyiqun.png' },
      { name: '秋裤', img: '../../imgs/dress/qiuku.png' },
      { name: '衬衫', img: '../../imgs/dress/chenshan.png' },
      { name: '帽子', img: '../../imgs/dress/maozi.png' },
      { name: '毛衣', img: '../../imgs/dress/maoyi.png' },
      { name: '大衣', img: '../../imgs/dress/dayi.png' },
      { name: '牛仔裤', img: '../../imgs/dress/niuzhai.png' },
      { name: '连衣裙', img: '../../imgs/dress/lianyiqun.png' },
      { name: '秋裤', img: '../../imgs/dress/qiuku.png' },
      { name: '衬衫', img: '../../imgs/dress/chenshan.png' },
      { name: '帽子', img: '../../imgs/dress/maozi.png' },
      { name: '毛衣', img: '../../imgs/dress/maoyi.png' },
      { name: '毛衣', img: '../../imgs/dress/maoyi.png' },
      { name: '毛衣', img: '../../imgs/dress/maoyi.png' },
    ]
  },

  onLoad: function (options) {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          img_height: res.windowHeight -56,
        })
      }
    })
  },

  clickTitle:function(e){
    let that = this
    that.setData({
      option: e.currentTarget.dataset.title,
    })
  },

喜欢就点个赞再走呗,转发请注明出处。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 摘要: 社区是由共同爱好、需求的人组成的群体,社区涵盖了内容、互动,多种多样的形式。它实现了人与人、人与物的连...
    RInalina阅读 25,585评论 0 64
  • B2C垂直电商细分 淘宝的商品品类(SKU)是以数十亿计的,天猫和京东也应该在数千万的级别。海量的商品品类、鱼目混...
    ui_小鸡蛋阅读 764评论 0 1
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,252评论 4 61
  • 在图书馆看到这本书的时候,被它的名字所吸引《生命之轮》,我以为会讲述一些关于轮回,关于灵魂,关于生命。可是打开书看...
    魑魅魍魉吃下糯米粽子阅读 1,556评论 0 1
  • 结缘瑜伽: 十三年前(2005年6月),我对瑜伽完全不了解,只是隐约知道瑜伽是一种健身的方式,但一个偶然的机会我听...
    感恩瑜伽_感恩所有遇见阅读 583评论 0 0