小程序中的左右布局商品分类

左右布局分类效果图

实现逻辑

页面布局 

<!--pages/member/brand/brand.wxml-->
<view class="box">
  <view class="b_top">
    <view class="b_Search">
      <text class="iconfont iconsousuo" bindtap="search"></text>
      <input class="b_Search_input dib" bindinput="searchVal"></input>
    </view>
  </view>
  <view class="b_baner">
    <view wx:if="{{show}}" class="mask" bindtap="Notype"></view>
    <view wx:if="{{show}}" class="modalDlg">
      <view class="b_right_top" bindtap="Notype">
        <text class="b_right_top_fen fr">{{mold}}</text>
        <text class="iconfont iconshaixuan1"></text>
      </view>
      <view class="modalDlg_c">
        <!-- <view class="modalDlg_c_t Selection">全部</view> -->
        <block wx:for="{{types}}" wx:key="index">
          <view class="modalDlg_c_t {{typeId == index ? 'Selection' : ''}}" bindtap="typtTap" data-t="{{index}}">{{item.Name}}</view>
        </block>
        <!-- <view class="modalDlg_c_t">化妆品</view>
        <view class="modalDlg_c_t">精品</view>
        <view class="modalDlg_c_t">服饰</view>
        <view class="modalDlg_c_t">运动</view> -->
        <view class="modalDlg_none"></view>
        <view class="modalDlg_none"></view>
      </view>
    </view>
    <view class="b_left">
      <!-- <view class="b_left_text b_left_bf">全部</view> -->
      <block wx:for="{{foots}}" wx:key="index">
        <!-- <scroll-view class="b_left_text {{footId == index ? 'b_left_bf' : ''}}" bindtap="footTap" data-F="{{index}}" scroll-x="true" style='width:100%;'>
          {{item.FloorName}}
        </scroll-view> -->
        <view class="b_left_text {{footId == index ? 'b_left_bf' : ''}}" bindtap="footTap" data-F="{{index}}">{{item.FloorName}}</view>
      </block>
      <!-- <view class="b_left_text">一楼</view>
      <view class="b_left_text">二楼</view>
      <view class="b_left_text">三楼</view>
      <view class="b_left_text">四楼</view>
      <view class="b_left_text">五楼</view>
      <view class="b_left_text">负一</view>
      <view class="b_left_text">负二</view> -->
    </view>
    <view class="b_right">
      <view class="b_right_top" bindtap="type">
        <text class="b_right_top_fen fr">{{mold}}</text>
        <text class="iconfont iconshaixuan1"></text>
      </view>
      <block wx:for="{{brands}}" wx:key="index">
        <view class="b_right_content">
          <view class="b_right_content_left">
            <image src="{{item.Logo}}" class="b_r_c_l_i"></image>
          </view>
          <view class="b_right_content_right">
            <view class="b_right_content_right_top">
              <text class="b_name">{{item.Name}}</text>
              <text class="b_type fr">{{item.CatalogName}}</text>
            </view>
            <view class="b_right_content_right_bottom">
              <view class="dib">
                <text class="iconfont iconweizhi"></text>
                <text class="b_f">{{item.FloorName}}</text>
              </view>
              <text class="iconfont icondianhua1 fr {{skinStyle}}-item" bindtap="tel" data-tel="{{item.Phone}}"></text>
            </view>
          </view>
        </view>
      </block>
      <!-- <view class="b_right_content">
        <view class="b_right_content_left">
          <image src="/res/image/ysld.png" class="b_r_c_l_i"></image>
        </view>
        <view class="b_right_content_right">
          <view class="b_right_content_right_top">
            <text class="b_name">雅诗兰黛</text>
            <text class="b_type fr">化妆品</text>
          </view>
          <view class="b_right_content_right_bottom">
            <view class="dib">
              <text class="iconfont iconweizhi"></text>
              <text class="b_f">F1 103</text>
            </view>
            <text class="iconfont icondianhua1 fr"></text>
          </view>
        </view>
      </view> -->
    </view>
  </view>
</view>

 样式

/* pages/member/brand/brand.wxss */

.box {
  width: 100%;
  height: 100%;
  background: #fff;
}

