微信小程序,循环下拉列表,点击时只展开其中一个「建议收藏」

微信小程序,循环下拉列表,点击时只展开其中一个这是效果1.wxml<!–bigwarp–><viewclass=”dewarp”><viewclass=’com-selectBox’wx:for=”{{detil}}”wx:for-item=”item”wx:key=””><viewclass=’co…

大家好,又见面了,我是你们的朋友全栈君。

微信小程序,循环下拉列表,点击时只展开其中一个

这是效果

微信小程序,循环下拉列表,点击时只展开其中一个「建议收藏」

1.wxml

<!-- bigwarp -->
<view class="dewarp">
<view class='com-selectBox'  wx:for="{
  
  {detil}}"  wx:for-item="item" wx:key="">
    <view class='com-sContent'  bindtap='showList' data-id='{
  
  {item.repairitemsetid}}'>
        <view class='com-sTxt'>{
  
  {item.repairitemsetname}}</view>
        <view class="caricon">
        <image data-id='{
  
  {id}}' src="../../images/icon/carDetails1.png" class='com-sImg {
  
  {imgshow&&"select_img_rotate"}}'  ></image></view>
    </view>
    <view class=" {
  
  {item.isShow?'show':'hide'}}" >
    <!--  -->
        <view wx:for="{
  
  {notice}}" wx:for-item="item" wx:key="" class='com-sItem'>
       <i-row >
       <!--  -->
       <i-col span="15" i-class=""> 
       <view class="cb">
       <checkbox-group bindchange="checkboxChange">
            <label class="checkbox">
              <checkbox value="{
  
  {item.name}}" checked="{
  
  {item.checked}}"/>{
  
  {item.repairitemname}}
            </label>
         </checkbox-group>
         </view>
     </i-col>
     <!--  -->
       <i-col span="9" i-class="carmoney">
        <view class="carpropectdo">
         <view class="carpropectdollows"><input></input>元</view>
        </view>
       </i-col>
       </i-row>
        </view>
        <!--  -->
    </view>
</view>
</view>
<!-- end -->

2,wxss

