Authentication.js 123 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627
  1. MWF.xDesktop = MWF.xDesktop || {};
  2. MWF.xApplication = MWF.xApplication || {};
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.require("MWF.xDesktop.UserData", null, false);
  5. MWF.xDesktop.Authentication = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. // "width": "650",
  11. // "height": "480"
  12. "width": "420",
  13. "height": "640",
  14. "popupStyle_password": "o2platformSignupFlat",
  15. "popupStyle_signup": "o2platformSignup"
  16. },
  17. initialize: function (options, app, node) {
  18. this.setOptions(options);
  19. this.node = node;
  20. this.path = MWF.defaultPath + "/xDesktop/$Authentication/";
  21. // var css = null;
  22. // MWF.UD.getPublicData("loginStyleList", function (json) {
  23. // if (json && json.enabledId) {
  24. // MWF.UD.getPublicData(json.enabledId, function (json) {
  25. // if (json && json.data) {
  26. // css = json.data;
  27. // }
  28. // }.bind(this), false);
  29. // }
  30. // }.bind(this), false);
  31. // if (!css) {
  32. this.cssPath = MWF.defaultPath + "/xDesktop/$Authentication/" + this.options.style + "/css.wcss";
  33. this._loadCss();
  34. // } else {
  35. // this.css = css;
  36. // }
  37. this.lp = MWF.LP.authentication;
  38. this.app = app || {};
  39. },
  40. isAuthenticated: function (success, failure) {
  41. MWF.Actions.get("x_organization_assemble_authentication").getAuthentication(success, failure);
  42. },
  43. loadLogin: function (node) {
  44. o2.Actions.load("x_organization_assemble_authentication").EchoAction.get(function () {
  45. if (node) this.loginNode = node;
  46. if (!node && this.loginNode) node = this.loginNode;
  47. if (layout.config.loginPage && layout.config.loginPage.enable && layout.config.loginPage.portal) {
  48. MWF.xDesktop.loadPortal(layout.config.loginPage.portal, this.options.loginParameter, true);
  49. this.fireEvent("openLogin");
  50. } else {
  51. this.popupOptions = {
  52. "draggable": false,
  53. "closeAction": false,
  54. "hasMask": false,
  55. "relativeToApp": false
  56. };
  57. this.popupPara = {
  58. container: node
  59. };
  60. this.postLogin = function (json) {
  61. layout.desktop.session.user = json.data;
  62. layout.session.user = json.data;
  63. layout.session.token = layout.session.user.token;
  64. var user = layout.desktop.session.user;
  65. if (!user.identityList) user.identityList = [];
  66. if (user.roleList) {
  67. var userRoleName = [];
  68. user.roleList.each(function (role) {
  69. userRoleName.push(role.substring(0, role.indexOf("@")));
  70. });
  71. user.roleList = user.roleList.concat(userRoleName);
  72. }
  73. var roleLCList = (user.roleList || []).map(function (role) {
  74. return role.toLowerCase();
  75. }.bind(this));
  76. if (roleLCList.isIntersect(["systemmanager", "securitymanager", "auditmanager"])) {
  77. window.location = "../x_desktop/app.html?app=ThreeMember";
  78. } else {
  79. window.location.reload();
  80. }
  81. }.bind(this);
  82. this.openLoginForm(this.popupOptions);
  83. this.fireEvent("openLogin");
  84. }
  85. }.bind(this), function (xhr) {
  86. var message;
  87. if (xhr) {
  88. try {
  89. var responseJSON = JSON.parse(xhr.responseText);
  90. message = responseJSON.message; //message为错误提示文本
  91. } catch (e) {
  92. }
  93. }
  94. if (!message) message = MWF.LP.authentication.accessError;
  95. new Element("div", {
  96. "style": "font-size:16px;font-weight:bold;",
  97. "text": message
  98. }).inject(node);
  99. }.bind(this));
  100. },
  101. safeLogout: function(){
  102. o2.Actions.get("x_organization_assemble_authentication").safeLogout(function () {
  103. if (this.socket) {
  104. this.socket.close();
  105. this.socket = null;
  106. }
  107. if (layout.session && layout.session.user) layout.session.user.token = "";
  108. if (sessionStorage) sessionStorage.removeItem("o2LayoutSessionToken");
  109. window.location.reload();
  110. }.bind(this));
  111. },
  112. logout: function ( callback ) {
  113. MWF.Actions.get("x_organization_assemble_authentication").logout(function () {
  114. if (this.socket) {
  115. this.socket.close();
  116. this.socket = null;
  117. }
  118. if (layout.session && layout.session.user) layout.session.user.token = "";
  119. if (sessionStorage) sessionStorage.removeItem("o2LayoutSessionToken");
  120. if( callback ){
  121. callback();
  122. }else{
  123. window.location.reload();
  124. }
  125. }.bind(this));
  126. },
  127. openLoginForm: function (options, callback) {
  128. var opt = Object.merge(this.popupOptions || {}, options || {}, {
  129. onPostOk: function (json) {
  130. if (callback) callback(json);
  131. if (this.postLogin) this.postLogin(json);
  132. this.fireEvent("postOk", json)
  133. }.bind(this)
  134. });
  135. opt.width = this.options.width;
  136. opt.height = this.options.height;
  137. var form = new MWF.xDesktop.Authentication.LoginForm(this, {}, opt, this.popupPara);
  138. form.create();
  139. },
  140. openSignUpForm: function (options, callback) {
  141. var opt = Object.merge(this.popupOptions || {}, options || {}, {
  142. onPostOk: function (json) {
  143. if (callback) callback(json);
  144. this.fireEvent("postOk", json)
  145. }.bind(this)
  146. });
  147. delete opt.width;
  148. delete opt.height;
  149. if (this.options.popupStyle_signup) opt.popupStyle = this.options.popupStyle_signup;
  150. var form = new MWF.xDesktop.Authentication.SignUpForm(this, {}, opt, this.popupPara);
  151. form.create();
  152. },
  153. openResetPasswordForm: function (options, callback) {
  154. var opt = Object.merge(this.popupOptions || {}, options || {}, {
  155. onPostOk: function (json) {
  156. if (callback) callback(json);
  157. this.fireEvent("postOk", json)
  158. }.bind(this)
  159. });
  160. if (this.options.popupStyle_password) opt.popupStyle = this.options.popupStyle_password;
  161. // delete opt.width;
  162. // delete opt.height;
  163. var form = new MWF.xDesktop.Authentication.ResetPasswordForm(this, {}, opt, this.popupPara);
  164. form.create();
  165. },
  166. openChangePasswordForm: function (options, callback) {
  167. //options 里应该包括 userName
  168. var opt = Object.merge(this.popupOptions || {}, options || {}, {
  169. onPostOk: function (json) {
  170. if (callback) callback(json);
  171. this.fireEvent("postOk", json)
  172. }.bind(this)
  173. });
  174. // if (this.options.popupStyle_password) opt.popupStyle = this.options.popupStyle_password;
  175. var form = new MWF.xDesktop.Authentication.ChangePasswordForm(this, {}, opt, this.popupPara);
  176. form.create();
  177. }
  178. });
  179. MWF.xDesktop.Authentication.LoginForm = new Class({
  180. Extends: MPopupForm,
  181. Implements: [Options, Events],
  182. options: {
  183. "style": "default",
  184. "popupStyle": "o2platform",
  185. "width": "650",
  186. "height": "480",
  187. "hasTop": true,
  188. "hasIcon": false,
  189. "hasTopIcon": true,
  190. "hasTopContent": true,
  191. "hasBottom": false,
  192. "hasScroll": false,
  193. "hasMark": false,
  194. "title": "",
  195. "draggable": true,
  196. "closeAction": true
  197. },
  198. load: function () {
  199. this.setOptions({
  200. "title": (layout.config && (layout.config.systemTitle || layout.config.title)) ? (layout.config.title || layout.config.systemTitle) : MWF.LP.authentication.LoginFormTitle
  201. });
  202. this._loadCss();
  203. },
  204. //Camera Login
  205. _createTopContent: function () {
  206. this.actions = MWF.Actions.get("x_organization_assemble_authentication");
  207. this.faceLogin = false;
  208. // this.actions.getLoginMode(function (json) {
  209. // this.faceLogin = json.data.faceLogin;
  210. // }.bind(this), null, false);
  211. //
  212. // if (this.faceLogin) {
  213. // if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  214. // COMMON.AjaxModule.loadDom("../o2_lib/adapter/adapter.js", function () {
  215. // if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  216. // //暂时隐藏此功能
  217. // this.cameraLoginIcon = new Element("div", { "styles": this.explorer.css.cameraLoginIcon }).inject(this.formTopContentNode);
  218. // this.cameraLoginIcon.addEvent("click", function () {
  219. // if (!this.isCameraLogin) {
  220. // this.cameraLogin();
  221. // this.isCameraLogin = true;
  222. // } else {
  223. // this.closeCamera();
  224. // this.isCameraLogin = false;
  225. // }
  226. // }.bind(this));
  227. // }
  228. // }.bind(this));
  229. // }
  230. // }
  231. },
  232. closeCamera: function () {
  233. if (this.cameraLoginVideoNode) {
  234. if (this.video) this.video.destroy();
  235. if (this.canvas) this.canvas.destroy();
  236. if (this.cameraLoginVideoNode) this.cameraLoginVideoNode.destroy();
  237. this.video = null;
  238. this.canvas = null;
  239. this.cameraLoginVideoNode = null;
  240. }
  241. this.cameraLoginIcon.setStyles(this.explorer.css.cameraLoginIcon);
  242. },
  243. cameraLoginInit: function () {
  244. this.cameraLoginConfig = {
  245. "maxStep": 2,
  246. "step": 0,
  247. "count": 0,
  248. "max": 2,
  249. "errorCount": 0,
  250. "errorMax": 3,
  251. "user": "",
  252. "tokens": []
  253. };
  254. },
  255. cameraLoginReset: function (resetError) {
  256. this.cameraLoginConfig.count = 0;
  257. this.cameraLoginConfig.user = "";
  258. if (resetError) this.cameraLoginConfig.errorCount = 0;
  259. },
  260. cameraLogin: function () {
  261. this.cameraLoginInit();
  262. this.cameraLoginIcon.setStyles(this.explorer.css.closeCameraLoginIcon);
  263. this.createCameraLoginNode();
  264. this.startCameraLogin();
  265. },
  266. createCameraLoginNode: function () {
  267. this.cameraLoginVideoNode = new Element("div", { "styles": this.explorer.css.cameraLoginVideoNode }).inject(this.container);
  268. var size = this.formNode.getSize();
  269. var topSize = this.formTopNode.getSize();
  270. var h = size.y - topSize.y;
  271. this.cameraLoginVideoNode.setStyles({
  272. "width": "" + size.x + "px",
  273. "height": "" + h + "px"
  274. });
  275. this.cameraLoginVideoNode.position({
  276. "relativeTo": this.formContentNode,
  277. "position": "upperLeft",
  278. "edge": "upperLeft"
  279. });
  280. },
  281. startCameraLogin: function () {
  282. this.cameraLoginVideoAreaNode = new Element("div").inject(this.cameraLoginVideoNode);
  283. this.cameraLoginVideoInfoNode = new Element("div", { "styles": this.explorer.css.cameraLoginVideoInfoNode }).inject(this.cameraLoginVideoNode);
  284. this.cameraLoginVideoInfoNode.set("text", MWF.LP.desktop.login.camera_logining);
  285. var size = this.cameraLoginVideoNode.getSize();
  286. var infoSize = this.cameraLoginVideoInfoNode.getSize();
  287. var h = size.y - infoSize.y;
  288. this.cameraLoginVideoAreaNode.setStyle("height", "" + h + "px");
  289. this.cameraLoginVideoAreaNode.set("html", "<video autoplay></video>");
  290. this.video = this.cameraLoginVideoAreaNode.getFirst().setStyles({
  291. "background-color": "#000000",
  292. "width": "" + size.x + "px",
  293. "height": "" + h + "px"
  294. });
  295. this.videoStart();
  296. },
  297. videoStart: function () {
  298. this.video.addEventListener("canplay", function () {
  299. window.setTimeout(function () {
  300. this.startCameraAuthentication();
  301. }.bind(this), 500);
  302. }.bind(this));
  303. navigator.mediaDevices.getUserMedia({
  304. audio: false,
  305. video: true
  306. }).then(function (stream) {
  307. this.video.srcObject = stream;
  308. }.bind(this))["catch"](function (error) {
  309. console.log('navigator.getUserMedia error: ', error);
  310. this.closeCamera();
  311. }.bind(this));
  312. },
  313. getFormData: function () {
  314. if (!this.canvas) {
  315. this.canvas = new Element("canvas", { "styles": { "display": "none" } }).inject(this.cameraLoginVideoNode);
  316. this.canvas.width = this.video.videoWidth;
  317. this.canvas.height = this.video.videoHeight;
  318. }
  319. this.canvas.getContext('2d').drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
  320. var blob = this.toBlob(this.canvas.toDataURL());
  321. var formData = new FormData();
  322. formData.append('file', blob);
  323. this.canvas.destroy();
  324. return { "data": formData, "size": blob.size };
  325. },
  326. //检测出身份
  327. checkUserFace: function (formData) {
  328. var faceset = window.location.host;
  329. faceset = faceset.replace(/\./g, "_");
  330. this.faceAction.search(faceset, formData.data, { "name": "pic", "size": formData.size }, function (json) {
  331. if (json.data.results && json.data.results.length) {
  332. var hold = json.data.thresholds["1e-5"];
  333. if (json.data.results[0].confidence > hold) {
  334. var token = json.data.faces[0].face_token;
  335. var user = json.data.results[0].user_id;
  336. if ((!this.cameraLoginConfig.user) || (this.cameraLoginConfig.user === user)) {
  337. this.cameraLoginConfig.count++;
  338. this.cameraLoginConfig.user = user;
  339. this.cameraLoginConfig.tokens.push(token);
  340. this.cameraLoginConfig.step++;
  341. this.cameraLoginConfig.errorCount = 0;
  342. this.cameraLoginVideoInfoNode.set("text", MWF.LP.desktop.login["camera_logining_" + this.cameraLoginConfig.step]);
  343. } else {
  344. this.cameraLoginReset();
  345. this.cameraLoginConfig.errorCount++;
  346. }
  347. } else {
  348. this.cameraLoginReset();
  349. this.cameraLoginConfig.errorCount++;
  350. }
  351. } else {
  352. this.cameraLoginReset();
  353. this.cameraLoginConfig.errorCount++;
  354. }
  355. this.checkCameraLogin();
  356. }.bind(this), function () {
  357. window.setTimeout(function () { this.startCameraAuthentication(); }.bind(this), 500);
  358. }.bind(this));
  359. },
  360. checkUserAlive: function (formData, attr, method) {
  361. this.faceAction.detectattr(attr, formData.data, { "name": "pic", "size": formData.size }, function (json) {
  362. if (json.data.faces && json.data.faces.length) {
  363. if (this[method](json.data.faces[0].attributes)) {
  364. this.cameraLoginConfig.step++;
  365. this.cameraLoginConfig.errorCount = 0;
  366. this.cameraLoginVideoInfoNode.set("text", MWF.LP.desktop.login["camera_logining_" + this.cameraLoginConfig.step]);
  367. } else {
  368. //可能是照片
  369. this.cameraLoginConfig.errorCount++;
  370. }
  371. } else {
  372. this.cameraLoginConfig.errorCount++;
  373. }
  374. this.checkCameraLogin();
  375. }.bind(this), function () {
  376. this.cameraLoginConfig.errorCount++;
  377. this.checkCameraLogin();
  378. }.bind(this));
  379. },
  380. //检测微笑
  381. checkUserSmile: function (attr) {
  382. return attr.smile.value > attr.smile.threshold;
  383. },
  384. //检测抬头
  385. checkUserPitch: function (attr) {
  386. return attr.headpose.pitch_angle < -10;
  387. },
  388. startCameraAuthentication: function () {
  389. if (this.video) {
  390. var formData = this.getFormData();
  391. if (!this.faceAction) this.faceAction = MWF.Actions.get("x_faceset_control");
  392. if (this.cameraLoginConfig.step === 0) {
  393. this.checkUserFace(formData);
  394. }
  395. if (this.cameraLoginConfig.step === 1) {
  396. this.checkUserAlive(formData, "smiling", "checkUserSmile");
  397. }
  398. if (this.cameraLoginConfig.step === 2) {
  399. this.checkUserAlive(formData, "headpose", "checkUserPitch");
  400. }
  401. }
  402. },
  403. toBlob: function (base64) {
  404. var bytes;
  405. if (base64.substr(0, 10) === 'data:image') {
  406. bytes = window.atob(base64.split(',')[1]);
  407. } else {
  408. bytes = window.atob(base64);
  409. }
  410. var ab = new ArrayBuffer(bytes.length);
  411. var ia = new Uint8Array(ab);
  412. for (var i = 0; i < bytes.length; i++) {
  413. ia[i] = bytes.charCodeAt(i);
  414. }
  415. return new Blob([ab], { type: "image/png" });
  416. },
  417. getDIF: function (arr) {
  418. var max = Math.max.apply(this, arr);
  419. var min = Math.min.apply(this, arr);
  420. return max - min;
  421. },
  422. checkCameraLogin: function () {
  423. if (this.cameraLoginConfig.errorCount > this.cameraLoginConfig.errorMax) {
  424. this.cameraLoginVideoInfoNode.set("text", MWF.LP.desktop.login.camera_loginError);
  425. } else {
  426. if (this.cameraLoginConfig.step >= this.cameraLoginConfig.maxStep) {
  427. var text = MWF.LP.desktop.login.camera_loginSuccess.replace("{name}", this.cameraLoginConfig.user);
  428. this.cameraLoginVideoInfoNode.set("text", text);
  429. this.cameraLoginSuccess();
  430. } else {
  431. window.setTimeout(function () { this.startCameraAuthentication(); }.bind(this), 100);
  432. }
  433. }
  434. },
  435. cameraLoginSuccess: function () {
  436. COMMON.AjaxModule.loadDom(["../o2_lib/CryptoJS/tripledes.js", "../o2_lib/CryptoJS/mode-ecb.js"], function () {
  437. //COMMON.AjaxModule.loadDom(, function(){
  438. var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
  439. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  440. var appPort = addressObj.port || window.location.port;
  441. var url = layout.config.app_protocol + "//" + (addressObj.host || window.location.hostname)+ ((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort) + addressObj.context;
  442. var code = this.crypDES();
  443. var json = { "client": "face", "token": code };
  444. var _self = this;
  445. var res = new Request.JSON({
  446. "method": "POST",
  447. "url": o2.filterUrl(url + "/jaxrs/sso"),
  448. "data": JSON.stringify(json),
  449. secure: false,
  450. emulation: false,
  451. noCache: true,
  452. withCredentials: true,
  453. "headers": {
  454. "Content-Type": "application/json; charset=utf-8"
  455. },
  456. onSuccess: function (responseJSON) {
  457. _self._close();
  458. _self.closeCamera();
  459. if (_self.formMaskNode) _self.formMaskNode.destroy();
  460. _self.formAreaNode.destroy();
  461. var xToken = this.getHeader(o2.tokenName);
  462. if (layout.config && layout.config.sessionStorageEnable) sessionStorage.setItem("o2LayoutSessionToken", xToken);
  463. if (_self.explorer && _self.explorer.view) _self.explorer.view.reload();
  464. if (_self.app) _self.app.notice(_self.lp.loginSuccess, "success");
  465. _self.fireEvent("postOk", responseJSON);
  466. },
  467. onError: function () {
  468. this.cameraLoginVideoInfoNode.set("text", MWF.LP.desktop.login.camera_loginError2);
  469. }.bind(this)
  470. });
  471. res.send();
  472. //}.bind(this));
  473. }.bind(this));
  474. },
  475. crypDES: function () {
  476. var key = "xplatform";
  477. var userId = this.cameraLoginConfig.user;
  478. var d = (new Date()).getTime();
  479. var keyHex = CryptoJS.enc.Utf8.parse(key);
  480. var xtoken = CryptoJS.DES.encrypt(userId + "#" + d, keyHex, {
  481. mode: CryptoJS.mode.ECB,
  482. padding: CryptoJS.pad.Pkcs7
  483. });
  484. var str = xtoken.ciphertext.toString(CryptoJS.enc.Base64);
  485. str = str.replace(/=/g, "");
  486. str = str.replace(/\+/g, "-");
  487. str = str.replace(/\//g, "_");
  488. return str;
  489. },
  490. _createTableContent: function () {
  491. if( this.formTopTextNode && this.formTopCloseActionNode ){
  492. this.formTopCloseActionNode.inject( this.formTopTextNode, "before" )
  493. }
  494. this.loginType = "captcha";
  495. this.codeLogin = false;
  496. this.bindLogin = false;
  497. this.captchaLogin = true;
  498. this.twoFactorLogin = false;
  499. this.actions.getLoginMode(function (json) {
  500. this.codeLogin = json.data.codeLogin;
  501. this.bindLogin = json.data.bindLogin;
  502. this.captchaLogin = json.data.captchaLogin;
  503. this.twoFactorLogin = json.data.twoFactorLogin;
  504. if( this.codeLogin && this.twoFactorLogin ){ //如果两个都是true,以短信登录为准
  505. this.twoFactorLogin = false;
  506. }
  507. }.bind(this), null, false);
  508. MWF.Actions.get("x_organization_assemble_personal").getRegisterMode(function (json) {
  509. this.signUpMode = json.data.value;
  510. }.bind(this), null, false);
  511. if (this.bindLogin) {
  512. this.bindLoginTipPic = new Element("div.bindLoginTipPic", { styles: this.css.bindLoginTipPic }).inject(this.formContentNode, "top");
  513. this.bindLoginAction = new Element("div.bindLoginAction", { styles: this.css.bindLoginAction }).inject(this.formContentNode, "top");
  514. this.bindLoginAction.addEvent("click", function () {
  515. this.showBindCodeLogin();
  516. }.bind(this));
  517. this.backtoPasswordLoginTipPic = new Element("div.backtoPasswordLoginTipPic", { styles: this.css.backtoPasswordLoginTipPic }).inject(this.formContentNode, "top");
  518. this.backtoPasswordLoginAction = new Element("div.backtoPasswordLoginAction", { styles: this.css.backtoPasswordLoginAction }).inject(this.formContentNode, "top");
  519. this.backtoPasswordLoginAction.addEvent("click", function () {
  520. this.backtoPasswordLogin();
  521. }.bind(this));
  522. }
  523. var html =
  524. "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable'>" +
  525. "<tr><div><div item='passwordAction'>";
  526. if (this.codeLogin) {
  527. html += "</div><div styles='titleSep'></div><div item='codeAction'></div></tr>";
  528. }
  529. html += "</table>";
  530. html += "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable'>" +
  531. "<tr item='credentialTr'>" +
  532. " <td styles='formTableValueTop20'>" +
  533. " <div style='position: relative;'><div item='credential'></div><div class='inputUserIcon'></div></div>" +
  534. " </td>" +
  535. "</tr>" +
  536. "<tr item='passwordTr'>" +
  537. " <td styles='formTableValueTop20'>" +
  538. " <div style='position: relative;'><div item='password'></div><div class='inputPasswordIcon'></div></div>" +
  539. " </td>" +
  540. "</tr>";
  541. if (this.captchaLogin) {
  542. html += "<tr item='captchaTr'><td styles='formTableValueTop20'>" +
  543. "<div style='float:left;'>" +
  544. " <div style='position: relative;'><div item='captchaAnswer'></div><div class='inputVerificationCodeIcon'></div></div>" +
  545. "</div>" +
  546. "<div item='captchaPic' style='float:left;padding-left:5px'></div>" +
  547. "<div item='changeCaptchaAction' style='float:left;'></div>" +
  548. "</td></tr>";
  549. }
  550. if (this.codeLogin) {
  551. html += "<tr item='codeTr' style='display: none'><td styles='formTableValueTop20'>" +
  552. " <div style='float:left;'>" +
  553. " <div style='position: relative;'><div item='codeAnswer'></div><div class='inputVerificationCode2Icon'></div></div>" +
  554. " </div>" +
  555. " <div item='verificationAction' style='float:left;'></div>" +
  556. " <div item='resendVerificationAction' style='float:left;display:none;'></div>" +
  557. "</td></tr>";
  558. }else if(this.twoFactorLogin){
  559. html += "<tr item='codeTr' style='display: none'><td styles='formTableValueTop60'>" +
  560. " <div style='float:left;'>"+
  561. " <div style='position: relative;'><div item='codeAnswerWithTwoFactorlogin'></div><div class='inputVerificationCode3Icon'></div></div>" +
  562. " </div>" +
  563. "</td></tr>";
  564. html += "<tr item='twoFactorloginStep2Tr' style='display: none'><td styles='formTableValueTop20' item='twoFactorloginStep2Action'></td></tr>";
  565. }
  566. html += "<tr item='loginActionTr'><td styles='formTableValueTop20' item='loginAction'></td></tr>" +
  567. "</table>" +
  568. "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable'>";
  569. if (this.signUpMode && this.signUpMode !== "disable") {
  570. html += "<tr item='forgetPasswordTr'><td><div item='signUpAction'></div><div item='forgetPassword'></div></td></tr>";
  571. } else {
  572. html += "<tr item='forgetPasswordTr'><td><div styles='signUpAction'></div><div item='forgetPassword'></div></td></tr>";
  573. }
  574. if(this.twoFactorLogin){
  575. html += "<tr item='hideTwoFactorySendMsgTr' style='display: none'><td><div styles='signUpAction'></div><div item='hideTwoFactorySendMsgAction'></div></td></tr>";
  576. }
  577. html += "<tr><td styles='formTableValue' item='errorArea'></td></tr>" +
  578. "<tr><td styles='formTableValue' item='oauthArea'></td></tr>" +
  579. "</table>";
  580. this.formTableArea.set("html", html);
  581. new Element("div", {
  582. "styles": this.css.formFooter,
  583. // "styles": {
  584. // "text-align": "center",
  585. // "height": "40px",
  586. // "line-height": "40px"
  587. // },
  588. "text": layout.config.footer || layout.config.systemName
  589. }).inject(this.formTableArea, "after");
  590. if (this.captchaLogin) this.setCaptchaPic();
  591. this.errorArea = this.formTableArea.getElement("[item=errorArea]");
  592. this.oauthArea = this.formTableArea.getElement("[item=oauthArea]");
  593. MWF.xDesktop.requireApp("Template", "MForm", function () {
  594. this.form = new MForm(this.formTableArea, this.data, {
  595. style: this.options.popupStyle,
  596. verifyType: "single", //batch一起校验,或alert弹出
  597. isEdited: this.isEdited || this.isNew,
  598. itemTemplate: {
  599. credential: {
  600. text: this.lp.userName,
  601. defaultValue: this.lp.userName,
  602. className: "inputUser",
  603. notEmpty: true,
  604. defaultValueAsEmpty: true,
  605. emptyTip: this.lp.inputYourUserName,
  606. event: {
  607. focus: function (it) {
  608. if (this.lp.userName === it.getValue()) it.setValue("");
  609. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  610. }.bind(this),
  611. blur: function (it) {
  612. if ("" === it.getValue()) it.setValue(this.lp.userName);
  613. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputUser);
  614. }.bind(this),
  615. keyup: function (it, ev) {
  616. if (ev.event.keyCode === 13) this.ok();
  617. }.bind(this)
  618. },
  619. onEmpty: function (it) {
  620. it.getElements()[0].setStyles(this.css.inputEmpty);
  621. }.bind(this),
  622. onUnempty: function (it) {
  623. it.getElements()[0].setStyles(this.css.inputUser);
  624. }.bind(this)
  625. },
  626. password: {
  627. text: this.lp.password,
  628. type: "password",
  629. defaultValue: "password",
  630. className: "inputPassword",
  631. notEmpty: true,
  632. defaultValueAsEmpty: true,
  633. emptyTip: this.lp.inputYourPassword,
  634. event: {
  635. focus: function (it) {
  636. if ("password" === it.getValue()) it.setValue("");
  637. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  638. }.bind(this),
  639. blur: function (it) {
  640. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputPassword);
  641. }.bind(this),
  642. keyup: function (it, ev) {
  643. if (ev.event.keyCode === 13) this.ok();
  644. }.bind(this)
  645. },
  646. onEmpty: function (it) {
  647. it.getElements()[0].setStyles(this.css.inputEmpty);
  648. }.bind(this),
  649. onUnempty: function (it) {
  650. it.getElements()[0].setStyles(this.css.inputPassword);
  651. }.bind(this)
  652. },
  653. captchaAnswer: {
  654. tType: "number",
  655. text: this.lp.verificationCode,
  656. defaultValue: this.lp.verificationCode,
  657. className: "inputVerificationCode",
  658. notEmpty: true,
  659. defaultValueAsEmpty: true,
  660. emptyTip: this.lp.inputPicVerificationCode,
  661. event: {
  662. focus: function (it) {
  663. if (this.lp.verificationCode === it.getValue()) it.setValue("");
  664. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  665. }.bind(this),
  666. blur: function (it) {
  667. if ("" === it.getValue()) it.setValue(this.lp.verificationCode);
  668. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode);
  669. }.bind(this),
  670. keyup: function (it, ev) {
  671. if (ev.event.keyCode === 13) this.ok();
  672. }.bind(this)
  673. },
  674. onEmpty: function (it) {
  675. it.getElements()[0].setStyles(this.css.inputEmpty);
  676. }.bind(this),
  677. onUnempty: function (it) {
  678. it.getElements()[0].setStyles(this.css.inputVerificationCode);
  679. }.bind(this)
  680. },
  681. changeCaptchaAction: {
  682. value: this.lp.changeVerification,
  683. type: "innerText",
  684. className: "verificationChange",
  685. event: {
  686. click: function () {
  687. this.setCaptchaPic();
  688. }.bind(this)
  689. }
  690. },
  691. codeAnswer: {
  692. text: this.lp.verificationCode,
  693. defaultValue: this.lp.inputVerificationCode,
  694. className: "inputVerificationCode2",
  695. notEmpty: true,
  696. defaultValueAsEmpty: true,
  697. emptyTip: this.lp.inputVerificationCode,
  698. event: {
  699. focus: function (it) {
  700. if (this.lp.inputVerificationCode === it.getValue()) it.setValue("");
  701. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  702. }.bind(this),
  703. blur: function (it) {
  704. if ("" === it.getValue()) it.setValue(this.lp.inputVerificationCode);
  705. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  706. }.bind(this),
  707. keyup: function (it, ev) {
  708. if (ev.event.keyCode === 13) this.ok();
  709. }.bind(this)
  710. },
  711. onEmpty: function (it) {
  712. it.getElements()[0].setStyles(this.css.inputEmpty);
  713. }.bind(this),
  714. onUnempty: function (it) {
  715. it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  716. }.bind(this)
  717. },
  718. codeAnswerWithTwoFactorlogin: {
  719. text: this.lp.verificationCode,
  720. defaultValue: this.lp.inputVerificationCode,
  721. className: "inputVerificationCode3",
  722. notEmpty: false,
  723. defaultValueAsEmpty: true,
  724. emptyTip: this.lp.inputVerificationCode,
  725. event: {
  726. focus: function (it) {
  727. if (this.lp.inputVerificationCode === it.getValue()) it.setValue("");
  728. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  729. }.bind(this),
  730. blur: function (it) {
  731. if ("" === it.getValue()) it.setValue(this.lp.inputVerificationCode);
  732. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode3);
  733. }.bind(this),
  734. keyup: function (it, ev) {
  735. if (ev.event.keyCode === 13) this.doTwoFactorlogin();
  736. }.bind(this)
  737. },
  738. onEmpty: function (it) {
  739. it.getElements()[0].setStyles(this.css.inputEmpty);
  740. }.bind(this),
  741. onUnempty: function (it) {
  742. it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  743. }.bind(this)
  744. },
  745. verificationAction: {
  746. value: this.lp.sendVerification,
  747. type: "button",
  748. className: "inputSendVerification",
  749. event: {
  750. click: function () {
  751. this.sendVerificationAction();
  752. }.bind(this)
  753. }
  754. },
  755. resendVerificationAction: {
  756. value: this.lp.resendVerification,
  757. type: "button",
  758. className: "inputResendVerification"
  759. },
  760. loginAction: {
  761. value: this.twoFactorLogin ? this.lp.sendVerification : this.lp.loginAction,
  762. type: "button",
  763. className: "inputLogin",
  764. event: {
  765. click: function () {
  766. this.ok();
  767. }.bind(this)
  768. }
  769. },
  770. twoFactorloginStep2Action: {
  771. value: this.lp.loginAction,
  772. type: "button",
  773. className: "inputLogin",
  774. event: {
  775. click: function () {
  776. this.doTwoFactorlogin();
  777. }.bind(this)
  778. }
  779. },
  780. passwordAction: {
  781. value: this.lp.passwordLogin,
  782. type: "innerText",
  783. className: "titleNode_active",
  784. event: {
  785. click: function () {
  786. if (this.codeLogin) this.showPasswordLogin();
  787. }.bind(this)
  788. }
  789. },
  790. codeAction: {
  791. value: this.lp.codeLogin,
  792. type: "innerText",
  793. className: "titleNode_normal",
  794. event: {
  795. click: function () {
  796. this.showCodeLogin();
  797. }.bind(this)
  798. }
  799. },
  800. signUpAction: {
  801. value: this.lp.signUp,
  802. type: "innerText",
  803. className: "signUpAction",
  804. event: {
  805. click: function () {
  806. this.gotoSignup();
  807. }.bind(this)
  808. }
  809. },
  810. forgetPassword: {
  811. value: this.lp.forgetPassword,
  812. type: "innerText",
  813. className: "forgetPassword",
  814. event: {
  815. click: function () {
  816. this.gotoResetPassword();
  817. }.bind(this)
  818. }
  819. },
  820. hideTwoFactorySendMsgAction: {
  821. value: this.lp.return,
  822. type: "innerText",
  823. className: "forgetPassword",
  824. event: {
  825. click: function () {
  826. this.hideTwoFactorySendMsgArea();
  827. }.bind(this)
  828. }
  829. }
  830. }
  831. }, this.app, this.css);
  832. this.form.load();
  833. }.bind(this), true);
  834. if (this.bindLogin) {
  835. this.bindLoginContainer = new Element("div", {
  836. styles: this.css.bindLoginContainer
  837. }).inject(this.formContentNode);
  838. var html2 = "<div item='bindLoginTitle' styles='bindTitleNode'></div>" +
  839. "<div styles='bindBodyArea'>" +
  840. "<div item='bindPicArea' styles='bindPicArea'></div>" +
  841. "<div styles='bindSepArea'></div>" +
  842. "<div styles='bindExampleArea'></div>" +
  843. "</div>" +
  844. "<div styles='bindTipArea'>" +
  845. " <div styles='bindTipIconArea'></div>" +
  846. " <div styles='bindTipTextArea'>" +
  847. " " + this.lp.userAppCameraHtml +
  848. " <div>"+this.lp.loginToPage +"</div>" +
  849. "</div>" +
  850. "<div styles='bindErrorArea'></div>";
  851. this.bindLoginContainer.set("html", html2);
  852. this.isShowEnable = true;
  853. this.bindBodyArea = this.bindLoginContainer.getElement("[styles='bindBodyArea']");
  854. this.bindLoginContainer.addEvent("mousemove", function (ev) {
  855. if (this.bindBodyArea.isOutside(ev)) {
  856. this.hideExampleArea(ev);
  857. } else {
  858. this.showExampleArea(ev);
  859. }
  860. }.bind(this));
  861. this.bindPicArea = this.bindLoginContainer.getElement("[item='bindPicArea']");
  862. this.setBindPic();
  863. this.bindExampleArea = this.bindLoginContainer.getElement("[styles='bindExampleArea']");
  864. this.bindSepArea = this.bindLoginContainer.getElement("[styles='bindSepArea']");
  865. var link = this.bindLoginContainer.getElement("[styles='bindTipLinkArea']");
  866. link.addEvent("click", function () {
  867. if( layout.config.appUrl ){
  868. window.open(layout.config.appUrl, "_blank");
  869. }else{
  870. window.open(this.lp.o2downloadLink, "_blank");
  871. }
  872. }.bind(this));
  873. this.bindErrorArea = this.bindLoginContainer.getElement("[styles='bindErrorArea']");
  874. MWF.xDesktop.requireApp("Template", "MForm", function () {
  875. this.bindform = new MForm(this.bindLoginContainer, {}, {
  876. style: "o2platform",
  877. verifyType: "single", //batch一起校验,或alert弹出
  878. isEdited: this.isEdited || this.isNew,
  879. itemTemplate: {
  880. bindLoginTitle: { value: this.lp.bingLoginTitle, type: "innerText" }
  881. }
  882. }, this.app, this.css);
  883. this.bindform.load();
  884. }.bind(this), true);
  885. }
  886. this.loadOauthContent()
  887. },
  888. _beforeFormNodeSize: function () {
  889. if (!this.isPlusOauthSize && this.oauthListNode) {
  890. this.options.height = parseInt(this.options.height) + this.oauthArea.getSize().y;
  891. this.isPlusOauthSize = true;
  892. }
  893. if (this.oauthListNode || (!this.captchaLogin && !this.bindLogin)) { //留高度给二维码
  894. this.options.height = this.options.height - 60;
  895. }
  896. if (this.oauthListNode && this.captchaLogin) {
  897. this.options.height = this.options.height + 60;
  898. }
  899. },
  900. loadOauthContent: function () {
  901. this.actions.listOauthServer(function (json) {
  902. this.oauthList = json.data || [];
  903. if (this.oauthList.length > 0) {
  904. if (!this.oauthArea.getChildren().length) {
  905. this.oauthListNode = new Element("div", { styles: this.css.oauthListNode }).inject(this.oauthArea);
  906. }
  907. this.oauthList.each(function (d) {
  908. if (d.displayName === "@O2企业微信") {
  909. d.qywx = true;
  910. } else if (d.displayName === "@O2钉钉") {
  911. d.dingding = true;
  912. }
  913. this.loadOauthItem(d);
  914. }.bind(this));
  915. }
  916. }.bind(this), null, false);
  917. },
  918. loadOauthItem: function (data) {
  919. var url = data.icon.indexOf("http") == 0 ? data.icon : ("data:image/png;base64," + data.icon);
  920. var itemNode = new Element("div", {
  921. styles: this.css.oauthItemNode,
  922. events: {
  923. click: function () {
  924. var url = "../x_desktop/oauth.html?oauth=" + encodeURIComponent(this.name);
  925. if (this.qywx) {
  926. url += "&qywx=" + this.qywx;
  927. }
  928. if (this.dingding) {
  929. url += "&dingding=" + this.dingding;
  930. }
  931. window.location = url;
  932. }.bind(data)
  933. }
  934. }).inject(this.oauthListNode);
  935. var iconNode = new Element("img", {
  936. styles: this.css.oauthItemIconNode,
  937. src: url
  938. }).inject(itemNode);
  939. var textNode = new Element("div", {
  940. styles: this.css.oauthItemTextNode,
  941. text: data.name
  942. }).inject(itemNode);
  943. },
  944. showTwoFactorySendMsgArea: function (){
  945. this.errorArea.empty();
  946. ["credentialTr","passwordTr","captchaTr", "forgetPasswordTr", "loginActionTr"].each(function (itemName){
  947. var node = this.formTableArea.getElement("[item='"+itemName+"']");
  948. if( node )node.setStyle("display", "none");
  949. }.bind(this));
  950. ["codeTr","hideTwoFactorySendMsgTr","twoFactorloginStep2Tr"].each(function (itemName){
  951. var node = this.formTableArea.getElement("[item='"+itemName+"']");
  952. if( node )node.setStyle("display", "");
  953. }.bind(this));
  954. },
  955. hideTwoFactorySendMsgArea: function (){
  956. this.errorArea.empty();
  957. if (this.captchaLogin) {
  958. var captchaItem = this.form.getItem("captchaAnswer");
  959. if (captchaItem){
  960. captchaItem.setValue( this.lp.verificationCode );
  961. this.setCaptchaPic();
  962. }
  963. }
  964. var codeItem = this.form.getItem("codeAnswerWithTwoFactorlogin");
  965. codeItem.options.notEmpty = false;
  966. codeItem.setValue( this.lp.inputVerificationCode );
  967. ["credentialTr","passwordTr","captchaTr", "forgetPasswordTr", "loginActionTr"].each(function (itemName){
  968. var node = this.formTableArea.getElement("[item='"+itemName+"']");
  969. if( node )node.setStyle("display", "");
  970. }.bind(this));
  971. ["codeTr","hideTwoFactorySendMsgTr","twoFactorloginStep2Tr"].each(function (itemName){
  972. var node = this.formTableArea.getElement("[item='"+itemName+"']");
  973. if( node )node.setStyle("display", "none");
  974. }.bind(this));
  975. },
  976. showExampleArea: function () {
  977. if (this.isHiddingExample || this.isShowingExample) return;
  978. if (!this.isShowEnable) return;
  979. this.isShowingExample = true;
  980. var left = this.bindBodyArea.getPosition(this.bindBodyArea.getParent()).x;
  981. var hideLeft = ((this.bindBodyArea.getParent().getSize().x) - 400) / 2;
  982. this.intervalId = setInterval(function () {
  983. if (left > hideLeft) {
  984. this.bindBodyArea.setStyle("margin-left", (left - 5) + "px");
  985. left = left - 5;
  986. } else {
  987. clearInterval(this.intervalId);
  988. this.bindBodyArea.setStyle("width", "400px");
  989. this.bindSepArea.setStyle("display", "");
  990. this.bindExampleArea.setStyle("display", "");
  991. this.isHidEnable = true;
  992. this.isShowEnable = false;
  993. this.isShowingExample = false;
  994. }
  995. }.bind(this), 10)
  996. },
  997. hideExampleArea: function () {
  998. if (this.isShowingExample || this.isHiddingExample) return;
  999. if (!this.isHidEnable) return;
  1000. this.isHiddingExample = true;
  1001. var left = this.bindBodyArea.getPosition(this.bindBodyArea.getParent()).x;
  1002. this.bindSepArea.setStyle("display", "none");
  1003. this.bindExampleArea.setStyle("display", "none");
  1004. var hideLeft = ((this.bindBodyArea.getParent().getSize().x) - 200) / 2;
  1005. this.intervalId2 = setInterval(function () {
  1006. if (left < hideLeft) {
  1007. this.bindBodyArea.setStyle("margin-left", (left + 5) + "px");
  1008. left = left + 5;
  1009. } else {
  1010. clearInterval(this.intervalId2);
  1011. this.bindBodyArea.setStyle("width", "204px");
  1012. this.isHidEnable = false;
  1013. this.isShowEnable = true;
  1014. this.isHiddingExample = false;
  1015. }
  1016. }.bind(this), 10)
  1017. },
  1018. showPasswordLogin: function () {
  1019. this.errorArea.empty();
  1020. this.loginType = "captcha";
  1021. this.form.getItem("passwordAction").setStyles(this.css.titleNode_active);
  1022. this.form.getItem("codeAction").setStyles(this.css.titleNode_normal);
  1023. this.formTableArea.getElement("[item='passwordTr']").setStyle("display", "");
  1024. var captchaTr = this.formTableArea.getElement("[item='captchaTr']");
  1025. if (captchaTr) captchaTr.setStyle("display", "");
  1026. this.formTableArea.getElement("[item='codeTr']").setStyle("display", "none");
  1027. },
  1028. showCodeLogin: function () {
  1029. this.errorArea.empty();
  1030. this.loginType = "code";
  1031. this.form.getItem("passwordAction").setStyles(this.css.titleNode_normal);
  1032. this.form.getItem("codeAction").setStyles(this.css.titleNode_active);
  1033. this.formTableArea.getElement("[item='passwordTr']").setStyle("display", "none");
  1034. var captchaTr = this.formTableArea.getElement("[item='captchaTr']");
  1035. if (captchaTr) captchaTr.setStyle("display", "none");
  1036. this.formTableArea.getElement("[item='codeTr']").setStyle("display", "");
  1037. },
  1038. showBindCodeLogin: function () {
  1039. this.errorArea.empty();
  1040. this.formTableContainer.setStyle("display", "none");
  1041. this.bindLoginContainer.setStyle("display", "");
  1042. this.bindLoginTipPic.setStyle("display", "none");
  1043. this.bindLoginAction.setStyle("display", "none");
  1044. this.backtoPasswordLoginTipPic.setStyle("display", "");
  1045. this.backtoPasswordLoginAction.setStyle("display", "");
  1046. this.checkBindStatus();
  1047. },
  1048. backtoPasswordLogin: function () {
  1049. this.errorArea.empty();
  1050. if (this.bindStatusInterval) clearInterval(this.bindStatusInterval);
  1051. this.formTableContainer.setStyle("display", "");
  1052. this.bindLoginContainer.setStyle("display", "none");
  1053. this.bindLoginTipPic.setStyle("display", "");
  1054. this.bindLoginAction.setStyle("display", "");
  1055. this.backtoPasswordLoginTipPic.setStyle("display", "none");
  1056. this.backtoPasswordLoginAction.setStyle("display", "none");
  1057. },
  1058. setBindPic: function () {
  1059. this.bindPicArea.empty();
  1060. this.actions.getLoginBind(function (json) {
  1061. this.bindMeta = json.data.meta;
  1062. new Element("img", {
  1063. src: "data:image/png;base64," + json.data.image
  1064. }).inject(this.bindPicArea);
  1065. }.bind(this))
  1066. },
  1067. setCaptchaPic: function () {
  1068. if (!this.captchaLogin) return;
  1069. var captchaPic = this.formTableArea.getElement("[item='captchaPic']");
  1070. captchaPic.empty();
  1071. this.actions.getLoginCaptcha(120, 50, function (json) {
  1072. this.captcha = json.data.id;
  1073. new Element("img", {
  1074. src: "data:image/png;base64," + json.data.image,
  1075. styles: this.css.verificationImage
  1076. }).inject(captchaPic);
  1077. }.bind(this), null, true, null, false)
  1078. },
  1079. sendVerificationAction: function () {
  1080. var flag = true;
  1081. var credentialItem = this.form.getItem("credential");
  1082. var credential = credentialItem.getValue();
  1083. if (!credential || credential.trim() === "") {
  1084. credentialItem.setWarning(this.lp.inputYourUserName, "empty");
  1085. return;
  1086. } else {
  1087. // this.actions.checkCredential(credential, function (json) {
  1088. // if (!json.data.value) {
  1089. // flag = false;
  1090. // credentialItem.setWarning(this.lp.userNotExist, "invalid");
  1091. // }
  1092. // }.bind(this), function (errorObj) {
  1093. // flag = false;
  1094. // var error = JSON.parse(errorObj.responseText);
  1095. // credentialItem.setWarning(error.message, "invalid");
  1096. // }.bind(this), false)
  1097. }
  1098. if (!flag) {
  1099. return;
  1100. } else {
  1101. credentialItem.clearWarning("invalid");
  1102. }
  1103. this.actions.createCredentialCode(credential, function (json) {
  1104. }, function (errorObj) {
  1105. var error = JSON.parse(errorObj.responseText);
  1106. var codeAnswerItem = this.form.getItem("codeAnswer");
  1107. if(codeAnswerItem){
  1108. codeAnswerItem.clearWarning("empty");
  1109. }
  1110. this.setWarning(error.message);
  1111. flag = false
  1112. }.bind(this));
  1113. if (!flag) {
  1114. return;
  1115. } else {
  1116. this.errorArea.empty();
  1117. }
  1118. this.form.getItem("verificationAction").container.setStyle("display", "none");
  1119. this.setResendVerification();
  1120. },
  1121. setResendVerification: function () {
  1122. var resendItem = this.form.getItem("resendVerificationAction");
  1123. resendItem.container.setStyle("display", "");
  1124. this.resendElement = resendItem.getElements()[0];
  1125. this.resendElement.set("text", this.lp.resendVerification + "(60)");
  1126. var i = 60;
  1127. this.timer = setInterval(function () {
  1128. if (i > 0) {
  1129. this.resendElement.set("text", this.lp.resendVerification + "(" + --i + ")")
  1130. } else {
  1131. this.form.getItem("verificationAction").container.setStyle("display", "");
  1132. resendItem.container.setStyle("display", "none");
  1133. clearInterval(this.timer)
  1134. }
  1135. }.bind(this), 1000)
  1136. },
  1137. gotoSignup: function () {
  1138. this.explorer.openSignUpForm();
  1139. //this.explorer.openResetPasswordForm();
  1140. this.close();
  1141. },
  1142. gotoResetPassword: function () {
  1143. this.explorer.openResetPasswordForm();
  1144. this.close();
  1145. },
  1146. gotoChangePassword : function( options ){ //密码过期
  1147. this.explorer.openChangePasswordForm( options, function(){
  1148. this.explorer.loadLogin();
  1149. }.bind(this));
  1150. this.close();
  1151. },
  1152. checkBindStatus: function () {
  1153. this.bindStatusInterval = setInterval(function () {
  1154. this.actions.checkBindStatus(this.bindMeta, function (json) {
  1155. if (json.data) {
  1156. if (json.data.name && json.data.name !== "anonymous") {
  1157. this.fireEvent("queryOk");
  1158. this._close();
  1159. if (this.formMaskNode) this.formMaskNode.destroy();
  1160. this.formAreaNode.destroy();
  1161. if (this.explorer && this.explorer.view) this.explorer.view.reload();
  1162. if (this.app) this.app.notice(this.lp.loginSuccess, "success");
  1163. this.fireEvent("postOk", json);
  1164. }
  1165. }
  1166. }.bind(this), function (errorObj) {
  1167. var error = JSON.parse( errorObj.responseText );
  1168. if (this.app) {
  1169. this.app.notice(error.message, "error");
  1170. }else{
  1171. this.setBindWarning( error.message );
  1172. }
  1173. }.bind(this))
  1174. }.bind(this), 3000);
  1175. },
  1176. _close: function () {
  1177. if (this.bindStatusInterval) clearInterval(this.bindStatusInterval);
  1178. if (this.timer) clearInterval(this.timer);
  1179. },
  1180. ok: function () {
  1181. this.fireEvent("queryOk");
  1182. this.errorArea.empty();
  1183. var captchaItem = null;
  1184. var codeItem = null;
  1185. if (this.loginType === "captcha") {
  1186. this.form.getItem("password").options.notEmpty = true;
  1187. if (this.captchaLogin) {
  1188. captchaItem = this.form.getItem("captchaAnswer");
  1189. if (captchaItem) captchaItem.options.notEmpty = true;
  1190. }
  1191. codeItem = this.form.getItem("codeAnswer");
  1192. if (codeItem) codeItem.options.notEmpty = false;
  1193. } else if (this.loginType === "code") {
  1194. this.form.getItem("password").options.notEmpty = false;
  1195. if (this.captchaLogin) {
  1196. captchaItem = this.form.getItem("captchaAnswer");
  1197. if (captchaItem) captchaItem.options.notEmpty = false;
  1198. }
  1199. codeItem = this.form.getItem("codeAnswer");
  1200. if (codeItem) codeItem.options.notEmpty = true;
  1201. }
  1202. var data = this.form.getResult(true, ",", true, false, true);
  1203. if (data) {
  1204. this._ok(data, function (json) {
  1205. this.afterLogin( json );
  1206. }.bind(this));
  1207. }
  1208. },
  1209. afterLogin: function (json) {
  1210. if (json.type === "error") {
  1211. if (this.app) this.app.notice(json.message, "error");
  1212. } else if( json.data.passwordExpired ){ //密码过期
  1213. var userName = json.data.distinguishedName;
  1214. this.explorer.logout( function(){ //注销再到密码修改页
  1215. this.gotoChangePassword({
  1216. userName : userName
  1217. });
  1218. }.bind(this))
  1219. } else {
  1220. this._close();
  1221. if (this.formMaskNode) this.formMaskNode.destroy();
  1222. this.formAreaNode.destroy();
  1223. if (this.explorer && this.explorer.view) this.explorer.view.reload();
  1224. if (this.app) this.app.notice(this.lp.loginSuccess, "success");
  1225. this.fireEvent("postOk", json);
  1226. }
  1227. },
  1228. doTwoFactorlogin: function (){
  1229. var codeItem = this.form.getItem("codeAnswerWithTwoFactorlogin");
  1230. codeItem.options.notEmpty = true;
  1231. if ( codeItem.verify(true) ) {
  1232. var d = {
  1233. credential: this.captchaLoginData.credential,
  1234. codeAnswer: codeItem.getValue()
  1235. };
  1236. this.actions.loginByCode(d, function (json) {
  1237. codeItem.options.notEmpty = false;
  1238. this.afterLogin(json);
  1239. }.bind(this), function (errorObj) {
  1240. codeItem.options.notEmpty = false;
  1241. var error = JSON.parse(errorObj.responseText);
  1242. this.setWarning(error.message);
  1243. }.bind(this));
  1244. }
  1245. },
  1246. setWarning: function (text) {
  1247. this.errorArea.empty();
  1248. new Element("div", {
  1249. "text": text,
  1250. "styles": this.css.warningMessageNode
  1251. }).inject(this.errorArea);
  1252. },
  1253. setBindWarning: function (text) {
  1254. if( this.bindErrorArea ){
  1255. this.bindErrorArea.empty();
  1256. new Element("div", {
  1257. "text": text,
  1258. "styles": this.css.warningMessageNode
  1259. }).inject(this.bindErrorArea);
  1260. }
  1261. },
  1262. _ok: function (data, callback) {
  1263. var d = null;
  1264. if (this.loginType === "captcha") {
  1265. d = {
  1266. credential: data.credential,
  1267. password: data.password
  1268. };
  1269. if (this.captchaLogin) {
  1270. d.captchaAnswer = data.captchaAnswer;
  1271. d.captcha = this.captcha;
  1272. }
  1273. if( this.twoFactorLogin ){
  1274. this.captchaLoginData = d;
  1275. this.actions.loginByTwoFactor(d, function (json){
  1276. if( json.data.passwordExpired ){ //密码过期
  1277. //var userName = json.data.distinguishedName;
  1278. this.gotoChangePassword({
  1279. userName : d.credential,
  1280. oldPassword: d.password
  1281. });
  1282. }else{
  1283. this.showTwoFactorySendMsgArea();
  1284. }
  1285. }.bind(this), function (errorObj) {
  1286. var error = JSON.parse(errorObj.responseText);
  1287. this.setWarning(error.message);
  1288. this.setCaptchaPic();
  1289. if (this.form.getItem("captchaAnswer")) this.form.getItem("captchaAnswer").setValue("");
  1290. }.bind(this));
  1291. }else{
  1292. this.actions.loginByCaptcha(d, function (json) {
  1293. if (callback) callback(json);
  1294. //this.fireEvent("postOk")
  1295. }.bind(this), function (errorObj) {
  1296. var error = JSON.parse(errorObj.responseText);
  1297. this.setWarning(error.message);
  1298. this.setCaptchaPic();
  1299. if (this.form.getItem("captchaAnswer")) this.form.getItem("captchaAnswer").setValue("");
  1300. }.bind(this));
  1301. }
  1302. } else if (this.loginType === "code") {
  1303. d = {
  1304. credential: data.credential,
  1305. codeAnswer: data.codeAnswer
  1306. };
  1307. this.actions.loginByCode(d, function (json) {
  1308. if (callback) callback(json);
  1309. //this.fireEvent("postOk")
  1310. }.bind(this), function (errorObj) {
  1311. var error = JSON.parse(errorObj.responseText);
  1312. this.setWarning(error.message);
  1313. }.bind(this));
  1314. }
  1315. }
  1316. });
  1317. MWF.xDesktop.Authentication.SignUpForm = new Class({
  1318. Extends: MPopupForm,
  1319. Implements: [Options, Events],
  1320. options: {
  1321. "style": "default",
  1322. "popupStyle": "o2platformSignup",
  1323. "width": "910",
  1324. "height": "740",
  1325. "hasTop": true,
  1326. "hasIcon": false,
  1327. "hasTopIcon": true,
  1328. "hasTopContent": true,
  1329. "hasBottom": false,
  1330. "title": "",
  1331. "draggable": true,
  1332. "closeAction": true
  1333. },
  1334. load: function () {
  1335. if (!this.options.title) this.setOptions({
  1336. "title": MWF.LP.authentication.SignUpFormTitle
  1337. });
  1338. this._loadCss();
  1339. },
  1340. _createTableContent: function () {
  1341. if( this.formTopTextNode && this.formTopCloseActionNode ){
  1342. this.formTopCloseActionNode.inject( this.formTopTextNode, "before" )
  1343. }
  1344. var self = this;
  1345. this.actions = MWF.Actions.get("x_organization_assemble_personal");
  1346. var signUpMode = "code";
  1347. this.actions.getRegisterMode(function (json) {
  1348. signUpMode = json.data.value;
  1349. }.bind(this), null, false);
  1350. this.formTopNode.setStyle("height","50px");
  1351. this.formTableContainer.setStyles({
  1352. "width": "890px",
  1353. "margin-top": "40px"
  1354. });
  1355. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1356. "<tr><td styles='formTableTitle' lable='name' width='200'></td>" +
  1357. " <td styles='formTableValue' width='350'>" +
  1358. " <div style='position: relative;'><div item='name'></div><div class='inputUserIcon'></div></div>" +
  1359. " </td>" +
  1360. " <td styles='formTableValue' item='nameTip'></td></tr>" +
  1361. "<tr><td styles='formTableTitle' lable='password'></td>" +
  1362. " <td styles='formTableValue'>" +
  1363. " <div style='position: relative;'><div item='password'></div><div class='inputPasswordIcon'></div></div>" +
  1364. " </td>" +
  1365. " <td styles='formTableValue'><div item='passwordStrengthArea'></div></div><div item='passwordTip'></div></td></tr>" +
  1366. "<tr><td styles='formTableTitle' lable='confirmPassword'></td>" +
  1367. " <td styles='formTableValue'>" +
  1368. " <div style='position: relative;'><div item='confirmPassword'></div><div class='inputComfirmPasswordIcon'></div></div>" +
  1369. " </td>" +
  1370. " <td styles='formTableValue' item='confirmPasswordTip'></td></tr>" +
  1371. "<tr><td styles='formTableTitle' lable='genderType'></td>" +
  1372. " <td styles='formTableValue' item='genderType'></td>" +
  1373. " <td styles='formTableValue' item='genderTypeTip'></td></tr>" +
  1374. "<tr><td styles='formTableTitle' lable='mail'></td>" +
  1375. " <td styles='formTableValue'>" +
  1376. " <div style='position: relative;'><div item='mail'></div><div class='inputMailIcon'></div></div>" +
  1377. " </td>" +
  1378. " <td styles='formTableValue' item='mailTip'></td></tr>" +
  1379. "<tr><td styles='formTableTitle' lable='mobile'></td>" +
  1380. " <td styles='formTableValue'>" +
  1381. " <div style='position: relative;'><div item='mobile'></div><div class='inputMobileIcon'></div></div>" +
  1382. " </td>" +
  1383. " <td styles='formTableValue' item='mobileTip'></td></tr>";
  1384. if (signUpMode === "code") {
  1385. html += "<tr><td styles='formTableTitle' lable='codeAnswer'></td>" +
  1386. " <td styles='formTableValue'>" +
  1387. " <div style='float:left;'>" +
  1388. " <div style='position: relative;'><div item='codeAnswer'></div><div class='inputVerificationCode2Icon'></div></div>" +
  1389. " </div>" +
  1390. " <div item='verificationAction' style='float:left;'></div>" +
  1391. " <div item='resendVerificationAction' style='float:left;display:none;'></div>" +
  1392. " </td>" +
  1393. " <td styles='formTableValue' item='verificationCodeTip'></td></tr>";
  1394. } else {
  1395. html += "<tr><td styles='formTableTitle' lable='captchaAnswer'></td>" +
  1396. " <td styles='formTableValue'>" +
  1397. " <div style='float:left;'>" +
  1398. " <div style='position: relative;'><div item='captchaAnswer'></div><div class='inputVerificationCodeIcon'></div></div>" +
  1399. " </div>" +
  1400. " <div item='captchaPic' style='float:left;'></div>" +
  1401. " <div item='changeCaptchaAction' style='float:left;'></div>" +
  1402. " </td>" +
  1403. " <td styles='formTableValue' item='captchaAnswerTip'></td></tr>";
  1404. }
  1405. html += "<tr><td styles='formTableTitle'></td>" +
  1406. " <td styles='formTableValue' item='signUpAction'></td>" +
  1407. " <td styles='formTableValue' item='signUpTip'></td></tr>" +
  1408. "<tr><td></td>" +
  1409. " <td><div item='hasAccountArea'></div><div item='gotoLoginAction'></div></td>" +
  1410. " <td></td></tr>" +
  1411. "</table>";
  1412. this.formTableArea.set("html", html);
  1413. if (signUpMode === "captcha") {
  1414. this.setCaptchaPic();
  1415. }
  1416. //this.createPasswordStrengthNode();
  1417. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1418. this.form = new MForm(this.formTableArea, this.data, {
  1419. style: this.options.popupStyle,
  1420. verifyType: "batchSingle", //batch一起校验,或alert弹出
  1421. isEdited: this.isEdited || this.isNew,
  1422. onPostLoad: function () {
  1423. var form = this.form;
  1424. var table = this.formTableArea;
  1425. form.getItem("name").tipNode = table.getElement("[item='nameTip']");
  1426. form.getItem("password").tipNode = table.getElement("[item='passwordTip']");
  1427. form.getItem("confirmPassword").tipNode = table.getElement("[item='confirmPasswordTip']");
  1428. form.getItem("mail").tipNode = table.getElement("[item='mailTip']");
  1429. form.getItem("genderType").tipNode = table.getElement("[item='genderTypeTip']");
  1430. form.getItem("mobile").tipNode = table.getElement("[item='mobileTip']");
  1431. this.tipNode = table.getElement("[item='signUpTip']");
  1432. var captchaAnswer = form.getItem("captchaAnswer");
  1433. if (captchaAnswer) {
  1434. form.getItem("captchaAnswer").tipNode = table.getElement("[item='captchaAnswerTip']");
  1435. }
  1436. var codeAnswer = form.getItem("codeAnswer");
  1437. if (codeAnswer) {
  1438. form.getItem("codeAnswer").tipNode = table.getElement("[item='verificationCodeTip']");
  1439. }
  1440. }.bind(this),
  1441. itemTemplate: {
  1442. name: {
  1443. text: this.lp.userName, defaultValue: this.lp.userName, className: "inputUser",
  1444. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourUserName,
  1445. validRule: { isInvalid: function (value, it) { return this.checkUserName(value, it); }.bind(this) },
  1446. validMessage: { isInvalid: this.lp.userExist },
  1447. event: {
  1448. focus: function (it) { if (this.lp.userName === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1449. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this),
  1450. blur: function (it) {
  1451. if (it.verify(true)) {
  1452. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputUser);
  1453. }
  1454. }.bind(this)
  1455. }, onEmpty: function (it) {
  1456. it.getElements()[0].setStyles(this.css.inputEmpty);
  1457. }.bind(this), onUnempty: function (it) {
  1458. it.getElements()[0].setStyles(this.css.inputUser);
  1459. }.bind(this)
  1460. },
  1461. password: {
  1462. text: this.lp.password, type: "password", className: "inputPassword",
  1463. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourPassword,
  1464. validRule: {
  1465. passwordIsWeak: function (value, it) {
  1466. return !this.getPasswordRule(it.getValue());
  1467. }.bind(this)
  1468. },
  1469. validMessage: {
  1470. passwordIsWeak: function () {
  1471. return self.getPasswordRule(this.getValue());
  1472. }
  1473. }, //this.lp.passwordIsSimple
  1474. event: {
  1475. focus: function (it) { if ("password" === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1476. //keyup : function(it){ this.pwStrength(it.getValue()) }.bind(this),
  1477. blur: function (it) { it.verify(true) }.bind(this)
  1478. }, onEmpty: function (it) {
  1479. it.getElements()[0].setStyles(this.css.inputEmpty);
  1480. }.bind(this), onUnempty: function (it) {
  1481. it.getElements()[0].setStyles(this.css.inputPassword);
  1482. }.bind(this)
  1483. },
  1484. confirmPassword: {
  1485. text: this.lp.confirmPassword, type: "password", className: "inputComfirmPassword",
  1486. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputComfirmPassword,
  1487. validRule: {
  1488. passwordNotEqual: function (value, it) {
  1489. if (it.getValue() === this.form.getItem("password").getValue()) return true;
  1490. }.bind(this)
  1491. },
  1492. validMessage: { passwordNotEqual: this.lp.passwordNotEqual },
  1493. event: {
  1494. focus: function (it) { if ("password" === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1495. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this),
  1496. blur: function (it) {
  1497. if (it.verify(true)) {
  1498. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputComfirmPassword);
  1499. }
  1500. }.bind(this)
  1501. }, onEmpty: function (it) {
  1502. it.getElements()[0].setStyles(this.css.inputEmpty);
  1503. }.bind(this), onUnempty: function (it) {
  1504. it.getElements()[0].setStyles(this.css.inputComfirmPassword);
  1505. }.bind(this)
  1506. },
  1507. mail: {
  1508. text: this.lp.mail, defaultValue: this.lp.inputYourMail, className: "inputMail",
  1509. notEmpty: false, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourMail,
  1510. validRule: { isFormatInvalid: function (value, it) {
  1511. if( (!value || value===this.lp.inputYourMail) ||
  1512. /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value ) ){
  1513. it.tipNode.empty();
  1514. it.warningStatus = false;
  1515. return true;
  1516. }else{
  1517. it.warningStatus = true;
  1518. return false;
  1519. }
  1520. }.bind(this) },
  1521. validMessage: { isFormatInvalid: this.lp.mailFormatError },
  1522. event: { //validRule: { email: false },
  1523. focus: function (it) {
  1524. if (this.lp.inputYourMail === it.getValue()) it.setValue("");
  1525. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  1526. }.bind(this),
  1527. blur: function (it) {
  1528. it.verify(true);
  1529. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputMail);
  1530. }.bind(this),
  1531. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this)
  1532. }, onEmpty: function (it) {
  1533. // it.getElements()[0].setStyles(this.css.inputEmpty);
  1534. }.bind(this), onUnempty: function (it) {
  1535. // it.getElements()[0].setStyles(this.css.inputMail);
  1536. }.bind(this)
  1537. },
  1538. genderType: {
  1539. text: this.lp.genderType, className: "inputGenderType", type: "select", selectValue: this.lp.genderTypeValue.split(","), selectText: this.lp.genderTypeText.split(","),
  1540. notEmpty: true, emptyTip: this.lp.selectGenderType, event: {
  1541. focus: function (it) { if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1542. blur: function (it) { it.verify(true); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputGenderType); }.bind(this),
  1543. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this)
  1544. }, onEmpty: function (it) {
  1545. it.getElements()[0].setStyles(this.css.inputEmpty);
  1546. }.bind(this), onUnempty: function (it) {
  1547. it.getElements()[0].setStyles(this.css.inputGenderType);
  1548. }.bind(this)
  1549. },
  1550. mobile: {
  1551. text: this.lp.mobile, defaultValue: this.lp.inputYourMobile, className: "inputMobile", tType: "number",
  1552. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourMobile,
  1553. validRule: { isInvalid: function (value, it) { return this.checkMobile(value, it); }.bind(this) },
  1554. validMessage: { isInvalid: this.lp.mobileIsRegisted },
  1555. event: {
  1556. focus: function (it) { if (this.lp.inputYourMobile === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1557. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this),
  1558. blur: function (it) {
  1559. if (it.verify(true)) {
  1560. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputMobile);
  1561. }
  1562. }.bind(this)
  1563. }, onEmpty: function (it) {
  1564. it.getElements()[0].setStyles(this.css.inputEmpty);
  1565. }.bind(this), onUnempty: function (it) {
  1566. it.getElements()[0].setStyles(this.css.inputMobile);
  1567. }.bind(this)
  1568. },
  1569. captchaAnswer: {
  1570. tType: "number", text: this.lp.verificationCode, defaultValue: this.lp.verificationCode, className: "inputVerificationCode",
  1571. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputPicVerificationCode, event: {
  1572. focus: function (it) { if (this.lp.verificationCode === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1573. blur: function (it) { it.verify(true); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode); }.bind(this),
  1574. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this)
  1575. }, onEmpty: function (it) {
  1576. it.getElements()[0].setStyles(this.css.inputEmpty);
  1577. }.bind(this), onUnempty: function (it) {
  1578. it.getElements()[0].setStyles(this.css.inputVerificationCode);
  1579. }.bind(this)
  1580. },
  1581. changeCaptchaAction: {
  1582. value: this.lp.changeVerification, type: "innerText", className: "verificationChange", event: {
  1583. click: function () {
  1584. this.setCaptchaPic();
  1585. }.bind(this)
  1586. }
  1587. },
  1588. codeAnswer: {
  1589. text: this.lp.verificationCode, defaultValue: this.lp.inputVerificationCode, className: "inputVerificationCode2",
  1590. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputVerificationCode, event: {
  1591. focus: function (it) { if (this.lp.inputVerificationCode === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1592. blur: function (it) { it.verify(true); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode2); }.bind(this),
  1593. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.ok() } }.bind(this)
  1594. }, onEmpty: function (it) {
  1595. it.getElements()[0].setStyles(this.css.inputEmpty);
  1596. }.bind(this), onUnempty: function (it) {
  1597. it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  1598. }.bind(this)
  1599. },
  1600. verificationAction: {
  1601. value: this.lp.sendVerification, type: "button", className: "inputSendVerification", event: {
  1602. click: function () { this.sendVerificationAction() }.bind(this)
  1603. }
  1604. },
  1605. resendVerificationAction: { value: this.lp.resendVerification, type: "button", className: "inputResendVerification" },
  1606. signUpAction: {
  1607. value: this.lp.signUp, type: "button", className: "inputSignUp", event: {
  1608. click: function () { this.ok() }.bind(this)
  1609. }
  1610. },
  1611. hasAccountArea: { value: this.lp.hasAccount, type: "innerText", className: "hasCountArea" },
  1612. gotoLoginAction: {
  1613. value: this.lp.gotoLogin, type: "innerText", className: "gotoLoginAction", event: {
  1614. click: function () { this.gotoLogin() }.bind(this)
  1615. }
  1616. }
  1617. }
  1618. }, this.app, this.css);
  1619. this.form.load();
  1620. }.bind(this), true);
  1621. },
  1622. checkMobile: function (mobile, it) {
  1623. var flag = true;
  1624. this.actions.checkRegisterMobile(mobile, function () {
  1625. flag = true
  1626. }.bind(this), function (errorObj) {
  1627. if (errorObj.status === 404) {
  1628. it.options.validMessage.isInvalid = this.lp.pageNotFound;
  1629. flag = false;
  1630. } else {
  1631. var error = JSON.parse(errorObj.responseText);
  1632. it.options.validMessage.isInvalid = error.message;
  1633. flag = false;
  1634. }
  1635. }.bind(this), false);
  1636. return flag;
  1637. },
  1638. checkUserName: function (userName, it) {
  1639. var flag = true;
  1640. this.actions.checkRegisterName(userName, function () {
  1641. flag = true
  1642. }.bind(this), function (errorObj) {
  1643. if (errorObj.status === 404) {
  1644. it.options.validMessage.isInvalid = this.lp.pageNotFound;
  1645. flag = false
  1646. } else {
  1647. var error = JSON.parse(errorObj.responseText);
  1648. it.options.validMessage.isInvalid = error.message;
  1649. flag = false
  1650. }
  1651. }.bind(this), false);
  1652. return flag;
  1653. },
  1654. setCaptchaPic: function () {
  1655. var captchaPic = this.formTableArea.getElement("[item='captchaPic']");
  1656. captchaPic.empty();
  1657. this.actions.getRegisterCaptcha(120, 50, function (json) {
  1658. this.captcha = json.data.id;
  1659. new Element("img", {
  1660. src: "data:image/png;base64," + json.data.image,
  1661. styles: this.css.verificationImage
  1662. }).inject(captchaPic);
  1663. }.bind(this))
  1664. },
  1665. sendVerificationAction: function () {
  1666. var flag = true;
  1667. var it = this.form.getItem("mobile");
  1668. if (it.verify(true)) {
  1669. it.clearWarning();
  1670. it.getElements()[0].setStyles(this.css.inputMobile);
  1671. } else {
  1672. return;
  1673. }
  1674. this.actions.createRegisterCode(it.getValue(), function (json) {
  1675. }, function (errorObj) {
  1676. var codeIt = this.form.getItem("codeAnswer");
  1677. var error = JSON.parse(errorObj.responseText);
  1678. if (errorObj.status === 404) {
  1679. codeIt.setWarning(error.message, this.lp.pageNotFound);
  1680. flag = false;
  1681. } else {
  1682. codeIt.setWarning(error.message, "invalid");
  1683. flag = false;
  1684. }
  1685. }.bind(this), false);
  1686. if (!flag) return false;
  1687. this.form.getItem("verificationAction").container.setStyle("display", "none");
  1688. this.setResendVerification();
  1689. },
  1690. setResendVerification: function () {
  1691. var resendItem = this.form.getItem("resendVerificationAction");
  1692. resendItem.container.setStyle("display", "");
  1693. this.resendElement = resendItem.getElements()[0];
  1694. this.resendElement.set("text", this.lp.resendVerification + "(60)");
  1695. var i = 60;
  1696. this.timer = setInterval(function () {
  1697. if (i > 0) {
  1698. this.resendElement.set("text", this.lp.resendVerification + "(" + --i + ")")
  1699. } else {
  1700. this.form.getItem("verificationAction").container.setStyle("display", "");
  1701. resendItem.container.setStyle("display", "none");
  1702. clearInterval(this.timer)
  1703. }
  1704. }.bind(this), 1000)
  1705. },
  1706. getPasswordRule: function (password) {
  1707. var str = "";
  1708. this.actions.checkRegisterPassword(password, function (json) {
  1709. str = json.data.value || "";
  1710. }.bind(this), null, false);
  1711. return str;
  1712. },
  1713. //createPasswordStrengthNode : function(){
  1714. // var passwordStrengthArea = this.formTableArea.getElement("[item='passwordStrengthArea']");
  1715. //
  1716. // var lowNode = new Element( "div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  1717. // this.lowColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( lowNode );
  1718. // this.lowTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.weak }).inject( lowNode );
  1719. //
  1720. // var middleNode = new Element( "div" , {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  1721. // this.middleColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( middleNode );
  1722. // this.middleTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.middle }).inject( middleNode );
  1723. //
  1724. // var highNode = new Element("div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  1725. // this.highColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( highNode );
  1726. // this.highTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.high }).inject( highNode );
  1727. //},
  1728. //getPasswordLevel: function( password ){
  1729. // // Level(级别)
  1730. // // •0-3 : [easy]
  1731. // // •4-6 : [midium]
  1732. // // •7-9 : [strong]
  1733. // // •10-12 : [very strong]
  1734. // // •>12 : [extremely strong]
  1735. // var level = 0;
  1736. // this.actions.checkRegisterPassword( password, function( json ){
  1737. // level = json.data.value;
  1738. // }.bind(this), null, false );
  1739. // return level;
  1740. //},
  1741. //pwStrength: function(pwd){
  1742. // this.lowColorNode.setStyles( this.css.passwordStrengthColor );
  1743. // this.lowTextNode.setStyles( this.css.passwordStrengthText );
  1744. // this.middleColorNode.setStyles( this.css.passwordStrengthColor );
  1745. // this.middleTextNode.setStyles( this.css.passwordStrengthText );
  1746. // this.highColorNode.setStyles( this.css.passwordStrengthColor );
  1747. // this.highTextNode.setStyles( this.css.passwordStrengthText );
  1748. // if (!pwd){
  1749. // }else{
  1750. // //var level = this.checkStrong(pwd);
  1751. // var level = this.getPasswordLevel(pwd);
  1752. // switch(level) {
  1753. // case 0:
  1754. // case 1:
  1755. // case 2:
  1756. // case 3:
  1757. // this.lowColorNode.setStyles( this.css.passwordStrengthColor_low );
  1758. // this.lowTextNode.setStyles( this.css.passwordStrengthText_current );
  1759. // break;
  1760. // case 4:
  1761. // case 5:
  1762. // case 6:
  1763. // this.middleColorNode.setStyles( this.css.passwordStrengthColor_middle );
  1764. // this.middleTextNode.setStyles( this.css.passwordStrengthText_current );
  1765. // break;
  1766. // default:
  1767. // this.highColorNode.setStyles( this.css.passwordStrengthColor_high );
  1768. // this.highTextNode.setStyles( this.css.passwordStrengthText_current );
  1769. // }
  1770. // }
  1771. //},
  1772. gotoLogin: function () {
  1773. this.explorer.openLoginForm({}, function () { window.location.reload(); });
  1774. this.close();
  1775. },
  1776. setWarning: function (text) {
  1777. this.tipNode.empty();
  1778. new Element("div", {
  1779. "text": text,
  1780. "styles": this.css.warningMessageNode
  1781. }).inject(this.tipNode);
  1782. },
  1783. setNotice: function (text) {
  1784. this.tipNode.empty();
  1785. new Element("div", {
  1786. "text": text,
  1787. "styles": this.css.noticeMessageNode
  1788. }).inject(this.tipNode);
  1789. },
  1790. ok: function () {
  1791. this.tipNode.empty();
  1792. this.fireEvent("queryOk");
  1793. var data = this.form.getResult(true, ",", true, false, true);
  1794. if (data) {
  1795. this._ok(data, function (json) {
  1796. if (json.type === "error") {
  1797. if (this.app) this.app.notice(json.message, "error");
  1798. } else {
  1799. if (this.formMaskNode) this.formMaskNode.destroy();
  1800. this.formAreaNode.destroy();
  1801. this.setNotice(this.lp.registeSuccess);
  1802. if (this.app) this.app.notice(this.lp.registeSuccess, "success");
  1803. this.fireEvent("postOk", json);
  1804. this.gotoLogin();
  1805. }
  1806. }.bind(this))
  1807. }
  1808. },
  1809. _ok: function (data, callback) {
  1810. data.captcha = this.captcha;
  1811. this.actions.register(data, function (json) {
  1812. if (callback) callback(json);
  1813. }.bind(this), function (errorObj) {
  1814. if (errorObj.status === 404) {
  1815. this.setWarning(this.lp.pageNotFound);
  1816. } else {
  1817. var error = JSON.parse(errorObj.responseText);
  1818. this.setWarning(error.message);
  1819. }
  1820. }.bind(this));
  1821. }
  1822. });
  1823. //忘记密码
  1824. MWF.xDesktop.Authentication.ResetPasswordForm = new Class({
  1825. Extends: MPopupForm,
  1826. Implements: [Options, Events],
  1827. options: {
  1828. "style": "default",
  1829. "popupStyle": "o2platformSignup",
  1830. "width": "710",
  1831. "height": "450",
  1832. "hasTop": true,
  1833. "hasIcon": false,
  1834. "hasTopIcon": true,
  1835. "hasTopContent": true,
  1836. "hasBottom": false,
  1837. "title": "",
  1838. "draggable": true,
  1839. "closeAction": true
  1840. },
  1841. load: function () {
  1842. if (!this.options.title) this.setOptions({
  1843. "title": MWF.LP.authentication.ResetPasswordFormTitle
  1844. });
  1845. this._loadCss();
  1846. },
  1847. _createTopContent: function () {
  1848. this.actions = MWF.Actions.get("x_organization_assemble_personal");
  1849. this.actions.getRegisterMode(function (json) {
  1850. this.signUpMode = json.data.value;
  1851. }.bind(this), null, false);
  1852. if (this.signUpMode && this.signUpMode !== "disable") {
  1853. this.gotoSignupNode = new Element("div", {
  1854. styles: this.css.formTopContentCustomNode,
  1855. text: this.lp.signUp
  1856. }).inject(this.formTopContentNode);
  1857. this.gotoSignupNode.addEvent("click", function () { this.gotoSignup() }.bind(this));
  1858. new Element("div", { styles: this.css.formTopContentSepNode }).inject(this.formTopContentNode);
  1859. }
  1860. this.gotoLoginNode = new Element("div", {
  1861. styles: this.css.formTopContentCustomNode,
  1862. text: this.lp.loginAction
  1863. }).inject(this.formTopContentNode);
  1864. this.gotoLoginNode.addEvent("click", function () { this.gotoLogin() }.bind(this));
  1865. },
  1866. _createTableContent: function () {
  1867. if( this.formTopTextNode && this.formTopCloseActionNode ){
  1868. this.formTopCloseActionNode.inject( this.formTopTextNode, "before" )
  1869. }
  1870. this.formTableContainer.setStyles(this.css.formTableContainer2);
  1871. this.loadSteps();
  1872. this.loadStepForm_1();
  1873. this.loadStepForm_2();
  1874. this.loadStepForm_3();
  1875. },
  1876. reset: function () {
  1877. this.formTableArea.empty();
  1878. this._createTableContent();
  1879. },
  1880. loadSteps: function () {
  1881. var stepsContainer = new Element("div", { styles: this.css.stepsContainer }).inject(this.formTableArea);
  1882. this.step_1 = new Element("div", {
  1883. styles: this.css.step_1_active,
  1884. text: this.lp.shotMessageCheck
  1885. }).inject(stepsContainer);
  1886. this.stepLink_1 = new Element("div", { styles: this.css.stepLink_1 }).inject(this.step_1);
  1887. this.step_2 = new Element("div", {
  1888. styles: this.css.step_2,
  1889. text: this.lp.setMewPassword
  1890. }).inject(stepsContainer);
  1891. this.stepLink_2 = new Element("div", { styles: this.css.stepLink_2 }).inject(this.step_2);
  1892. this.step_3 = new Element("div", {
  1893. styles: this.css.step_3,
  1894. text: this.lp.completed
  1895. }).inject(stepsContainer);
  1896. },
  1897. loadStepForm_1: function () {
  1898. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1899. "<tr><td styles='formTableTitle' lable='name' width='80'></td>" +
  1900. " <td styles='formTableValue' width='350'>" +
  1901. " <div style='position: relative;'><div item='name'></div><div class='inputUserIcon'></div></div>" +
  1902. " </td>" +
  1903. "</tr>" +
  1904. "<tr><td styles='formTableTitle' lable='codeAnswer'></td>" +
  1905. " <td styles='formTableValue'>" +
  1906. " <div style='float:left;'>" +
  1907. " <div style='position: relative;'><div item='codeAnswer'></div><div class='inputVerificationCode2Icon'></div></div>" +
  1908. " </div>" +
  1909. " <div item='verificationAction' style='float:left;'></div>" +
  1910. " <div item='resendVerificationAction' style='float:left;display:none;'></div></td>" +
  1911. " </tr>" +
  1912. "<tr><td styles='formTableTitle'></td>" +
  1913. " <td styles='formTableValue' item='nextStep'></td></tr>" +
  1914. "</table>";
  1915. this.stepNode_1 = new Element("div", { html: html, styles: { display: "" } }).inject(this.formTableArea);
  1916. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1917. this.stepForm_1 = new MForm(this.stepNode_1, {}, {
  1918. style: this.options.popupStyle,
  1919. verifyType: "single", //batch一起校验,或alert弹出
  1920. isEdited: this.isEdited || this.isNew,
  1921. itemTemplate: {
  1922. name: {
  1923. text: this.lp.userName, defaultValue: this.lp.userName, className: "inputUser",
  1924. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourUserName,
  1925. // validRule: { isInvalid: function (value, it) { return this.checkUserName(value, it); }.bind(this) },
  1926. // validMessage: { isInvalid: this.lp.userNotExist },
  1927. event: {
  1928. focus: function (it) { if (this.lp.userName === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1929. blur: function (it) { if (it.getValue() === "") it.setValue(this.lp.userName); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputUser); }.bind(this),
  1930. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.gotoStep(2) } }.bind(this)
  1931. }, onEmpty: function (it) {
  1932. it.getElements()[0].setStyles(this.css.inputEmpty);
  1933. }.bind(this), onUnempty: function (it) {
  1934. it.getElements()[0].setStyles(this.css.inputUser);
  1935. }.bind(this)
  1936. },
  1937. codeAnswer: {
  1938. text: this.lp.verificationCode, defaultValue: this.lp.inputVerificationCode, className: "inputVerificationCode2",
  1939. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputVerificationCode, event: {
  1940. focus: function (it) { if (this.lp.inputVerificationCode === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  1941. blur: function (it) {
  1942. if (it.getValue() === "") it.setValue(this.lp.inputVerificationCode);
  1943. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  1944. }.bind(this),
  1945. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.gotoStep(2) } }.bind(this)
  1946. }, onEmpty: function (it) {
  1947. it.getElements()[0].setStyles(this.css.inputEmpty);
  1948. }.bind(this), onUnempty: function (it) {
  1949. it.getElements()[0].setStyles(this.css.inputVerificationCode2);
  1950. }.bind(this)
  1951. },
  1952. verificationAction: {
  1953. value: this.lp.sendVerification, type: "button", className: "inputSendVerification", event: {
  1954. click: function () { this.sendVerificationAction() }.bind(this)
  1955. }
  1956. },
  1957. resendVerificationAction: { value: this.lp.resendVerification, type: "button", className: "inputResendVerification" },
  1958. nextStep: {
  1959. value: this.lp.nextStep, type: "button", className: "inputSignUp", event: {
  1960. click: function () { this.gotoStep(2) }.bind(this)
  1961. }
  1962. }
  1963. }
  1964. }, this.app, this.css);
  1965. this.stepForm_1.load();
  1966. }.bind(this), true);
  1967. },
  1968. loadStepForm_2: function () {
  1969. var self = this;
  1970. html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1971. "<tr><td styles='formTableTitle' lable='password' width='80'></td>" +
  1972. " <td styles='formTableValue' width='350'>" +
  1973. " <div style='position: relative;'><div item='password'></div><div class='inputPasswordIcon'></div></div>" +
  1974. " </td>" +
  1975. " <td styles='formTableValue'><div item='passwordStrengthArea'></div></td></tr>" +
  1976. "<tr><td styles='formTableTitle' lable='confirmPassword'></td>" +
  1977. " <td styles='formTableValue'>" +
  1978. " <div style='position: relative;'><div item='confirmPassword'></div><div class='inputComfirmPasswordIcon'></div></div>" +
  1979. " </td>" +
  1980. " <td styles='formTableValue'></td></tr>" +
  1981. "<tr><td styles='formTableTitle'></td>" +
  1982. " <td styles='formTableValue' item='nextStep'></td>" +
  1983. " <td styles='formTableValue'></td></tr>" +
  1984. "</table>";
  1985. this.stepNode_2 = new Element("div", {
  1986. html: html,
  1987. styles: { "display": "none" }
  1988. }).inject(this.formTableArea);
  1989. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1990. this.stepForm_2 = new MForm(this.stepNode_2, {}, {
  1991. style: this.options.popupStyle,
  1992. verifyType: "single", //batch一起校验,或alert弹出
  1993. isEdited: this.isEdited || this.isNew,
  1994. itemTemplate: {
  1995. password: {
  1996. text: this.lp.setNewPassword, type: "password", className: "inputPassword",
  1997. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputYourPassword,
  1998. attr: { "placeholder": this.lp.inputYourPassword },
  1999. validRule: {
  2000. passwordIsWeak: function (value, it) {
  2001. return !this.getPasswordRule(it.getValue());
  2002. }.bind(this)
  2003. },
  2004. validMessage: {
  2005. passwordIsWeak: function () {
  2006. return self.getPasswordRule(this.getValue());
  2007. }
  2008. },
  2009. event: {
  2010. focus: function (it) { if ("password" === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  2011. blur: function (it) { it.verify(true); }.bind(this)
  2012. //if( !it.warningStatus )it.getElements()[0].setStyles( this.css.inputPassword );
  2013. //keyup : function(it){ this.pwStrength(it.getValue()) }.bind(this)
  2014. }, onEmpty: function (it) {
  2015. it.getElements()[0].setStyles(this.css.inputEmpty);
  2016. }.bind(this), onUnempty: function (it) {
  2017. it.getElements()[0].setStyles(this.css.inputPassword);
  2018. }.bind(this)
  2019. },
  2020. confirmPassword: {
  2021. text: this.lp.confirmNewPassword, type: "password", className: "inputComfirmPassword",
  2022. notEmpty: true, defaultValueAsEmpty: true, emptyTip: this.lp.inputComfirmPassword,
  2023. attr: { "placeholder": this.lp.inputComfirmPassword },
  2024. validRule: {
  2025. passwordNotEqual: function (value, it) {
  2026. if (it.getValue() === this.stepForm_2.getItem("password").getValue()) return true;
  2027. }.bind(this)
  2028. },
  2029. validMessage: { passwordNotEqual: this.lp.passwordNotEqual },
  2030. event: {
  2031. focus: function (it) { if ("password" === it.getValue()) it.setValue(""); if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive); }.bind(this),
  2032. blur: function (it) { if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputComfirmPassword); }.bind(this),
  2033. keyup: function (it, ev) { if (ev.event.keyCode === 13) { this.gotoStep(3) } }.bind(this)
  2034. }, onEmpty: function (it) {
  2035. it.getElements()[0].setStyles(this.css.inputEmpty);
  2036. }.bind(this), onUnempty: function (it) {
  2037. it.getElements()[0].setStyles(this.css.inputComfirmPassword);
  2038. }.bind(this)
  2039. },
  2040. nextStep: {
  2041. value: this.lp.nextStep, type: "button", className: "inputSignUp", event: {
  2042. click: function () { this.gotoStep(3) }.bind(this)
  2043. }
  2044. }
  2045. }
  2046. }, this.app, this.css);
  2047. this.stepForm_2.load();
  2048. }.bind(this), true);
  2049. //this.createPasswordStrengthNode();
  2050. },
  2051. loadStepForm_3: function () {
  2052. this.stepNode_3 = new Element("div", {
  2053. styles: this.css.stepFormResult
  2054. }).inject(this.formTableArea);
  2055. },
  2056. createSetForm_3: function (isSuccess, text) {
  2057. var area = null;
  2058. var action = null;
  2059. if (isSuccess) {
  2060. this.stepNode_3.setStyles(this.css.stepFormResult);
  2061. this.stepNode_3.setStyle("display", "");
  2062. new Element("div", {
  2063. styles: this.css.resetPasswordSuccess,
  2064. text: this.lp.resetPasswordSuccess
  2065. }).inject(this.stepNode_3);
  2066. area = new Element("div", {
  2067. styles: this.css.resetPasswordResultArea
  2068. }).inject(this.stepNode_3);
  2069. new Element("div", {
  2070. styles: this.css.resetPasswordResultWord,
  2071. text: this.lp.resetPasswordSuccessWord
  2072. }).inject(area);
  2073. action = new Element("div", {
  2074. styles: this.css.resetPasswordResultAction,
  2075. text: this.lp.gotoLogin
  2076. }).inject(area);
  2077. action.addEvent("click", function () { this.gotoLogin() }.bind(this));
  2078. } else {
  2079. this.stepNode_3.setStyles(this.css.stepFormResult_fail);
  2080. this.stepNode_3.setStyle("display", "");
  2081. new Element("div", {
  2082. styles: this.css.resetPasswordFail,
  2083. text: text + this.lp.resetPasswordFail
  2084. }).inject(this.stepNode_3);
  2085. area = new Element("div", {
  2086. styles: this.css.resetPasswordResultArea
  2087. }).inject(this.stepNode_3);
  2088. new Element("div", {
  2089. styles: this.css.resetPasswordResultWord,
  2090. text: this.lp.resetPasswordFailWord
  2091. }).inject(area);
  2092. action = new Element("div", {
  2093. styles: this.css.resetPasswordResultAction,
  2094. text: this.lp.backtoModify
  2095. }).inject(area);
  2096. action.addEvent("click", function () { this.reset() }.bind(this));
  2097. }
  2098. },
  2099. gotoStep: function (step) {
  2100. var form = this["stepForm_" + (step - 1)];
  2101. form.clearWarning();
  2102. var data = form.getResult(true, ",", true, false, true);
  2103. if (!data) {
  2104. return;
  2105. }
  2106. var i;
  2107. for (i = 1; i <= step; i++) {
  2108. this["step_" + i].setStyles(this.css["step_" + i + "_active"]);
  2109. if (i !== step && this["stepLink_" + i]) {
  2110. this["stepLink_" + i].setStyles(this.css["stepLink_" + i + "_active"]);
  2111. }
  2112. }
  2113. for (i = step + 1; i <= 3; i++) {
  2114. this["step_" + i].setStyles(this.css["step_" + i]);
  2115. if (i !== 3) {
  2116. this["stepLink_" + i].setStyles(this.css["stepLink_" + i]);
  2117. }
  2118. }
  2119. for (i = 1; i <= 3; i++) {
  2120. if (i === step) {
  2121. this["stepNode_" + i].setStyle("display", "");
  2122. } else {
  2123. this["stepNode_" + i].setStyle("display", "none");
  2124. }
  2125. }
  2126. if (step === 3) {
  2127. var d = {
  2128. credential: this.stepForm_1.getItem("name").getValue(),
  2129. codeAnswer: this.stepForm_1.getItem("codeAnswer").getValue(),
  2130. password: this.stepForm_2.getItem("password").getValue()
  2131. };
  2132. this.actions.resetPassword(d, function () {
  2133. this.createSetForm_3(true)
  2134. }.bind(this), function (errorObj) {
  2135. var error = JSON.parse(errorObj.responseText);
  2136. //this.app.notice( error.message );
  2137. this.createSetForm_3(false, error.message)
  2138. }.bind(this), false);
  2139. }
  2140. },
  2141. checkMobile: function (mobile) {
  2142. var flag = true;
  2143. this.actions.checkRegisterMobile(mobile, function () {
  2144. flag = true
  2145. }.bind(this), function () {
  2146. flag = false;
  2147. }.bind(this), false);
  2148. return flag;
  2149. },
  2150. checkUserName: function (userName, it) {
  2151. var flag = false;
  2152. this.actions.checkCredentialOnResetPassword(userName, function (json) {
  2153. if (json.data) {
  2154. flag = json.data.value;
  2155. }
  2156. }.bind(this), function (errorObj) {
  2157. if (errorObj.status === 404) {
  2158. it.options.validMessage.isInvalid = this.lp.pageNotFound;
  2159. flag = false
  2160. } else {
  2161. var error = JSON.parse(errorObj.responseText);
  2162. it.options.validMessage.isInvalid = error.message;
  2163. flag = false
  2164. }
  2165. }.bind(this), false);
  2166. return flag;
  2167. },
  2168. sendVerificationAction: function () {
  2169. var flag = true;
  2170. var it = this.stepForm_1.getItem("name");
  2171. this.stepForm_1.clearWarning();
  2172. if (it.verify(true)) {
  2173. } else {
  2174. return;
  2175. }
  2176. this.actions.createCodeOnResetPassword(it.getValue(), function (json) {
  2177. }, function (errorObj) {
  2178. var error = JSON.parse(errorObj.responseText);
  2179. it.setWarning(error.message, "invalid");
  2180. flag = false
  2181. }.bind(this), false);
  2182. if (!flag) return false;
  2183. this.stepForm_1.getItem("verificationAction").container.setStyle("display", "none");
  2184. this.setResendVerification();
  2185. },
  2186. setResendVerification: function () {
  2187. var resendItem = this.stepForm_1.getItem("resendVerificationAction");
  2188. resendItem.container.setStyle("display", "");
  2189. this.resendElement = resendItem.getElements()[0];
  2190. this.resendElement.set("text", this.lp.resendVerification + "(60)");
  2191. var i = 60;
  2192. this.timer = setInterval(function () {
  2193. if (i > 0) {
  2194. this.resendElement.set("text", this.lp.resendVerification + "(" + --i + ")")
  2195. } else {
  2196. this.stepForm_1.getItem("verificationAction").container.setStyle("display", "");
  2197. resendItem.container.setStyle("display", "none");
  2198. clearInterval(this.timer)
  2199. }
  2200. }.bind(this), 1000)
  2201. },
  2202. getPasswordRule: function (password) {
  2203. var str = "";
  2204. this.actions.checkRegisterPassword(password, function (json) {
  2205. str = json.data.value || "";
  2206. }.bind(this), null, false);
  2207. return str;
  2208. },
  2209. //createPasswordStrengthNode : function(){
  2210. // var passwordStrengthArea = this.formTableArea.getElement("[item='passwordStrengthArea']");
  2211. //
  2212. // var lowNode = new Element( "div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  2213. // this.lowColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( lowNode );
  2214. // this.lowTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.weak }).inject( lowNode );
  2215. //
  2216. // var middleNode = new Element( "div" , {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  2217. // this.middleColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( middleNode );
  2218. // this.middleTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.middle }).inject( middleNode );
  2219. //
  2220. // var highNode = new Element("div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  2221. // this.highColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( highNode );
  2222. // this.highTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.high }).inject( highNode );
  2223. //},
  2224. //getPasswordLevel: function( password ){
  2225. // /*Level(级别)
  2226. // •0-3 : [easy]
  2227. // •4-6 : [midium]
  2228. // •7-9 : [strong]
  2229. // •10-12 : [very strong]
  2230. // •>12 : [extremely strong]
  2231. // */
  2232. // var level = 0;
  2233. // this.actions.checkRegisterPassword( password, function( json ){
  2234. // level = json.data.value;
  2235. // }.bind(this), null, false );
  2236. // return level;
  2237. //},
  2238. //pwStrength: function(pwd){
  2239. // this.lowColorNode.setStyles( this.css.passwordStrengthColor );
  2240. // this.lowTextNode.setStyles( this.css.passwordStrengthText );
  2241. // this.middleColorNode.setStyles( this.css.passwordStrengthColor );
  2242. // this.middleTextNode.setStyles( this.css.passwordStrengthText );
  2243. // this.highColorNode.setStyles( this.css.passwordStrengthColor );
  2244. // this.highTextNode.setStyles( this.css.passwordStrengthText );
  2245. // if (!pwd){
  2246. // }else{
  2247. // //var level = this.checkStrong(pwd);
  2248. // var level = this.getPasswordLevel(pwd);
  2249. // switch(level) {
  2250. // case 0:
  2251. // case 1:
  2252. // case 2:
  2253. // case 3:
  2254. // this.lowColorNode.setStyles( this.css.passwordStrengthColor_low );
  2255. // this.lowTextNode.setStyles( this.css.passwordStrengthText_current );
  2256. // break;
  2257. // case 4:
  2258. // case 5:
  2259. // case 6:
  2260. // this.middleColorNode.setStyles( this.css.passwordStrengthColor_middle );
  2261. // this.middleTextNode.setStyles( this.css.passwordStrengthText_current );
  2262. // break;
  2263. // default:
  2264. // this.highColorNode.setStyles( this.css.passwordStrengthColor_high );
  2265. // this.highTextNode.setStyles( this.css.passwordStrengthText_current );
  2266. // }
  2267. // }
  2268. //},
  2269. gotoLogin: function () {
  2270. this.explorer.openLoginForm({}, function () { window.location.reload(); });
  2271. this.close();
  2272. },
  2273. gotoSignup: function () {
  2274. this.explorer.openSignUpForm();
  2275. this.close();
  2276. }
  2277. });
  2278. //密码过期
  2279. MWF.xDesktop.Authentication.ChangePasswordForm = new Class({
  2280. Extends: MPopupForm,
  2281. Implements: [Options, Events],
  2282. options: {
  2283. "style": "default",
  2284. "popupStyle": "o2platform",
  2285. "width": "650",
  2286. "height": "480",
  2287. "hasTop": true,
  2288. "hasIcon": false,
  2289. "hasTopIcon": true,
  2290. "hasTopContent": true,
  2291. "hasBottom": false,
  2292. "hasScroll": false,
  2293. "hasMark": false,
  2294. "title": "",
  2295. "draggable": true,
  2296. "closeAction": true,
  2297. "userName" : ""
  2298. },
  2299. load: function () {
  2300. if (!this.options.title) this.setOptions({
  2301. "title": MWF.LP.authentication.ChangePasswordFormTitle
  2302. });
  2303. this._loadCss();
  2304. },
  2305. _createTableContent: function () {
  2306. var self = this;
  2307. if( this.formTopTextNode && this.formTopCloseActionNode ){
  2308. this.formTopCloseActionNode.inject( this.formTopTextNode, "before" )
  2309. }
  2310. this.actions = MWF.Actions.get("x_organization_assemble_personal");
  2311. var html = "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable'>" +
  2312. "<tr><td styles='formTableValueTop20'>" +
  2313. " <div style='position: relative;'><div item='password'></div><div class='inputPasswordIcon'></div></div>" +
  2314. "</td></tr>" +
  2315. "<tr><td styles='formTableValueTop20'>" +
  2316. " <div style='position: relative;'><div item='newPassword'></div><div class='inputPasswordIcon'></div></div>" +
  2317. "</td>" +
  2318. "<tr><td styles='formTableValue'><div item='passwordTip'></div></td></tr>" +
  2319. "<tr><td styles='formTableValueTop20'>" +
  2320. " <div style='position: relative;'><div item='confirmPassword'></div><div class='inputComfirmPasswordIcon'></div></div>" +
  2321. "</td></tr>" +
  2322. "<tr><td styles='formTableValueTop20' item='submitAction'></td></tr>" +
  2323. "<tr><td><div item='forgetPassword'></div><div item='gotoLoginAction'></div></td></tr>"+
  2324. "<tr><td styles='formTableValue' item='errorArea'></td></tr>" +
  2325. "</table>";
  2326. this.formTableArea.set("html", html);
  2327. this.errorArea = this.formTableArea.getElement("[item=errorArea]");
  2328. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2329. this.form = new MForm(this.formTableArea, this.data, {
  2330. style: this.options.popupStyle,
  2331. verifyType: "single", //batch一起校验,或alert弹出
  2332. isEdited: this.isEdited || this.isNew,
  2333. onPostLoad: function () {
  2334. var form = this.form;
  2335. form.getItem("password").tipNode = this.errorArea;
  2336. form.getItem("newPassword").tipNode = this.errorArea;
  2337. form.getItem("confirmPassword").tipNode = this.errorArea;
  2338. }.bind(this),
  2339. itemTemplate: {
  2340. password: {
  2341. text: this.lp.oldPassword,
  2342. type: "password",
  2343. className: "inputPassword",
  2344. notEmpty: true,
  2345. defaultValueAsEmpty: false,
  2346. defaultValue: this.options.oldPassword || "",
  2347. emptyTip: this.lp.inputYourOldPassword,
  2348. attr: {"placeholder": this.lp.oldPassword},
  2349. event: {
  2350. focus: function (it) {
  2351. if ("password" === it.getValue()) it.setValue("");
  2352. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  2353. }.bind(this),
  2354. blur: function (it) {
  2355. // it.verify(true);
  2356. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputPassword);
  2357. }.bind(this),
  2358. keyup: function (it, ev) {
  2359. if (ev.event.keyCode === 13) this.ok();
  2360. }.bind(this)
  2361. },
  2362. onEmpty: function (it) {
  2363. it.getElements()[0].setStyles(this.css.inputEmpty);
  2364. }.bind(this),
  2365. onUnempty: function (it) {
  2366. it.getElements()[0].setStyles(this.css.inputPassword);
  2367. }.bind(this)
  2368. },
  2369. newPassword: {
  2370. text: this.lp.newPassword,
  2371. type: "password",
  2372. className: "inputPassword",
  2373. notEmpty: true,
  2374. defaultValueAsEmpty: true,
  2375. emptyTip: this.lp.inputYourNewPassword,
  2376. attr: {"placeholder": this.lp.newPassword},
  2377. validRule: {
  2378. passwordIsWeak: function (value, it) {
  2379. return !this.getPasswordRule(it.getValue());
  2380. }.bind(this)
  2381. },
  2382. validMessage: {
  2383. passwordIsWeak: function () {
  2384. return self.getPasswordRule(this.getValue());
  2385. }
  2386. },
  2387. event: {
  2388. focus: function (it) {
  2389. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  2390. }.bind(this),
  2391. blur: function (it) {
  2392. // it.verify(true);
  2393. }.bind(this),
  2394. keyup: function (it, ev) {
  2395. if (ev.event.keyCode === 13)this.ok();
  2396. }.bind(this)
  2397. },
  2398. onEmpty: function (it) {
  2399. it.getElements()[0].setStyles(this.css.inputEmpty);
  2400. }.bind(this),
  2401. onUnempty: function (it) {
  2402. it.getElements()[0].setStyles(this.css.inputPassword);
  2403. }.bind(this)
  2404. },
  2405. confirmPassword: {
  2406. text: this.lp.confirmNewPassword,
  2407. type: "password",
  2408. className: "inputComfirmPassword",
  2409. notEmpty: true,
  2410. defaultValueAsEmpty: true,
  2411. emptyTip: this.lp.inputComfirmPassword,
  2412. attr: {"placeholder": this.lp.confirmPassword},
  2413. validRule: {
  2414. passwordNotEqual: function (value, it) {
  2415. if (it.getValue() === this.form.getItem("newPassword").getValue()) return true;
  2416. }.bind(this)
  2417. },
  2418. validMessage: {passwordNotEqual: this.lp.passwordNotEqual},
  2419. event: {
  2420. focus: function (it) {
  2421. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
  2422. }.bind(this),
  2423. blur: function (it) {
  2424. // it.verify(true);
  2425. if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputComfirmPassword);
  2426. }.bind(this),
  2427. keyup: function (it, ev) {
  2428. if (ev.event.keyCode === 13)this.ok();
  2429. }.bind(this)
  2430. },
  2431. onEmpty: function (it) {
  2432. it.getElements()[0].setStyles(this.css.inputEmpty);
  2433. }.bind(this),
  2434. onUnempty: function (it) {
  2435. it.getElements()[0].setStyles(this.css.inputComfirmPassword);
  2436. }.bind(this)
  2437. },
  2438. forgetPassword: {
  2439. value: this.lp.forgetPassword,
  2440. type: "innerText",
  2441. className: "forgetPassword",
  2442. event: {
  2443. click: function () {
  2444. this.gotoResetPassword();
  2445. }.bind(this)
  2446. }
  2447. },
  2448. gotoLoginAction: {
  2449. value: this.lp.loginAction,
  2450. type: "innerText",
  2451. className: "signUpAction",
  2452. event: {
  2453. click: function () { this.gotoLogin() }.bind(this)
  2454. }
  2455. },
  2456. passwordTip: {
  2457. type: "innerText",
  2458. className: "forgetPassword",
  2459. defaultValue: layout.config.passwordRegexHint || ""
  2460. },
  2461. submitAction: {
  2462. value: this.lp.submitAction,
  2463. type: "button",
  2464. className: "inputLogin",
  2465. event: {
  2466. click: function () {
  2467. this.ok();
  2468. }.bind(this)
  2469. }
  2470. }
  2471. }
  2472. }, this.app, this.css);
  2473. this.form.load();
  2474. }.bind(this), true);
  2475. },
  2476. gotoLogin: function () {
  2477. this.explorer.openLoginForm({}, function () { window.location.reload(); });
  2478. this.close();
  2479. },
  2480. getPasswordRule: function (password) {
  2481. var str = "";
  2482. this.actions.checkRegisterPassword(password, function (json) {
  2483. str = json.data.value || "";
  2484. }.bind(this), null, false);
  2485. return str;
  2486. },
  2487. gotoResetPassword: function () {
  2488. this.explorer.openResetPasswordForm();
  2489. this.close();
  2490. },
  2491. ok: function () {
  2492. this.fireEvent("queryOk");
  2493. this.errorArea.empty();
  2494. var data = this.form.getResult(true, ",", true, false, true);
  2495. if (data) {
  2496. this._ok(data, function (json) {
  2497. if (json.type === "error") {
  2498. if (this.app) this.app.notice(json.message, "error");
  2499. } else {
  2500. this._close();
  2501. if (this.formMaskNode) this.formMaskNode.destroy();
  2502. this.formAreaNode.destroy();
  2503. if (this.explorer && this.explorer.view) this.explorer.view.reload();
  2504. if (this.app) this.app.notice(this.lp.changePasswordSuccess, "success");
  2505. this.fireEvent("postOk", json);
  2506. }
  2507. }.bind(this));
  2508. }
  2509. },
  2510. setWarning: function (text) {
  2511. this.errorArea.empty();
  2512. new Element("div", {
  2513. "text": text,
  2514. "styles": this.css.warningMessageNode
  2515. }).inject(this.errorArea);
  2516. },
  2517. _ok: function (data, callback) {
  2518. var d = {
  2519. userName : this.options.userName,
  2520. oldPassword : data.password,
  2521. newPassword : data.newPassword,
  2522. confirmPassword : data.confirmPassword
  2523. //isEncrypted : "n" //是否启用加密,默认不加密,启用(y)。注意:使用加密先要在服务器运行 create encrypt key"
  2524. }
  2525. //o2.Actions.load("x_organization_assemble_personal").ResetAction.setPasswordAnonymous( d, function (json) {
  2526. MWF.Actions.get("x_organization_assemble_personal").setPasswordAnonymous( d, function (json) {
  2527. if (callback) callback(json);
  2528. //this.fireEvent("postOk")
  2529. }.bind(this), function (errorObj) {
  2530. var error = JSON.parse(errorObj.responseText);
  2531. this.setWarning(error.message);
  2532. }.bind(this) )
  2533. }
  2534. });