|
@@ -0,0 +1,160 @@
|
|
|
+$(function(){
|
|
|
+ var tel={
|
|
|
+ //总入口
|
|
|
+ init:function(){
|
|
|
+ var that=this;
|
|
|
+ that.validate('#hack',that.msg.no_tel);
|
|
|
+ that.time('#hack');
|
|
|
+ that.active();
|
|
|
+ that.blurValidatetel('keyup');
|
|
|
+ that.blurValidatetel('blur');
|
|
|
+ that.focu(document);
|
|
|
+ },
|
|
|
+
|
|
|
+ //弹出信息
|
|
|
+ msg:{
|
|
|
+ no_tel:'请认真填写你的手机号',
|
|
|
+ no_yanz:'请填写验证码',
|
|
|
+ yanz_err:'验证码错误',
|
|
|
+ lg:'该手机已经领取过红包',
|
|
|
+ no_lq:'该手机不能领取红包',
|
|
|
+ remove:'获取验证码哦',
|
|
|
+ over:'该手机已经领取过红包',
|
|
|
+ no_pass:'该手机号不能领取红包'
|
|
|
+ },
|
|
|
+ //判断验证顺序
|
|
|
+ b:false,
|
|
|
+ //插入验证结构
|
|
|
+ validate:function(id,msg,btnmsg,sj){
|
|
|
+ var that=this;
|
|
|
+ $(id).on('tap',function(e){
|
|
|
+ e.preventDefault();//阻止浏览器默认事件
|
|
|
+ var telVal=$('#tel_number').val(),
|
|
|
+ tel=new RegExp("^[1][3-8]+\\d{9}");
|
|
|
+ //验证输入手机规则
|
|
|
+ if(telVal==''||(!tel.test(telVal))){
|
|
|
+ alert(msg);
|
|
|
+ that.b=false;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ that.b=true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ blurValidatetel:function(eve){
|
|
|
+ var that=this;
|
|
|
+ $("#tel_number").on(eve,function(){
|
|
|
+ var thisVal=$(this).val(),
|
|
|
+ tel=new RegExp("^[1][3-8]+\\d{9}");
|
|
|
+ if(thisVal==''||(!tel.test(thisVal))){
|
|
|
+ that.b=false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ that.b=true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //留言
|
|
|
+ input_msg:function(){
|
|
|
+ var dom='<div class="layer_box" id="bomb">'+
|
|
|
+ '<div class="layer" style="padding-bottom: 2px">'+
|
|
|
+ '<div class="top_msg" style="padding: 0 20px;line-height: 126px">'+
|
|
|
+ '<div><textarea id="pass_msg" placeholder="写下你想说的话" style="width:98%;height:50px;font-size: 0.4rem;line-height: 0.4rem;"></textarea></div>'+
|
|
|
+ '</div>'+
|
|
|
+ '<div class="bottom_btn center" style="background: #fff;">'+
|
|
|
+ '<p id="go" class="post_btn" style="float: left;width: 50%;border-top: 1px solid #bfbfbf;color: #000;">取消</p>'+
|
|
|
+ '<p id="post" style="float:left; color: #ff4e4e;width: 49.5%;border-top: 1px solid #bfbfbf;border-left: 1px solid #bfbfbf;">发送</p>'+
|
|
|
+ '</div>'+
|
|
|
+ '</div>'+
|
|
|
+ '</div>';
|
|
|
+ $('body').append(dom);
|
|
|
+ },
|
|
|
+ //倒计时
|
|
|
+ time:function(id,msg,btnmsg){
|
|
|
+ var that=this,
|
|
|
+ times=function(){
|
|
|
+ if(that.b==false){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ tel = $("#tel_number").val();
|
|
|
+ var url_host=window.location.hostname;
|
|
|
+ $.post("/mobile/index.php?act=login&op=getcode&type=getbonus&client_type=ajax", {
|
|
|
+ mobile: tel
|
|
|
+ }), function (data, status) {
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ var yzVal = $('#yanz').val(),
|
|
|
+ time = 60,
|
|
|
+ a = setInterval(function () {
|
|
|
+ time = time - 1;
|
|
|
+ $(id).text(time);
|
|
|
+ if (time == 0) {
|
|
|
+ clearInterval(a);
|
|
|
+ $(id).text('重新发送');
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ };
|
|
|
+ $(id).on('tap', function () {
|
|
|
+ //判断倒计时是否开始了
|
|
|
+ var text = $(this).text();
|
|
|
+ if (text == '重新发送' || text == '获取验证码') {
|
|
|
+ times();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //验证码验证
|
|
|
+ active: function () {
|
|
|
+ var that = this;
|
|
|
+ $('#bind').on('tap', function () {
|
|
|
+ var b = that.b;
|
|
|
+ if (b == false) {
|
|
|
+ alert(that.msg.no_tel);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (yanzVal == '') {
|
|
|
+ alert(that.msg.no_yanz);
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+ var yanzVal = $("#yanz").val();
|
|
|
+ var tel = $("#tel_number").val();
|
|
|
+ $.ajax({
|
|
|
+ type:'post',
|
|
|
+ dataType:'json',
|
|
|
+ url:'/mobile/index.php?act=bonusex&op=bind&client_type=ios',
|
|
|
+ data:{
|
|
|
+ mobile: tel,
|
|
|
+ code: yanzVal
|
|
|
+ },
|
|
|
+ success:function(data)
|
|
|
+ {
|
|
|
+ if (data.code==200) {
|
|
|
+ alert('领取成功');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert(that.msg.yanz_err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //收起键盘
|
|
|
+ focu:function(id){
|
|
|
+ $(id).on('tap',function(event){
|
|
|
+ var eventName=event.target.localName;
|
|
|
+ if(eventName.indexOf('input')!==-1||eventName.indexOf('button')!==-1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $('input').blur();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+ tel.init();
|
|
|
+});
|