.b_top {
  width: 100%;
  height: 90rpx;
  border-bottom: 1rpx solid rgba(226, 226, 226, 1);
}

.b_Search {
  width: 676rpx;
  height: 68rpx;
  margin: 0 auto;
  background: rgba(245, 246, 247, 1);
  border-radius: 34rpx;
  /* line-height: 68rpx; */
  display: flex;
  align-items: center;
}

.iconsousuo {
  margin-left: 32rpx;
  font-size: 26rpx;
  color: rgba(205, 205, 205, 1);
}

.b_Search_input {
  width: 500rpx;
  margin-left: 10rpx;
}

.b_baner {
  display: flex;
  justify-content: space-around;
  position: relative;
}

.b_left {
  width: 186rpx;
  height: 100vh;
  border-right: 1rpx solid rgba(226, 226, 226, 1);
}

.b_left_text {
  white-space: nowrap;
  width: 100%;
  height: 102rpx;
  text-align: center;
  line-height: 102rpx;
  font-size: 28rpx;
  font-family: Microsoft YaHei Regular;
  color: rgba(51, 51, 51, 1);
}

.b_left_bf {
  position: relative;
}

.b_left_bf::before {
  content: '';
  width: 59rpx;
  height: 6rpx;
  background: rgba(91, 161, 231, 1);
  position: absolute;
  left: 50%;
  right: 50%;
  transform: translate(-50%, -50%);
  bottom: 20rpx;
}
.b_right {
  width: 100%;
  height: 100%;
}

.b_right_top {
  width: 100%;
  height: 102rpx;
  border-bottom: 1rpx solid rgba(226, 226, 226, 1);
  line-height: 102rpx;
  position: relative;
}

.b_right_top_fen {
  font-size: 30rpx;
  font-family: Microsoft YaHei Regular;
  color: rgba(51, 51, 51, 1);
  margin-right: 78rpx;
}

.iconshaixuan1 {
  font-size: 32rpx;
  color: #cdcdcd;
  position: absolute;
  right: 33rpx;
}

.b_right_content {
  width: 100%;
  height: 192rpx;
  display: flex;
  align-items: center;
}

.b_right_content_left {
  width: 117rpx;
  height: 117rpx;
  border: 1rpx solid #e2e2e2;
  border-radius: 50%;
  margin-left: 15rpx;
  margin-right: 23rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.b_r_c_l_i {
  border-radius: 50%;
}

.b_right_content_right {
  width: 430rpx;
  height: 192rpx;
  border-bottom: 1rpx solid rgba(226, 226, 226, 1);
}

.b_right_content_right_top {
  margin-top: 37rpx;
}

.b_name {
  font-size: 28rpx;
  font-family: Microsoft YaHei Regular;
  color: rgba(51, 51, 51, 1);
}

.b_type {
  font-size: 24rpx;
  font-family: Microsoft YaHei Light;
  color: rgba(153, 153, 153, 1);
  margin-right: 34rpx;
}

.b_right_content_right_bottom {
  margin-top: 54rpx;
}

.iconweizhi {
  font-size: 22rpx;
  color: rgba(205, 205, 205, 1);
  margin-right: 10rpx;
}

.b_f {
  font-size: 26rpx;
  font-family: Microsoft YaHei Light;
  font-weight: initial;
  color: rgba(102, 102, 102, 1);
}

.icondianhua1 {
  font-size: 46rpx;
  color: rgba(91, 161, 231, 1);
  margin-right: 34rpx;
}

/* 弹窗 */

.mask {
  width: 100%;
  height: 100%;
  position: absolute;
  /* top: 90rpx; */
  top: 0;
  left: 0;
  background: #000;
  z-index: 900;
  opacity: 0.3;
}

.modalDlg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: #fff;
  z-index: 999;
}

