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 define(
 11 	[
 12 		"component/verify_code",
 13 		"component/process_components"
 14 	], 
 15 	function() {
 16 		var _html = '<div class="we_cell_form_box" attr="root"></div>',
 17 			_tips = "为了账号安全,请填写本人手机号码";
 18 
 19 		/**
 20 		 * 绑定手机组件
 21 		 * @lends  $we.widget.bind_mobile
 22 		 */
 23 		$we.widget.reg("bind_mobile", {
 24 			/**
 25 			 * @constructs
 26 			 */
 27 			init: function(el, params) {
 28 				this.el = el;
 29 				this.params = params || {};
 30 
 31 				this.params.tips = $we.utils.setValue(this.params.tips, _tips);
 32 				var me = this;
 33 				this.params.formCommit = function() {
 34 					me.notify("next");
 35 				}
 36 			},
 37 			/**
 38 			 * interfaces
 39 			 * @memberOf $we.widget.bind_mobile#
 40 			 */
 41 			interfaces: {
 42 				render: function(params) {
 43 					if (typeof params == "object") {
 44 						for (var i in params) {
 45 							this.params[i] = params[i];
 46 						}
 47 					}
 48 
 49 					if (this.params.tips) {
 50 						this.tips = $we.widget.add("process.tips.small", this.el, {
 51 							content: this.params.tips
 52 						});	
 53 					}
 54 
 55 					this.append(this.el, _html);
 56 					this.verifyMobile = $we.widget.add("comp.verify_code", this.node.root, this.params);
 57 
 58 					this.verifyMobile.render();
 59 				}
 60 			},
 61 			/**
 62 			 * process
 63 			 * @memberOf $we.widget.bind_mobile#
 64 			 */
 65 			process: {
 66 				start: function(params) {
 67 					this.render(params);
 68 				},
 69 				end: function() {
 70 					$(this.node.root).remove();
 71 					this.tips && this.tips.remove();
 72 				},
 73 				checkSucc: function() {
 74 					var me = this;
 75 					this.verifyMobile.verifyCode(function(data) {
 76 						if (!data) {
 77 							me.notify("goNext");
 78 							return;
 79 						}
 80 						if (false && data.reject) {
 81 							$we.comp.alert(data.reject_reason);
 82 							me.notify("close");
 83 						} else {
 84 							for (var i in data) {
 85 								$we.process.setData(i, data[i]);
 86 							}
 87 
 88 							me.notify("goNext", data);
 89 						}
 90 					});
 91 				}
 92 			}
 93 		});
 94 
 95 		var _endHtml = [
 96 				'<div attr="root" class="we_cell_func_intro">',
 97 					'<p class="we_mb20">推荐使用<a href="http://g.sdo.com" target="_blank">G家</a>管理您的账号,保证账号安全</p>',
 98 					'<ul>',
 99 						'<li class="we_func_item">',
100 							'<h3 class="we_func_title"><i class="we_icon_key_login"></i>一键登录</h3>轻滑手机即可登录,安全又便捷',
101 						'</li>',
102 						'<li class="we_func_item">',
103 							'<h3 class="we_func_title"><i class="we_mul_mana"></i>多账号管理</h3>一手掌控,轻松管理,同步保护',
104 					  '</li>',
105 						'<li class="we_func_item">',
106 							'<h3 class="we_func_title"><i class="we_dyn_pwd"></i>动态密码</h3>会变的密码,让账户与消费更安心',
107 						'</li>',
108 						'<li class="we_func_item">',
109 							'<h3 class="we_func_title"><i class="we_safe_notice"></i>安全通知</h3>即时的账号、消费安全通知一手掌握',
110 						'</li>',
111 					'</ul>',
112 				'</div>'
113 			].join(""),
114 			_btmTips = '<strong>温馨提示:</strong>手机验证期内,如果成功找回账号密码,将会自动解绑手机,请慎重操作';
115 
116 		$we.widget.reg("bind_mobile.end", {
117 			init: function(el, config) {
118 				this.el = el;
119 				this.config = config;
120 			},
121 			interfaces: {
122 				render: function(params) {
123 					if (!params || !params.mobile || !params.v_date) return;
124 
125 					this.tips = $we.widget.add("process.tips.big", this.el, {
126 						type: "success",
127 						title: '您已成功绑定手机<span class="we_yellow">'+params.mobile+'</span>',
128 						content: "将在" + params.v_date + "通过验证期。"
129 					});
130 
131 					this.append(this.el, _endHtml);
132 
133 					this.notify("setButton", {next: "完成"});
134 					this.notify("renderBottom", _btmTips);
135 				}
136 			},
137 			process: {
138 				start: function(params) { this.render(params); },
139 				end: function() { this.config.success(); $(this.node.root).remove(); },
140 				checkSucc: function() { this.notify("close");}	
141 			}
142 		});
143 
144 		return $we.widget.amd("bind_mobile");
145 	}
146 );