微信小程序折叠面板 (类似手风琴 收起展开一样的噢)

效果图微信小程序折叠面板 (类似手风琴 收起展开一样的噢)_第1张图片微信小程序折叠面板 (类似手风琴 收起展开一样的噢)_第2张图片

sass/lsee 转换css 网站 SASS 转 CSS 工具,在线 SASS/SCSS 编译工具 - 在线工具-wetools.com微工具

wxml

 
  
   
    
      
        
          
            
          
          {{item.questions}}
        
        
          
          
        
      
      
      
      
        
          
            
          
          
            
              {{item.answers}}
            
          
        
      
    

  

js

data:{
 // 显示的下标
    showIndex: false,
    // 数据源
     questList: [
      {
        questions: '是否需要预约?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: true,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '会否出报告?报告是纸质还是电子版的?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '报告是现场给吗?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '我的猫狗需要提前准备什么吗?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '我的猫狗体检的时候,我可以在旁边吗?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '我的猫狗刚刚做过检查,我可以不重复做同样?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      },
      {
        questions: '我的猫狗在检查过程中发现有比较严重的问题?',
        answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
        t: false,
        // icon q 
        icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
        // icon a
        icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
        // 下箭头
        icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
        // 上箭头
        icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
      }
    ],

},

  // 折叠面板 展开收起的方法
  changOpen(e) {
    this.data.questList[e.currentTarget.dataset.index].t = !this.data.questList[e.currentTarget.dataset.index].t
    this.setData({
      questList: this.data.questList
    })
    if (e.currentTarget.dataset.index != this.data.showIndex) {
      // console.log('true的时候');
      this.setData({
        showIndex: e.currentTarget.dataset.index,
      })
    }
    else {
      // console.log('false的时候');
      this.setData({
        showIndex: 10
      })
    }

  },


wxss

.mt-20 {
  margin-top: 40rpx;
}

.mt-10 {
  margin-top: 20rpx;
}

.ml-10 {
  margin-left: 20rpx;
}



.mb-20 {
  margin-bottom: 40rpx;
}

.ml-10 {
  margin-left: 20rpx;
}

.b {

  font-weight: bold;
}

.font-14 {
  font-size: 28rpx;
}

.pr-20 {
  padding-right: 40rpx;
}

.flex{
  display: flex;
}



.problem2 {
  min-height: 0rpx;
  background-color: #fff;
  margin: 20rpx;
  margin-top: 40rpx;
  border-radius: 40rpx;
  padding: 34rpx;

  // 每一项
  .problem2-item {
    border-bottom: 1px solid #f5f3ed;
    padding: 30rpx 0;

    // 标题  
    .problem2-item-title {
      display: flex;
      justify-content: space-between;

      >view:nth-child(1) {
        display: flex;

        >view:nth-child(1) {
          margin-top: 2rpx;
          width: 32rpx;
          border-radius: 50%;

          image {
            width: 100%;
            height: 100%;
          }
        }
      }


      >view:nth-child(2) {
        width: 11px;
        height: 6px;
        border: 50%;

        image {
          width: 100%;
          height: 100%;
        }
      }

    }

    // 问题区域
    .detailedquestions {
      border-right-color: seagreen;

      .l {
        margin-top: 10rpx;
        width: 32rpx;
        height: 32rpx;
        // background-color: pink;

        image {
          width: 32rpx;
          height: 32rpx;
        }
      }
    }
  }
}

你可能感兴趣的:(微信小程序,前端,小程序)