Java 实现用户资料完整度的前端显示(或根据填写资料自动评分)

1548年前java技术3336

前端使用 Bootstrap 的进度条组件显示百分比,后台读取权重并计算信息完整度,并将计算的结果返回给前端,供页面显示。

CSS

1
<link href="static/sc/css/bootstrap.min.css" rel="stylesheet">

JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script src="static/sc/js/jquery-1.9.1.js"></script>  
<script src="static/sc/js/bootstrap.min.js"></script>  
   
<script language="javascript">  
 $(function() {  
    // 加载页面时,动态读取个人资料完整度  
     $.ajax({  
            async: false,  
            url : 'getInfoDegree.do',  
            type : 'POST',  
            dataType : 'json',  
            data : {},  
            error : function(XmlHttpRequest, textStatus, errorThrown) {  
                alert("服务器错误:" + XmlHttpRequest.status  
                        " " + XmlHttpRequest.statusText + '!');  
            },  
            success : function(data) {  
                if (!data)  
                    return;  
                if(data.flag == "true"){  
                    $("#showSpan").html(data.degree);  
                    $("#showBar").css("width", data.degree);  
                    $("#showPercent").html(data.degree);  
                }else if(data.flag == "false"){  
                    $("#infodegree").html(data.desc);  
                    return false;  
                }  
            }     
        });  
 });  
</script>

DOM

1
2
3
4
5
6
7

<p style="color:#666;">个人资料完整度:

<span id="showSpan" style="color:#ff9933;font-size:20px;font-weight:bold;"></span></p>  

  <div class="progress progress-striped" style="width:210px;height:15px;">  

    <span style="white-space:pre">    </span>

    <div id="showBar" class="progress-bar progress-bar-info" role="progressbar"aria-valuenow="60" aria-valuemin="0" aria-valuemax=     "100" >  

       <span style="white-space:pre">        </span>

       <span id="showPercent" class="sr-only"></span>  

       <span style="white-space:pre">    </span>

    </div>  

  </div>  
<em id="infodegree"></em>

后台

Java(部分代码)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/** 
 * 根据权重计算资料完整度 
 * @param map 
 * @return 
 */  
private String getInfoDegree(List<TScAcntProp> list) {  
    int sum = 0;  
    if (list.size() > 0) {  
        // 遍历权重配置文件,获取权重  
        for (int i = 0; i < list.size(); i++) {  
            int degree = Integer.parseInt(CommonUtil.getProperty(list.get(i).getPLabelName()));  
            sum += degree;  
        }  
    }  
    // 返回计算后的权重  
    return sum + "%";//自动评分的话 就去掉%即可

配置文件

config.properties配置文件中存放的是表字段的所占权重。在config.properties里加入一下内容


channel.name=5
channel.owner=5
channel.telphone=5
channel.man=5
channel.email=10
channel.pic=10
channel.earning=10
channel.pronum=10
channel.expnum=10
channel.way=10
channel.plan=10
channel.budget=10

相关文章

微信公众号开发基础教程

微信公众号开发基础教程

开发和调试之殇微信公众号的开发,说简单也简单,说麻烦也麻烦,麻烦的不是开发过程,而是搭建开发环境的过程。不过俗话说得好,磨刀不误砍柴工,我们有必要花点时间来研 究下如何攻破微信公众号的开发环。说白了...

java实现用ffmpeg 获取视频时长

首先需要引入ffmpeg.exe调用 int time = ConvertM3U8.getVideoTime(downloadPath);方法: st...

java实现合并多个word文档 且可换页 实例代码(基于docx4j)

org.docx4j/docx4j/ Maven依赖写法Maven下载jar包<dependency>    <groupId>org.docx4...

org.apache.subversion.javahl.ClientException: ¾ܾø·ÃÎʡ£ svn: Can't move 'E:\workspace\TourMarkets\.

org.apache.subversion.javahl.ClientException: ¾ܾø·ÃÎʡ£  svn: Can't move 'E:\workspace\T...

org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locked dir

 svn更新或提交时候报错:org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locke...

The content of elements must consist of well-formed character data or markup

 XML 元素必须遵循以下命名规则:1.名称可以含字母、数字以及其他的字符 (尤其是 你的内容是否包含了"< "或 ">&quo...

评论列表

工控资料窝
2016-09-22 11:25:05

萨瓦迪卡,看不懂呀

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。