1function signin() { 2 get("loginForm").submit({ 3 url : "login/signin", 4 headers : { 5 screenWidth : window.screen.width, 6 screenHeight : window.screen.height 7 }, 8 async : false, 9 onBeforeLoad : function(param) { 10 param.loginForm.isWeekPassword = get("password").isWeekPassword(); 11 }, 12 onLoadSuccess : function(rtn) { 13 if (rtn.code === AppConstant.RESULT_SUCCESS) { 14 preLoginSuccess(rtn); 15 } else { 16 showInvalidMsg(rtn.msg); 17 18 switch (rtn.code) { 19 case AppConstant.RESULT_LOGIN_FAIL_ADD_VERIFY_CODE: 20 case AppConstant.RESULT_LOGIN_FAIL_VERIFY_CODE_WRONG: 21 get("verifyCode").resetVerifyCode().toggle(true); 22 $(".verify-code-hide").removeClass("verify-code-hide"); 23 default: 24 get("loginId").focus(); 25 break; 26 } 27 } 28 } 29 }); 30} 31 32function preLoginSuccess(rtn) { 33 if (rtn.datas.isIdentitySwitchMode) { 34 var userRoleIds = $.util.getCookie("userRoleIds") || {}; 35 36 var loginId = get("loginId").getValue(); 37 if (userRoleIds[loginId]) { 38 signin4ChooseIdentity(userRoleIds[loginId]); 39 } else { 40 var bodyContent = createTag(""); 41 var buttonContainer = createTag("div").addClass("button-container") 42 .appendTo(bodyContent); 43 44 var identitys = rtn.datas.roles; 45 for (var i = 0; i < identitys.length; i++) { 46 var data = identitys[i]; 47 var options = { 48 id : "identityBtn", 49 text : data.roleName, 50 iconCls : "icon-check-circle-o", 51 outline : true, 52 data : { 53 id : data.roleId 54 } 55 } 56 57 if (i == 0) { 58 options.cls = "active"; 59 } 60 61 TagUtils.createButton(options).appendTo(buttonContainer); 62 } 63 64 TagUtils.createCheckbox({ 65 id : "rmbIdentity", 66 name : "rmbIdentity", 67 text : "é»è®¤å½åéä¸èº«ä»½ï¼ä¸æ¬¡ç»å½ä¸åéæ©", 68 value : 1 69 }).appendTo(bodyContent); 70 71 var confirmBtn = createTag("div").addClass("text-center").appendTo( 72 bodyContent); 73 TagUtils.createButton({ 74 text : "ç¡®å®", 75 type : "primary", 76 width : 200, 77 cls : "confirm-btn" 78 }).appendTo(confirmBtn); 79 80 var modal = $.openDialog({ 81 title : "è¯·éæ©èº«ä»½", 82 width : 704, 83 closeBtn : false, 84 content : bodyContent.toString(), 85 headerCloseBtn : false 86 }); 87 88 var $modalBody = modal.$body; 89 $.fn.checkbox.util.init($modalBody.find(".box-control")); 90 91 $modalBody.find(".button-container>#identityBtn").on( 92 "click", 93 function() { 94 if (!$(this).hasClass("active")) { 95 $(".button-container .active") 96 .removeClass("active"); 97 $(this).addClass("active"); 98 } 99 }); 100 101 $modalBody 102 .find(".text-center>.confirm-btn") 103 .on( 104 "click", 105 function() { 106 var roleId = $modalBody 107 .find( 108 ".button-container>#identityBtn.active") 109 .data("id"); 110 var checkbox = $modalBody 111 .find("#rmbIdentity:checkbox"); 112 if (checkbox.prop("checked")) { 113 var userRoleIds = $.util.getCookie("userRoleIds") || {}; 114 userRoleIds[get("loginId").getValue()] = roleId; 115 $.util.setCookie("userRoleIds", userRoleIds); 116 } 117 118 signin4ChooseIdentity(roleId); 119 }) 120 } 121 } else { 122 loginSuccess(); 123 } 124} 125 126function loginSuccess() { 127 var redirectUrl = getUrlParam("redirectUrl"); 128 if (!redirectUrl || redirectUrl.indexOf("login/enterLogin") > 0) { 129 redirectUrl = "login/enterMain"; 130 } 131 if (redirectUrl.indexOf("http") == -1) { 132 redirectUrl = $.util.getBaseUrl() + redirectUrl; 133 } else if (redirectUrl.indexOf($.util.getBaseUrl()) != 0) { 134 redirectUrl = $.util.getBaseUrl() + "login/enterMain"; 135 } 136 window.location.href = redirectUrl; 137} 138 139function signin4ChooseIdentity(roleId) { 140 var url = new Url("login/chooseIdentity"); 141 url.addParam("roleId", roleId); 142 $.req({ 143 url : url, 144 headers : { 145 screenWidth : window.screen.width, 146 screenHeight : window.screen.height 147 }, 148 onLoadSuccess : function() { 149 loginSuccess(); 150 } 151 }) 152} 153 154function getUrlParam(name) { 155 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); 156 var r = window.location.search.substr(1).match(reg); 157 if (r != null) { 158 return unescape(r[2]); 159 } 160 return null; 161} 162 163function validLogin(is, msg, label) { 164 if (!is) { 165 showInvalidMsg("请è¾å ¥" + label); 166 } 167} 168 169function showInvalidMsg(msg) { 170 $(".hint-msg").show(); 171 var $msg = $(".hint-msg"); 172 var oldHeight = $msg.height(); 173 $msg.addClass("alert-danger").html( 174 "<div><i class='icon icon-minus-circle'></i>" + msg + "</div>"); 175 $msg.height(oldHeight); 176 177 var newHeight = $msg.find(">div").height(); 178 $msg.height(newHeight); 179 180 setTimeout(function() { 181// $(".hint-msg").hide(); 182 $msg.css("height", ""); 183 }, 500); 184} 185 186function triggerLogin() { 187 get("submitBtn").focus().click(); 188} 189 190// 以ä¸ä¸ºæ¾åå¯ç js 191function validateLoginId() { 192 get("verifyCodeForm").submit("login/validateLoginId", function(result) { 193 switch (result.code) { 194 case AppConstant.RESULT_SUCCESS:
195 var $main = $(".find-password-main .main-container"); 196 $main.find(".main-header-description").text("为äºä¿æ¤è´¦å·å®å ¨ï¼éè¦éªè¯èº«ä»½ "); 197 $main.find(".main-content .content-step-one").hide(); 198 $main.find(".main-content .content-step-choose").show(); 199 // é®ç®±åææºå·è¾åºä¿®æ¹æ ¼å¼ 并䏿¾ç¤ºä¸åçéªè¯æ¹å¼ 200 var mobile = result.data.mobile; 201 var email = result.data.email; 202 if(mobile || email) { 203 if(mobile) { 204 $("#chooseMobile").html(mobile); 205 $(".mobile-container").show(); 206 } 207 208 209 if(email) { 210 $("#chooseEmail").html(email); 211 $(".email-container").show(); 212 } 213 214 if(mobile && email) { 215 $(".toggle-container").show(); 216 } 217 } else { 218 $(".admin-container").show(); 219 } 220 221 break; 222 case AppConstant.FIND_PASSWORD_VALIDATE_MOBILE_FAIL: 223 get("loginId").showValidateResult(false, result.msg).focus(); 224 get("verifyCode").resetVerifyCode(); 225 break; 226 case AppConstant.RESULT_LOGIN_FAIL_VERIFY_CODE_WRONG: 227 case AppConstant.RESULT_LOGIN_FAIL_VERIFY_CODE_EXPIRE: 228 get("verifyCode").showValidateResult(false, result.msg).focus(); 229 get("verifyCode").resetVerifyCode(); 230 default: 231 break; 232 } 233 }); 234} 235 236var validateType = null; 237function validateMobile() { 238 get("verifyCodeForm").submit("login/validateMobile", function(result) { 239 switch (result.code) { 240 case AppConstant.RESULT_SUCCESS: 241 var $main = $(".find-password-main .main-container"); 242 $main.find(".main-header-description").addClass("warning").text("éªè¯ç æ£å¨åéä¸ããã"); 243 get("readMobile").setValue(get("account").getValue()); 244 $main.find(".main-content .content-step-one").hide(); 245 get("smsVerifyCode").sendSms(); 246 $main.find(".main-content .content-step-two").show(); 247 break; 248 case AppConstant.FIND_PASSWORD_VALIDATE_MOBILE_FAIL: 249 get("account").showValidateResult(false, result.msg).focus(); 250 break; 251 case AppConstant.RESULT_LOGIN_FAIL_VERIFY_CODE_WRONG: 252 case AppConstant.RESULT_LOGIN_FAIL_VERIFY_CODE_EXPIRE: 253 get("verifyCode").showValidateResult(false, result.msg, "auto bottom").focus(); 254 default : 255 break; 256 } 257 }); 258} 259 260function sendSmsCode() { 261 var account = get("account").getValue(); 262 var isMobileResult = StringUtils.validate(account, "phone"); 263 var url = new Url("login/sendRetrieveSmsCode"); 264 $.req(url, function(result) { 265 if(result.valid) { 266 $.notify("åé宿ï¼è¯·æ³¨ææ¥æ¶", "success"); 267 $(".main-header-description").text("éªè¯ç å·²ç»åéè³æ¨å¨ç³»ç»ä¸ç»è®°ç" + (isMobileResult.isValid ? "ææºå·ç " : "é®ç®±") + "ã"); 268 } else { 269 $.notify(result.msg, "danger"); 270 $(".main-header-description").text(result.msg); 271 } 272 }); 273} 274 275function validateSmsCode() { 276 if(get("smsVerifyCodeForm").validate()) { 277 var url = new Url("login/validateSmsCode", "smsVerifyCode", get("smsVerifyCode").getValue()); 278 $.req(url, function(result) { 279 switch (result.code) { 280 case AppConstant.RESULT_SUCCESS: 281 $.notify("éªè¯éè¿ï¼è¯·è®¾ç½®æ°å¯ç ", "success"); 282 var $main = $(".find-password-main .main-container"); 283 $main.find(".main-header-title").text("设置æ°å¯ç "); 284 $main.find(".main-header-description").removeClass("warning").text("æ°å¯ç ç±8-20ä½å¤§å忝ãå°å忝忰åç»æ"); 285 $main.find(".main-content .content-step-two").hide(); 286 $main.find(".main-content .content-step-three").show(); 287 break; 288 case AppConstant.RESULT_FAIL: 289 case AppConstant.FIND_PASSWORD_VALIDATE_SMS_EXPIRE: 290 get("smsVerifyCode").showValidateResult(false, result.msg, "auto bottom").focus(); 291 break; 292 case AppConstant.FIND_PASSWORD_SYS_EXCEPTION: 293 $.notify(result.msg, "danger"); 294 break; 295 default : 296 break; 297 } 298 }) 299 } 300} 301 302function validateEmail() { 303 validateType = "email"; 304 get("validateCode").sendSms(); 305} 306 307function sendSms() { 308 var url = new Url("login/sendCode"); 309 url.addParam("validateType", validateType); 310 $.req(url, function(result) { 311 if (result.valid) { 312 $.notify("åé宿ï¼è¯·æ³¨ææ¥æ¶", "success"); 313
314 var $main = $(".find-password-main .main-container"); 315 316 var isMobile = validateType == "mobile"; 317 var text = "éªè¯ç å·²ç»åéè³æ¨ç»å®ç" + (isMobile ? "ææº" + $("#chooseMobile").text() : "é®ç®±" + $("#chooseEmail").text()) 318 + "ï¼15åéå ææï¼è¯·å¿æ³é²"; 319 $main.find(".main-header-description").text(text); 320 321 $main.find(".main-content .content-step-choose").hide(); 322 $main.find(".main-content .content-step-code").show(); 323 get("validateCode").showValidateResult(true) 324 } else { 325 $.notify(result.msg, "danger"); 326 get("validateCode").showValidateResult(false, result.msg) 327 .focus(); 328 } 329 }); 330} 331 332function validateCode() { 333 if (get("validateForm").validate()) { 334 var url = new Url("login/validateCode"); 335 url.addParam("validateType", validateType); 336 url.addParam("code", get("validateCode").getValue()); 337 $.req(url, function(result) { 338 switch (result.code) { 339 case AppConstant.RESULT_SUCCESS: 340 $.notify("éªè¯éè¿ï¼è¯·è®¾ç½®æ°å¯ç ", "success"); 341 var $main = $(".find-password-main .main-container"); 342 $main.find(".main-header-title").text("设置æ°å¯ç "); 343 $main.find(".main-header-description").removeClass("warning") 344 .text("æ°å¯ç ç±8-20ä½å¤§å忝ãå°å忝忰åç»æ"); 345 346 $main.find(".main-content .content-step-code").hide(); 347 $main.find(".main-content .content-step-three").show(); 348 break; 349 350 default: 351 $.notify(result.msg, "danger"); 352 get("validateCode").showValidateResult(false, result.msg).focus(); 353 354 break; 355 } 356 }) 357 } 358} 359 360function comfirmPassord(value) { 361 var password = get("password").getInputValue(); 362 return { 363 isValid : value == password, 364 msg : "两次è¾å ¥çå¯ç ä¸ä¸è´ï¼è¯·éæ°è¾å ¥" 365 }; 366} 367 368function resetPassword() { 369 get("passwordForm").submit({ 370 url : "login/saveResetPassword", 371 onBeforeLoad : function(param) { 372 var smsVerifyCode = get("smsVerifyCode"); 373 param.smsVerifyCode = smsVerifyCode.getValue(); 374 }, 375 onLoadSuccess : function(result) { 376 if (AppConstant.RESULT_SUCCESS == result.code) { 377 var $main = $(".find-password-main .main-container"); 378 $main.find(".main-header").hide(); 379 $main.find(".main-content .content-step-three").hide(); 380 $main.find(".main-content .content-step-four").show(); 381 } else { 382 $.notify(result.msg, "danger"); 383 } 384 } 385 }) 386} 387 388function toggleValidateType() { 389 var $main = $(".find-password-main .main-container"); 390 $main.find(".content-step-code").hide(); 391 $main.find(".content-step-choose").show(); 392}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.