当前位置:网站首页>Wechat applet realizes five-star evaluation
Wechat applet realizes five-star evaluation
2022-06-27 11:49:00 【Draw a flourishing fireworks with a black pencil】
pingxing.js
function pingfenxing(pingfen) {
var _this = this, // The path of the picture here , I need to modify
data = {
ling: "/img/icon-ling.png",
zheng: "/img/icon-zheng.png",
ban: "/img/icon-ban.png",
},
nums =[];// Here is an array that returns the order in which the pictures are arranged , Here we should pay attention to the path of the image when the page is used , But it doesn't matter if you use web photos if((pingfen/0.2)%2==0){// If the score is positive , Such as 4.0, 5.0}
// The full score of this effect is 5 branch , if 10 Special rules
//var pingfen = Math.ceil(pingfen)/2;
if((pingfen/0.2) % 2 == 0) {
for (var i = 0; i < 5; i++) {
if (i < pingfen) {
nums.push(data.zheng);
} else {
nums.push(data.ling)
}
}
} else { // Score is not an integer , Such as 3.5, 2.5
for(var i=0; i<5; i++) {
if(i<pingfen-0.5) {
nums.push(data.zheng); // First, separate the certificates , Such as : 3.5 Here is to put 3 separate from , Put it on behalf of 1 Put the picture of
} else if(i==(pingfen-0.5)) {
nums.push(data.ban); // Separate the decimal parts , Such as : 3.5 Inside 0.5, Put it on behalf of 0.5 Put the picture of
} else {
nums.push(data.ling); // Then the rest is represented by the not full 0 Put the picture of , Such as : 3.5, It's inside 3 A representative 1 Pictures of the , Then put it in 1 A representative 0.5 Pictures of the , Finally, there is a picture left , At this time, it means 0 Pictures of the
}
}
}
return nums;
}
function information(data){
for (var i = 0; i < data.length; i++) {
// console.log(data[i].score) Find the scoring data in the data
data[i].pingfenpic = this.pingfen(parseFloat(data[i].score)); // Using functions
}
module.exports = {
pingfen: pingfenxing,
information: information
}js
var pingxin = require("../../utils/pingxing.js");
Page({
/**
* Initial data of the page
*/
data: {
tiyan: [ // score
{pingfen: 3.5}
],
}
/**
* Life cycle function -- Monitor page loading
*/
onLoad: function(options) {
var _this = this;
var tiyan = this.data.tiyan;
tiyan = pingxin.information(tiyan);
_this.setData({
tiyan: tiyan
})
},
})wxss
image {
width: 14rpx;
height: 14rpx;
margin-right: 5rpx;
}wxml
<block wx:for="{
{tiyan}}" wx:key="index">
<block wx:for="{
{item.pingfenpic}}" wx:key="index">
<image src="{
{item}}"></image>
</block>
</block>Pictures of stars

边栏推荐
- C# wpf 实现撤销重做功能
- 杰理之一直喂狗会频繁开关中断导致定时器【篇】
- Summary of qstype class usage (III)
- [tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
- Jerry's serial port communication serial port receiving IO needs to set digital function [chapter]
- Code for structural design of proe/creo household appliances - electric frying pan
- After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
- [tcapulusdb knowledge base] tcapulusdb system user group introduction
- 最大路径和问题(摘樱桃问题)
- Oracle multi table query
猜你喜欢

I.MX6ULL启动方式

从零开始搭建物联网系统

Peak store app imitation station development play mode explanation source code sharing

Safe landing practice of software supply chain under salesforce containerized ISV scenario

Excel中输入整数却总是显示小数,如何调整?

Usage of rxjs mergemap

Native JS implements page scroll bar loading data and page drop-down loading content
![[tcapulusdb knowledge base] Introduction to tcapulusdb general documents](/img/04/b1194ca3340b23a4fb2091d1b2a44d.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb general documents

Heap heap sort TOPK
![[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area](/img/b7/2358e8cf1cdaeaba77e52d04cc74d4.png)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
随机推荐
[tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction
How to adjust an integer that is entered in Excel but always displays decimals?
Glide caching mechanism
Mqtt protocol stack principle and interaction flow chart
Rxjs mergeMap 的使用场合
QStyle类用法总结(二)
Deep understanding of happens before principle
AUTOCAD——三种修剪方式
QStyle实现自绘界面项目实战(一)
【TcaplusDB知识库】TcaplusDB单据受理-事务执行介绍
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用VGAM包的vglm函数对有序多分类logistic回归模型进行平行性假设作检验
JSP自定义标签
Co jump
千万不要错过,新媒体运营15个宝藏公众号分享
Jerry's seamless looping [chapter]
R language uses the polR function of mass package to construct the ordered multi classification logistic regression model, and uses the vglm function of VGAM package to test the parallelism hypothesis
JSP custom tag
内存四区(栈,堆,全局,代码区)
C語言0長度數組的妙用
Leetcode 177 The nth highest salary (June 26, 2022)