| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import tools from '/common/tools';
- import {
- teamName
- } from '/common/define';
-
- var rankfunc = {
-
- getTeamName(teamType, teamIndex) {
- return teamName[teamType][teamIndex];
- },
-
- fmtTime(time) {
- if (time > 0)
- return tools.convertSecondsToHMS(time, 1);
- else
- return '--';
- },
-
- // 格式化 距离
- fmtDistanct(val) {
- return Math.round(val * 100 / 1000) / 100;
- // if (val < 1000)
- // return Math.round(val * 10 / 1000) / 10;
- // else
- // return Math.round(val / 1000);
- },
-
- // 格式化 配速
- fmtPace(val) {
- if (val > 0)
- return tools.convertSecondsToHMS(val, 2);
- else
- return '--';
- },
-
- // 根据成绩类型格式化成绩
- // rankNum:成绩,rankType:成绩类型,addUnit:是否添加单位
- fmtRankNumByType(rankNum, rankType, addUnit=true) {
- let fmtRank = rankNum;
- let unit = '';
- if (rankType == 'totalDistance') {
- fmtRank = this.fmtDistanct(rankNum);
- unit = ' km';
- } else if (rankType == 'fastPace') {
- fmtRank = this.fmtPace(rankNum);
- } else if (rankType == 'speed') {
- fmtRank = this.fmtTime(rankNum);
- } else if (rankType == 'rightAnswerPer') {
- unit = '%';
- } else if (rankType == 'totalCp' || rankType == 'totalSysPoint') {
- unit = ' 个';
- }
-
- if (addUnit) {
- fmtRank += unit;
- }
- return fmtRank;
- }
-
- };
- export default rankfunc;
|