<link href="static/sc/css/bootstrap.min.css" rel="stylesheet">
<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>
<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>
/** * 根据权重计算资料完整度 * @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 + "%"; }
原文:http://blog.csdn.net/happylee6688/article/details/43192171