当前位置: 首页 > article >正文

微信小程序实现【点击 滑动 评分 评星(5星)】功能

wxml文件:

    <view class="wxpl_xing">
      <view class="manyidu">{{scoreContent}}</view>
      <view>
        <block wx:for='{{scoreArray}}' wx:for-item="item">
          <view class='starLen' bindtap='changeScore' data-sy="{{index}}">
            <image class='star' src="{{score>index?fullStarUrl:nullStarUrl}}" />
          </view>
        </block>
      </view>
    </view>

js文件:

Page({
  data: {
    bsm: '', //标识码
    fullStarUrl: '../../images/fullStar.png', //满星图片
    nullStarUrl: '../../images/nullStar.png', //空星图片
    score: 0, //评价分数
    scoreArray: [0, 1, 2, 3, 4, 5], //5.非常满意,4.满意,3.比较满意,2.一般,1.不满意,0.非常不满意
    scoreText: ['非常不满意', '不满意', '一般', '比较满意', '满意', '非常满意'], //评分列表
    scoreContent: '' //文字显示评分情况
  },
  changeScore: function (e) {
    var that = this;
    var wxsy = e.currentTarget.dataset.sy
    that.setData({
      score: wxsy+1,
      scoreContent: that.data.scoreText[wxsy]
    }) 
  },
})

wxss文件:

.wxpl_xing{ position: fixed; background: #fff; height:240px; bottom: 0px; width: 100%; z-index: 11; display: flex; align-items: center; justify-content: center; flex-direction: column;}
.manyidu{ font-size:28rpx; padding-bottom: 30rpx; height: 40rpx; line-height: 40rpx;}
.starLen{margin-right:10px;display:inline-block}
.star{width:30px;height:30px;vertical-align:text-bottom;display:inline-block}
.scoreContent{margin-left:100px;display:inline-block}


http://www.kler.cn/a/144961.html

相关文章:

  • C语言指针专题四 -- 多级指针
  • Docker技术简介
  • AI DeepSeek-R1 Windos 10 环境搭建
  • JSR303校验教学
  • CentOS 7 搭建lsyncd实现文件实时同步 —— 筑梦之路
  • 开发环境搭建-4:WSL 配置 docker 运行环境
  • 2 时间序列预测入门:GRU
  • Scrapy爬虫异步框架(一篇文章齐全)
  • leetcode设计循环队列(链表方式来实现)
  • STM32分区跳转问题
  • Go 本地搭建playground
  • 漏电流直流互感器1-50ua
  • 2023.11.23使用flask实现在指定路径生成文件夹操作
  • Android flutter this and base files have different roots
  • 【Go实现】实践GoF的23种设计模式:备忘录模式
  • 世岩清上:未来科技展览的策展视野
  • 【开源】基于JAVA的车险自助理赔系统
  • PasteNow for mac剪贴板工具
  • 本地缓存与分布式缓存
  • 【SpringCloud】设计原则之分层架构与统一通信协议
  • 20231125硬盘电源线5线不能识别日立10T的硬盘的解决方法
  • 01、Tensorflow实现二元手写数字识别
  • Spring Boot WebSocket 客户端
  • Android 匿名内存深入分析
  • OpenCV快速入门:相机标定——单目视觉和双目视觉
  • Flask,uWSGI,nginx的理解