分类

作者: 前端许 | 来源:发表于2022-01-13 18:51 被阅读0次

<view class="box">

  <view class="fenlei">

    <scroll-view scroll-y="true" style="height: 100vh;">

      <view class="{{countindex==index?'active':''}} fenlei-item" wx:for="{{categories}}" wx:key="index" wx:for-item="categories" bindtap="get" data-children="{{categories.children}}" data-index="{{index}}">

        {{categories.name}}

      </view>

    </scroll-view>

  </view>

  <view class="content">

    <scroll-view scroll-y="true" style="height: 100vh;">

      <view wx:for="{{categories}}" wx:key="index" wx:for-item="icon">

        <view wx:for="{{icon.children}}" wx:key="index" wx:for-item="list">

          <block wx:if="{{pid==icon.id}}">

            {{list.name}}

          </block>

        </view>

      </view>

.box {

  display: flex;

}

.fenlei {

  height: 100vh;

  background: #ccc;

}

.content {

  flex: 1;

  height: 100vh;

  background: red;

}

.fenlei-item {

  width: 100%;

  line-height: 150rpx;

  text-align: center;

  background-color: #F7F8FA;

  box-sizing: border-box;

  border-bottom: 1px dashed #ccc;

}

.active {

  border-left: 5px solid rgb(64, 180, 70);

  background: #ccc;

}

Page({

  /**

  * 页面的初始数据

  */

  data: {

    categories: [],

    children: [],

    countindex: 0,

    pid: 1

  },

  get(e) {

    let index = e.currentTarget.dataset.index

    // console.log(e.currentTarget.dataset.id);

    // console.log(e.currentTarget.dataset.children);

    // console.log(e.currentTarget.dataset.index);

    if (this.data.countindex != index) {

      this.setData({

        countindex: index

      })

    }

    this.setData({

      children: e.currentTarget.dataset.children,

    })

    this.data.children.forEach(r => {

      this.setData({

        pid: r.pid

      })

      console.log(this.data.pid);

    })

  },

  /**

  * 生命周期函数--监听页面加载

  */

  onLoad: function (options) {

    wx.request({

      method: 'GET',

      url: '路径',

      header: {

        Authorization: wx.getStorageSync('token')

      },

      success: (res => {

        // console.log(res);

        this.setData({

          categories: res.data.categories

        })

        // console.log(res.data.categories);

      })

    })

  },

  /**

  * 生命周期函数--监听页面初次渲染完成

  */

  onReady: function () {

  },

  /**

  * 生命周期函数--监听页面显示

  */

  onShow: function () {

  },

  /**

  * 生命周期函数--监听页面隐藏

  */

  onHide: function () {

  },

  /**

  * 生命周期函数--监听页面卸载

  */

  onUnload: function () {

  },

  /**

  * 页面相关事件处理函数--监听用户下拉动作

  */

  onPullDownRefresh: function () {

  },

  /**

  * 页面上拉触底事件的处理函数

  */

  onReachBottom: function () {

  },

  /**

  * 用户点击右上角分享

  */

  onShareAppMessage: function () {

  }

})

    </scroll-view>

  </view>

</view>

相关文章

  • 一次性产品

    包装材质分类 牙具分类 牙膏分类 梳子分类 拖鞋材质

  • 一明音频6按次序表答

    分类演讲,有条理,按男女分类,年龄分类,籍贯分类,其它。职业分类,戴眼镜,头发分类,例如对深圳的认识?一,天气,二...

  • 客户分类

    酒店布草租赁项目:市场细分是动脑干活的基础!数量分类、地域分类、男女分类、品牌分类、出租率分类、价格分类等等!举例...

  • 分类页面通用变量

    $sortid分类id $sortName分类名称 $template分类模版 $lognum该分类文章数 $so...

  • Excel学习笔记5

    知识点 1.分类汇总工具 -必须先排序再分类汇总 分类字段 -分类汇总-全部删除 可以撤销掉之前的分类汇总 -分类...

  • 生活垃圾分类

    1、什么是垃圾分类 生活垃圾分类通俗得说就是在源头将生活垃圾进行分类投放,并通过分类收集、分类运输和分类处理,力争...

  • 机器学习之分类器

    0、分类器热身,NextStep比较懒,直接看图 分类分类,先分解再分类,比如,疾病分类模型先将病情的表现信息进行...

  • 商品管理案例——案例准备

    一、案例的概述 1、案例实现的功能 分类管理  查询分类  添加分类  删除分类  修改分类 商品管理  查询商品...

  • 分类(Category)与类拓展(Extension)

    分类(Category) 1.分类(Category)是什么? 分类是oc特有的语法,表示指向分类的结构体指针。分...

  • Emlog531获取指定分类的子分类信息

    //获得指定分类的子分类,参数为分类ID function getsubcategoryinfo($categor...

网友评论

      本文标题:分类

      本文链接:https://www.haomeiwen.com/subject/mkxocrtx.html