Main.js 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  1. MWF.xApplication.Collect.options.multitask = false;
  2. MWF.require("MWF.xDesktop.Access", null, false);
  3. // MWF.xDesktop.requireApp("Collect", "Actions.RestActions", null, false);
  4. MWF.xApplication.Collect.Main = new Class({
  5. Extends: MWF.xApplication.Common.Main,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "name": "Collect",
  10. "icon": "icon.png",
  11. "width": "400",
  12. "height": "500",
  13. "isResize": false,
  14. "isMax": false,
  15. "title": MWF.xApplication.Collect.LP.title
  16. },
  17. onQueryLoad: function(){
  18. this.lp = MWF.xApplication.Collect.LP;
  19. this.action = MWF.Actions.get("x_program_center");
  20. //this.action = new MWF.xApplication.Collect.Actions.RestActions();
  21. this.connected = false;
  22. this.login = false;
  23. this.connectChecked = false;
  24. this.loginChecked = false;
  25. },
  26. loadWindow: function(isCurrent){
  27. this.fireAppEvent("queryLoadWindow");
  28. this.window = new MWF.xDesktop.WindowTransparent(this, {"container": this.desktop.node});
  29. this.fireAppEvent("loadWindow");
  30. this.window.show();
  31. this.content = this.window.content;
  32. if (isCurrent) this.setCurrent();
  33. this.fireAppEvent("postLoadWindow");
  34. this.fireAppEvent("queryLoadApplication");
  35. this.loadApplication(function(){
  36. this.fireAppEvent("postLoadApplication");
  37. }.bind(this));
  38. },
  39. loadApplication: function(callback){
  40. debugger;
  41. if (!MWF.AC.isAdministrator()){
  42. try{
  43. this.close();
  44. }catch(e){};
  45. }else{
  46. this.outBox = new Element("div", {"styles": this.css.outBox}).inject(this.content);
  47. this.loadContent();
  48. this.addEvent("queryclose", function(){
  49. if (this.registerForm){
  50. if (this.registerForm.codeNextTimer){
  51. window.clearTimeout(this.registerForm.codeNextTimer);
  52. }
  53. }
  54. }.bind(this));
  55. }
  56. },
  57. loadContent: function(){
  58. this.titleAreaNode = new Element("div", {"styles": this.css.titleAreaNode}).inject(this.outBox);
  59. // 返回按钮
  60. this.backNode = new Element("div", {"styles": this.css.backNode}).inject(this.titleAreaNode);
  61. new Element("img", {"styles": this.css.backNodeImg, "src": "../x_component_Collect/$Main/default/icon/icon_back.png"}).inject(this.backNode);
  62. new Element("div", {"styles": this.css.backNodeText, "text": this.lp.backUp}).inject(this.backNode);
  63. // this.closeNode = new Element("div", {"styles": this.css.closeNode}).inject(this.titleAreaNode);
  64. // this.closeNode.addEvent("click", function(){this.close();}.bind(this));
  65. this.titleNode = new Element("div", {"styles": this.css.titleNode, "text": this.lp.title}).inject(this.outBox);
  66. // 内容
  67. this.node = new Element("div", {"styles": this.css.node}).inject(this.outBox);
  68. // this.setNodeResize();
  69. this.node.addEvent("selectstart", function(e){e.target.setStyle("-webkit-user-select", "none")}.bind(this));
  70. this.checkContentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  71. this.loginContentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  72. this.modifyContentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  73. this.modifyPwdContentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  74. this.deleteContentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  75. this.registerContentNode = new Element("div", {"styles": this.css.registerContentNode}).inject(this.node);
  76. this.check = new MWF.xApplication.Collect.Check(this);
  77. this.showContent("checkContentNode");
  78. },
  79. showContent: function(node){
  80. this.checkContentNode.setStyle("display", "none");
  81. this.loginContentNode.setStyle("display", "none");
  82. this.modifyContentNode.setStyle("display", "none");
  83. this.modifyPwdContentNode.setStyle("display", "none");
  84. this.deleteContentNode.setStyle("display", "none");
  85. this.registerContentNode.setStyle("display", "none");
  86. this[node].setStyle("display", "block");
  87. },
  88. setNodeResize: function(){
  89. this.setNodePositionAndSizeFun = this.setNodePositionAndSize.bind(this);
  90. this.setNodePositionAndSizeFun();
  91. $(window).addEvent("resize", this.setNodePositionAndSizeFun);
  92. this.addEvent("queryClose", function(){
  93. $(window).removeEvent("resize", this.setNodePositionAndSizeFun);
  94. }.bind(this));
  95. },
  96. setNodePositionAndSize: function(){
  97. this.node.position({
  98. relativeTo: this.desktop.node,
  99. position: 'center',
  100. edge: 'center'
  101. });
  102. }
  103. });
  104. MWF.xApplication.Collect.Check = new Class({
  105. initialize: function(collect){
  106. this.collect = collect;
  107. this.lp = this.collect.lp;
  108. this.css = this.collect.css;
  109. this.contentNode = this.collect.checkContentNode;
  110. this.action = this.collect.action;
  111. this.load();
  112. },
  113. load: function(){
  114. this.connectChecked = true;
  115. this.loginChecked = false;
  116. this.statusConnectNode = new Element("div", {"styles": this.css.statusConnectNode}).inject(this.contentNode);
  117. this.setStatusConnectNode();
  118. this.statusLoginNode = new Element("div", {"styles": this.css.statusLoginNode}).inject(this.contentNode);
  119. this.setStatusLoginNode();
  120. this.actionsNode = new Element("div", {"styles": this.css.actionsNode}).inject(this.contentNode);
  121. },
  122. setActionsNode: function(){
  123. if (this.connectChecked && this.loginChecked) {
  124. this.actionsNode.empty();
  125. if (this.connected && this.login){
  126. this.setLoginInfor();
  127. }else if (this.connected && !this.login){
  128. this.setNotLoginInfor();
  129. }else if (!this.connected && !this.login){
  130. this.setDisconnectedInfor();
  131. }else{
  132. //impossible
  133. }
  134. }
  135. },
  136. setLoginInfor: function(){
  137. new Element("div", {"styles": this.css.loginInforTextNode, "html": this.lp.connectedAndLogin}).inject(this.actionsNode);
  138. new Element("div", {"styles": this.css.loginInfor, "html": this.lp.modifyAccount}).inject(this.actionsNode);
  139. this.modifyAccountAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.modifyAccountAction}).inject(this.actionsNode);
  140. this.disconnectAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.doDisconnect}).inject(this.actionsNode);
  141. this.disconnectAction.addEvent("click", this.disconnect.bind(this));
  142. this.modifyPwdAccountAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.modifyPwdAccountAction}).inject(this.actionsNode);
  143. this.deleteAccountAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.deleteAccountAction}).inject(this.actionsNode);
  144. this.modifyAccountAction.addEvent("click", this.showModifyForm.bind(this));
  145. this.modifyPwdAccountAction.addEvent("click", this.showModifyPwdForm.bind(this));
  146. this.deleteAccountAction.addEvent("click", this.showDeleteForm.bind(this));
  147. new Element("div", {"styles": this.css.loginInfor, "html": this.lp.loginAccount}).inject(this.actionsNode);
  148. this.loginAccountAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.login}).inject(this.actionsNode);
  149. this.loginAccountAction.addEvent("click", this.showLoginForm.bind(this));
  150. },
  151. setNotLoginInfor: function(){
  152. new Element("div", {"styles": this.css.notLoginInforTextNode, "html": this.lp.notLogin}).inject(this.actionsNode);
  153. this.loginLine1 = new Element("div", {"styles": this.css.notLoginInforTextNode}).inject(this.actionsNode);
  154. new Element("div", {"styles": this.css.notLoginInfor, "html": this.lp.notLoginInfoLogin}).inject(this.loginLine1);
  155. this.loginAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.login}).inject(this.loginLine1);
  156. this.loginLine2 = new Element("div", {"styles": this.css.notLoginInforTextNode}).inject(this.actionsNode);
  157. new Element("div", {"styles": this.css.notLoginInfor, "html": this.lp.notLoginInfoRegister}).inject(this.loginLine2);
  158. this.registerAction = new Element("div", {"styles": this.css.inforAction, "html": this.lp.register}).inject(this.loginLine2);
  159. this.loginAction.addEvent("click", this.showLoginForm.bind(this));
  160. this.registerAction.addEvent("click", this.showRegisterForm.bind(this));
  161. //this.modifyAccountAction = new Element("div", {"styles": this.css.modifyAccountAction, "html": this.lp.modifyAccountAction}).inject(this.actionsNode);
  162. },
  163. setDisconnectedInfor: function(){
  164. new Element("div", {"styles": this.css.loginInfor, "html": this.lp.disconnect}).inject(this.actionsNode);
  165. new Element("div", {"styles": this.css.disconnectInfor, "html": this.lp.disconnectInfo}).inject(this.actionsNode);
  166. },
  167. setStatusConnectNode: function(){
  168. this.statusConnectNode.empty();
  169. this.setStatusConnectNodeContent();
  170. this.action.collectConnected(function(json){
  171. if (json.data.value){
  172. this.setStatusConnectSuccess();
  173. this.connected = true;
  174. }else{
  175. this.setStatusConnectFailure();
  176. this.connected = false;
  177. }
  178. this.connectChecked = true;
  179. this.setActionsNode();
  180. }.bind(this), function(){
  181. this.setStatusConnectFailure();
  182. this.connected = false;
  183. this.connectChecked = true;
  184. this.setActionsNode();
  185. }.bind(this));
  186. },
  187. setStatusConnectNodeContent: function(){
  188. this.statusConnectNode.empty();
  189. this.statusConnectIconsNode = new Element("div", {"styles": this.css.statusConnectIconsConnectedNode}).inject(this.statusConnectNode);
  190. //
  191. // this.statusConnectIconCenterNode = new Element("div", {"styles": this.css.statusConnectIconCenterNode}).inject(this.statusConnectIconsNode);
  192. // this.statusConnectIconConnectNode = new Element("div", {"styles": this.css.statusConnectIconConnectNode}).inject(this.statusConnectIconsNode);
  193. // this.statusConnectIconCollectNode = new Element("div", {"styles": this.css.statusConnectIconCollectNode}).inject(this.statusConnectIconsNode);
  194. this.statusConnectTextNode = new Element("div", {"styles": this.css.statusConnectTextNode, "text": this.lp.checking}).inject(this.statusConnectNode);
  195. },
  196. setStatusConnectSuccess: function(){
  197. // this.statusConnectIconConnectNode.setStyles(this.css.statusConnectIconConnectedNode);
  198. this.statusConnectIconsNode.setStyles(this.css.statusConnectIconsConnectedNode);
  199. this.statusConnectTextNode.set("text", this.lp.collectConnected);
  200. },
  201. setStatusConnectFailure: function(){
  202. // this.statusConnectIconConnectNode.setStyles(this.css.statusConnectIconDisconnectNode);
  203. this.statusConnectIconsNode.setStyles(this.css.statusConnectIconsConnectedNode);
  204. this.statusConnectTextNode.set("text", this.lp.collectDisconnect);
  205. },
  206. setStatusLoginNode: function(){
  207. this.statusLoginNode.empty();
  208. this.setStatusLoginNodeContent();
  209. this.action.collectValidate(function(json){
  210. if (json.data.value){
  211. this.setStatusLoginSuccess();
  212. this.login = true;
  213. }else{
  214. this.setStatusLoginFailure();
  215. this.login = false;
  216. }
  217. this.recheckActionNode = new Element("div", {"styles": this.css.recheckActionNode, "text": this.lp.recheck}).inject(this.statusLoginTextNode, "before");
  218. this.recheckActionNode.addEvent("click", function(){this.recheck();}.bind(this));
  219. this.loginChecked = true;
  220. this.setActionsNode();
  221. }.bind(this), function(){
  222. this.setStatusLoginFailure();
  223. this.login = false;
  224. this.recheckActionNode = new Element("div", {"styles": this.css.recheckActionNode, "text": this.lp.recheck}).inject(this.statusLoginTextNode, "before");
  225. this.recheckActionNode.addEvent("click", function(){this.recheck();}.bind(this));
  226. this.loginChecked = true;
  227. this.setActionsNode();
  228. }.bind(this));
  229. },
  230. setStatusLoginNodeContent: function(){
  231. this.statusLoginIconsNode = new Element("div", {"styles": this.css.statusLoginIconsConnectedNode}).inject(this.statusLoginNode);
  232. // this.statusLoginIconCenterNode = new Element("div", {"styles": this.css.statusLoginIconCenterNode}).inject(this.statusLoginIconsNode);
  233. // this.statusLoginIconConnectNode = new Element("div", {"styles": this.css.statusLoginIconConnectNode}).inject(this.statusLoginIconsNode);
  234. // this.statusLoginIconCollectNode = new Element("div", {"styles": this.css.statusLoginIconCollectNode}).inject(this.statusLoginIconsNode);
  235. this.statusLoginTextNode = new Element("div", {"styles": this.css.statusLoginTextNode, "text": this.lp.checking}).inject(this.statusLoginNode);
  236. },
  237. setStatusLoginSuccess: function(){
  238. // this.statusLoginIconConnectNode.setStyles(this.css.statusLoginIconConnectedNode);
  239. this.statusLoginIconsNode.setStyles(this.css.statusLoginIconsConnectedNode);
  240. this.statusLoginTextNode.set("text", this.lp.collectLogin);
  241. },
  242. setStatusLoginFailure: function(){
  243. // this.statusLoginIconConnectNode.setStyles(this.css.statusLoginIconDisconnectNode);
  244. this.statusLoginIconsNode.setStyles(this.css.statusLoginIconsDisconnectNode);
  245. this.statusLoginTextNode.set("text", this.lp.collectNotLogin);
  246. },
  247. disconnect : function(){
  248. this.action.disconnect( function(json){
  249. this.recheck();
  250. }.bind(this), null , false);
  251. },
  252. recheck: function(){
  253. this.contentNode.empty();
  254. this.load();
  255. },
  256. showModifyForm: function(){
  257. if (!this.collect.modifyForm){
  258. this.collect.modifyForm = new MWF.xApplication.Collect.ModifyForm(this.collect);
  259. }
  260. this.collect.modifyForm.show();
  261. },
  262. showModifyPwdForm: function(){
  263. if (!this.collect.modifyPwdForm){
  264. this.collect.modifyPwdForm = new MWF.xApplication.Collect.ModifyPwdForm(this.collect);
  265. }
  266. this.collect.modifyPwdForm.show();
  267. },
  268. showDeleteForm: function(){
  269. if (!this.collect.deleteForm){
  270. this.collect.deleteForm = new MWF.xApplication.Collect.DeleteForm(this.collect);
  271. }
  272. this.collect.deleteForm.show();
  273. },
  274. showLoginForm: function(){
  275. if (!this.collect.loginForm){
  276. this.collect.loginForm = new MWF.xApplication.Collect.LoginForm(this.collect);
  277. }
  278. this.collect.loginForm.show();
  279. },
  280. showRegisterForm: function(){
  281. if (!this.collect.registerForm){
  282. this.collect.registerForm = new MWF.xApplication.Collect.RegisterForm(this.collect);
  283. }
  284. this.collect.registerForm.show();
  285. }
  286. });
  287. MWF.xApplication.Collect.LoginForm = new Class({
  288. initialize: function(collect){
  289. this.collect = collect;
  290. this.lp = this.collect.lp;
  291. this.css = this.collect.css;
  292. this.contentNode = this.collect.loginContentNode;
  293. this.action = this.collect.action;
  294. this.load();
  295. },
  296. load: function(){
  297. this.usernameNode = new Element("div", {"styles": this.css.loginUsernameNode}).inject(this.contentNode);
  298. var icon = new Element("div", {"styles": this.css.loginUsernameIconNode}).inject(this.usernameNode);
  299. var inputArea = new Element("div", {"styles": this.css.loginInputAreaNode}).inject(this.usernameNode);
  300. this.usernameInput = new Element("input", {"styles": this.css.loginInputNode, "type": "text", "value": this.lp.username}).inject(inputArea);
  301. var errorNode = new Element("div", {"styles": this.css.loginErrorNode}).inject(this.contentNode);
  302. this.passwordNode = new Element("div", {"styles": this.css.loginPasswordNode}).inject(this.contentNode);
  303. icon = new Element("div", {"styles": this.css.loginPasswordIconNode}).inject(this.passwordNode);
  304. inputArea = new Element("div", {"styles": this.css.loginInputAreaNode}).inject(this.passwordNode);
  305. this.passwordInput = new Element("input", {"styles": this.css.loginInputNode, "type": "password", "value": this.lp.password}).inject(inputArea);
  306. errorNode = new Element("div", {"styles": this.css.loginErrorNode}).inject(this.contentNode);
  307. this.setInputEvent();
  308. this.setDefaultValue();
  309. this.loginActionNode = new Element("div", {"styles": this.css.loginActionNode, "text": this.lp.login}).inject(this.contentNode);
  310. this.loginActionNode.addEvent("click", this.login.bind(this));
  311. this.otherActionNode = new Element("div", {"styles": this.css.loginOtherActionNode}).inject(this.contentNode);
  312. this.registerActionNode = new Element("div", {"styles": this.css.loginRegisterActionNode, "text": this.lp.register}).inject(this.otherActionNode);
  313. this.forgetActionNode = new Element("div", {"styles": this.css.loginForgetActionNode, "text": this.lp.forget}).inject(this.otherActionNode);
  314. this.setOtherActionEvent();
  315. this.errorNode = new Element("div", {"styles": this.css.loginErrorNode}).inject(this.contentNode);
  316. },
  317. login: function(){
  318. if (!this.isLogining){
  319. this.loginActionNode.set("text", this.lp.logining);
  320. this.isLogining = true;
  321. this.errorNode.set("text", "");
  322. var user = this.usernameInput.get("value");
  323. var pass = this.passwordInput.get("value");
  324. var errorText = "";
  325. this.checkLogin = true;
  326. if (!user || user==this.lp.username) this.errorUsername(this.lp.errorUsername);
  327. if (!pass || pass==this.lp.password) this.errorPassword(this.lp.errorPassword);
  328. if (this.checkLogin){
  329. this.action.collectValidateInput({"name": user, "password": pass}, function(json){
  330. if (json.data.value){
  331. this.action.updateCollect({"name": user, "password": pass, "enable": true}, function(json){
  332. this.loginCanceled();
  333. this.collect.showContent("checkContentNode");
  334. this.collect.backNode.setStyle("display", "none");
  335. this.collect.check.recheck();
  336. }.bind(this), function(xhr, text, error){
  337. var errorText = error+":"+text;
  338. if (xhr) errorText = xhr.responseText;
  339. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  340. this.loginCanceled();
  341. }.bind(this));
  342. }else{
  343. this.errorNode.set("text", this.lp.loginError);
  344. this.loginCanceled();
  345. }
  346. }.bind(this), function(xhr, text, error){
  347. if (xhr){
  348. var json = JSON.decode(xhr.responseText);
  349. this.errorNode.set("text", json.message);
  350. }else{
  351. var errorText = error+":"+text;
  352. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  353. }
  354. this.loginCanceled();
  355. }.bind(this));
  356. } else {
  357. this.loginCanceled();
  358. }
  359. }
  360. },
  361. loginCanceled: function(){
  362. this.loginActionNode.set("text", this.lp.login);
  363. this.isLogining = false;
  364. },
  365. errorUsername: function(text){
  366. if (text){
  367. this.usernameNode.setStyles(this.css.loginUsernameNode_error);
  368. this.checkLogin = false;
  369. }else{
  370. this.usernameNode.setStyles(this.css.loginUsernameNode);
  371. }
  372. this.usernameNode.getNext().set("text", text);
  373. },
  374. errorPassword: function(text){
  375. if (text){
  376. this.passwordNode.setStyles(this.css.loginPasswordNode_error);
  377. this.checkLogin = false;
  378. }else{
  379. this.passwordNode.setStyles(this.css.loginPasswordNode);
  380. }
  381. this.passwordNode.getNext().set("text", text);
  382. },
  383. show: function(){
  384. this.collect.showContent("loginContentNode");
  385. this.collect.backNode.setStyle("display", "flex");
  386. this.collect.backNode.removeEvents("click");
  387. this.collect.backNode.addEvent("click", function(){
  388. this.collect.showContent("checkContentNode");
  389. this.collect.backNode.setStyle("display", "none");
  390. }.bind(this));
  391. this.setDefaultValue();
  392. },
  393. setInputEvent: function(){
  394. this.usernameInput.addEvents({
  395. "focus": function(){
  396. this.errorUsername("");
  397. this.usernameNode.setStyles(this.css.loginUsernameNode_over);
  398. if (this.usernameInput.get("value")==this.lp.username){
  399. this.usernameInput.set("value", "");
  400. }
  401. }.bind(this),
  402. "blur": function(){
  403. this.usernameNode.setStyles(this.css.loginUsernameNode);
  404. if (!this.usernameInput.get("value")){
  405. this.usernameInput.set("value", this.lp.username);
  406. this.errorUsername(this.lp.errorUsername);
  407. }
  408. }.bind(this),
  409. "selectstart": function(e){e.stopPropagation();}
  410. });
  411. this.passwordInput.addEvents({
  412. "focus": function(){
  413. this.errorPassword("");
  414. this.passwordNode.setStyles(this.css.loginPasswordNode_over);
  415. if (this.passwordInput.get("value")==this.lp.password){
  416. this.passwordNode.getNext().set("text", "");
  417. this.passwordInput.set("value", "");
  418. }
  419. }.bind(this),
  420. "blur": function(){
  421. this.passwordNode.setStyles(this.css.loginPasswordNode);
  422. if (!this.passwordInput.get("value")){
  423. this.errorPassword(this.lp.errorPassword);
  424. this.passwordInput.set("value", this.lp.password);
  425. }
  426. }.bind(this),
  427. "selectstart": function(e){e.stopPropagation();}
  428. });
  429. },
  430. setDefaultValue: function(){
  431. this.action.getCollectConfig(function(json){
  432. if (json.data.name) this.usernameInput.set("value", json.data.name);
  433. if (json.data.password) this.passwordInput.set("value", json.data.password);
  434. }.bind(this));
  435. },
  436. setOtherActionEvent: function(){
  437. this.registerActionNode.addEvents({
  438. "mouseover": function(){this.registerActionNode.setStyles(this.css.loginRegisterActionNode_over);}.bind(this),
  439. "mouseout": function(){this.registerActionNode.setStyles(this.css.loginRegisterActionNode);}.bind(this),
  440. "click": this.showRegisterForm.bind(this)
  441. });
  442. this.forgetActionNode.addEvents({
  443. "mouseover": function(){this.forgetActionNode.setStyles(this.css.loginForgetActionNode_over);}.bind(this),
  444. "mouseout": function(){this.forgetActionNode.setStyles(this.css.loginForgetActionNode);}.bind(this),
  445. "click": this.showModifyForm.bind(this)
  446. });
  447. },
  448. showModifyForm: function(){
  449. /*if (!this.collect.modifyForm){
  450. this.collect.modifyForm = new MWF.xApplication.Collect.ModifyForm(this.collect);
  451. }
  452. this.collect.modifyForm.show();*/
  453. if (!this.collect.modifyPwdForm){
  454. this.collect.modifyPwdForm = new MWF.xApplication.Collect.ModifyPwdForm(this.collect);
  455. }
  456. this.collect.modifyPwdForm.show();
  457. },
  458. showRegisterForm: function(){
  459. if (!this.collect.registerForm){
  460. this.collect.registerForm = new MWF.xApplication.Collect.RegisterForm(this.collect);
  461. }
  462. this.collect.registerForm.show();
  463. }
  464. });
  465. MWF.xApplication.Collect.RegisterForm = new Class({
  466. initialize: function(collect){
  467. this.collect = collect;
  468. this.lp = this.collect.lp;
  469. this.css = this.collect.css;
  470. this.contentNode = this.collect.registerContentNode;
  471. this.action = this.collect.action;
  472. this.load();
  473. },
  474. createNode: function(iconCss, text, type){
  475. var node = new Element("div", {"styles": this.css.registerAreaNode}).inject(this.contentNode);
  476. var icon = new Element("div", {"styles": this.css[iconCss]}).inject(node);
  477. var inputCheckArea = new Element("div", {"styles": this.css.registerCheckIconNode}).inject(node);
  478. var inputArea = new Element("div", {"styles": this.css.registerInputAreaNode}).inject(node);
  479. var inputNode = new Element("input", {"styles": this.css.registerInputNode, "type": type || "text", "value": this.lp[text]}).inject(inputArea);
  480. var errorNode = new Element("div", {"styles": this.css.registerErrorNode}).inject(this.contentNode);
  481. return node;
  482. },
  483. load: function(){
  484. this.contentNode.setStyle("padding-top", "30px");
  485. this.usernameNode = this.createNode("registerUsernameIconNode", "username");
  486. this.usernameInput = this.usernameNode.getElement("input");
  487. this.mobileNode = this.createNode("registerMobileIconNode", "mobile");
  488. this.mobileInput = this.mobileNode.getElement("input");
  489. this.mailNode = this.createNode("registerMailIconNode", "mail");
  490. this.mailInput = this.mailNode.getElement("input");
  491. this.codeNode = this.createNode("registerCodeIconNode", "code");
  492. this.codeInput = this.codeNode.getElement("input");
  493. this.passwordNode = this.createNode("registerPasswordIconNode", "password", "password");
  494. this.passwordInput = this.passwordNode.getElement("input");
  495. this.setInputEvent();
  496. this.registerActionNode = new Element("div", {"styles": this.css.registerActionNode, "text": this.lp.register}).inject(this.contentNode);
  497. this.registerActionNode.addEvent("click", this.register.bind(this));
  498. //this.otherActionNode = new Element("div", {"styles": this.css.loginOtherActionNode}).inject(this.contentNode);
  499. //this.registerActionNode = new Element("div", {"styles": this.css.loginRegisterActionNode, "text": this.lp.register}).inject(this.otherActionNode);
  500. //this.forgetActionNode = new Element("div", {"styles": this.css.loginForgetActionNode, "text": this.lp.forget}).inject(this.otherActionNode);
  501. //this.setOtherActionEvent();
  502. this.errorNode = new Element("div", {"styles": this.css.registerErrorNode}).inject(this.contentNode);
  503. },
  504. errorInput: function(node, text){
  505. if (text){
  506. node.setStyles(this.css.registerAreaNode_error);
  507. this.checkRegister = false;
  508. }else{
  509. node.setStyles(this.css.registerAreaNode_normal);
  510. }
  511. node.getNext().set("text", text);
  512. },
  513. setInputNodeEvent: function(node, input, text, errorText, name){
  514. input.addEvents({
  515. "focus": function(){
  516. this.errorInput(node, "");
  517. node.setStyles(this.css.registerAreaNode_over);
  518. if (input.get("value")==text) input.set("value", "");
  519. }.bind(this),
  520. "blur": function(){
  521. node.setStyles(this.css.registerAreaNode_normal);
  522. if (!input.get("value")) input.set("value", text);
  523. this[name+"Verification"]();
  524. //if (!input.get("value")){
  525. // input.set("value", text);
  526. // this.errorInput(node, errorText);
  527. //}
  528. }.bind(this),
  529. "selectstart": function(e){e.stopPropagation();}
  530. });
  531. },
  532. resetCodeNode: function(){
  533. this.codeAreaNode = new Element("div", {"styles": this.css.registerCodeAreaNode}).inject(this.codeNode, "before");
  534. this.codeNode.getNext().inject(this.codeAreaNode);
  535. this.codeNode.inject(this.codeAreaNode, "top");
  536. this.codeNode.setStyles({
  537. "width": "auto",
  538. "margin": "0px 160px 0px 0px"
  539. });
  540. this.getCodeAtionNode = new Element("div", {"styles": this.css.registerGetCodeAtionNode, "text": this.lp.getCodeAtion}).inject(this.codeAreaNode, "top");
  541. this.getCodeAtionNode.addEvent("click", this.getCode.bind(this));
  542. },
  543. getCodeNext: function(){
  544. this.getCodeAtionNode.setStyles(this.css.registerGetCodeAtionNode_next);
  545. this.getCodeAtionNode.set("text", this.lp.getCodeNext+"(60)");
  546. this.getCodeAtionNode.removeEvents("click");
  547. this.codeNextTimerCount = 60;
  548. },
  549. getCodeNextTimer: function(){
  550. this.codeNextTimerCount--;
  551. if (this.codeNextTimerCount>0){
  552. this.getCodeAtionNode.set("text", this.lp.getCodeNext+"("+this.codeNextTimerCount+")");
  553. this.codeNextTimer = window.setTimeout(function(){
  554. this.getCodeNextTimer();
  555. }.bind(this), 1000);
  556. }else{
  557. this.regetCode();
  558. }
  559. },
  560. regetCode: function(){
  561. this.getCodeAtionNode.setStyles(this.css.registerGetCodeAtionNode);
  562. this.getCodeAtionNode.set("text", this.lp.getCodeAtion);
  563. this.getCodeAtionNode.addEvent("click", this.getCode.bind(this));
  564. this.codeNextTimer = null;
  565. },
  566. getCode: function(){
  567. if (this.mobileVerification()){
  568. this.getCodeNext();
  569. this.action.getCode(this.mobileInput.get("value"), function(json){
  570. this.codeNextTimer = window.setTimeout(function(){
  571. this.getCodeNextTimer();
  572. }.bind(this), 1000);
  573. }.bind(this), function(xhr, text, error){
  574. if (xhr){
  575. var json = JSON.decode(xhr.responseText);
  576. this.errorNode.set("text", json.message);
  577. }else{
  578. var errorText = error+":"+text;
  579. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  580. }
  581. this.regetCode();
  582. }.bind(this));
  583. }
  584. },
  585. setInputEvent: function(){
  586. this.setInputNodeEvent(this.usernameNode, this.usernameInput, this.lp.username, this.lp.errorUsername, "username");
  587. this.setInputNodeEvent(this.passwordNode, this.passwordInput, this.lp.password, this.lp.errorPassword, "password");
  588. this.setInputNodeEvent(this.mobileNode, this.mobileInput, this.lp.mobile, this.lp.errorMobile, "mobile");
  589. if( this.mailNode && this.mailInput ){
  590. this.setInputNodeEvent(this.mailNode, this.mailInput, this.lp.mail, this.lp.errorMail, "mail");
  591. }
  592. this.setInputNodeEvent(this.codeNode, this.codeInput, this.lp.code, this.lp.errorCode, "code");
  593. this.resetCodeNode();
  594. },
  595. show: function(){
  596. this.collect.showContent("registerContentNode");
  597. this.collect.backNode.setStyle("display", "flex");
  598. this.collect.backNode.removeEvents("click");
  599. this.collect.backNode.addEvent("click", function(){
  600. this.collect.showContent("checkContentNode");
  601. this.collect.backNode.setStyle("display", "none");
  602. }.bind(this));
  603. },
  604. registering: function(){
  605. this.registerActionNode.removeEvents("click");
  606. this.registerActionNode.set("text", this.lp.registering);
  607. },
  608. registered: function(){
  609. this.registerActionNode.addEvent("click", this.register.bind(this));
  610. this.registerActionNode.set("text", this.lp.register);
  611. },
  612. register: function(){
  613. var user = this.usernameInput.get("value");
  614. var mobile = this.mobileInput.get("value");
  615. var mail = this.mailInput.get("value");
  616. var code = this.codeInput.get("value");
  617. var password = this.passwordInput.get("value");
  618. if (this.usernameVerification() && this.mobileVerification() && this.mailVerification() && this.codeVerification() && this.passwordVerification()){
  619. this.registering();
  620. var data = {
  621. codeAnswer: code,
  622. mobile: mobile,
  623. mail: mail,
  624. name: user,
  625. password: password
  626. };
  627. this.action.createCollect(data, function(){
  628. this.action.updateCollect({"name": user, "password": password, "enable": true}, function(json){
  629. this.registered();
  630. this.collect.showContent("checkContentNode");
  631. this.collect.backNode.setStyle("display", "none");
  632. window.setTimeout(function(){
  633. this.collect.check.recheck();
  634. }.bind(this), 1000);
  635. }.bind(this), function(xhr, text, error){
  636. var errorText = error+":"+text;
  637. if (xhr) errorText = xhr.responseText;
  638. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  639. this.registered();
  640. }.bind(this));
  641. }.bind(this), function(xhr, text, error){
  642. if (xhr){
  643. var json = JSON.decode(xhr.responseText);
  644. this.errorNode.set("text", json.message);
  645. }else{
  646. var errorText = error+":"+text;
  647. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  648. }
  649. this.registered();
  650. }.bind(this));
  651. }
  652. },
  653. passwordVerification: function(){
  654. var password = this.passwordInput.get("value");
  655. if (!password || password==this.lp.password){
  656. this.errorInput(this.passwordNode, this.lp.errorPassword);
  657. return false;
  658. }
  659. var flag = "";
  660. this.action.passwordValidate({"password": password}, function(json){
  661. //if (json.data.value<4){
  662. // flag = this.lp.errorPasswordRule;
  663. //}
  664. flag = json.data.value || "";
  665. }.bind(this), function(xhr, text, error){
  666. }.bind(this), false);
  667. if (flag){
  668. this.errorInput(this.passwordNode, flag);
  669. return false;
  670. }
  671. return true;
  672. },
  673. codeVerification: function(){
  674. var code = this.codeInput.get("value");
  675. if (!code || code==this.lp.mobile){
  676. this.errorInput(this.codeNode, this.lp.errorCode);
  677. return false;
  678. }
  679. return true;
  680. },
  681. usernameVerification: function(){
  682. var user = this.usernameInput.get("value");
  683. if (!user || user==this.lp.username){
  684. this.errorInput(this.usernameNode, this.lp.errorUsername);
  685. return false;
  686. }
  687. var flag = "";
  688. this.action.nameExist(user, function(json){
  689. if (json.data.value){
  690. flag = this.lp.usernameExisted;
  691. }
  692. }.bind(this), function(xhr, text, error){
  693. if (xhr){
  694. var json = JSON.decode(xhr.responseText);
  695. flag = json.message;
  696. //this.errorNode.set("text", json.message);
  697. }else{
  698. var errorText = error+":"+text;
  699. flag = this.lp.requestError+errorText;
  700. //MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  701. }
  702. }.bind(this), false);
  703. if (flag){
  704. this.errorInput(this.usernameNode, flag);
  705. return false;
  706. }
  707. return true;
  708. },
  709. mobileVerification: function(){
  710. var mobile = this.mobileInput.get("value");
  711. if (!mobile || mobile==this.lp.mobile){
  712. this.errorInput(this.mobileNode, this.lp.errorMobile);
  713. return false;
  714. }
  715. if (mobile.length!=11){
  716. this.errorInput(this.mobileNode, this.lp.errorMobile);
  717. return false;
  718. }
  719. return true;
  720. },
  721. mailVerification: function(){
  722. var mail = this.mailInput.get("value");
  723. if (!mail || mail==this.lp.mail){
  724. this.errorInput(this.mailNode, this.lp.errorMail);
  725. return false;
  726. }
  727. var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
  728. if (!reg.test(mail)){
  729. this.errorInput(this.mailNode, this.lp.errorMail);
  730. return false;
  731. }
  732. return true;
  733. }
  734. });
  735. MWF.xApplication.Collect.ModifyForm = new Class({
  736. Extends: MWF.xApplication.Collect.RegisterForm,
  737. initialize: function(collect){
  738. this.collect = collect;
  739. this.lp = this.collect.lp;
  740. this.css = this.collect.css;
  741. this.contentNode = this.collect.modifyContentNode;
  742. this.action = this.collect.action;
  743. this.load();
  744. },
  745. load: function(){
  746. this.contentNode.setStyle("padding-top", "30px");
  747. this.usernameNode = this.createNode("registerUsernameIconNode", "username");
  748. this.usernameInput = this.usernameNode.getElement("input");
  749. this.mobileNode = this.createNode("registerMobileIconNode", "mobile");
  750. this.mobileInput = this.mobileNode.getElement("input");
  751. this.codeNode = this.createNode("registerCodeIconNode", "code");
  752. this.codeInput = this.codeNode.getElement("input");
  753. this.newNameNode = this.createNode("registerNewNameIconNode");
  754. this.newNameInput = this.newNameNode.getElement("input");
  755. this.secretNode = this.createNode("registerSecretIconNode", "secret");
  756. this.secretInput = this.secretNode.getElement("input");
  757. this.keyNode = this.createNode("registerKeyIconNode", "key");
  758. this.keyInput = this.keyNode.getElement("input");
  759. this.setInputEvent();
  760. this.nextActionNode = new Element("div", {"styles": this.css.registerActionNode, "text": this.lp.modifyNextStep}).inject(this.contentNode);
  761. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  762. this.errorNode = new Element("div", {"styles": this.css.registerErrorNode}).inject(this.contentNode);
  763. this.newNameNode.setStyle("display", "none");
  764. this.newNameNode.getNext().setStyle("display", "none");
  765. this.secretNode.setStyle("display", "none");
  766. this.secretNode.getNext().setStyle("display", "none");
  767. this.keyNode.setStyle("display", "none");
  768. this.keyNode.getNext().setStyle("display", "none");
  769. this.setDefaultValue();
  770. },
  771. setDefaultValue: function(){
  772. this.action.getCollectConfig(function(json){
  773. if (json.data.name) this.usernameInput.set("value", json.data.name);
  774. if (json.data.name) this.newNameInput.set("value", json.data.name);
  775. if (json.data.key) this.keyInput.set("value", json.data.key);
  776. if (json.data.secret) this.secretInput.set("value", json.data.secret);
  777. }.bind(this));
  778. },
  779. nextStepWait: function(){
  780. this.nextActionNode.removeEvents("click");
  781. this.nextActionNode.set("text", this.lp.nextStepWait);
  782. this.errorNode.empty();
  783. },
  784. setInputEvent: function(){
  785. this.setInputNodeEvent(this.usernameNode, this.usernameInput, this.lp.username, this.lp.errorUsername, "username");
  786. this.setInputNodeEvent(this.newNameNode, this.newNameInput, this.lp.username, this.lp.errorUsername, "newName");
  787. this.setInputNodeEvent(this.secretNode, this.secretInput, this.lp.secret, this.lp.errorSecret, "secret");
  788. this.setInputNodeEvent(this.keyNode, this.keyInput, this.lp.key, this.lp.errorKey, "key");
  789. this.setInputNodeEvent(this.mobileNode, this.mobileInput, this.lp.mobile, this.lp.errorMobile, "mobile");
  790. this.setInputNodeEvent(this.codeNode, this.codeInput, this.lp.code, this.lp.errorCode, "code");
  791. this.resetCodeNode();
  792. },
  793. nextStepWaited: function(){
  794. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  795. this.nextActionNode.set("text", this.lp.modifyNextStep);
  796. },
  797. firstStep: function(){
  798. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  799. this.nextActionNode.set("text", this.lp.modifyNextStep);
  800. this.newNameNode.setStyle("display", "none");
  801. this.newNameNode.getNext().setStyle("display", "none");
  802. this.secretNode.setStyle("display", "none");
  803. this.secretNode.getNext().setStyle("display", "none");
  804. this.keyNode.setStyle("display", "none");
  805. this.keyNode.getNext().setStyle("display", "none");
  806. this.usernameNode.setStyle("display", "block");
  807. this.usernameNode.getNext().setStyle("display", "block");
  808. this.mobileNode.setStyle("display", "block");
  809. this.mobileNode.getNext().setStyle("display", "block");
  810. this.codeNode.getParent().setStyle("display", "block");
  811. this.codeNode.getNext().setStyle("display", "block");
  812. this.errorNode.empty();
  813. },
  814. nextStep: function(){
  815. var user = this.usernameInput.get("value");
  816. var mobile = this.mobileInput.get("value");
  817. var code = this.codeInput.get("value");
  818. if (this.usernameVerification() & this.mobileVerification() & this.codeVerification()){
  819. this.nextStepWait();
  820. this.action.codeValidate({"codeAnswer": code, "mobile": mobile}, function(json){
  821. if (json.data.value){
  822. this.nextActionNode.removeEvents("click");
  823. this.nextActionNode.set("text", this.lp.modifyUnit);
  824. this.nextActionNode.addEvent("click", this.modifyUnit.bind(this));
  825. this.newNameNode.setStyle("display", "block");
  826. this.newNameNode.getNext().setStyle("display", "block");
  827. this.secretNode.setStyle("display", "block");
  828. this.secretNode.getNext().setStyle("display", "block");
  829. this.keyNode.setStyle("display", "block");
  830. this.keyNode.getNext().setStyle("display", "block");
  831. this.usernameNode.setStyle("display", "none");
  832. this.usernameNode.getNext().setStyle("display", "none");
  833. this.mobileNode.setStyle("display", "none");
  834. this.mobileNode.getNext().setStyle("display", "none");
  835. this.codeNode.getParent().setStyle("display", "none");
  836. this.codeNode.getNext().setStyle("display", "none");
  837. this.errorNode.empty();
  838. }else{
  839. this.errorInput(this.codeNode, this.lp.errorCode);
  840. this.nextStepWaited();
  841. }
  842. }.bind(this), function(xhr, text, error){
  843. if (xhr){
  844. var json = JSON.decode(xhr.responseText);
  845. this.errorInput(this.codeNode, json.message);
  846. }else{
  847. var errorText = error+":"+text;
  848. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  849. }
  850. this.nextStepWaited();
  851. }.bind(this));
  852. }
  853. },
  854. modifyUnit: function(){
  855. var user = this.usernameInput.get("value");
  856. var newName = this.newNameInput.get("value");
  857. var code = this.codeInput.get("value");
  858. var secret = this.secretInput.get("value") == this.lp.secret ? "" : this.secretInput.get("value");
  859. var key = this.keyInput.get("value")== this.lp.key ? "" : this.keyInput.get("value");
  860. var mobile = this.mobileInput.get("value");
  861. if (this.newNameVerification()){
  862. this.nextStepWait();
  863. var data = {
  864. mobile: mobile,
  865. codeAnswer: code,
  866. newName: newName,
  867. secret: secret,
  868. key: key,
  869. name: user
  870. };
  871. this.action.updateUnitCollect(data, function(json){
  872. if (user != newName) {
  873. this.usernameInput.set("value", newName);
  874. }
  875. this.firstStep();
  876. this.collect.showContent("checkContentNode");
  877. this.collect.backNode.setStyle("display", "none");
  878. this.collect.check.recheck();
  879. }.bind(this), function(xhr, text, error){
  880. var errorText = error+":"+text;
  881. if (xhr) errorText = xhr.responseText;
  882. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  883. this.firstStep();
  884. }.bind(this));
  885. }
  886. },
  887. usernameVerification: function(){
  888. var user = this.usernameInput.get("value");
  889. if (!user || user==this.lp.username){
  890. this.errorInput(this.usernameNode, this.lp.errorUsername);
  891. return false;
  892. }
  893. return true;
  894. },
  895. newNameVerification: function(){
  896. var user = this.usernameInput.get("value");
  897. if (!user || user==this.lp.username){
  898. this.errorInput(this.usernameNode, this.lp.errorUsername);
  899. return false;
  900. }
  901. return true;
  902. },
  903. keyVerification: function(){
  904. var user = this.usernameInput.get("value");
  905. if (!user || user==this.lp.username){
  906. this.errorInput(this.usernameNode, this.lp.errorUsername);
  907. return false;
  908. }
  909. return true;
  910. },
  911. secretVerification: function(){
  912. var user = this.usernameInput.get("value");
  913. if (!user || user==this.lp.username){
  914. this.errorInput(this.usernameNode, this.lp.errorUsername);
  915. return false;
  916. }
  917. return true;
  918. },
  919. show: function(){
  920. this.collect.showContent("modifyContentNode");
  921. this.collect.backNode.setStyle("display", "flex");
  922. this.collect.backNode.removeEvents("click");
  923. this.collect.backNode.addEvent("click", function(){
  924. this.firstStep();
  925. this.collect.showContent("checkContentNode");
  926. this.collect.backNode.setStyle("display", "none");
  927. }.bind(this));
  928. }
  929. });
  930. MWF.xApplication.Collect.ModifyPwdForm = new Class({
  931. Extends: MWF.xApplication.Collect.RegisterForm,
  932. initialize: function(collect){
  933. this.collect = collect;
  934. this.lp = this.collect.lp;
  935. this.css = this.collect.css;
  936. this.contentNode = this.collect.modifyPwdContentNode;
  937. this.action = this.collect.action;
  938. this.load();
  939. },
  940. load: function(){
  941. this.contentNode.setStyle("padding-top", "30px");
  942. this.usernameNode = this.createNode("registerUsernameIconNode", "username");
  943. this.usernameInput = this.usernameNode.getElement("input");
  944. this.mobileNode = this.createNode("registerMobileIconNode", "mobile");
  945. this.mobileInput = this.mobileNode.getElement("input");
  946. this.codeNode = this.createNode("registerCodeIconNode", "code");
  947. this.codeInput = this.codeNode.getElement("input");
  948. this.passwordNode = this.createNode("registerPasswordIconNode", "password", "password");
  949. this.passwordInput = this.passwordNode.getElement("input");
  950. this.setInputEvent();
  951. this.nextActionNode = new Element("div", {"styles": this.css.registerActionNode, "text": this.lp.modifyNextStep}).inject(this.contentNode);
  952. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  953. //this.otherActionNode = new Element("div", {"styles": this.css.loginOtherActionNode}).inject(this.contentNode);
  954. //this.registerActionNode = new Element("div", {"styles": this.css.loginRegisterActionNode, "text": this.lp.register}).inject(this.otherActionNode);
  955. //this.forgetActionNode = new Element("div", {"styles": this.css.loginForgetActionNode, "text": this.lp.forget}).inject(this.otherActionNode);
  956. //this.setOtherActionEvent();
  957. this.errorNode = new Element("div", {"styles": this.css.registerErrorNode}).inject(this.contentNode);
  958. this.passwordNode.setStyle("display", "none");
  959. this.passwordNode.getNext().setStyle("display", "none");
  960. this.setDefaultValue();
  961. },
  962. setDefaultValue: function(){
  963. this.action.getCollectConfig(function(json){
  964. if (json.data.name) this.usernameInput.set("value", json.data.name);
  965. }.bind(this));
  966. },
  967. nextStepWait: function(){
  968. this.nextActionNode.removeEvents("click");
  969. this.nextActionNode.set("text", this.lp.nextStepWait);
  970. this.errorNode.empty();
  971. },
  972. nextStepWaited: function(){
  973. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  974. this.nextActionNode.set("text", this.lp.modifyNextStep);
  975. },
  976. firstStep: function(){
  977. this.nextActionNode.addEvent("click", this.nextStep.bind(this));
  978. this.nextActionNode.set("text", this.lp.modifyNextStep);
  979. this.passwordNode.setStyle("display", "none");
  980. this.passwordNode.getNext().setStyle("display", "none");
  981. this.usernameNode.setStyle("display", "block");
  982. this.usernameNode.getNext().setStyle("display", "block");
  983. this.mobileNode.setStyle("display", "block");
  984. this.mobileNode.getNext().setStyle("display", "block");
  985. this.codeNode.getParent().setStyle("display", "block");
  986. this.codeNode.getNext().setStyle("display", "block");
  987. this.errorNode.empty();
  988. },
  989. nextStep: function(){
  990. var user = this.usernameInput.get("value");
  991. var mobile = this.mobileInput.get("value");
  992. var code = this.codeInput.get("value");
  993. if (this.usernameVerification() & this.mobileVerification() & this.codeVerification()){
  994. this.nextStepWait();
  995. this.action.codeValidate({"codeAnswer": code, "mobile": mobile}, function(json){
  996. if (json.data.value){
  997. this.nextActionNode.removeEvents("click");
  998. this.nextActionNode.set("text", this.lp.modifyPassword);
  999. this.nextActionNode.addEvent("click", this.modifyPassword.bind(this));
  1000. this.passwordNode.setStyle("display", "block");
  1001. this.passwordNode.getNext().setStyle("display", "block");
  1002. this.usernameNode.setStyle("display", "none");
  1003. this.usernameNode.getNext().setStyle("display", "none");
  1004. this.mobileNode.setStyle("display", "none");
  1005. this.mobileNode.getNext().setStyle("display", "none");
  1006. this.codeNode.getParent().setStyle("display", "none");
  1007. this.codeNode.getNext().setStyle("display", "none");
  1008. this.errorNode.empty();
  1009. }else{
  1010. this.errorInput(this.codeNode, this.lp.errorCode);
  1011. this.nextStepWaited();
  1012. }
  1013. }.bind(this), function(xhr, text, error){
  1014. if (xhr){
  1015. var json = JSON.decode(xhr.responseText);
  1016. this.errorInput(this.codeNode, json.message);
  1017. }else{
  1018. var errorText = error+":"+text;
  1019. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  1020. }
  1021. this.nextStepWaited();
  1022. }.bind(this));
  1023. }
  1024. },
  1025. modifyPassword: function(){
  1026. var user = this.usernameInput.get("value");
  1027. var mobile = this.mobileInput.get("value");
  1028. var code = this.codeInput.get("value");
  1029. var password = this.passwordInput.get("value");
  1030. if (this.usernameVerification() & this.mobileVerification() & this.codeVerification() & this.passwordVerification()){
  1031. this.nextStepWait();
  1032. var data = {
  1033. codeAnswer: code,
  1034. mobile: mobile,
  1035. name: user,
  1036. password: password
  1037. };
  1038. debugger;
  1039. this.action.resetPassword(data, function(){
  1040. this.action.updateCollect({"name": user, "password": password, "enable": true}, function(json){
  1041. this.firstStep();
  1042. this.collect.showContent("checkContentNode");
  1043. this.collect.backNode.setStyle("display", "none");
  1044. this.collect.check.recheck();
  1045. }.bind(this), function(xhr, text, error){
  1046. var errorText = error+":"+text;
  1047. if (xhr) errorText = xhr.responseText;
  1048. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  1049. this.firstStep();
  1050. }.bind(this));
  1051. }.bind(this), function(xhr, text, error){
  1052. if (xhr){
  1053. var json = JSON.decode(xhr.responseText);
  1054. this.errorNode.set("text", json.message);
  1055. }else{
  1056. var errorText = error+":"+text;
  1057. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  1058. }
  1059. this.firstStep();
  1060. }.bind(this));
  1061. }
  1062. },
  1063. usernameVerification: function(){
  1064. var user = this.usernameInput.get("value");
  1065. if (!user || user==this.lp.username){
  1066. this.errorInput(this.usernameNode, this.lp.errorUsername);
  1067. return false;
  1068. }
  1069. return true;
  1070. },
  1071. show: function(){
  1072. this.collect.showContent("modifyPwdContentNode");
  1073. this.collect.backNode.setStyle("display", "flex");
  1074. this.collect.backNode.removeEvents("click");
  1075. this.collect.backNode.addEvent("click", function(){
  1076. this.firstStep();
  1077. this.collect.showContent("checkContentNode");
  1078. this.collect.backNode.setStyle("display", "none");
  1079. }.bind(this));
  1080. }
  1081. });
  1082. MWF.xApplication.Collect.DeleteForm = new Class({
  1083. Extends: MWF.xApplication.Collect.RegisterForm,
  1084. initialize: function(collect){
  1085. this.collect = collect;
  1086. this.lp = this.collect.lp;
  1087. this.css = this.collect.css;
  1088. this.contentNode = this.collect.deleteContentNode;
  1089. this.action = this.collect.action;
  1090. this.load();
  1091. },
  1092. load: function(){
  1093. this.contentNode.setStyle("padding-top", "30px");
  1094. this.usernameNode = this.createNode("registerUsernameIconNode", "username");
  1095. this.usernameInput = this.usernameNode.getElement("input");
  1096. this.mobileNode = this.createNode("registerMobileIconNode", "mobile");
  1097. this.mobileInput = this.mobileNode.getElement("input");
  1098. this.codeNode = this.createNode("registerCodeIconNode", "code");
  1099. this.codeInput = this.codeNode.getElement("input");
  1100. this.passwordNode = this.createNode("registerPasswordIconNode", "password", "password");
  1101. this.passwordInput = this.passwordNode.getElement("input");
  1102. this.setInputEvent();
  1103. this.nextActionNode = new Element("div", {"styles": this.css.registerActionNode, "text": this.lp.confirmDelete}).inject(this.contentNode);
  1104. this.nextActionNode.addEvent("click", this.deleteCollect.bind(this));
  1105. this.errorNode = new Element("div", {"styles": this.css.registerErrorNode}).inject(this.contentNode);
  1106. this.passwordNode.setStyle("display", "none");
  1107. this.passwordNode.getNext().setStyle("display", "none");
  1108. this.setDefaultValue();
  1109. },
  1110. setDefaultValue: function(){
  1111. this.action.getCollectConfig(function(json){
  1112. if (json.data.name) this.usernameInput.set("value", json.data.name);
  1113. }.bind(this));
  1114. },
  1115. deleteCollect:function(){
  1116. var user = this.usernameInput.get("value");
  1117. var mobile = this.mobileInput.get("value");
  1118. var code = this.codeInput.get("value");
  1119. if (this.usernameVerification() & this.mobileVerification() & this.codeVerification() ){
  1120. this.action.deleteCollect(user,mobile,code, function(json){
  1121. this.collect.showContent("checkContentNode");
  1122. this.collect.backNode.setStyle("display", "none");
  1123. this.collect.check.recheck();
  1124. }.bind(this), function(xhr, text, error){
  1125. var errorText = error+":"+text;
  1126. if (xhr) errorText = xhr.responseText;
  1127. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  1128. this.firstStep();
  1129. }.bind(this));
  1130. }
  1131. },
  1132. usernameVerification: function(){
  1133. var user = this.usernameInput.get("value");
  1134. if (!user || user==this.lp.username){
  1135. this.errorInput(this.usernameNode, this.lp.errorUsername);
  1136. return false;
  1137. }
  1138. return true;
  1139. },
  1140. firstStep: function(){
  1141. this.passwordNode.setStyle("display", "none");
  1142. this.passwordNode.getNext().setStyle("display", "none");
  1143. this.usernameNode.setStyle("display", "block");
  1144. this.usernameNode.getNext().setStyle("display", "block");
  1145. this.mobileNode.setStyle("display", "block");
  1146. this.mobileNode.getNext().setStyle("display", "block");
  1147. this.codeNode.getParent().setStyle("display", "block");
  1148. this.codeNode.getNext().setStyle("display", "block");
  1149. this.errorNode.empty();
  1150. },
  1151. show: function(){
  1152. this.collect.showContent("deleteContentNode");
  1153. this.collect.backNode.setStyle("display", "flex");
  1154. this.collect.backNode.removeEvents("click");
  1155. this.collect.backNode.addEvent("click", function(){
  1156. this.firstStep();
  1157. this.collect.showContent("checkContentNode");
  1158. this.collect.backNode.setStyle("display", "none");
  1159. }.bind(this));
  1160. }
  1161. });