您好,登錄后才能下訂單哦!
本文實(shí)例講述了微信小程序?qū)崿F(xiàn)的五星評(píng)價(jià)功能。分享給大家供大家參考,具體如下:
實(shí)現(xiàn)五星評(píng)價(jià)功能,效果圖如下:
.wxml文件:
<view class="star-title">1、品質(zhì)效果</view> <view class="star-pos"> <image class='stars' bindtap="changeColor" data-index='0' data-no="{{item}}" wx:for="{{stardata}}" src="{{flag[0]>=item? '../../images/icon/star1.png': '../../images/icon/star0.png'}}" /> <view style='margin-left: 30rpx;'>{{startext[0]}}</view> </view> <view class="star-title">2、服務(wù)質(zhì)量</view> <view class="star-pos"> <image class='stars' bindtap="changeColor" data-index='1' data-no="{{item}}" wx:for="{{stardata}}" src="{{flag[1]>=item? '../../images/icon/star1.png': '../../images/icon/star0.png'}}" /> <view style='margin-left: 30rpx;'>{{startext[1]}}</view> </view> <view class="star-title">3、綜合管理</view> <view class="star-pos"> <image class='stars' bindtap="changeColor" data-index='2' data-no="{{item}}" wx:for="{{stardata}}" src="{{flag[2]>=item? '../../images/icon/star1.png': '../../images/icon/star0.png'}}" /> <view style='margin-left: 30rpx;'>{{startext[2]}}</view> </view>
.js 文件:
page: ({ data: { flag:[0, 0, 0], startext: ['', '', ''], stardata: [1, 2, 3, 4, 5], }, // 五星評(píng)價(jià)事件 changeColor: function (e) { var index = e.currentTarget.dataset.index; var num = e.currentTarget.dataset.no; var a = 'flag[' + index + ']'; var b = 'startext[' + index + ']'; var that = this; if(num == 1) { that.setData({ [a]: 1, [b]: '非常不滿意' }); } else if (num == 2){ that.setData({ [a]: 2, [b]: '不滿意' }); } else if (num == 3) { that.setData({ [a]: 3, [b]: '一般' }); } else if (num == 4) { that.setData({ [a]: 4, [b]: '滿意' }); } else if (num == 5) { that.setData({ [a]: 5, [b]: '非常滿意' }); } }, })
.wxss文件:
.star-pos { margin: 10rpx; display: flex; flex-direction: row; } .stars{ width: 40rpx; height: 40rpx; margin-left: 30rpx; }
希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。