/* bigwarp */
.rotateRight{
  transform: rotate(180deg) 
}
.com-selectBox{
    width: 90%;
    margin: 0 auto;
}
.com-sContent{
    /* border: 1px solid #e2e2e2; */
    background: white;
    font-size: 16px;
    line-height: 30px;
    box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(85, 85, 85, 0.13);
    border-radius: 20rpx;
    height: 100rpx;
    margin-top: 40rpx;
    display: flex;
    justify-content:  space-between;
    align-items: center;
}
.com-sImg{
    width: 16px;
    height: 9px;
}
.caricon{
  /* border: 1px solid black; */
  right: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 15%;
  height: 100%;
}
.com-sTxt{
    width: 15%;
    /* border: 1px solid black; */
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.com-sList{
    box-shadow: 0rpx 2rpx 2rpx 2rpx rgba(85, 85, 85, 0.13);
    width: inherit;
    position: absolute;
    box-sizing: border-box;
    z-index: 3;
    max-height: 120px;
    overflow: auto;
}
.com-sItem{
    height: 55px;
    line-height: 35px;
    padding: 0 6px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
.com-sItem:first-child{
    border-top: none;
}
.dewarp{
  margin: 0 auto;
  width: 100%;
}
.carpropectdo{
  padding: 10px 10px;
}
.carpropectdollows{
  width:90%;
  border: 1rpx solid #D1D1D1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 10rpx;
  color: #999999;
  font-size: 32rpx;
  height: 27px;
}

.checkbox checkbox{
    padding:0 5rpx;
}
.checkbox{
  font-size: 13px;
}
.cb{
  padding: 13rpx 5rpx;
}

.hide{
    display: none;
}
.select_img_rotate{

  transform:rotate(180deg); 

}
/* end */

3.wxjs

// pages/a/a.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.login().then(() => {
      this.carDetailtitle(),
        this.carDetail()
    })
  },
  showList(e) {
    let index = 0;
    let arrayItem = this.data.detil;//获取循环数组对象
    for (let item of arrayItem) {
      //如果当前点击的对象id和循环对象里的id一致
      if (item.repairitemsetid == e.currentTarget.dataset.id ) {
        //判断当前对象中的isShow是否为true(true为显示,其他为隐藏) 
        if (arrayItem[index].isShow == "" || arrayItem[index].isShow == undefined) {
          arrayItem[index].isShow = "true"
          imgshow: !this.data.imgshow
        } else {
          arrayItem[index].isShow = ""
          imgshow: !this.data.imgshow
        }
      }
      index++;
    
      

    }
    //将数据动态绑定 
    this.setData({
      detil: arrayItem
    })
  },
  carDetailtitle(down) {
    var a = app.data
    libs.post('接口', {
      miniopenid: a.openid,
      carplate: a.carplate
    }, down).then(res => {
      console.log(JSON.parse(res))
      this.setData({
        detil: JSON.parse(res),
      })

    })
  },
  carDetail(down) {
    var a = app.data
    libs.post('接口', {
      miniopenid: a.openid,
      carplate: a.carplate,
      rcid: 7
    }, down).then(res => {
      console.log(JSON.parse(res))
      this.setData({
        notice: JSON.parse(res),
      })

    })
  },
  

  checkboxChange: function (e) {
    console.log('checkbox发生change事件,携带value值为:', e.detail.value)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

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

  },

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

  },

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

  },

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

  }
})

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127833.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • typescript 多继承_说明类的继承和多态有什么作用

    typescript 多继承_说明类的继承和多态有什么作用前言对于传统的JavaScript程序我们会使用函数和基于原型的继承来创建可重用的组件,但对于熟悉使用面向对象方式的程序员使用这些语法就有些棘手,因为他们用的是基于类的继承并且对象是由类构建出来

    2022年7月31日
    7
  • Drupal教程之安装篇

    Drupal教程之安装篇星期一,01/12/2009—似曾相识文章地址:[url]http://www.drupaluser.org/node/3[/url]象许多CMS一样,Drupal也是需要安装,其主要步骤如下(以[url]http://drupaluser.org/[/url]为例):1.在[url]http://drupaluser.org/[/u…

    2022年6月8日
    29
  • export在linux中用法_from . import

    export在linux中用法_from . import镜像下载、域名解析、时间同步请点击阿里云开源镜像站export命令用于将shell变量输出为环境变量,或者将shell函数输出为环境变量。一个变量创建时,它不会自动地为在它之后创建的shell进程所知。而命令export可以向后面的shell传递变量的值。命令语法export[参数]命令参数-f:指向函数。-n:删除变量的导出属性。-p:显示全部拥有导出属性的变量。-pf:显示全部拥有导出属性的函数。-nf:删除函数的导出属性。列出当前所有的环境变量>expo

    2025年9月27日
    3
  • idea mybatis跳转插件_idea添加本地jar包到maven

    idea mybatis跳转插件_idea添加本地jar包到maven我相信目前在绝大部分公司里,主要使用的框架是S(spring)S(springMVC)M(mybatis),其中mybatis总体架构是编写mapper接口,框架扫描其对应的mapper.xml文件,由于xml里面编写大量的sql语句,所以在平时调试中需要对其进行调试,但是xml文件并不能像java文件一样,能快速进行跳转,对查找对应xml文件带来巨大的不便。网友基础idea强大的插件系…

    2022年10月6日
    1
  • Android数据库框架——GreenDao轻量级的对象关系映射框架,永久告别sqlite

    Android数据库框架——GreenDao轻量级的对象关系映射框架,永久告别sqlite

    2021年9月16日
    60
  • 2021.7goland激活码【2021.7最新】

    (2021.7goland激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月21日
    39

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号