计算数字

This commit is contained in:
daihh
2022-10-14 21:37:59 +08:00
parent 5e633f5867
commit e7b0132a3a
2 changed files with 27 additions and 9 deletions

View File

@@ -264,7 +264,7 @@ export function getUType(type) {
return name; return name;
} }
/**此方法的意义,需要一起讨论*/
export function experienceValue(total) { export function experienceValue(total) {
let data = { let data = {
start:'', start:'',
@@ -324,8 +324,8 @@ export function experienceValue(total) {
data.endValue = 30000; data.endValue = 30000;
data.percentage = parseFloat((total / 30000) * 100); data.percentage = parseFloat((total / 30000) * 100);
} }
console.log("&&&&&&&&&&&&&&&&&&&&&&&"); //console.log("&&&&&&&&&&&&&&&&&&&&&&&");
console.log(data); //console.log(data);
return data; return data;
} }
export function translate(field) { export function translate(field) {
@@ -340,3 +340,20 @@ export function translate(field) {
} }
return name; return name;
} }
/**格式化人数的文档 ,学习人数,关注人数等*/
export function formatUserNumber(num) {
let rsNum =0;
if(num<5){
return 0;
}
if(num<95){
rsNum=Math.round((num+5)/10)*10;
return rsNum+'+';
}
if(num>94){
rsNum=Math.round((num+50)/100)*100;
return rsNum+'+';
}
return 0;
}

View File

@@ -100,8 +100,7 @@
<div class="course-author"> <div class="course-author">
<div class="course-author-left"> <div class="course-author-left">
{{ course.authorInfo.name }} {{ course.authorInfo.name }}
<span class="study-num" v-if="course.studiesFormat == 0">{{course.studiesFormat}}人学习</span> <span class="study-num" >{{formatNum(course.studys)}}人学习</span>
<span class="study-num" v-if="course.studiesFormat != 0">{{course.studiesFormat}}+人学习</span>
</div> </div>
<div style="display: flex;"> <div style="display: flex;">
<div style="width:30px;"> <div style="width:30px;">
@@ -409,11 +408,12 @@
import GuideBox from '@/components/Portal/guideBox.vue' import GuideBox from '@/components/Portal/guideBox.vue'
import { import {
toScore, toScore,
cutFullName cutFullName,
formatUserNumber
} from '@/utils/tools.js'; } from '@/utils/tools.js';
import { import {
swiper, swiper,
swiperSlide swiperSlide,
} from 'vue-awesome-swiper'; } from 'vue-awesome-swiper';
import apiPlace from "@/api/phase2/place.js" import apiPlace from "@/api/phase2/place.js"
import authorImg from '@/components/Portal/authorImg.vue'; import authorImg from '@/components/Portal/authorImg.vue';
@@ -447,7 +447,8 @@
uvalue:0, uvalue:0,
totalStudyHour:0 totalStudyHour:0
}, },
userInfo: {}, formatNum:formatUserNumber,
//userInfo: {},
ankingList: [], ankingList: [],
answersList: [], answersList: [],
Popularity: [], Popularity: [],
@@ -506,7 +507,7 @@
}; };
}, },
mounted() { mounted() {
this.userInfo = this.$store.getters.userInfo; //this.userInfo = this.$store.getters.userInfo;
// console.log(this.this.userInfo) // console.log(this.this.userInfo)
this.getCourseData(1); this.getCourseData(1);
this.getCaseData(); this.getCaseData();