portal html css js resource

inviteAuthor.js 9.4KB

    (function($) { $(document).ready(function() { var state; var imgUrl = "http://www.ekexiu.com/images/logo180.png"; var lineLink = document.location.href; var descContent="赶快认领,上千家企业正在期待与您合作"; var shareTitle; function Init() { this.id = s64to16(GetQueryString("i")); if(GetQueryString("d")) { this.inviteId =s64to16(GetQueryString("d")); }else{ this.inviteId =""; } this.flag = GetQueryString("f"); if(this.flag) { shareTitle="您的论文被科袖网收录了"; }else{ shareTitle="您的专利被科袖网收录了"; $(".biaoti").attr("src","../images/share_bg_zhuanli_nor@3x.png") } this.passCode=false; this.ajax({ url: (this.flag)?"/ajax/ppaper/qo":"/ajax/ppatent/qo", obj: { "id":this.id }, type: "get", status:true, oFun: this.title }); this.bindEvent(this); } Init.prototype.ajax = function(objec) { $.ajax({ url: objec.url, data: objec.obj, dataType: 'json', //服务器返回json格式数据 type: objec.type, //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; async:objec.status, traditional: true, success: function(data) { objec.oFun(data); }, error: function(e) { console.log(e); bombox("服务器链接超时"); return; } }); } Init.prototype.title = function($data) { console.log($data); if($data.success) { $(".formTit").html("《"+$data.data.name+"》") } console.log($data); } Init.prototype.sendAuthentication = function($data) { if($data.success) { state = $data.data; doClick(); } } Init.prototype.code = function(data) { if(data.success) { if(data.data==false) { bombox("验证码错误,请检查后重新输入"); return; }else{ init.passCode=true; return; } }else{ if(data.msg=="验证超时"){ bombox("验证码已过期,请重新获取"); return; }else{ bombox("请填写正确的手机号,验证码"); return; } } } Init.prototype.completeReg = function(data) { if (data.success) { if(init.flag) { location.href="../ekexiu/InviteResult.html?flag=1&code="+data.data }else{ location.href="../ekexiu/InviteResult.html?code="+data.data } } } Init.prototype.bindEvent = function(sel) { /*校验提交按钮显示状态*/ $('.form-group').on('keyup', "#userphone,#code,#username", function() { if($("#userphone").val() == "" || $("#code").val() == "" || $("#username").val() == "") { $("#regbtn").attr("disabled", true); } else { $("#regbtn").attr("disabled", false); } }); /*注册按钮*/ $("#regbtn").on('click', function() { var oStringLength = $("#username").val().length; if(oStringLength > 10) { bombox("请输入您的真实姓名"); return; } sel.ajax({ url: "/ajax/validCode", obj: { "state": state, "vc": $("#code").val() }, status:false, type: "post", oFun: sel.code }); if(sel.passCode) { sel.ajax({ url: (sel.flag)?"/ajax/regAndAssPaper":"/ajax/regAndAssPatent", obj: (sel.flag)?{ "state":state, "vc":$("#code").val(), "phone":$("#userphone").val(), "inviterId":sel.inviteId, "name":$("#username").val(), "paper":sel.id }:{ "state":state, "vc":$("#code").val(), "phone":$("#userphone").val(), "inviterId":sel.inviteId, "name":$("#username").val(), "patent":sel.id }, status:true, type: "post", oFun: sel.completeReg }); } }); /*点击获取验证码*/ $('#obtain-code').on('click', function() { var hunPhone = /^1[3|4|5|7|8]\d{9}$/; if(hunPhone.test($("#userphone").val())) { sel.ajax({ url: "/ajax/phoneValidCode", obj: { "phone":$("#userphone").val(), }, status:true, type: "get", oFun: sel.sendAuthentication }); } else { bombox("请输入正确的手机号码"); return; } }); } /*控制提示框样式*/ function bombox(textt) { $(".bomb-box").fadeIn("slow"); $(".bomb-box").text(textt); var bombwidth = $(".bomb-box").width(); $(".bomb-box").css({ "marginLeft": -(bombwidth + 25) / 2 + "px" }); setTimeout(function() { $(".bomb-box").fadeOut("slow"); }, 4000); } /*30s后重新获取验证码*/ function doClick() { $("#obtain-code").attr("disabled",true); $("#obtain-code").text("60s后重新获取"); var clickTime = new Date().getTime(); var Timer = setInterval(function() { var nowTime = new Date().getTime(); var second = Math.ceil(60 - (nowTime - clickTime) / 1000); if(second > 0) { $("#obtain-code").text(second + "s后重新获取"); } else { clearInterval(Timer); $("#obtain-code").attr("disabled",false); $("#obtain-code").text("获取验证码"); } }, 1000); } var r64 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "-", "_"]; var d64 = { "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15, "G": 16, "H": 17, "I": 18, "J": 19, "K": 20, "L": 21, "M": 22, "N": 23, "O": 24, "P": 25, "Q": 26, "R": 27, "S": 28, "T": 29, "U": 30, "V": 31, "W": 32, "X": 33, "Y": 34, "Z": 35, "a": 36, "b": 37, "c": 38, "d": 39, "e": 40, "f": 41, "g": 42, "h": 43, "i": 44, "j": 45, "k": 46, "l": 47, "m": 48, "n": 49, "o": 50, "p": 51, "q": 52, "r": 53, "s": 54, "t": 55, "u": 56, "v": 57, "w": 58, "x": 59, "y": 60, "z": 61, "-": 62, "_": 63 }; function s16to64(s) { var out, idx, n1, n2, n3; idx = s.length - 1; out = ""; while(idx >= 0) { n1 = d64[s.charAt(idx--)]; if(idx < 0) { out = r64[n1] + out; break; } n2 = d64[s.charAt(idx--)]; if(idx < 0) { out = r64[(n2 >>> 2)] + r64[((n2 & 0x3) << 4) + n1] + out; break; } n3 = d64[s.charAt(idx--)]; out = r64[(n2 >>> 2) + (n3 << 2)] + r64[((n2 & 0x3) << 4) + n1] + out; } return out; } function s64to16(s) { var out, idx, n1, n2; idx = s.length - 1; out = ""; while(idx >= 0) { n1 = d64[s.charAt(idx--)]; if(idx < 0) { out = r64[n1 >>> 4] + r64[n1 & 0xF] + out; break; } n2 = d64[s.charAt(idx--)]; out = r64[(n2 >>> 2)] + r64[(n1 >>> 4) + ((n2 & 0x3) << 2)] + r64[n1 & 0xF] + out; } if(out.length>32) { return out.substring(1); } return out; } /*微信分享*/ $.ajax({ url: "../ajax/weixin/jsapiTicket", type: 'get', dataType: 'json', contentType: "application/x-www-form-urlencoded; charset=utf-8", data: { 'url': location.href.split('#')[0] }, success: function(data) { if(data.data) { wx.config({ debug: false, //调试模式好犀利 appId: data.data.appId, timestamp: data.data.timestamp, nonceStr: data.data.nonceStr, signature: data.data.signature, jsApiList: [ // 所有要调用的 API 都要加到这个列表中 "onMenuShareAppMessage", "onMenuShareTimeline", "onMenuShareQQ", "onMenuShareQZone", "scanQRCode", ] }); wx.ready(function() { // 在这里调用 API wx.onMenuShareAppMessage({ //分享给朋友 title: shareTitle, // 分享标题 desc: descContent, // 分享描述 link: lineLink, // 分享链接 imgUrl: imgUrl, // 分享图标 success: share_success_callback, cancel: share_cancel_callback }); wx.onMenuShareTimeline({ //分享到朋友圈 title: shareTitle, // 分享标题 desc: descContent, // 分享描述 link: lineLink, // 分享链接 imgUrl: imgUrl, // 分享图标 success: share_success_callback, cancel: share_cancel_callback }); wx.onMenuShareQQ({ //分享到QQ title: shareTitle, // 分享标题 desc: descContent, // 分享描述 link: lineLink, // 分享链接 imgUrl: imgUrl, // 分享图标 success: share_success_callback, cancel: share_cancel_callback }); wx.onMenuShareQZone({ //分享到QQ空间 title: shareTitle, // 分享标题 desc: descContent, // 分享描述 link: lineLink, // 分享链接 imgUrl: imgUrl, // 分享图标 success: share_success_callback, cancel: share_cancel_callback }); }); //分享成功后的回调函数 function share_success_callback() {} //用户取消分享后执行的回调函数 function share_cancel_callback() {} } } }); var init=new Init(); }) })(jQuery);