.modalDlg_c {
  width: 100%;
  height: 100%;
  padding-top: 47rpx;
  padding-left:40rpx;
  padding-right: 30rpx; 
  padding-bottom: 60rpx;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.modalDlg_c_t {
  width: 151rpx;
  height: 52rpx;
  font-size: 24rpx;
  line-height: 52rpx;
  border-radius: 26rpx 26rpx 26rpx 26rpx;
  text-align: center;
  background: rgba(255, 255, 255, 1);
  border: 1rpx solid #cdcdcd;
}
.modalDlg_none{
  width: 151rpx;
  height: 0rpx;
}
.Selection {
  background: rgba(205, 223, 240, 1);
  border: 1rpx solid #0579cb;
}

 逻辑代码

// pages/member/brand/brand.js
const http = require('../../../server/request.js');
//调用公共js对象以便调用其方法
var app = require('../../../utils/uselogn.js'); //获取应用实例
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    brands: [],
    foots: [{
      FloorName: '全部'
    }],
    types: [{
      Name: '全部'
    }],
    footId: '',
    typeId: '',
    mold: '分类',
    CodeOrName: '',
    FloorCode:'',
    ClassCode:'',
    searchValue: '',
    skinStyle: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    app.userLogin(this.authCallback);
    let skin = wx.getStorageSync("skin");
    this.setData({
      skinStyle: skin
    })
  },
  authCallback: function () {
    this.getBrandGuideInfo();
    this.getFloorListInfo();
    this.getClassInfo();
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {
    this.setData({
      foots: [{
        FloorName: '全部'
      }],
      types: [{
        Name: '全部'
      }],
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  // 分类
  type() {
    this.setData({
      show: true
    })
  },
  // 关闭分类
  Notype() {
    this.setData({
      show: false
    })
  },
  // 搜索信息
  searchVal(e) {
    console.log(e.detail.value)
    this.setData({
      searchValue: e.detail.value
    })
  },
  // 搜索品牌
  search() {
    this.setData({
      CodeOrName: this.data.searchValue
    })
    // 根据输入请求品牌
    this.getBrandGuideInfo();
  },
  // 切换楼层
  footTap(e) {
    console.log(e.target.dataset.f)
    if (e.target.dataset.f > 0) {
      let index = e.target.dataset.f;
      let value = this.data.foots[index].FloorId;
      this.setData({
        FloorCode: value
      })
    } else {
      this.setData({
        FloorCode: ''
      })
    }
    // 根据楼层请求数据
    this.getBrandGuideInfo();
    this.setData({
      footId: e.target.dataset.f
    })
  },
  // 切换分类
  typtTap(e) {
    if (e.target.dataset.t > 0) {
      let index = e.target.dataset.t;
      let value = this.data.types[index].Id;
      let name = this.data.types[index].Name;
      this.setData({
        mold: name,
        ClassCode: value
      })
    } else {
      this.setData({
        mold: "分类",
        ClassCode: ''
      })
    }
    // 根据类别请求数据
    this.getBrandGuideInfo();
    this.setData({
      typeId: e.target.dataset.t
    })
  },
  // 拨打电话
  tel(e) {
    console.log(e.currentTarget.dataset.tel)
    if (e.currentTarget.dataset.tel == null) {
      wx.showToast({
        title: '该商家还没有电话',
        icon: 'none'
      })
    }
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.tel
    })
  },
  // 获取品牌导视信息
  getBrandGuideInfo() {
    http.requestLoading('api/services/app/MemberIndexService/GetBrandGuideInfo', {
      CodeOrName: this.data.CodeOrName,
      FloorCode: this.data.FloorCode,
      ClassCode: this.data.ClassCode
    }, '', 'GET').then(res => {
      if (res.data.Result.Code == 0) {
        console.log(res)
        this.setData({
          brands: res.data.Result.Data
        })
      }
    })
  },
  // 获取楼层列表
  getFloorListInfo() {
    http.requestLoading('api/services/app/MemberIndexService/GetFloorListInfo', '', '', 'GET').then(res => {
      if (res.data.Result.Code == 0) {
        console.log(res)
        this.setData({
          foots: this.data.foots.concat(res.data.Result.Data)
        })
      }
    })
  },
  // 获取分类信息
  getClassInfo() {
    http.requestLoading('api/services/app/MemberIndexService/GetClassInfo', '', '', 'GET').then(res => {
      if (res.data.Result.Code == 0) {
        console.log(res)
        this.setData({
          types: this.data.types.concat(res.data.Result.Data)
        })
      }
    })
  }
})

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
Jshop小程序商城,是一款开源的电商系统,包含微信小程序、支付宝小程序、APP、公众号和H5端,为大小企业提供移动电子商务优秀的解决方案。 后台采用Thinkphp5.1框架开发,执行效率、扩展性、稳定性值得信赖。并且Jshop小程序商城上手难度低,可大量节省定制化开发周期。 前台H5使用Vue开发,在页面的打开和渲染效率上更快,下单流程流畅自然,可大大增加用户体验,提升订单量。 强大的促销引擎,多种促销方式自由搭配,满足各种场景的促销方式需求,做活动更灵活简单,并且在促销的扩展上也非常方便。 最新uniapp简约模板介绍 uni-app简约序模板,全新UI设计,更多交互细节,我们倾尽全力为您提供更加流畅舒爽的体验,增加对支付宝小程序、APP的支持,实现一个后台,管理5个前端。 同时又实现了一套前端代码,发布多个平台,为您的业务可以提供更加强有力的支撑! 关于开源 这不是一款免费的系统,商用记得授权哦。 之所以不彻底免费,一方面是可以让我们有持续维护下去的动力和资源,另外一方面也是不想让您有后顾之忧,避免后期尴尬。 我们的团队水平有限,也是在探索学习,在改进。之所以开源,就是为了方便大家,也是为了提升下该项目的质量,我们相信有您的参与,可以使我们的系统更加完善和健壮。 功能介绍 商品管理,单规格、多规格商品管理,品牌、分类管理、商品评价 订单管理,订单支付、发货、取消、售后等 会员管理,会员列表,消息管理等 运营管理,广告管理、文章管理 微信管理,小程序管理、微信公众号管理、模板列表、公众号菜单管理 促销管理,商品促销、订单促销、优惠券、团购秒杀、拼团列表 财务管理,支付单、退款单管理、提现管理、账户资金管理 控制面板,计划任务、插件、图片、地区、消息、店铺配置、支付方式、配送方式、物流公司管理。信任登录插件、阿里云OSS插件、阿里云短信插件、微信消息模板插件、分销心、PC设置 门店管理,门店列表。门店核销、店员管理、提货单管理。 智能表单,表单列表、表单统计、表单提交管理、表单小程序码等 统计报表,商品销量统计、财务收款统计、订单销量统计 页面管理,布局管理,页面可视化操作 H5端说明 H5端采用Vue开发,数据和页面分离,封装APP时体验效果也更好。H5端可以放在离客户最近的地方,比如单独服务器、电脑桌面、PAD、手机、广告机等。 智能表单说明 智能表单包含有:订单、付款码、留言、反馈、登记、调研这几种类型,可实现店铺收款、门店内扫码下单、活动预约、活动预定、会议登记、在线报名、上课签到等等。 智能表单可以为您的线上线下结合提供更强大的助力。 目录结构 初始的目录结构如下: wwwroot  WEB部署目录(或者子目录) ├─addons                应用插件目录 ├─application           应用目录 │  ├─api                api接口模块目录 │  ├─b2c                前台模块 │  ├─common             公共模块目录 │  ├─crontab            定时任务目录 │  ├─job                任务队列目录 │  ├─manage             后台管理目录 │  ├─wechat             接收微信消息目录 │  ├─command.php        命令行工具配置文件 │  ├─common.php         公共函数文件 │  ├─tags.php           应用行为扩展定义文件 │ ├─config                配置文件目录 ├─h5                    前台H5源码 ├─public                WEB目录(对外访问目录) │  ├─install            自动安装目录 │  ├─static             前台静态文件 │  ├─wap                前台手机端运行目录 │  ├─index.php          入口文件 │  └─.htaccess          用于apache的重写 │ ├─thinkphp              thinkphp框架系统目录 ├─update                版本升级包 ├─extend                扩展类库目录 ├─runtime               应用的运行时目录(可写,可定制) ├─vendor                第三方类库目录(Composer依赖库) ├─wechat_app            微信小程序源码

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

耀南.

你的鼓励将是我最最最最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值