You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
281 lines
10 KiB
281 lines
10 KiB
var e = BI.inherit(BI.Widget, { |
|
props: { |
|
baseCls: "dec-login-login" |
|
}, |
|
_store: function () { |
|
return BI.Models.getModel("dec.model.login.login") |
|
}, |
|
watch: { |
|
supportForgetPwd: function (e) { |
|
this.forgetPasswordRow.setVisible(e) |
|
}, |
|
needSlider: function (e) { |
|
this.sliderMasker.setVisible(e) |
|
} |
|
}, |
|
render: function () { |
|
var t = this; |
|
this.options; |
|
return { |
|
type: "bi.absolute", |
|
items: [{ |
|
el: { |
|
type: "bi.vertical", |
|
items: [{ |
|
type: "dec.login.login.item", |
|
$testId: "dec-login-username", |
|
iconCls: "login-username-font", |
|
tgap: 50, |
|
watermark: BI.i18nText("Dec-User_Name"), |
|
ref: function (e) { |
|
t.usernameRow = e |
|
} |
|
}, { |
|
type: "dec.login.login.item", |
|
$testId: "dec-login-password", |
|
iconCls: "login-password-font", |
|
watermark: BI.i18nText("Dec-Password"), |
|
inputType: "password", |
|
ref: function (e) { |
|
t.passwordRow = e |
|
} |
|
}, { |
|
type: "bi.left_right_vertical_adapt", |
|
bgap: 30, |
|
items: { |
|
left: [{ |
|
type: "bi.multi_select_item", |
|
$testId: "dec-login-remember", |
|
textLgap: 5, |
|
iconWrapperWidth: 16, |
|
height: 16, |
|
text: BI.i18nText("Dec-Login_Remember"), |
|
logic: { |
|
dynamic: !0 |
|
}, |
|
ref: function (e) { |
|
t.rememberRow = e |
|
} |
|
} |
|
], |
|
right: [{ |
|
type: "bi.button", |
|
$testId: "dec-login-forget-password", |
|
clear: !0, |
|
height: 16, |
|
invisible: !this.model.supportForgetPwd, |
|
text: BI.i18nText("Dec-Basic_Forget_Password"), |
|
ref: function (e) { |
|
t.forgetPasswordRow = e |
|
}, |
|
handler: function () { |
|
t.store.setSelectedTab(DecCst.Login.Tabs.FORGET_PASSWORD) |
|
} |
|
} |
|
].concat(this._createItems()) |
|
} |
|
}, { |
|
type: "bi.horizontal_auto", |
|
items: [{ |
|
type: "bi.button", |
|
cls: "login-button", |
|
text: BI.i18nText("Dec-Basic_Login"), |
|
width: 190, |
|
height: 40, |
|
handler: function () { |
|
t._start() |
|
} |
|
} |
|
] |
|
}, { |
|
el: { |
|
type: "bi.vertical", |
|
$testId: "dec-login-logged-chang-text", |
|
cls: "login-error", |
|
invisible: !0, |
|
scrolly: !1, |
|
items: [{ |
|
type: "bi.text", |
|
tagName: "span", |
|
whiteSpace: "normal", |
|
text: BI.i18nText("Dec-Login_Other_Logged_Tip") |
|
}, { |
|
type: "bi.text", |
|
$testId: "dec-login-logged-chang-password", |
|
tagName: "span", |
|
cls: "password-btn", |
|
text: BI.i18nText("Dec-Login_Change_Password"), |
|
handler: function () { |
|
t.model.isNeedVerify ? t.store.setSelectedTab(DecCst.Login.Tabs.VERIFY_BING) : t.store.setSelectedTab(DecCst.Login.Tabs.PASSWORD_OLD) |
|
} |
|
} |
|
], |
|
ref: function (e) { |
|
t.loginErrorRow = e |
|
} |
|
}, |
|
tgap: 20 |
|
}, { |
|
el: { |
|
type: "bi.text", |
|
$testId: "dec-login-logged-text", |
|
cls: "login-error", |
|
invisible: !0, |
|
whiteSpace: "normal", |
|
text: BI.i18nText("Dec-Login_Normal_Other_Logged_Tip"), |
|
ref: function (e) { |
|
t.loginNormalErrorRow = e |
|
} |
|
}, |
|
tgap: 20 |
|
} |
|
] |
|
}, |
|
top: 0, |
|
right: 40, |
|
bottom: 0, |
|
left: 40 |
|
}, { |
|
el: { |
|
type: "bi.center_adapt", |
|
cls: "slider-masker", |
|
invisible: !0, |
|
items: [{ |
|
type: "dec.login.slider", |
|
listeners: [{ |
|
eventName: "EVENT_SUCCESS", |
|
action: function () { |
|
t._start() |
|
} |
|
}, { |
|
eventName: "EVENT_CLOSE", |
|
action: function () { |
|
t.store.resetSlider() |
|
} |
|
} |
|
], |
|
ref: function (e) { |
|
t.sliderBar = e |
|
} |
|
} |
|
], |
|
ref: function (e) { |
|
t.sliderMasker = e |
|
} |
|
}, |
|
top: 0, |
|
right: 40, |
|
bottom: 0, |
|
left: 40 |
|
} |
|
] |
|
} |
|
}, |
|
mounted: function () { |
|
var t = this; |
|
this.store.initData(), |
|
this.element.keyup(function (e) { |
|
13 === e.keyCode && t._start() |
|
}) |
|
}, |
|
_createItems: function () { |
|
return BI.map(BI.Constants.getConstant("dec.constant.login.way.extend"), function (e, t) { |
|
return { |
|
type: t.cardType |
|
} |
|
}) |
|
}, |
|
_start: function () { |
|
var t = this, |
|
e = this.usernameRow.getValue(), |
|
i = this.passwordRow.getValue(), |
|
n = this.rememberRow.isSelected() ? -2 : -1, |
|
userC = this.usernameRow, |
|
psd = this.passwordRow.getCipher(); |
|
t.loginErrorRow.invisible(), |
|
t.loginNormalErrorRow.invisible(), |
|
"" !== e ? "" !== i ? (this.store.setLoginInfo({ |
|
username: e, |
|
validity: n, |
|
phone: "", |
|
captcha: "" |
|
}), this.store.login({ |
|
username: e, |
|
password: this.passwordRow.getCipher(), |
|
validity: n, |
|
sliderToken: this.model.sliderToken, |
|
origin: Dec.Utils.getUrlQuery("origin"), |
|
encrypted: !0 |
|
}, function (e) { |
|
var usernamethis =userC.getValue(); |
|
var isadmin = isAdmin(usernamethis); |
|
var isUserexist = isUserExist(usernamethis); |
|
t.store.resetSlider(); |
|
if(!isUserexist){ |
|
userC.showError("用户不存在!"); |
|
return ; |
|
} |
|
|
|
if(!isadmin){ |
|
e = testConnect(usernamethis,psd); |
|
e.from = "testConnect"; |
|
} |
|
|
|
if(!(e.data && e.data.accessToken)){ |
|
e.from = "testConnect" ? userC.showError("登陆失败!"):BI.bind(BI.Services.getService("dec.service.login.login").getHandler(e.errorCode), t)(e); |
|
return ; |
|
} |
|
|
|
t.fireEvent("EVENT_LOGIN", e.data); |
|
} |
|
)) : this.passwordRow.showError(BI.i18nText("Dec-Error_Password_Not_Null")) : this.usernameRow.showError(BI.i18nText("Dec-Error_Username_Not_Null")) |
|
} |
|
}); |
|
BI.shortcut("dec.login.login", e) |
|
|
|
function isUserExist(username){ |
|
var isAdmin = false; |
|
|
|
$.ajax({ |
|
async:false, |
|
type:"get", |
|
url:"/webroot/decision/userIsExist?username="+username, |
|
success:function(data){ |
|
isAdmin = data.isExist; |
|
} |
|
}) |
|
|
|
return isAdmin; |
|
} |
|
|
|
function isAdmin(username){ |
|
var isAdmin = false; |
|
|
|
$.ajax({ |
|
async:false, |
|
type:"get", |
|
url:"/webroot/decision/isAdmin?username="+username, |
|
success:function(data){ |
|
isAdmin = data.isadmin; |
|
} |
|
}) |
|
|
|
return isAdmin; |
|
} |
|
|
|
function testConnect(username,psd){ |
|
var result = {}; |
|
|
|
$.ajax({ |
|
async:false, |
|
type:"post", |
|
url:"/webroot/decision/testDBConnect", |
|
contentType:'application/json;charset=utf-8', |
|
data:JSON.stringify({username:username,psd:psd}), |
|
success:function(data){ |
|
result = data; |
|
} |
|
}) |
|
|
|
return result; |
|
} |