1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726 |
- /**统一登录js文件**/
- var loginfg='';//websocket请求标识
- var bIE9=false;
- if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/[6789]./i)) {
- bIE9=true
- }
- var wsUrl = "ws"+(!bIE9&&"https:"==document.location.protocol?"s":"")+"://"+window.location.host+"/ws";
- var ws = null;
- var openid = "";
- var jylgi = 0;
- var loginflag = false;//登录状态
- var mynum = "";//页面参数num
- var keysorpname = "";//项目名称
- var thurl = "";//url
- var semnum = "";//SEM
- var ldpnum = "";//落地页扫码后调整标识
- var ldmold = "";//落地页扫码后调整标识
- var pageshareid = "";
- var kopshareid = "";
- var oldshareid = "";
- var encryptId = null;
- var qr_type = "s";
- var unseatflag = false;//未登录情况下,用户点击超级搜索等开启按钮或者功能,根据此状态看是否弹出二维码
- var unseatzbqyflag = false;//未登录情况下,用户点击中标企业等开启按钮或者功能,根据此状态看是否弹出二维码
- var sendMsgInterval = null;
- var entjumpflag = false;
- //轮询查询
- var LoginPolling = {
- isPostLoginPolling: true,//是否发起轮询请求
- loginPollingInterval: null,
- initInterval: null,
- init: function(){
- //防止重复调用
- if(this.initInterval != null){
- return;
- }
- //先发一个消息,保存session
- this.postShareid();
- this.initInterval = setInterval(this.postShareid,3000);
- },
- postShareid: function(){
- if(WSpolling.isPageHidden || pageshareid == "" || kopshareid == ""){
- return;
- }
- $.ajax({
- type: "POST",
- url: "/front/ajaxPolling",
- data: {reqType: 1,shareIds: pageshareid+"___"+kopshareid},
- dataType: "json",
- timeout: 3000,
- success: function(r){
- clearInterval(LoginPolling.initInterval);
- LoginPolling.initInterval = null;
- }
- });
- },
- start: function(){
- //防止重复调用
- if(this.loginPollingInterval != null){
- return;
- }
- this.init();
- //定时器,定时请求看是否扫码登录,返回用户信息,登录
- this.loginPollingInterval = setInterval(function(){
- //如果浏览器不支持webscoket,走ajax轮询方式
- if(WSpolling.isPageHidden || !LoginPolling.isPostLoginPolling){
- return;
- }
- $.ajax({
- type: "POST",
- url: "/front/ajaxPolling",
- data: {reqType:2},
- dataType: "json",
- timeout: 3000,
- success: function(r){
- if(!jQuery.isEmptyObject(r)){
- logic(r,mynum);
- }
- }
- });
- },5000);
- },
- stop: function(){
- clearInterval(this.loginPollingInterval);
- this.loginPollingInterval = null;
- this.isPostLoginPolling = false;
- this.initInterval = null;
- }
- }
- var webSocketHeartCheck = new WebSocketHeartCheck(LoginPolling);
- //创建websocket连接
- var createWebSocket = function(){
- if("WebSocket" in window){
- try{
- ws = new WebSocket(wsUrl);//实例化websocket对象
- initEventHandle();
- }catch(e){
- reconnect();
- //console.log(e)
- }
- }else{
- LoginPolling.isPostLoginPolling = true;
- }
- }
- //
- var initEventHandle = function(){
- ws.onmessage = function(e){
- //接收消息正常,就不再发ajax轮询
- LoginPolling.isPostLoginPolling = false;
- if(e.data==""){
- return
- }else if(e.data=="HeartBeat"){//心跳检测
- //如果获取到消息,心跳检测重置
- //拿到任何消息都说明当前连接是正常的
- webSocketHeartCheck.reset().start(ws,loginflag);
- return;
- }
- //用户登录
- logic($.parseJSON(e.data),mynum);
- }
- ws.onerror = function(e){
- //console.info("onerror");
- reconnect();
- }
- ws.onclose = function(e) {
- //console.info("onclose");
- reconnect();
- }
- ws.onopen = function(e) {
- SendMsg();
- //心跳检测重置
- webSocketHeartCheck.reset().start(ws,loginflag);
- }
- }
- //
- function reconnect() {
- if(webSocketHeartCheck.lockReconnect || loginflag){
- return;
- }
- LoginPolling.isPostLoginPolling = true;
- webSocketHeartCheck.lockReconnect = true;
- LoginPolling.init();
- //没连接上会一直重连,设置延迟避免请求过多
- setTimeout(function () {
- createWebSocket();
- webSocketHeartCheck.lockReconnect = false;
- }, 2000);
- }
- //websocket查看用户是否登录
- var JYLogin = function(num){
- clearInterval(loginfg)
- loginfg = setInterval(function(){
- jylgi++;
- //console.log(jylgi+"-----")
- if(jylgi>120*60){
- getNewShareId(num,false);
- jylgi = 0;
- }
- },1000)
- }
- var SendMsg = function(){
- if(pageshareid==""||kopshareid==""){
- return;
- }
- if(ws!=null&&ws.readyState==1){
- //console.log("发送:"+pageshareid+"___"+kopshareid)
- ws.send(pageshareid+"___"+kopshareid);
- }else{
- LoginPolling.isPostLoginPolling = true;
- }
- }
- //生成页面二维码,不同页面处理逻辑
- var getNewShareId = function(num,isFirst){
- mynum = num;
- pageType = "T"
- var rref = document.referrer;
- if (localStorage.getItem("oldshareid")!=null){
- oldshareid=localStorage.getItem("oldshareid");
- }
- //console.log("num:"+num)
- $.post("/front/getLoginNum/"+num,{rref:rref,oid:oldshareid},function(data){
- if($("#bidLogin").attr("data-rec")=="sjdc"){
- window.location.href = "/front/dataExport/toSieve";
- return;
- }
- if(data&&data.num){
- pageshareid = data.num;
- kopshareid = data.numot;
- mynum = num;
- if(!loginflag){
- if(isFirst){
- LoginPolling.start();
- createWebSocket();
- }else if(!isFirst){
- LoginPolling.init();
- SendMsg();
- }
- }
- localStorage.setItem("oldshareid", pageshareid);
- //redisUserInfo(pageshareid,kopshareid);
- $(".jyhead_qr img").attr("src","/front/share/"+pageshareid);
- $("#bottomimg").attr("src","/front/share/"+pageshareid);
- $("*[data-share-img]").attr("src","/front/share/"+pageshareid);
- $("#layerImg-login").attr("src","/front/share/"+pageshareid);
- $("#layerImg-zbsq").attr("src","/front/share/"+pageshareid);
- switch(num){
- case "10"://首页
- //$("#layerImg").attr("src","/front/share/"+pageshareid);
- //$("#sy-shareimg img").attr("src","/front/share/"+pageshareid);
- $(".wxlinkdiv").attr("src","/front/share/"+pageshareid);
- break;
- case "11"://订阅页面
- $("#dyym-1 img").attr("src","/front/share/"+kopshareid);
- $("#dyym-2").attr("src","/front/share/"+pageshareid);
- $(".secondleft img").attr("src","/front/share/"+pageshareid);
- $("#vipCode").attr("src","/front/share/"+kopshareid);
- break;
- case "12"://搜索列表页
- $("#layerImg").attr("src","/front/share/"+pageshareid);
- $("#wxCode").attr("src","/front/share/"+pageshareid);
- $("#keyImg").attr("src","/front/share/"+kopshareid);
- if(keysorpname!=undefined&&keysorpname!=""){
- var ref = document.referrer;
- if(ref != ""&&ref.indexOf("jianyu360.com")<0||ref.indexOf("qmx.top")<0){
- $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
- }
- }
- break;
- case "13": case "130"://快照页
- $("#layerImg").attr("src","/front/share/"+pageshareid);
- $("#wxCode").attr("src","/front/share/"+kopshareid);
- //生成二维码
- if(keysorpname!=undefined&&keysorpname!=""){
- $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
- }
- break;
- case "14"://标签页面
- $("#bottomimg").attr("src","/front/share/"+pageshareid);
- $("*[data-share-img]").attr("src","/front/share/"+pageshareid);
- $("#layerImg").attr("src","/front/share/"+pageshareid);
- $("#keyImg").attr("src","/front/share/"+pageshareid);
- break;
- case "15"://博客列表和内容页面
- break;
- case "16"://关于我们页面
- break;
- case "18"://扫码关注企业18
- $("#layerImg").attr("src","/front/share/"+pageshareid);
- var company = $.trim($("#zbSeatchT input[name='keywords']").val());
- if(company != "" && company != null && company.length >0){
- $("#keyImg").attr("src","/front/share/"+kopshareid);
- $.post("/front/rediskw",{"skw":company,"num":kopshareid});
- }else{
- $("#keyImg").attr("src","/front/share/"+pageshareid);
- }
- break;
- case "19"://拟建项目
- $("#layerImg").attr("src","/front/share/"+pageshareid);
- $("#wxCode").attr("src","/front/share/"+pageshareid);
- $("#keyImg").attr("src","/front/share/"+kopshareid);
- if(keysorpname!=undefined&&keysorpname!=""){
- $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
- }
- break;
- case "17"://1808新落地页
- $(".ewm1").attr("src","/front/share/"+pageshareid);
- $(".ewm2").attr("src","/front/share/"+kopshareid);
- $("#kwewm").attr("src","/front/share/"+kopshareid);
- $(".ecode_img img").attr("src","/front/share/"+kopshareid).css("display","");
- break;
- case "23"://数据导出
- break;
- }
- JYLogin(num);
- }
- },'json');
- }
- //
- var redisUserInfo = function(pid,kid){
- var rurl = window.location.href;
- var rref = document.referrer;
- if (localStorage.getItem("oldshareid")!=null){
- oldshareid=localStorage.getItem("oldshareid");
- }
- $.post("/front/followinfo",{pid:pid,kid:kid,rurl:rurl,rref:rref,oid:oldshareid},function(data){
- if(data&&data.result=="ok"){
- localStorage.setItem("oldshareid", pid);
- }
- })
- }
- function checkBigStatus () {
- $.ajax({
- type: 'post',
- url: '/bigmember/use/isAdd',
- success: function (res) {
- if (res && res.data) {
- window.memberStatus = res.data.memberStatus
- window.memberPower = res.data.power
- window.vipStatus = res.data.vipStatus
- sessionStorage.setItem('bidPower', JSON.stringify(res.data.power))
- if (res.data.memberStatus > 0) {
- $(".myorderDiv.lastBox").show()
- }
- if (res.data.viper) {
- $(".myorderDiv.ent-search").show()
- }
- }
- }
- })
- }
- // 查询商机管理PC权限
- function checkMenuForEnt () {
- $.ajax({
- type: 'get',
- url: '/entbase/ent/mySelectent?t=' + new Date().getTime(),
- success: function () {
- $.ajax({
- type: 'get',
- url: '/front/entExportAuth/getAuth?t=' + new Date().getTime(),
- success: function (r) {
- var tempHtml = ''
- if(r.myEntMenu){
- tempHtml += "<div class=\"myorderDiv\" onclick=\"window.location.href='/entpc/myent'\">"
- +"<span>我的企业</span>"
- +"</div>"
- }
- if(r.entnicheMenu){
- tempHtml+= "<div class=\"myorderDiv\" onclick=\"window.location.href='/entpc/bus'\">"
- +"<span>商机管理</span>"
- +"</div>"
- }
- $(".infoList .lastBox").before(tempHtml)
- }
- })
- }
- })
- }
- //查询用户信息,响应页面登录信息
- var logic = function(data,num){
- if(data.result=="ok"){
- clearLoginStorage(/-login-clear/)
- //$(".QRLogin").hide();
- $("#bidLogin").modal("hide")
- $("#bidcommunity").modal("hide")
- clearInterval(loginfg);
- loginflag = true;
- processpage(data.shareid,num);
- //登录成功,停止轮询
- LoginPolling.stop();
- //登录成功,停止心跳监测
- webSocketHeartCheck.reset();
- if(ws.readyState==1){
- ws.send("close");
- ws.close();
- }
- encryptId = data.encryptId
- if(data.s_nickname.length>11){
- data.s_nickname = data.s_nickname.substring(0,11);
- data.s_nickname = data.s_nickname + "...";
- }
- var hhtml = "<img "
- if(data.redisheadimg==null||data.redisheadimg==undefined||data.redisheadimg=="<nil>"){
- data.redisheadimg = ""
- }
- if(data.s_headimage==null||data.s_headimage==undefined||data.s_headimage=="<nil>"){
- data.s_headimage = ""
- }
- if(data.redisheadimg!=""){
- hhtml+="src='"+data.redisheadimg+"' class='imgShow nomalheadimg'"
- }else if(data.s_headimage!=""){
- hhtml+="src='"+data.s_headimage+"' class='imgShow nomalheadimg'"
- }else{
- hhtml+="src='"+data.s_headimage+"' class='imgShow'"
- }
- hhtml+=" onerror='this.src=\"/images/auto.png\";$(this).removeClass(\"nomalheadimg\");'>"
- +"<div class='userInfo'>"
- +"<div class='infoList' style='display:none'>"
- +"<span class='one'></span>"
- +"<span class='two'></span>"
- +"<div class='usernameDiv'>"
- +data.s_nickname
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/front/dataPack/index'\">"
- +"<span>我的数据</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" style=\"border-bottom:0;\" onclick=\"window.location.href='/swordfish/docs//user/docs'\">"
- +"<span>我的文库</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/docs//user/collections'\">"
- +"<span>文库收藏</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/integral/index'\">"
- +"<span>我的剑鱼币</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/coupon/'\">"
- +"<span>我的奖券</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/front/swordfish/toMyOrder'\">"
- +"<span>我的订单</span>"
- +"</div>"
- +"<div class=\"myorderDiv lastBox\" style='display: none' onclick=\"window.location.href='/swordfish/page_big_pc'\">"
- +"<span>大会员</span>"
- +"</div>"
- +"<div class=\"myorderDiv ent-search\" style='display: none' onclick=\"window.location.href='/swordfish/page_big_pc/svip/ent_search'\">"
- +"<span>企业查询</span>"
- +"</div>"
- +"<div class=\"myorderDiv bx-collection\" onclick=\"window.location.href='/swordfish/frontPage/collection/sess/index'\">"
- +"<span>标讯收藏</span>"
- +"</div>"
- hhtml+= "<div class='exitDiv' onclick='signout()'>"
- +"<img id='outImg' src='/images/userexit.png'/>"
- +"<span>退出</span>"
- +"</div>"
- +"</div>"
- +"</div>"
- $("#login").html(hhtml);
- try{
- checkBigStatus()
- checkMenuForEnt()
- infoListCss();
- commonMouseEvent();
- }catch(e){}
- }
- }
- //登录后处理页面逻辑
- var processpage = function(shareid,num){
- var toHref=$("#bidLogin").attr("data-rec")
- switch (toHref) {
- case "sjdc":
- window.location.href = "/front/dataExport/toSieve";
- return;
- case "jydocs":
- window.location.href = "/swordfish/docs";
- return;
- }
- clearInterval(loginfg);
- switch(num){
- case "10"://10首页
- var ful = $("#myModal").attr("aria-hidden");
- if(ful=="true"){
- break;
- }
- $("#myModal").modal("hide");
- // if(dataListId!=""){
- // setTimeout(function(){
- // window.open("/article/content/"+dataListId+".html");
- // },500)
- // }
- break;
- case "11"://11订阅页面
- //$("#myModal-01").click();
- $(".modal").click();
- break;
- case "12"://12搜索列表
- var ful = $("#myModal").attr("aria-hidden");
- if(ful=="true"){
- break;
- }
- $("#myModal").modal("hide");
- $("#labModal").modal("hide");
- if(dataId!=""){
- setTimeout(function(){
- //$('a[dataId="'+ dataId +'"]').click();
- var aHref = "";
- if(searchvalue != ""){
- aHref += '.html?kds='+searchvalue;
- }else{
- aHref += '.html';
- }
- window.open("/article/content/"+dataId+aHref);
- },500);
- }
- break;
- case "13": case "130"://13快照页
- if(thurl!=""&&thurl!="D"){
- window.location.href=thurl;
- }else if(thurl==""){
- window.location.href="/";
- }
- break;
- case "14"://14标签页面
- var ful = $("#myModal").attr("aria-hidden");
- if(ful=="true"){
- break;
- }
- $("#myModal").click();
- if(dataId!=""){
- setTimeout(function(){
- window.open("/article/content/"+dataId+".html");
- },500);
- }
- break;
- case "15"://15剑鱼标讯博客页面
- break;
- case "16"://关于我们页面16
- break;
- case "18"://中标企业搜索
- var ful = $("#myModal").attr("aria-hidden");
- if(ful=="true"){
- break;
- }
- $("#myModal").modal("hide");
- $("#labModal").modal("hide");
- if(dataId!=""){
- setTimeout(function(){
- //$('a[dataId="'+ dataId +'"]').click();
- var aHref = "";
- if(searchvalue != ""){
- aHref += '.html?kds='+searchvalue;
- }else{
- aHref += '.html';
- }
- window.open("/article/content/"+dataId+aHref);
- },500);
- }
- break;
- break;
- case "19"://拟建项目
- var ful = $("#myModal").attr("aria-hidden");
- if(ful=="true"){
- break;
- }
- $("#myModal").modal("hide");
- $("#labModal").modal("hide");
- if(dataId!=""){
- setTimeout(function(){
- var aHref = "";
- if(searchvalue != ""){
- aHref += '.html?kds='+searchvalue;
- }else{
- aHref += '.html';
- }
- window.open("/article/content/"+dataId+aHref);
- },500);
- }
- break;
- case "17"://落地页
- $("#bidLogin").modal("hide");
- $(".close").click();
- if(ldpnum=="0"){
- window.open('/jylab/supsearch/index.html', '_self')
- }else if(ldpnum=="1"){
- window.open('/front/subscribe.html', '_self')
- }else if(ldpnum=="2"){
- window.open('/jylab/supsearch/proposedProject.html', '_self')
- }else if(ldpnum=="3"){
- if(ldmold!=""){
- window.open('/list/stype/'+ldmold+'.html', '_self')
- }else{
- window.open('/jylab/supsearch/index.html', '_self')
- }
- }else if(ldpnum=="4"){
- if(ldmold!=""){
- window.open('/list/area/'+ldmold+'.html', '_self')
- }else{
- window.open('/jylab/supsearch/index.html', '_self')
- }
- }else if(ldpnum=="5"){
- if(ldmold){
- window.open('/article/content/'+ldmold+'.html')
- }else{
- window.open('/jylab/supsearch/index.html')
- }
- }else if(ldpnum=="6"){
- window.open('/front/dataExport/toSieve')
- }
- break;
- case "24"://百度SEM-p 快照页推广-落地页
- window.open(semHref, '_self')
- break
- }
- }
- function clearObjKeyForRegFn (obj, reg) {
- if (obj) {
- for(var k in obj) {
- if (reg.test(k)) {
- obj.removeItem(k)
- }
- }
- }
- }
- function clearLoginStorage (reg) {
- clearObjKeyForRegFn(sessionStorage, reg)
- clearObjKeyForRegFn(localStorage, reg)
- }
- //退出登录
- var signout = function(){
- clearInterval(loginfg);
- loginflag = false;
- unseatflag = false;
- unseatzbqyflag = false;
- $("#login").html("<button class='loginBtn' data-toggle='modal' onclick='openLoginDig()'>登录</button>");
- loginBtnType();
- $(".control-tabBtn>a:first>font").text("招标搜索");
- $(".control-tabBtn>a:eq(2)").addClass("hidden");
- $(".control-tabBtn>a:eq(3)").addClass("hidden");
- $(".superSearch").show();
- $.post("/front/signOut",function(data){
- if(data=="ok"){
- clearLoginStorage(/-login-clear/)
- try{
- $.cookie("userid_secure","",{expires:-1,path:"/",domain:document.domain.replace(/[^.]+/,"")});
- }catch(e){
- document.cookie = "userid_secure=;expires=-1;path=/";
- }
- window.location.href="/";
- var pt = new RegExp("^/article/content/.+$|^/front/dataExport/.+$|^/front/course/codePay$|^/front/course/orderPay$|^/entpc/.+$|^/bid/pc/page/.+$");
- if(pt.test(window.location.pathname)){
- window.location.href="/";
- }else{
- window.location.reload();
- /*LoginPolling.start();
- createWebSocket();
- getNewShareId(mynum,true);*/
- }
- }
- })
- }
- //查看用户是否已经登录
- var haslogin = function(num,kyorpn,url){
- mynum = num;//页面logid
- keysorpname = kyorpn;//其他参数
- thurl = url;//列表也跳转快照页url
- $.post("/front/hasSign",function(data, location){
- if(data){
- loginflag = true;
- encryptId = data.encryptId
- if(data.s_nickname!=null&&data.s_nickname.length>11){
- data.s_nickname = data.s_nickname.substring(0,11);
- data.s_nickname = data.s_nickname + "...";
- }
- var hhtml = "<img "
- if(data.redisheadimg==null||data.redisheadimg==undefined||data.redisheadimg=="<nil>"){
- data.redisheadimg=""
- }
- if(data.s_headimage==null||data.s_headimage==undefined||data.s_headimage=="<nil>"){
- data.s_headimage=""
- }
- if(data.redisheadimg!=""){
- hhtml+="src='"+data.redisheadimg+"' class='imgShow nomalheadimg'"
- }else if(data.s_headimage!=""){
- hhtml+="src='"+data.s_headimage+"' class='imgShow nomalheadimg'"
- }else{
- hhtml+="src='"+data.s_headimage+"' class='imgShow'"
- }
- hhtml+=" onerror='this.src=\"/images/auto.png\";$(this).removeClass(\"nomalheadimg\");'>"
- +"<div class='userInfo'>"
- +"<div class='infoList' style='display:none'>"
- +"<span class='one'></span>"
- +"<span class='two'></span>"
- +"<div class='usernameDiv'>"
- +data.s_nickname
- +"</div>"
- +"<div class=\"myorderDiv\" style=\"display:flex;align-items: center;\" onclick=\"window.location.href='/front/dataPack/index'\">"
- +"<span>我的数据</span>"
- +"<span class=\"new_msg\" >NEW</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" style=\"border-bottom:0;\" onclick=\"window.location.href='/swordfish/docs//user/docs'\">"
- +"<span>我的文库</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/docs//user/collections'\">"
- +"<span>文库收藏</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/integral/index'\">"
- +"<span>我的剑鱼币</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/coupon/'\">"
- +"<span>我的奖券</span>"
- +"</div>"
- +"<div class=\"myorderDiv\" onclick=\"window.location.href='/front/swordfish/toMyOrder'\">"
- +"<span>我的订单</span>"
- +"</div>"
- +"<div class=\"myorderDiv lastBox\" style='display: none' onclick=\"window.location.href='/swordfish/page_big_pc'\">"
- +"<span>大会员</span>"
- +"</div>"
- +"<div class=\"myorderDiv ent-search\" style='display: none' onclick=\"window.location.href='/swordfish/page_big_pc/svip/ent_search'\">"
- +"<span>企业查询</span>"
- +"</div>"
- +"<div class=\"myorderDiv bx-collection\" onclick=\"window.location.href='/swordfish/frontPage/collection/sess/index'\">"
- +"<span>标讯收藏</span>"
- +"</div>"
- hhtml+= "<div class='exitDiv' onclick='signout()'>"
- +"<img id='outImg' src='/images/userexit.png'/>"
- +"<span>退出</span>"
- +"</div>"
- +"</div>"
- +"</div>"
- $("#login").html(hhtml);
- try{
- checkBigStatus()
- checkMenuForEnt()
- infoListCss();
- commonMouseEvent();
- }catch(e){}
- }else{
- $("#login").html("<button class='loginBtn' data-toggle='modal' onclick='openLoginDig()'>登录</button>");
- loginBtnType();
- //pc限制登陆
- var nosess = getParam("nol");
- if (nosess=="1"&& (!loginflag) ){
- openLoginDig();
- }
- }
- getNewShareId(num,true);
- })
- }
- function loginBtnType(){
- var href = window.location.pathname;
- var curTheme =$("#public-nav").attr('data-theme')
- if (href=="/"||href.indexOf("subscribe")>-1||href.indexOf("advservices")>-1||href.indexOf("solution")>-1||href.indexOf("partner")>-1||href.indexOf("aboutus")>-1||href.indexOf("busicooperation")>-1||href.indexOf("pcindex.html")>-1||window.location.pathname==="/jyxspc/"||window.location.pathname==="/entpc/"){
- if(curTheme == 'dark'){
- $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
- $(".loginBtn").attr("onmouseout","this.style.borderColor='#fff'; this.style.color='#fff';");
- }else{
- $(".loginBtn").css({"border-color":"#e0e0e0","color":"rgb(37, 38, 39)"});
- $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
- $(".loginBtn").attr("onmouseout","this.style.borderColor='#e0e0e0'; this.style.color='#252627';");
- }
-
- }else if(href.indexOf("topics")>-1){
- $(".loginBtn").css({"border":"none"});
- }else{
- $(".loginBtn").css({"border-color":"#e0e0e0","color":"rgb(37, 38, 39)"});
- $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
- $(".loginBtn").attr("onmouseout","this.style.borderColor='#e0e0e0'; this.style.color='#252627';");
- }
- }
- ///////////////////////////////
- // ajax部分匿名函数自执行,防止泄露全局变量
- $(function(){
- function goBackOrigin (cb) {
- var backOrigin = $.cookie('article')
- if (backOrigin) {
- location.replace(backOrigin)
- } else {
- typeof cb === 'function' ? cb() : window.close()
- }
- }
- var Direct = {
- verify: {},
- forge: {},
- ajaxSms: function (e, type) {
- var _this = this;
- switch (type) {
- case 'verify': {
- $.post("/phone/login",{
- reqType:"sendIdentCode",
- phone:$("#bidLogin .login-dig-input-box [name='verify_phone']").val(),
- code:$("#bidLogin .login-dig-input-box [name='verify_code']").val()
- },function(r){
- if(r.status==-1){
- _this.verify.phone.showError('手机号格式错误');
- }else if(r.status==-2){//图形验证码错误
- _this.verify.code.showError('图形验证码输入错误');
- $("#bidLogin .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else if(r.status==-3){//图形验证码错误
- _this.verify.phone.showError('手机号已被注册');
- $("#bidLogin .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else{
- sessionStorage.setItem('login-verify-start-time', new Date().getTime())
- startTimeDown(type)
- }
- });
- break
- }
- case 'register': {
- $.post("/phone/login",{
- reqType:"sendIdentCode",
- register: 'true',
- phone:$(".register-form-box .login-dig-input-box [name='register_phone']").val(),
- code:$(".register-form-box .login-dig-input-box [name='register_code']").val()
- },function(r){
- if(r.status==-1){
- _this.register.phone.showError('手机号格式错误');
- }else if(r.status==-2){//图形验证码错误
- _this.register.code.showError('图形验证码输入错误');
- $(".register-form-box .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else if(r.status==-3){
- _this.register.phone.showError('手机号已被注册');
- $(".register-form-box .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else{
- sessionStorage.setItem('login-verify-start-time', new Date().getTime())
- startTimeDown(type)
- }
- });
- break
- }
- case 'forge': {
- $.post("/phone/forgetPwd",{
- reqType:"sendIdentCode",
- phone:$(".forgetpwd_page .login-dig-input-box [name='forge_phone']").val(),
- code:$(".forgetpwd_page .login-dig-input-box [name='forge_code']").val()
- },function(r){
- if(r.status=="phoneError"){
- _this.forge.phone.showError('手机号格式错误');
- }else if(r.status=="codeError"){
- _this.forge.code.showError('图形验证码输入错误');
- $(".forgetpwd_page .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else if(r.status=="phoneNotExists"){
- _this.forge.phone.showError('手机号尚未注册');
- $(".forgetpwd_page .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
- }else if(r.status=="y"){
- sessionStorage.setItem('login-verify-start-time', new Date().getTime())
- startTimeDown(type)
- }
- });
- break
- }
- case 'bind-phone': {
- $.post("/jypay/user/phone/bind",{
- step: 1,
- phone:$("#bidLogin .login-dig-input-box [name='verify_phone']").val(),
- code:$("#bidLogin .login-dig-input-box [name='verify_code']").val()
- },function(r){
- if (r && r.error_code > -1) {
- sessionStorage.setItem('login-verify-start-time', new Date().getTime())
- startTimeDown(type)
- } else {
- if (r.error_msg === '图形验证码错误') {
- if (_this.verify.code.value !== "HIDE") {
- _this.verify.code.showError(r.error_msg || '发送错误,请稍后再试');
- }
- getNewVerify()
- } else if (r.error_msg === '手机号已被使用') {
- _this.verify.phone.showError('该手机号已被绑定,请更换手机号');
- } else {
- _this.verify.sms.showError(r.error_msg || '发送错误,请稍后再试');
- }
- }
- });
- break
- }
- }
- },
- // 忘记密码
- ajaxStepOne: function (e, arr) {
- $.post("/phone/forgetPwd",{reqType:"nextStep",identCode:arr[2].value},function(r){
- e.setAttribute('data-loading', 'false');
- if(r.status=="identCodeError"){
- arr[2].showError('短信验证码错误');
- }else if(r.status=="y"){
- toggleStep(false);
- }
- });
- },
- ajaxStepTwo: function (e, arr) {
- $.post("/phone/forgetPwd",{reqType:"save",password:arr[1].value},function(r){
- e.setAttribute('data-loading', 'false');
- if(r.status=="passwordError"){
- arr[0].showError('密码格式错误');
- }else if(r.status=="passwordRepeat"){
- arr[0].showError('新密码不能与之前设置过的密码重复');
- }else{
- var toast = document.querySelector('.login-dig-success-toast')
- toast.classList.add('is-show')
- setTimeout(function () {
- toast.classList.remove('is-show')
- if(sessionStorage){
- sessionStorage.reLogin=1;
- }
- window.history.back();
- }, 1500);
- }
- });
- },
- // 验证码/密码登录
- ajaxLoginPass: function (e, arr) {
- $.post("/phone/login",{reqType:"phoneLogin",phone:arr[0].value,password: arr[1].value},function(r){
- e.setAttribute('data-loading', 'false')
- if(r.status==1){
- logic(r.userInfo,mynum);
- }else if(r.status==-1){
- arr[0].showError('该手机号未注册')
- }else if(r.status==-2){
- arr[1].showError('密码输入错误')
- }
- });
- },
- ajaxLoginSms: function (e, arr) {
- if ($('#bidLogin').attr('data-name') === 'bind-phone') {
- $.post("/jypay/user/phone/bind",{
- step: 2,
- phone: arr[0].value,
- code: arr[2].value,
- mode: isBindPage ? 'mergeBind' : ''
- },function(r){
- e.setAttribute('data-loading', 'false')
- if (r && r.error_code > -1) {
- if(r.data.state==1){
- if (isBindPage) {
- if (history.length === 1) {
- goBackOrigin()
- } else {
- if (document.referrer === location.href) {
- goBackOrigin(function () {
- location.href = '/'
- })
- } else {
- history.back()
- }
- }
- return
- }
- if (r.data.needMerge) {
- location.href = '/swordfish/frontPage/userMerge/sess/merge?token=' + r.data.mergeToken
- return
- } else {
- $("#bidLogin").modal("hide")
- sessionStorage.setItem('bind-phone', arr[0].value.trim())
- typeof window.callBindPhoneSuccess === 'function' && window.callBindPhoneSuccess(true)
- }
- } else if (r.data.state==2){
- location.replace('/swordfish/frontPage/userMerge/sess/merge?token=' + r.data.token)
- }
- } else {
- arr[2].showError(r.error_msg || '绑定错误,请稍后再试')
- }
- });
- } else {
- var source = getParam("source");//百度SEM
- if (source!=null){
- var pathname = window.location.pathname;
- if (pathname=="/front/structed/pc_index.html"){//结构化数据
- source+="_structed";
- }else if (pathname=="/bid/pc/page/bidfile_landpage"){//招标文件解读
- source+="_bidfile";
- }else if (pathname=="/big/page/index"){//大会员
- source+="_member";
- }
- }else{
- source="";
- }
- $.post("/phone/login",{reqType:"identCodeLogin",identCode:arr[2].value,"source":source},function(r){
- e.setAttribute('data-loading', 'false')
- if(r.status==1){
- logic(r.userInfo,mynum);
- }else if(r.status==-1){
- arr[2].showError('短信验证码输入错误')
- }
- });
- }
- },
- ajaxRegister: function (e, arr) {
- var source = getParam("source");//百度SEM
- if (source!=null){
- var pathname = window.location.pathname;
- if (pathname=="/front/structed/pc_index.html"){//结构化数据
- source+="_structed";
- }else if (pathname=="/bid/pc/page/bidfile_landpage"){//招标文件解读
- source+="_bidfile";
- }else if (pathname=="/big/page/index"){//大会员
- source+="_member";
- }
- }else{
- source="";
- }
- $.post("/phone/login",{reqType:"identCodeLogin",s_entname: arr[3].value, identCode:arr[2].value,"source":source},function(r){
- e.setAttribute('data-loading', 'false')
- if(r.status==1){
- logic(r.userInfo,mynum);
- var toast = document.querySelector('.login-dig-success-toast')
- toast.classList.add('is-show')
- setTimeout(function () {
- toast.classList.remove('is-show')
- window.history.back();
- }, 1500);
- }else if(r.status==-1){
- arr[2].showError('短信验证码输入错误')
- }
- });
- }
- }
- // @手机号绑定以及账号合并 2021/1/25
- function toggleNeedVerifyInput (f, src) {
- var verifyInput = $(".login-dig-tabbar-content.is-active .login-dig-input-box:eq(1)")
- if (($('#bidLogin').attr('data-name') === 'bind-phone')) {
- if (f) {
- if (verifyInput.find('input').val() === 'HIDE') {
- verifyInput.find('input').val('')
- Direct.verify.code.showError()
- }
- verifyInput.find('.verify-img').attr('src', src)
- verifyInput.show()
- } else {
- verifyInput.find('input').val('HIDE')
- Direct.verify.code.skip('HIDE')
- verifyInput.hide()
- }
- }
- }
- var oldNeedStatus = false
- window.getBindVerify = getNewVerify
- function getNewVerify (cb) {
- if (!oldNeedStatus) {
- toggleNeedVerifyInput(false)
- }
- $.ajax({
- url: '/jypay/user/phone/imgCaptcha?t=' + new Date().getTime(),
- success: function (r) {
- console.log(r)
- if (r && r.data) {
- oldNeedStatus = r.data.needVerify
- if (r.data.needVerify) {
- toggleNeedVerifyInput(true, 'data:image/png;base64,' + r.data.imageData)
- typeof cb === 'function' ? cb('data:image/png;base64,' + r.data.imageData) : null
- } else {
- toggleNeedVerifyInput(false)
- }
- }
- }
- })
- }
- // 初始化弹窗
- try{
- initDirect()
- }catch(e){}
- // 初始化忘记密码
- initForgetDirect()
- initRegisterDirect()
- if(sessionStorage&&sessionStorage.reLogin==1){
- sessionStorage.removeItem("reLogin");
- $(".login-dig-tabbar-navbar>[name='pass']").click();
- openLoginDig();
- }
- $("#bidLogin").on("show.bs.modal", function () {
- if ($('#bidLogin').attr('data-name') === 'bind-phone') {
- getNewVerify()
- } else {
- var verify_path = "/front/landpage/captcha?v="
- $("#bidLogin .verify-img").attr("src", verify_path + new Date().getTime());
- }
- });
- $("#bidLogin").on("hidden.bs.modal", function () {
- $(".public-nav").css({"padding-right":""});
- if($("#bidLogin").attr("data-rec")){
- $("#bidLogin").removeAttr("data-rec");
- }
- });
- function startTimeDown (type) {
- var nowCount = 60
- if (sessionStorage.getItem('login-verify-start-time')) {
- var cCount = parseInt((new Date().getTime() - sessionStorage.getItem('login-verify-start-time')) / 1000)
- if (cCount >= 0 & cCount <= 60) {
- nowCount -= cCount
- } else {
- sessionStorage.removeItem('login-verify-start-time')
- return
- }
- } else {
- return
- }
- var nowQ = 'span[data-name="verify_get_sms"]'
- var otherQ = 'span[data-name="forge_get_sms"]'
- if (type === 'forge') {
- var tempQ = nowQ
- nowQ = otherQ
- otherQ = tempQ
- }
- if (type === 'register') {
- nowQ = 'span[data-name="register_get_sms"]'
- otherQ = 'span[data-name="verify_get_sms"]'
- }
- var Ele = document.querySelector(nowQ)
- var otherEle = document.querySelector(otherQ)
- var defalutIT = '重新获取('+ --nowCount +'s)'
- if (Ele) Ele.innerText = defalutIT
- if (otherEle) otherEle.innerText = defalutIT
- var nowSS = window.setInterval(function () {
- if (nowCount === 1 || !sessionStorage.getItem('login-verify-start-time')) {
- clearInterval(nowSS)
- if (Ele) Ele.innerText = '获取验证码'
- if (Ele) Ele.classList.remove('is-stop')
- if (otherEle) otherEle.innerText = '获取验证码'
- sessionStorage.removeItem('login-verify-start-time')
- return
- }
- var iT = '重新获取('+ --nowCount +'s)'
- if (Ele) Ele.classList.add('is-stop')
- if (Ele) Ele.innerText = iT
- if (otherEle) otherEle.classList.add('is-stop')
- if (otherEle) otherEle.innerText = iT
- }, 1000)
- }
- function getSMSCode (e) {
- if (e.classList.contains('is-stop')) return
- var verifyStartTime = new Date().getTime()
- var oldTime = sessionStorage.getItem('login-verify-start-time') || verifyStartTime - 70000
- if (verifyStartTime - oldTime >= 60000) {
- var nowQ = e.getAttribute('data-name') === 'forge_get_sms' ? 'forge' : 'verify'
- if ($("#bidLogin").attr('data-name') === 'bind-phone') {
- nowQ = 'bind-phone'
- // getNewVerify()
- }
- if (e.getAttribute('data-name') === 'register_get_sms') {
- nowQ = 'register'
- }
- Direct.ajaxSms(e, nowQ)
- }
- }
- // 表单规则
- function ruleForPhone (data, type) {
- var checkStatus = /^[1][3-9][0-9]{9}$/.test(data.value)
- if (type === 'input') {
- return data.value.length >= 11 ? checkStatus : true
- }
- if (type === 'blur') {
- return data.value.length ? checkStatus : true
- }
- return checkStatus
- }
- function ruleForCode (data, type) {
- var checkStatus = /^\S{4}$/.test(data.value)
- if (type === 'blur') {
- return data.value.length ? checkStatus : true
- }
- if (type === 'input') {
- return data.value.length == 4 ? checkStatus : true
- }
- return checkStatus
- }
- function ruleForSms (data, type) {
- var checkStatus = /^\S{6}$/.test(data.value)
- if (type === 'blur') {
- return data.value.length ? checkStatus : true
- }
- if (type === 'input') {
- return data.value.length == 6 ? checkStatus : true
- }
- return checkStatus
- }
- function ruleForPass (data, type) {
- var checkStatus = /^\S{6,}$/.test(data.value)
- if (type === 'blur') {
- return data.value.length ? checkStatus : true
- }
- if (type === 'input') {
- return data.value.length >= 6 ? checkStatus : true
- }
- return checkStatus
- }
- function createFormStauts (formOption) {
- var nowEle = document.querySelector(formOption.el)
- var errClass = 'is-error'
- // 实时状态
- var nowData = {
- status: null,
- next: formOption.next || false,
- value: null,
- el: nowEle,
- skip: function (value) {
- this.status = true
- this.next = true
- this.value = value
- formOption.upStatus()
- },
- showError: function (error) {
- this.status = false
- this.next = false
- formOption.upStatus()
- if (error) {
- this.el.parentNode.setAttribute('data-error', error)
- this.el.parentNode.classList.add(errClass)
- }
- }
- }
- // 错误提示
- if (formOption.errorTip && formOption.errorTip !== '') {
- nowEle.parentNode.setAttribute('data-error', formOption.errorTip)
- }
- // 校验规则
- if (typeof formOption.rule !== "function") {
- formOption.rule = function (data) {
- return true
- }
- }
- // 状态变动通知回调
- if (typeof formOption.upStatus !== "function") {
- formOption.upStatus = function (data) {
- return true
- }
- }
- // 监听事件
- var events = formOption.event;
- for(var i=0;i<events.length;i++){
- if (nowEle) nowEle.addEventListener(events[i],function (e) {
- // input
- var nowTarget = e.target
- var errorTarget = nowTarget.parentNode
- // 移除错误提示
- errorTarget.classList.remove(errClass)
- // 更新状态
- nowData.value = nowTarget.value
- nowData.status = formOption.rule(nowData, e.type)
- nowData.next = formOption.rule(nowData, 'next')
- formOption.upStatus()
- // 更新错误提示
- if (nowData.status) {
- errorTarget.classList.remove(errClass)
- } else {
- errorTarget.classList.add(errClass)
- }
- })
- }
- /*formOption.event.forEach(function(v){
- if (nowEle) nowEle.addEventListener(v,function (e) {
- // input
- var nowTarget = e.target
- var errorTarget = nowTarget.parentNode
- // 移除错误提示
- errorTarget.classList.remove(errClass)
- // 更新状态
- nowData.value = nowTarget.value
- nowData.status = formOption.rule(nowData, v)
- nowData.next = formOption.rule(nowData, 'next')
- formOption.upStatus()
- // 更新错误提示
- if (nowData.status) {
- errorTarget.classList.remove(errClass)
- } else {
- errorTarget.classList.add(errClass)
- }
- })
- });*/
- return nowData
- }
- // 事件
- function installInputEvent () {
- // verify img event for click
- var s1 = document.querySelectorAll('.login-dig-input-box .verify-img');
- for(var i=0;i<s1.length;i++){
- s1[i].addEventListener('click', function (e) {
- var verify_path = "/front/landpage/captcha?v="
- if ($('#bidLogin').attr('data-name') === 'bind-phone') {
- getNewVerify(function (src) {
- e.target.src = src
- })
- } else {
- e.target.src = verify_path+new Date().getTime();
- }
- })
- }
- var s2 = document.querySelectorAll('.login-dig-input-box .l-get-sms');
- for(var i=0;i<s2.length;i++){
- s2[i].addEventListener('click', function (e) {
- getSMSCode(e.target)
- })
- }
- var s3 = document.querySelectorAll('.login-dig-input-box input');
- for(var i=0;i<s3.length;i++){
- s3[i].addEventListener('focus', function (e) {
- var nowInput = e.target
- nowInput.parentNode.classList.add('is-focus')
- })
- s3[i].addEventListener('blur', function (e) {
- var nowInput = e.target
- nowInput.parentNode.classList.remove('is-focus')
- })
- }
- }
- // E-公用
- // 忘记密码
- function toggleStep (type) {
- var nowArr = ['.forget-form-box[data-step="1"]', '.forget-step-title[data-step="1"]']
- var otherArr = ['.forget-form-box[data-step="2"]', '.forget-step-title[data-step="2"]']
- for(var i=0;i<otherArr.length;i++){
- if (document.querySelector(otherArr[i])) document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
- }
- for(var i=0;i<nowArr.length;i++){
- if (document.querySelector(nowArr[i])) document.querySelector(nowArr[i]).style.display = (type ? '' : 'none')
- }
- }
- // 弹窗登录
- function installAddEventListener () {
- // tabbar toggle event
- document.querySelector('.login-dig-tabbar-navbar').addEventListener('click', function (e) {
- if (e.target.nodeName !== "SPAN") return
- if (e.target.classList.contains('is-active')) {
- return
- }
- var SelectName = e.target.getAttribute('name')
- document.querySelector('.login-dig-tabbar-navbar span.is-active').classList.toggle('is-active')
- e.target.classList.toggle('is-active')
- // content toggle
- document.querySelector('.login-dig-tabbar-content.is-active').classList.toggle('is-active')
- document.querySelector('.login-dig-tabbar-content[data-name="'+ SelectName +'"]').classList.toggle('is-active')
- })
- installInputEvent()
- }
- // 初始化
- function isCheckInit(type) {
- if (type === 'forge') {
- return document.querySelector('button[name="forge_submit_phone"]')
- } else {
- return document.querySelector('button[name="register_submit_phone"]')
- }
- }
- function initDirect () {
- // 初始化事件
- installAddEventListener()
- // 初始化倒计时
- startTimeDown()
- // 验证码登录
- var verifySubmit = {
- el: 'button[name="verify_submit"]',
- arr: [],
- init: function (arr) {
- this.arr = arr
- this.check()
- var submitEle = document.querySelector(this.el)
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- var e = e.target
- if (e.getAttribute('data-loading') === 'true') return
- e.setAttribute('data-loading', 'true')
- Direct.ajaxLoginSms(e, verifySubmit.arr)
- },
- check: function () {
- var submitEle = document.querySelector(this.el)
- var checkStauts = false
- for(var i=0;i<this.arr.length;i++){
- if (!this.arr[i].next) {
- checkStauts = true
- }
- }
- if (checkStauts) {
- submitEle.setAttribute('disabled', checkStauts)
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- var verifySendSms = {
- el: '.login-dig-input-box span[data-name="verify_get_sms"]',
- update: function (type) {
- var Ele = document.querySelector(this.el)
- if (type) {
- Ele.classList.remove('is-stop')
- } else {
- Ele.classList.add('is-stop')
- }
- }
- }
- var verifyPhone = createFormStauts({
- el: '.login-dig-input-box input[name="verify_phone"]',
- rule: ruleForPhone,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifyCode = createFormStauts({
- el: '.login-dig-input-box input[name="verify_code"]',
- rule: ruleForCode,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifySms = createFormStauts({
- el: '.login-dig-input-box input[name="verify_sms"]',
- rule: ruleForSms,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- }
- })
- verifySubmit.init([verifyPhone, verifyCode, verifySms])
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- Direct.verify = {
- phone: verifyPhone,
- code: verifyCode,
- sms: verifySms
- }
- // 密码登录
- var passSubmit = {
- el: 'button[name="pass_submit"]',
- arr: [],
- init: function (arr) {
- this.arr = arr
- this.check()
- var submitEle = document.querySelector(this.el)
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- var e = e.target
- if (e.getAttribute('data-loading') === 'true') return
- e.setAttribute('data-loading', 'true')
- Direct.ajaxLoginPass(e, passSubmit.arr)
- },
- check: function () {
- var submitEle = document.querySelector(this.el)
- var checkStauts = false
- for(var i=0;i<this.arr.length;i++){
- if (!this.arr[i].next) {
- checkStauts = true
- }
- }
- if (checkStauts) {
- submitEle.setAttribute('disabled', checkStauts)
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- var passPhone = createFormStauts({
- el: '.login-dig-input-box input[name="pass_phone"]',
- rule: ruleForPhone,
- event: ['input', 'blur'],
- upStatus: function () {
- passSubmit.check()
- }
- })
- var passPass = createFormStauts({
- el: '.login-dig-input-box input[name="pass_pass"]',
- rule: ruleForPass,
- event: ['input', 'blur'],
- upStatus: function () {
- passSubmit.check()
- }
- })
- passSubmit.init([passPhone, passPass])
- }
- function initForgetDirect () {
- // 判断是否需要初始化
- if (!isCheckInit('forge')) return
- // 初始化显示
- toggleStep(true)
- // 初始化倒计时
- startTimeDown('forge')
- // 手机验证
- var verifySubmit = {
- el: 'button[name="forge_submit_phone"]',
- arr: [],
- init: function(arr) {
- this.arr = arr
- this.check()
- var submitEle = document.querySelector(this.el)
- if (!submitEle) return
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- var e = e.target
- if (e.getAttribute('data-loading') === 'true') return
- e.setAttribute('data-loading', 'true')
- Direct.ajaxStepOne(e, verifySubmit.arr)
- },
- check: function () {
- var submitEle = document.querySelector(this.el)
- if (!submitEle) return
- var checkStauts = false
- for(var i=0;i<this.arr.length;i++){
- if (!this.arr[i].next) {
- checkStauts = true
- }
- }
- if (checkStauts) {
- submitEle.setAttribute('disabled', checkStauts)
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- var verifySendSms = {
- el: '.login-dig-input-box span[data-name="forge_get_sms"]',
- update: function(type) {
- var Ele = document.querySelector(this.el)
- if (type) {
- Ele.classList.remove('is-stop')
- } else {
- Ele.classList.add('is-stop')
- }
- }
- }
- var verifyPhone = createFormStauts({
- el: '.login-dig-input-box input[name="forge_phone"]',
- rule: ruleForPhone,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifyCode = createFormStauts({
- el: '.login-dig-input-box input[name="forge_code"]',
- rule: ruleForCode,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifySms = createFormStauts({
- el: '.login-dig-input-box input[name="forge_sms"]',
- rule: ruleForSms,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- }
- })
- verifySubmit.init([verifyPhone, verifyCode, verifySms])
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- // 密码重置
- var passSubmit = {
- el: 'button[name="forge_submit_pass"]',
- arr: [],
- init: function(arr) {
- this.arr = arr
- this.check()
- var submitEle = document.querySelector(this.el)
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- var e = e.target
- if (e.getAttribute('data-loading') === 'true') return
- e.setAttribute('data-loading', 'true')
- Direct.ajaxStepTwo(e, passSubmit.arr)
- },
- check: function () {
- var submitEle = document.querySelector(this.el)
- var checkStauts = false
- for(var i=0;i<this.arr.length;i++){
- if (!this.arr[i].next) {
- checkStauts = true
- }
- }
- if (checkStauts) {
- submitEle.setAttribute('disabled', checkStauts)
- } else {
- if (this.arr[0].value !== this.arr[1].value) {
- this.arr[1].showError('两次密码输入不一致')
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- }
- var passPhone = createFormStauts({
- el: '.login-dig-input-box input[name="forge_pass_one"]',
- rule: ruleForPass,
- event: ['input', 'blur'],
- upStatus: function () {
- passSubmit.check()
- }
- })
- var passPass = createFormStauts({
- el: '.login-dig-input-box input[name="forge_pass_two"]',
- rule: ruleForPass,
- event: ['input', 'blur'],
- upStatus: function () {
- passSubmit.check()
- }
- })
- passSubmit.init([passPhone, passPass])
- Direct.forge = {
- phone: verifyPhone,
- code: verifyCode
- }
- }
- function initRegisterDirect () {
- // 判断是否需要初始化
- if (!isCheckInit('register')) return
- // 初始化倒计时
- startTimeDown('register')
- // 手机验证
- var verifySubmit = {
- el: 'button[name="register_submit_phone"]',
- arr: [],
- init: function(arr) {
- this.arr = arr
- this.check()
- var submitEle = document.querySelector(this.el)
- if (!submitEle) return
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- var e = e.target
- if (e.getAttribute('data-loading') === 'true') return
- e.setAttribute('data-loading', 'true')
- Direct.ajaxRegister(e, verifySubmit.arr)
- },
- check: function () {
- var submitEle = document.querySelector(this.el)
- if (!submitEle) return
- var checkStauts = false
- for(var i=0;i<this.arr.length;i++){
- if (!this.arr[i].next) {
- checkStauts = true
- }
- }
- if (checkStauts) {
- submitEle.setAttribute('disabled', checkStauts)
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- var verifySendSms = {
- el: '.login-dig-input-box span[data-name="register_get_sms"]',
- update: function(type) {
- var Ele = document.querySelector(this.el)
- if (type) {
- Ele.classList.remove('is-stop')
- } else {
- Ele.classList.add('is-stop')
- }
- }
- }
- var verifyPhone = createFormStauts({
- el: '.login-dig-input-box input[name="register_phone"]',
- rule: ruleForPhone,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifyCode = createFormStauts({
- el: '.login-dig-input-box input[name="register_code"]',
- rule: ruleForCode,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- }
- })
- var verifySms = createFormStauts({
- el: '.login-dig-input-box input[name="register_sms"]',
- rule: ruleForSms,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- }
- })
- var entName = createFormStauts({
- el: '.login-dig-input-box input[name="register_entname"]',
- event: ['input', 'blur'],
- next: true,
- upStatus: function () {
- verifySubmit.check()
- }
- })
- verifySubmit.init([verifyPhone, verifyCode, verifySms, entName])
- verifySendSms.update(verifyCode.next && verifyPhone.next)
- Direct.register = {
- phone: verifyPhone,
- code: verifyCode
- }
- }
- });
- function openLoginDig() {
- $('#bidLogin .logo').show()
- $('#bidLogin .bind-phone-head').hide()
- $(".login-dig-tabbar-content.is-active .login-dig-input-box").show()
- if ($('#bidLogin').attr('data-name') === 'bind-phone') {
- $("#bidLogin").removeAttr('data-name')
- $('.login-dig-submit-button').removeClass('bindphonebtn')
- $('.login-dig-submit-button:disabled').css('background', '#E0E0E0')
- $('.login-dig-submit-button:disabled').css('opacity', '0.5')
- $('.login-dig-submit-button').css('margin-bottom', '0')
- $("#bidLogin .login-dig-submit-button[name='verify_submit']").text('登录 / 注册')
- $(".login-dig-tabbar-content[data-name='code'] .login-dig-input-box").removeClass('is-error').children('input').val('')
- }
- var href = window.location.href;
- var sourceStr =""
- if (href.indexOf("/front/structed/pc_index.html?source=baidusem")>-1){//结构化数据
- sourceStr="结构化数据-pc-baidusem";
- }else if (href.indexOf("/bid/pc/page/bidfile_landpage?source=baidusem")>-1){//招标文件解读
- sourceStr="招标文件解读-pc-baidusem";
- }
- if (sourceStr!=""){
- try {
- _hmt.push(['_trackEvent',sourceStr, 'click', "登录"]);
- } catch (e) {
- console.log('未初始化百度统计', e);
- }
- }
- $("#bidLogin").modal("show");
- }
- function openBindPhoneDig() {
- openLoginDigForWx(false);
- $('#bidLogin .logo').hide()
- $('#bidLogin .bind-phone-head').show()
- if ($('#bidLogin').attr('data-name') !== 'bind-phone') {
- $("#bidLogin").attr('data-name', 'bind-phone')
- // $('.login-dig-submit-button:disabled').css('background', '#2CB7CA')
- // $('.login-dig-submit-button:disabled').css('opacity', '0.5')
- $('.login-dig-submit-button').css('margin-bottom', '12px')
- $('.login-dig-submit-button').addClass('bindphonebtn')
- $("#bidLogin .login-dig-submit-button[name='verify_submit']").text('立即绑定')
- $(".login-dig-tabbar-content[data-name='code'] .login-dig-input-box").removeClass('is-error').children('input').val('')
- }
- $("#bidLogin").modal("show");
- }
- function closeLoginDig() {
- $("#bidLogin").modal("hide");
- }
- function openLoginDigForWx (type) {
- var otherArr = ['.login-dig-box > .logo','.login-dig-footer-box .wx-logo-box', '.login-dig-footer-box .login-dig-text-split' ,'.login-dig-tabbar-navbar', '.login-dig-tabbar-content', '.login-dig-tabbar-content.is-active']
- var wxArr = ['.login-dig-wx-qrcode-box', '.login-dig-top-back-box']
- for(var i=0;i<otherArr.length;i++){
- document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
- }
- for(var i=0;i<wxArr.length;i++){
- document.querySelector(wxArr[i]).style.display = (type ? '' : 'none')
- }
- }
|