1 /** 2 * 3 * 验证邮箱 4 * 5 * @fileOverView 6 * @author <a href="mailto:zhang.gd@foxmail.com">Zhang Guangda</a> 7 * @date 2012-10-25 8 */ 9 10 ; 11 define( 12 [ 13 "component/process_components", 14 "component/verify_code" 15 ], 16 function() { 17 var _html = '<div class="we_cell_form_box" attr="root"></div>', 18 _tips = "为了您的账号安全,系统要对以下邮箱进行邮箱验证", 19 _label1 = '邮箱', 20 _label1_empty = '请输入邮箱', 21 _label2 = '邮箱验证码', 22 _label3 = '输入邮箱验证码', 23 _defaultCooldown = 120, 24 _cookieName = "_we_comp_ve", 25 _verifyName = "email", 26 _saveVerifyName = "email", 27 _transName = "email", 28 _verifyReg = "email", 29 _getCodeUrl = $we.conf.ENV.__API + "/ajaxVcode/sendByEmail", 30 _verifyCodeUrl = $we.conf.ENV.__API + "/ajaxVcode/checkEmail"; 31 32 /** 33 * 绑定手机组件 34 * @lends $we.widget.verify_email 35 */ 36 $we.widget.reg("verify_email", { 37 /** 38 * @constructs 39 * @param {Element} el 元素 40 * @param {Object} params 参数 41 */ 42 init: function(el, params) { 43 this.el = el; 44 this.params = params || {}; 45 46 this.params.tips = $we.utils.setValue(this.params.tips, _tips); 47 this.params.getCodeUrl = $we.utils.setValue(this.params.getCodeUrl, _getCodeUrl); 48 this.params.verifyUrl = $we.utils.setValue(this.params.verifyUrl, _verifyCodeUrl); 49 this.params.verifyName = $we.utils.setValue(this.params.verifyName, _verifyName); 50 this.params.saveVerifyName = $we.utils.setValue(this.params.saveVerifyName, this.params.verifyName); 51 this.params.label1 = $we.utils.setValue(this.params.label1, _label1); 52 this.params.label1_empty = $we.utils.setValue(this.params.label1_empty, _label1_empty); 53 this.params.label2 = $we.utils.setValue(this.params.label2, _label2); 54 this.params.label3 = $we.utils.setValue(this.params.label3, _label3); 55 this.params.cooldown = $we.utils.setValue(this.params.cooldown, _defaultCooldown); 56 this.params.cookieName = $we.utils.setValue(this.params.cookieName, _cookieName); 57 this.params.verifyReg = $we.utils.setValue(this.params.verifyReg, _verifyReg); 58 this.params.transName = $we.utils.setValue(this.params.transName, _transName); 59 var me = this; 60 this.params.formCommit = function() { 61 me.notify("next"); 62 } 63 }, 64 /** 65 * interfaces 66 * @memberOf $we.widget.verify_email# 67 */ 68 interfaces: { 69 /** 70 * 渲染 71 * @param {Object} params 参数 72 * @memberOf $we.widget.verify_email# 73 */ 74 render: function(params) { 75 if (typeof params == "object") { 76 for (var i in params) { 77 this.params[i] = params[i]; 78 } 79 } 80 81 if (this.params.verifyName != this.params.saveVerifyName) { 82 this.tips = $we.widget.add("process.tips.small", this.el, { 83 content: this.params.tips 84 }); 85 } 86 87 this.append(this.el, _html); 88 this.extend("comp.verify_code", [this.node.root, this.params]); 89 this._super.render(); 90 } 91 }, 92 /** 93 * process 94 * @memberOf $we.widget.verify_email# 95 */ 96 process: { 97 /** 98 * 步骤开始 99 * @param {Object} params 参数 100 * @memberOf $we.widget.verify_email# 101 */ 102 start: function(params) { 103 this.render(params); 104 }, 105 /** 106 * 步骤结束 107 * @memberOf $we.widget.verify_email# 108 */ 109 end: function() { 110 $(this.node.root).remove(); 111 this.tips && this.tips.remove(); 112 }, 113 /** 114 * 检查步骤是否成功 115 * @memberOf $we.widget.verify_email# 116 */ 117 checkSucc: function() { 118 if(!this.form.valid()) { 119 this.notify("pause"); 120 return; 121 } 122 123 var me = this; 124 this.verifyCode(function(params) { 125 me.notify("goNext", params); 126 }); 127 } 128 } 129 }); 130 131 return $we.widget.amd("verify_email"); 132 } 133 );