微信小程序?qū)崿F(xiàn)展示評(píng)分結(jié)果功能
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)展示評(píng)分結(jié)果的具體代碼,供大家參考,具體內(nèi)容如下
星星評(píng)分展示1
根據(jù)評(píng)分展示整顆行星或者半顆星星
星星評(píng)分展示2
根據(jù)評(píng)分按照小數(shù)點(diǎn)展示整顆行星或者部分星星
wxml
<view class="conmmentbox"> <view class="starbox"> <view class="stars2" style="width: 130rpx"> <view> <image src="../../image/token_img/lp_ct2.png"></image> <image src="../../image/token_img/lp_ct2.png"></image> <image src="../../image/token_img/lp_ct2.png"></image> <image src="../../image/token_img/lp_ct2.png"></image> <image src="../../image/token_img/lp_ct2.png"></image> </view> </view> <view class="stars" style="width: {{praisestars}};"> <view> <image src="../../image/token_img/lp_dj1.png"></image> <image src="../../image/token_img/lp_dj1.png"></image> <image src="../../image/token_img/lp_dj1.png"></image> <image src="../../image/token_img/lp_dj1.png"></image> <image src="../../image/token_img/lp_dj1.png"></image> </view> </view> </view> {{ praiseNum }}分 </view>
wxss
.conmmentbox{ display: inline-block; font-size: 22rpx; color: #F74754; } .conmmentstars{ width: 26rpx; height: 26rpx; } .doortimes{ color: #F74754; margin-left: 10rpx; } .starbox{ width: 130rpx; height: 30rpx; position: relative; display: inline-block; overflow: hidden; float: left; } .stars{ width: 130rpx; height: 30rpx; position: relative; top: 0; left: 0; overflow: hidden; } .stars2{ height: 30rpx; width: 130rpx; overflow: hidden; position: absolute; top: 0; left: 0; overflow: hidden; } .stars image,.stars2 image{ width: 26rpx; height: 26rpx; float: left; white-space:nowrap; } .stars view,.stars2 view{ width: 130rpx; position: absolute; }
js
//星星評(píng)分 var praiseNums=res.data.result.praiseNum;//獲取數(shù)據(jù)評(píng)分 var praisestars=(praiseNums/5)*100+'%'; // console.log(praisestars); that.setData({ praisestars: praisestars })
星星評(píng)分
單擊星星,整顆星星
wxml
<!--pages/test/test.wxml--> <view> <view>一:顯示后臺(tái)給的評(píng)分</view> <block wx:for="{{one_1}}"> <image src='../../images/use_sc2.png'></image> </block> <block wx:for="{{two_1}}"> <image src='../../images/use_sc.png'></image> </block> </view> <view>這里num給的是幾分就顯示幾顆星星</view> <view style='margin-top:60px;'>二:顯示用戶(hù)選擇的評(píng)分</view> <block wx:for="{{one_2}}" wx:key="index"> <image catchtap='in_xin' id='{{index+1}}' data-in='use_sc2' src='../../images/use_sc2.png'></image> </block> <block wx:for="{{two_2}}" wx:key="index"> <image catchtap='in_xin' id='{{index+1}}' data-in='use_sc' src='../../images/use_sc.png'></image> </block> <view>{{one_2}}星</view>
js
// pages/test/test.js Page({ /** * 統(tǒng)一滿(mǎn)分為5星 */ data: { num: 4,//后端給的分?jǐn)?shù),顯示相應(yīng)的星星 one_1: '', two_1: '', one_2: 0, two_2: 5 }, onLoad: function (options) { //情況一:展示后臺(tái)給的評(píng)分 this.setData({ one_1: this.data.num, two_1: 5 - this.data.num }) }, //情況二:用戶(hù)給評(píng)分 in_xin:function(e){ var in_xin = e.currentTarget.dataset.in; var one_2; if (in_xin === 'use_sc2'){ one_2 = Number(e.currentTarget.id); } else { one_2 = Number(e.currentTarget.id) + this.data.one_2; } this.setData({ one_2: one_2, two_2: 5 - one_2 }) } })
wxss
/* pages/test/test.wxss */ image{ height: 60rpx; width: 60rpx; display: inline-block }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)星級(jí)評(píng)分
- 微信小程序?qū)崿F(xiàn)星級(jí)評(píng)分和展示
- 微信小程序?qū)崿F(xiàn)星星評(píng)分效果
- 微信小程序動(dòng)態(tài)評(píng)分展示/五角星展示/半顆星展示/自定義長(zhǎng)度展示功能的實(shí)現(xiàn)
- 微信小程序中的店鋪評(píng)分組件及vue中用svg實(shí)現(xiàn)的評(píng)分顯示組件
- 微信小程序 五星評(píng)分的實(shí)現(xiàn)實(shí)例
- 微信小程序五星評(píng)分效果實(shí)現(xiàn)代碼
- 微信小程序 五星評(píng)分(包括半顆星評(píng)分)實(shí)例代碼
- 微信小程序使用template標(biāo)簽實(shí)現(xiàn)五星評(píng)分功能
- 微信小程序?qū)崿F(xiàn)星級(jí)評(píng)分與展示
相關(guān)文章
關(guān)于moment.js的常用方法及使用說(shuō)明
這篇文章主要介紹了關(guān)于moment.js的常用方法及說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12簡(jiǎn)單三步實(shí)現(xiàn)報(bào)表頁(yè)面集成天氣
本文主要介紹了基于javascript實(shí)現(xiàn)報(bào)表頁(yè)面集成天氣的方法步驟,簡(jiǎn)單三步,一看就懂。具有很好的參考價(jià)值,需要的朋友一起來(lái)看下吧2016-12-12JavaScript判斷變量名是否存在數(shù)組中的實(shí)例
下面小編就為大家分享一篇JavaScript判斷變量名是否存在數(shù)組中的實(shí)例,具有很的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12js實(shí)現(xiàn)PC端根據(jù)IP定位當(dāng)前城市地理位置
本文主要分享了js實(shí)現(xiàn)PC端根據(jù)IP定位當(dāng)前城市地理位置的方法,具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-02-02ES6解構(gòu)賦值(數(shù)組,對(duì)象,函數(shù))使用詳解
這篇文章主要介紹了ES6解構(gòu)賦值(數(shù)組,對(duì)象,函數(shù))使用詳解,JavaScript 中最常用的兩種數(shù)據(jù)結(jié)構(gòu)是 Object 和 Array,解構(gòu)操作對(duì)那些具有很多參數(shù)和默認(rèn)值等的函數(shù)也很奏效,本文通過(guò)實(shí)例代碼詳細(xì)講解需要的朋友可以參考下2022-11-11