.net变量判断
<div class="AccountLevel" style="margin-top: 15px;">
<span style="float: left;">账户安全等级:</span>
@{
int levelValue = 0;
string levelName = "低";
string progressBarName = "progress-bar-warning";默认橘黄色
if (Model.CustomerInfo != null)
{
if (Model.CustomerInfo.IsPassWord != null && Model.CustomerInfo.IsPassWord.Value)
{
levelValue += 25;
}
if (Model.CustomerInfo.IsMobile != null && Model.CustomerInfo.IsMobile.Value)
{
levelValue += 25;
}
if (Model.CustomerInfo.IsEmail != null && Model.CustomerInfo.IsEmail.Value)
{
levelValue += 25;
}
if (Model.CustomerInfo.IsIdentity != null && Model.CustomerInfo.IsIdentity.Value)
{
levelValue += 25;
}
if (levelValue >= 50 && levelValue < 75)
{
levelName = "中";
}
else if (levelValue >= 75)
{
levelName = "高";
progressBarName = "progress-bar-success";判断之后绿色
}
}
string level = levelValue + "%";
<div class="progress progressDiv" style="margin-top: 10px;">
<div class="progress-bar @progressBarName" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: @level; line-height: 12px;"
id="accountLevel">
<span id="accountLevelValue">@level</span>
</div>
</div>
<span id="accountLevelName">@levelName</span>
if (levelName != "高")
{
<span class="Enhance"><a href="/AccountSetting/Index?tab=safety">提升</a></span>
}
}
</div>