123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- $(function(){
- tel={
- //总入口
- init:function(){
- var that=this;
- that.validate('#hack',that.msg.no_tel,that.btnname.just_white);
- //that.validate('#bind',that.msg.no_tel,that.btnname.just_white);
- that.time('#hack');
- //that.close('#close');
- that.close('#go');
- that.active();
- that.blurValidatetel('keyup');
- that.blurValidatetel('blur');
- that.message('#message');
- },
- //弹出信息
- msg:{
- no_tel:'请认真填写你的手机号',
- no_yanz:'请填写验证码',
- yanz_err:'验证码错误',
- lg:'该手机已经领取过红包',
- no_lq:'该手机不能领取红包',
- remove:'获取验证码哦',
- over:'该手机已经领取过红包',
- no_pass:'该手机号不能领取红包'
- },
- //按钮信息
- btnname:{
- just_white:'这就写',
- rewrite:'重新填写',
- check:'知道了'
- },
- //判断验证顺序
- b:false,
- //插入验证结构
- validate:function(id,msg,btnmsg,sj){
- var that=this;
- $(id).on('touchstart',function(e){
- e.preventDefault();//阻止浏览器默认事件
- var telVal=$('#tel_number').val(),
- tel=new RegExp("^[1][3-8]+\\d{9}");
- //console.log(tel.test(telVal));
- //验证输入手机规则
- if(telVal==''||(!tel.test(telVal))){
- that.appendDom(msg,btnmsg);//插入HTML弹窗结构
- 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;
- }
- })
- },
- //dom结构
- appendDom:function(msg,btnmsg){
- var dom='<div class="layer_box center" id="bomb">'+
- '<div class="layer">'+
- '<div class="top_msg">'+
- '<p>'+msg+'</p>'+
- '</div>'+
- '<div class="bottom_btn">'+
- '<p id="go">'+btnmsg+'</p>'+
- '</div>'+
- '</div>'+
- '</div>';
- $('body').append(dom);
- },
- //留言
- 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: 1.2rem"></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);
- },
- //关闭弹出
- close:function(id){
- $(id).live('touchstart',function(e){
- e.preventDefault();
- $('#bomb').remove();
- });
- },
- //倒计时
- 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("http://" + url_host + "/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('touchstart', function () {
- //判断倒计时是否开始了
- var text = $(this).text();
- if (text == '重新发送' || text == '获取验证码') {
- times();
- }
- else {
- return;
- }
- })
- },
- //验证码验证
- active: function () {
- var that = this;
- $('#bind').on('touchstart', function () {
- var b = that.b;
- //yanzVal = $('#yanz').val();
- if (b == false) {
- that.appendDom(that.msg.no_tel, that.btnname.just_white);
- }
- else {
- if (yanzVal == '') {
- that.appendDom(that.msg.no_yanz, that.btnname.just_white);
- }
- else {
- var yanzVal = $("#yanz").val();
- var tel = $("#tel_number").val();
- var alink = $("#url").val();
- var bonus_sn = $("#mine_bonus").val();
- var url_host=window.location.hostname;
- $.ajax({
- type:'post',
- dataType:'json',
- url:'http://'+url_host + '/mobile/index.php?act=bonusex&op=bind&client_type=ios',
- data:{
- mobile: tel,
- code: yanzVal,
- bonus_sn:bonus_sn
- },
- success:function(data) {
- if (data.code==200) {
- var tel = $("#tel_number").val();
- var alink = $("#url").val();
- var other_html='';
- var html='';
- var ser = function binded_info(){
- function formatDate(now) {
- //var year=now.getYear()+1900;
- var month=now.getMonth()+1;
- var date=now.getDate();
- var hour=now.getHours();
- var minute=now.getMinutes();
- var second=now.getSeconds();
- return month+"-"+date+" "+hour+":"+minute;
- }
- //其他用户的结构
- var other_ser=data.datas.binded_info;
- var king=data.datas.type_info.max_amount;
- var mine_bonus_sn=data.datas.mine_bonus.bonus_sn;
- var mine_bonus_value = data.datas.mine_bonus.bonus_value;
- var comment=data.datas.binded_info;
- //红包金额
- $('.price span').text(mine_bonus_value);
- for(var i=0;i<other_ser.length;i++){
- var king_icon='',
- mine ='',
- user_comment='';
- if(other_ser[i].bonus_sn==mine_bonus_sn){
- mine = '<a href="javascript:void(0)" id="message" style="color: #1927D1">留言</a>'
- }
- else {
- mine=formatDate(new Date(parseInt(other_ser[i].get_time)*1000));
- }
- if(other_ser[i].binded_over == 1 && other_ser[i].bonus_value==king) {
- king_icon = '<s class="king"></s>手气最佳';
- }
- if(comment[i].user_comment==''){
- user_comment='';
- }
- else {
- user_comment=comment[i].user_comment;
- }
- other_html+='<div class="li">'+
- '<div class="li_left">'+
- '<p class="p">'+other_ser[i].user_name+'</p>'+
- '<p class="prompt" id="my_prompt">'+mine+'</p>'+
- '<p style="color:#9b9b9b">'+user_comment+'</p>'+
- '</div>'+
- '<div class="li_right">'+
- '<p class="p">'+other_ser[i].bonus_value+'</p>'+
- '<p class="king_box">'+king_icon+'</p>'+
- '</div>'+
- '</div>';
- }
- var binded_num=data.datas.type_info.binded_num,
- total_num=data.datas.type_info.total_num,
- //抢购数量
- shtml='<div class="prompt text_left">'+
- '<p class="prompt pro">领取'+binded_num+'/'+total_num+'个</p>'+
- '</div>';
- html+=shtml+other_html;
- return html;
- };
- $('.list').html(ser());
- $('#bind_link').hide();
- $('#link').css('display','block').addClass('link_but');
- } else {
- that.appendDom(that.msg.yanz_err, that.btnname.rewrite);
- }
- }
- });
- }
- }
- })
- },
- //留言框
- message:function(id){
- var that=this;
- $(id).live('touchstart',function(){
- if($(this).text()!=='留言'){
- return false;
- }
- else{
- that.input_msg(that.msg.no_yanz, that.btnname.just_white);
- $('#pass_msg').focus();
- }
- });
- $('#post').live('touchstart',function(){
- var msg=$('#pass_msg').val();
- if(msg==''){return false;}
- else {
- var url_host=window.location.hostname;
- var my_bonus_sn=$('#mine_bonus').val();
- $.post("http://" + url_host + "/mobile/index.php?act=bonusex&op=comment&client_type=ajax", {
- comment: msg,
- bonus_sn:my_bonus_sn
- }),function (data, status) {
- return false;
- };
- $('#message').text(msg).css('color','9b9b9b');
- $('#bomb').remove();
- }
- });
- $('#pass_msg').live('textInput',function(){
- var msg_length=$(this).val().length;
- if(msg_length>20){
- $(this).val($(this).val().substr(0,20));
- }
- })
- }
- };
- tel.init();
- });
|