123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346 |
- /**统一登录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;//登录状态
- // 使用模版提供是否登录,默认值
- if (window.goTemplateData && window.goTemplateData.params && window.goTemplateData.params.login) {
- loginflag = Boolean(window.goTemplateData.params.login)
- }
- 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 isBindPage = false; // 是否是绑定手机号页面功能
- var _reconnectedConf = {
- count: 0, // ws重连了几次
- max: 10, // ws最大重连次数,重连max次后不再重连
- }
- //轮询查询
- 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 updateUserInfo (data) {
- if (data.update) {
- $.post("/jypay/user/getSimpleData", {}, function(result) {
- if (result && result.userId) {
- var userName = result.name ? (result.name === result.phone ? '' : result.name) : ''
- updateUserInfo({
- update: false,
- name: userName,
- phone: result.phone,
- avatar: result.headImage || ''
- })
- }
- })
- }
- $('#public-nav *[data-user-name]').text(data.name || '')
- $('#public-nav *[data-user-phone]').text(data.phone || '')
- $('#public-nav img[data-user-avatar]').attr('src', data.avatar || '/common-module/public/image/auto.png')
- $('#public-nav img[data-user-avatar]').on('error', function () {
- if ($(this).attr('src').indexOf('/common-module/public/image/auto.png') === -1) {
- $(this).attr('src', '/common-module/public/image/auto.png')
- }
- })
- }
- // 切换登录/未登录展示元素
- function toggleLoginDom (type) {
- if (type) {
- $("#login .loginBtn").hide()
- $("#public-nav .nav-avatar").show()
- $("#public-nav .work-link").show()
- $("#public-nav .fl").addClass('fix-work')
- // 客服入口显示
- $('#go-customer-4').show()
- } else {
- $("#public-nav .nav-avatar").hide()
- $("#public-nav .work-link").hide()
- $("#public-nav .fl").removeClass('fix-work')
- $("#login .loginBtn").show()
- // 客服入口隐藏
- $('#go-customer-4').hide()
- }
- }
- //
- function reconnect() {
- if(webSocketHeartCheck.lockReconnect || loginflag){
- return;
- }
- // 达到最大重连次数后,不再重连
- if (_reconnectedConf.count >= _reconnectedConf.max) {
- console.log('ws重连达到最大次数,不再重连')
- return
- }
- LoginPolling.isPostLoginPolling = true;
- webSocketHeartCheck.lockReconnect = true;
- LoginPolling.init();
- //没连接上会一直重连,设置延迟避免请求过多
- setTimeout(function () {
- _reconnectedConf.count++;
- console.log('ws第' + _reconnectedConf.count + '次重连')
- 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"://订阅页面
- $("#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);
- }
- })
- }
- // (必要!)优先获取用户权限,不管用户有没有登陆,以便在页面中更早的拿到权限
- ajaxGetUserPower()
- function ajaxGetUserPower (conf) {
- conf = conf || {}
- var success = conf.success
- var complete = conf.complete
- $.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.customers = res.data.customers
- window.vipStatus = res.data.vipStatus // 是否是超级订阅用户
- window.isFree = res.data.isFree // 是否是免费用户
- window.freeFile = res.data.freeFile // 免费用户 是否体验过 0:未体验过 -1:体验过
- window.viper = res.data.viper // 是否是超级订阅老用户 false:老用户 true: 新用户
- window.entniche = res.data.entniche // 商机管理用户
- window.fileNum = res.data.fileNum // 超级订阅用户可下载附件次数
- window.isLogin = true // 用于其他页面判断是否已登录
- window.isNewEntNiche = res.data.entIsNew
- window.isEntService = res.data.isEntService
- sessionStorage.setItem('bidPower', JSON.stringify(res.data.power))
- success && success(res)
- }
- },
- complete: function () {
- complete && complete()
- }
- })
- }
- function checkBigStatus () {
- ajaxGetUserPower({
- success: function (res) {
- try {
- setUserFree()
- } catch (error) {}
- if (res.data.memberStatus > 0) {
- $(".myorderDiv.lastBox").show()
- }
- if (res.data.viper) {
- $(".myorderDiv.ent-search").show()
- }
- if(res.data.power && res.data.power.length) {
- if (res.data.power.indexOf(4) == -1 && res.data.vipStatus>0&&res.data.viper) {
- $(".myorderDiv.entPortraitRecord").show()
- }
- if (res.data.power.indexOf(5) == -1 && res.data.vipStatus>0&&res.data.viper) {
- $(".myorderDiv.buyerPortraitRecord").show()
- }
- }
- if (res.data.memberStatus<=0&&res.data.vipStatus>0&&res.data.viper){
- $(".myorderDiv.portraitRecord").show()
- }
- if (res.data.memberStatus > 0 && res.data.vipStatus > 0 && res.data.viper && res.data.power.indexOf(3) === -1) {
- $('.fileRecord').show()
- }
- if (res.data.memberStatus <= 0 && res.data.vipStatus > 0 && res.data.viper) {
- $('.fileRecord').show()
- }
- if ($.isArray(res.data.power)) {
- // 大会员没有附加下载包权限用户且新版超级订阅用户
- if (res.data.memberStatus > 0 && res.data.vipStatus > 0 && res.data.viper && res.data.power.indexOf(3) === -1) {
- $('.fileRecord').show()
- }
- }
- },
- complete: function () {
- try {
- getPowerComplete && getPowerComplete()
- } catch (error) {}
- }
- })
- }
- // 查询商机管理PC权限
- function checkMenuForEnt () {
- $.ajax({
- type: 'get',
- url: '/entbase/ent/mySelectent?t=' + new Date().getTime(),
- success: function (er) {
- $.ajax({
- type: 'get',
- url: '/front/entExportAuth/getAuth?t=' + new Date().getTime(),
- success: function (r) {
- $(".myorderDiv[data-ent-menu]").remove()
- var tempHtml = ''
- if(er.data!=null && er.data.status==1){
- tempHtml += "<div data-ent-menu class=\"myorderDiv\" onclick=\"window.location.href='/orgpc/myent'\">"
- +"<span>我的企业</span>"
- +"</div>"
- }
- if(r.entnicheMenu == true){
- if (r.isNew == true) {
- tempHtml+= "<div data-ent-menu class=\"myorderDiv\" id=\"entDiv\">"
- +"<span>商机管理</span>"
- +"</div>"
- } else {
- tempHtml+= "<div data-ent-menu id=\"entDiv\" class=\"myorderDiv\">"
- +"<span>商机管理</span>"
- +"</div>"
- }
- }
- if(r.privatedata){
- tempHtml+= "<div data-ent-menu class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/page_big_pc/free/custom_search'\">"
- +"<span>画像分析系统</span>"
- +"</div>"
- }
- $(".infoList .lastBox").before(tempHtml)
- $('#entDiv').click(function () {
- $.ajax({
- type:'POST',
- url:'/entnicheNew/buy/whetherbuy',
- success:function () {
- if(r.entnicheMenu == true){
- if (r.isNew == true) {
- window.location.href='/entpc/newBus'
- } else {
- window.location.href='/entpc/bus'
- }
- }
- }
- })
- })
- }
- })
- }
- })
- }
- var msgTimer = null
- function toReaded(ids, type, url) {
- var _this = this
- $.ajax({
- type: 'POST',
- url:'/jymessageCenter/markRead',
- data: {
- msgId: ids,
- msgType: type
- },
- success:function () {
- if (url) {
- location.href = url
- } else {
- return
- }
- }
- })
- }
- /**
- * @date 2023/1/4 消息通知改为 webscoket 获取并调用浏览器消息通知
- */
- // 查看是否有新消息
- function checkCounts() {
- try {
- // 非工作台模式下需要重建链接,工作台嵌入页面不需要额外初始化
- if (!goTemplateData.inIframe) {
- getMsgBuoyActive.listenNotification()
- }
- } catch (e) {}
- }
- //查询用户信息,响应页面登录信息
- var logic = function(data,num){
- if(data.result=="ok"){
- //判断是否需要设置cookie
- if(data.cValue){
- afterLoginSetCookit(data.cName,data.cValue,data.expires)
- }
- clearInterval(loginfg);
- // loginflag置为true后在调用回调
- loginflag = true;
- // TODO login callback
- try {
- // header专用回调。
- loginCallbackHeader(data)
- } catch (e) {}
- try {
- // 页面专用回调
- loginCallback(data)
- } catch (e) {}
- clearLoginStorage(/-login-clear/)
- //$(".QRLogin").hide();
- $("#bidLogin").modal("hide")
- $("#bidcommunity").modal("hide")
- if(!data.phone && data.openid) {
- window.location.href = '/swordfish/frontPage/userMerge/sess/bind'
- }
- processpage(data,num);
- //登录成功,停止轮询
- LoginPolling.stop();
- //登录成功,停止心跳监测
- webSocketHeartCheck.reset();
- if(ws && 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 + "...";
- }
- toggleLoginDom(true)
- updateUserInfo({
- update: true,
- name: data.s_nickname || '',
- phone: '',
- avatar: data.s_headimage || ''
- })
- var skipInit = location.href.indexOf('/notin/page') !== -1
- if (!skipInit && typeof window.GuideIntroDialog === 'function') {
- window.guideIntroDialog = new GuideIntroDialog()
- }
- try{
- checkBigStatus()
- infoListCss();
- message.init()
- checkCounts()
- if (typeof window.initIndexMsgList === 'function') {
- initIndexMsgList()
- }
- } catch (e) {
- console.warn(e)
- }
- }
- }
- //登录后处理页面逻辑
- var processpage = function(item,num){
- var backToUrl = getParam('backTo')
- if (backToUrl) {
- return location.replace(decodeURIComponent(backToUrl))
- }
- 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;
- }
- // 未登录标签页注册后重定向首页
- if (location.href.indexOf('/tags/') > -1) {
- window.location.replace('/')
- } else if (location.href.indexOf('/nologin/content') > -1 || location.href.indexOf('/demand/detail') > -1) {
- // 未登录三级页注册后刷新(后端重定向到登陆后的三级页)
- // /demand/detail 供应搜索三级页登录后刷新
- window.location.reload()
- }
- 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
- }
- }
- /**
- * 检查是否需要前往新用户兴趣设置
- * @returns {boolean}
- */
- function checkNeedGoNewUserSettingPage () {
- // 同步请求判断是否新用户,需要跳转兴趣设置页面
- // 首页不走这个逻辑打开。首页登录后会刷新数据,会走首页重定向。
- // if (location.pathname === '/') return
- var goPage
- $.ajax({
- type: 'post',
- async: false,
- url: '/salesLeads/appIsNewUerSales',
- success: function (res) {
- if (res && res.data) {
- goPage = '/swordfish/frontPage/user/sess/set_favorite'
- }
- }
- })
- if (goPage) {
- window.open(goPage)
- return true
- }
- return false
- }
- 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 removeLocalStorage = function(){
- // 移除userId (大会员中标预测历史记录用到)
- localStorage.removeItem('BIGMEMBER_PC')
- }
- //退出登录
- var signout = function(){
- clearInterval(loginfg);
- loginflag = false;
- unseatflag = false;
- unseatzbqyflag = false;
- toggleLoginDom(false)
- 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"){
- $('#noticed').hide()
- clearLoginStorage(/-login-clear/)
- afterSignoutClearCookit();
- // window.location.href="/";
- var pt = new RegExp("^/article/content/.+$|^/front/dataExport/.+$|^/front/common(Footer|Header)|^/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);*/
- }
- window.localStorage.removeItem('bus-key-group-SCOPE')
- window.localStorage.removeItem('noMesg')
- clearInterval(msgTimer)
- // 移除浏览器缓存
- removeLocalStorage()
- }
- })
- }
- var afterSignoutClearCookit = function(){
- try{
- $.cookie("userid_secure","",{expires:-1,path:"/",domain:document.domain.replace(/[^.]+/,"")});
- $.cookie("klcn_value","",{expires:-1,path:"/",domain:document.domain.replace(/[^.]+/,"")});
- }catch(e){
- document.cookie = "userid_secure=;expires=-1;path=/";
- document.cookie = "klcn_value=;expires=-1;path=/";
- }
- }
- var afterLoginSetCookit = function(name,value,time){
- var expires = new Date(time)
- try{
- $.cookie(name,value,{expires:expires.toGMTString(),path:"/",domain:document.domain.replace(/[^.]+/,"")});
- }catch(e){
- document.cookie = name+"="+value+";expires="+expires.toGMTString()+";path=/;domain="+document.domain.replace(/[^.]+/,"");
- }
- }
- //查看用户是否已经登录
- var haslogin = function(num,kyorpn,url){
- mynum = num;//页面logid
- keysorpname = kyorpn;//其他参数
- thurl = url;//列表也跳转快照页url
- $.ajax({
- url: '/front/hasSign',
- method: 'post',
- success: function (data) {
- if(data){
- if(data.resetpwd){
- afterSignoutClearCookit();
- window.location.href = "/?nol=2";
- return;
- }
- // loginflag置为true后在调用回调
- loginflag = true;
- // TODO login callback
- try {
- // header专用回调。
- loginCallbackHeader(data)
- } catch (e) {}
- try {
- // 页面专用回调
- loginCallback(data)
- } catch (e) {}
- 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 + "...";
- }
- toggleLoginDom(true)
- updateUserInfo({
- update: true,
- name: data.s_nickname || '',
- phone: '',
- avatar: data.s_headimage || ''
- })
- try{
- checkBigStatus()
- infoListCss();
- message.init()
- checkCounts()
- if (typeof window.initIndexMsgList === 'function') {
- initIndexMsgList()
- }
- } catch (e) {
- console.warn(e)
- }
- } else{
- toggleLoginDom(false)
- loginBtnType();
- //pc限制登陆
- var nosess = getParam("nol");
- if (nosess && (!loginflag)){
- openLoginDig();
- }
- window.localStorage.setItem('noMesg', 0)
- }
- getNewShareId(num,true);
- },
- complete: function () {
- // TODO login callback
- try {
- checkLoginCallback()
- } catch (e) {}
- }
- })
- }
- 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部分匿名函数自执行,防止泄露全局变量
- window.__wait_listen_modal__ = false
- $(function(){
- function goBackOrigin (cb) {
- var backOrigin = $.cookie('article')
- if (backOrigin) {
- location.replace(backOrigin)
- } else {
- typeof cb === 'function' ? cb() : window.close()
- }
- }
- var Direct = {
- verify: {},
- forge: {},
- loginInfo: {},
- instance: {},
- 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(),
- // isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
- 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(),
- // isAutoLogin: $('.sms-login .auto-login-checkbox').hasClass('checked'),
- 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);
- }
- });
- },
- // 设置密码
- ajaxSetPassword: function (e, arr) {
- var payload = {
- password: arr[0].value
- };
- $.ajax({
- url: "/publicapply/password/update",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(payload),
- success: function(r) {
- e.setAttribute('data-loading', 'false');
- if (r) {
- // 密码保存成功,走登录成功步骤
- logic(Direct.loginInfo.userInfo, mynum);
- } else {
- arr[1].showError('密码保存失败');
- }
- }
- });
- },
- // 手机号+密码登录
- ajaxLoginPass: function (e, arr) {
- var payload = {
- reqType:"phoneLogin",
- isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
- phone:arr[0].value,
- password: arr[1].value
- }
- $.post("/phone/login",payload,function(r){
- e.setAttribute('data-loading', 'false')
- switch (r.status) {
- case -1: {
- arr[0].showError('手机号或账号名输入错误')
- break
- }
- case 1: {
- logic(r.userInfo,mynum);
- break
- }
- case -2: {
- arr[1].showError('密码输入错误')
- break
- }
- }
- });
- },
- 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){
- var backToUrl = getParam('backTo')
- if (backToUrl) {
- return location.replace(decodeURIComponent(backToUrl))
- }
- if (isBindPage) {
- if (history.length === 1) {
- goBackOrigin()
- } else {
- if (document.referrer === location.href) {
- goBackOrigin(function () {
- location.href = '/'
- })
- } else {
- checkNeedGoNewUserSettingPage()
- history.back()
- }
- }
- return
- }
- if (r.data.needMerge) {
- location.href = '/swordfish/frontPage/userMerge/sess/merge?token=' + r.data.mergeToken
- return
- } else {
- checkNeedGoNewUserSettingPage()
- $("#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="";
- }
- var payload = {
- reqType:"identCodeLogin",
- identCode:arr[2].value,
- isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
- source:source
- }
- // 短信验证码登录
- $.post("/phone/login",payload,function(r){
- e.setAttribute('data-loading', 'false')
- if(r.status==1){
- if (r.userInfo.isNewUser) {
- trackClick('注册行为-打开设置密码弹窗')
- Direct.showSetPassModule(true)
- Direct.loginInfo = r
- } else {
- logic(r.userInfo,mynum);
- }
- }else if(r.status==-1){
- arr[2].showError('短信验证码输入错误')
- }else if(r.status==-4){
- arr[2].showError('系统错误,请重试')
- }
- });
- }
- },
- // 新用户设置密码
- showSetPassModule: function (type) {
- var otherArr = ['.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', '.pass-bottom', '.login-dig-wx-qrcode-box', '.login-dig-top-back-box', '.code-bottom', '.login-common-title', '.login-auto-card']
- var setPassArr = ['.login-dig-tabbar-content.set-password', '.login-dig-tabbar-navbar.set-pass-module', '.set-pass-bottom', '.set-pass-title']
- 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<setPassArr.length;i++){
- if (document.querySelector(setPassArr[i])) {
- document.querySelector(setPassArr[i]).style.display = (type ? 'block' : 'none')
- }
- }
- },
- 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="";
- }
- var payload = {
- reqType:"identCodeLogin",
- s_entname: arr[3].value,
- identCode:arr[2].value,
- source:source,
- isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
- email: arr[4].value
- }
- // 短信验证码登录
- $.post("/phone/login",payload,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('短信验证码输入错误')
- }
- });
- }
- }
- // Direct.showSetPassModule(true) // 模拟显示 设置密码弹框
- // openLoginDigForReg() // 模拟显示注册弹框
- // openBindPhoneDig() // 模拟显示绑定手机号弹框
- // @手机号绑定以及账号合并 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();
- }
- window.__wait_listen_modal__ = true
- $("#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 () {
- window.needToWork = false
- $(".public-nav").css({"padding-right":""});
- if($("#bidLogin").attr("data-rec")){
- $("#bidLogin").removeAttr("data-rec");
- }
- if(Direct.loginInfo.userInfo && Direct.loginInfo.userInfo.result === 'ok') {
- location.reload()
- }
- });
- 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') === 'verify_get_sms' && !isBindPage) {
- nowQ = 'verify'
- trackClick('注册行为-验证码登录/注册-获取验证码')
- }
- if(isBindPage) {
- trackClick('绑定-发送验证码')
- }
- Direct.ajaxSms(e, nowQ)
- }
- }
- // 表单规则
- function ruleForPhoneOrName (data, type) {
- return true
- }
- function ruleForPhone (data, type) {
- var phoneReg = /^[1][3-9][0-9]{9}$/.test(data.value);
- var createPhoneReg =/^[1][0][0][0-9]{8}$/.test(data.value);
- var checkStatus = phoneReg || createPhoneReg;
- 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 ruleForEnt (data, type) {
- var checkStatus = /^\S{4,100}$/.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)
- showToast(error)
- }
- }
- }
- // 错误提示
- if (formOption.errorTip && formOption.errorTip !== '') {
- nowEle.parentNode.setAttribute('data-error', formOption.errorTip)
- showToast(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)
- var errorMsg = errorTarget.getAttribute('data-error')
- showToast(errorMsg, 4000)
- }
- })
- }
- /*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
- }
- if(e.target.innerText === '密码登录') {
- // $('.code-bottom').hide()
- $('.pass-bottom').show()
- $('.line-box').addClass('pass-line-box')
- } else {
- $('.pass-bottom').hide()
- // $('.code-bottom').show()
- $('.line-box').removeClass('pass-line-box')
- }
- 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')
- if (SelectName === 'pass' && Direct.instance.password) {
- $('.login-dig-footer-box p').addClass('passTip')
- var myEvent = new Event('blur')
- Direct.instance.password.arr[0].el.dispatchEvent(myEvent)
- Direct.instance.password.arr[1].el.dispatchEvent(myEvent)
- } else {
- $('.login-dig-footer-box p').removeClass('passTip')
- }
- })
- 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')
- if(isBindPage){
- trackClick('绑定-立即绑定')
- } else {
- trackClick('注册行为-登录/注册')
- }
- 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 {
- if(isBindPage) {
- 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: ruleForPhoneOrName,
- 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])
- Direct.instance.password = passSubmit
- // 设置密码
- var setPassSubmit = {
- el: 'button[name="set_pass_submit"]',
- 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
- trackClick('注册行为-设置密码-确定')
- Direct.ajaxSetPassword(e, setPassSubmit.arr)
- // 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 {
- if (this.arr[0].value !== this.arr[1].value) {
- this.arr[1].showError('两次密码输入不一致')
- } else {
- submitEle.removeAttribute('disabled')
- }
- }
- }
- }
- // 暂不设置密码,走登录成功步骤
- var setPassCancel = {
- el: 'button[name="set_pass_cancel"]',
- init: function () {
- var submitEle = document.querySelector(this.el)
- submitEle.addEventListener('click', this.submit)
- },
- submit: function (e) {
- trackClick('注册行为-设置密码-暂不订阅')
- logic(Direct.loginInfo.userInfo,mynum);
- },
- }
- var setInitPass = createFormStauts({
- el: '.login-dig-input-box input[name="init_pass"]',
- rule: ruleForPass,
- event: ['input', 'blur'],
- upStatus: function () {
- setPassSubmit.check()
- }
- })
- var setCheckPass = createFormStauts({
- el: '.login-dig-input-box input[name="check_pass"]',
- rule: ruleForPass,
- event: ['input', 'blur'],
- upStatus: function () {
- setPassSubmit.check()
- }
- })
- setPassSubmit.init([setInitPass, setCheckPass])
- setPassCancel.init()
- }
- 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')
- trackClick('注册行为-立即注册')
- 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 && verifyEnt.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 verifyEnt = createFormStauts({
- el: '.login-dig-input-box input[name="verify_entname"]',
- rule: ruleForEnt,
- event: ['input', 'blur'],
- upStatus: function () {
- verifySubmit.check()
- verifySendSms.update()
- }
- })
- var verifyEmail = createFormStauts({
- el: '.login-dig-input-box .register_email',
- event: ['input', 'blur'],
- next: true,
- upStatus: function () {
- verifySubmit.check()
- }
- })
- verifySubmit.init([verifyPhone, verifyCode, verifySms, verifyEnt, verifyEmail])
- verifySendSms.update(verifyCode.next && verifyPhone.next && verifyEnt.next)
- Direct.register = {
- phone: verifyPhone,
- code: verifyCode
- }
- }
- });
- // 注册埋点
- function trackClick (c_type) {
- if (!c_type) return
- try {
- clab_tracker.track('c_register', {
- c_platform: 'pc',
- c_type: c_type,
- date: new Date()
- })
- } catch (error) {
- console.dir(error)
- }
- }
- // type: true登录后直接跳转工作桌面
- function openLoginDig(type, redirectUrl,Logincallback) {
- $('#bidLogin .logo').hide()
- $('#bidLogin .bind-phone-head').hide()
- $(".login-dig-tabbar-content.is-active .login-dig-input-box").show()
- $('.login-auto-card').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);
- }
- }
- if (!window.__wait_listen_modal__) {
- var verify_path = "/front/landpage/captcha?v="
- $("#bidLogin .verify-img").attr("src", verify_path + new Date().getTime());
- }
- $("#bidLogin").modal("show");
- try {
- var injectLogic = logic
- var link = [
- '/jylab/supsearch/index.html',
- '/jylab/entSearch/index.html',
- '/jylab/purSearch/index.html',
- '/search/issued'
- ]
- console.info(location)
- logic = function (data, num) {
- window.needToWork = Boolean(type)
- if (data.result === 'ok') {
- //判断是否需要设置cookie
- if(data.cValue){
- afterLoginSetCookit(data.cName,data.cValue,data.expires)
- }
- // 判断是否绑定手机号
- if(!data.phone && data.openid) {
- window.location.href = '/swordfish/frontPage/userMerge/sess/bind'
- return
- }
- // 检查是否需要新窗口打开<新用户兴趣偏好设置页面>
- checkNeedGoNewUserSettingPage()
- try{
- if(Logincallback){
- Logincallback(data, num)
- }
- }catch(e){
- }
- // p415: 如果是在首页登录,需要刷新页面,以刷新页面用户信息卡片数据以及页面登录未登录下链接
- // 改为跳转工作桌面,此处注释掉
- // if (location.pathname === '/') {
- // return location.reload()
- // }
- // p525 如果是豆丁过来的 跳转到工作桌面
- if (getParam("partner")==="docin") {
- location.href = '/page_workDesktop/'
- return
- }
- if (redirectUrl === 'reload') {
- return location.reload()
- }
- // 需要登陆后重定向的页面
- if(redirectUrl){
- location.href = redirectUrl
- return
- }
- // 搜索页登录后返回当前页面
- if(link.indexOf(location.pathname) > -1) {
- location.href = location.pathname + location.search
- return
- }
- if (needToWork) {
- location.href = '/page_workDesktop/'
- return
- }
- }
- injectLogic(data, num)
- }
- } catch (e) {}
- // 埋点
- trackClick('注册行为-登录或注册弹窗')
- }
- function openBindPhoneDig() {
- openLoginDigForWx(false);
- $('#bidLogin .logo').hide()
- $('#bidLogin .bind-phone-head').show()
- $('.login-auto-card').hide()
- 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('')
- $('.login-auto-card').show()
- }
- $("#bidLogin").modal("show");
- }
- // 密码切换显示/隐藏
- function switchPassShow (e, str) {
- e.preventDefault()
- const type = $(str).attr('type')
- if(type === 'password') {
- $(str).attr('type', 'text')
- } else {
- $(str).attr('type', 'password')
- }
- }
- function closeLoginDig() {
- $("#bidLogin").modal("hide");
- // window.location.reload()
- }
- function openLoginDigForWx (type) {
- var otherArr = ['.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', '.pass-bottom']
- var wxArr = ['.login-dig-wx-qrcode-box', '.login-dig-top-back-box', '.code-bottom']
- 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<wxArr.length;i++){
- document.querySelector(wxArr[i]).style.display = (type ? '' : 'none')
- }
- $('.login-dig-footer-box p').removeClass('passTip')
- }
- function openLoginDigForReg (type) {
- document.querySelector('.login-dig-tabbar-content').style.display = 'none'
- document.querySelector('.login-dig-tabbar-content.is-active').style.display = 'none'
- $('.login-dig-wx-qrcode-box').hide()
- $('.login-dig-tabbar-navbar').hide()
- $('.login-dig-reg').show()
- $('.login-dig-footer-box').hide()
- $('.login-auto-card').hide()
- // 埋点
- trackClick('注册行为-登录或注册弹窗')
- }
- function backLogin (type) {
- var otherArr = ['.login-dig-box .new_login > .logo', '.login-dig-footer-box','.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', '.login-dig-wx-qrcode-box', '.login-auto-card']
- for(var i=0;i<otherArr.length;i++){
- if (document.querySelector(otherArr[i])) {
- document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
- }
- }
- $('.login-dig-reg').hide()
- }
- // 共三种登录。选择器要添加 sms-login / password-login / wx-qr-login 类名前缀限制
- var loginDialog = {
- init: function () {
- this.initEvnets()
- },
- initEvnets: function () {
- this.bindAutoLoginCheckboxEvent()
- this.enterLoginAction()
- },
- bindKeepLoginQr: function () {
- var payload = {
- isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
- // pageshareid: pageshareid,
- // kopshareid: kopshareid,
- loginER: [pageshareid, kopshareid].join('___')
- }
- $.ajax({
- url: '/free/setKeepLogin',
- method: 'POST',
- async: true,
- data: payload
- })
- },
- chcekBindKeep: function (dom) {
- var $parent = $(dom).parents('.login-module-card')
- var isWxQrLogin = $parent.hasClass('wx-qr-login')
- if (isWxQrLogin) {
- this.bindKeepLoginQr()
- }
- },
- bindAutoLoginCheckboxEvent: function () {
- var _this = this
- $('.auto-login-container').on('click', 'label, .auto-login-checkbox',function () {
- // 手机号验证码自动登录、手机号密码自动登录、微信 下次自动登录 状态分离
- // var $parent = $(this).parents('.auto-login-container')
- // $parent.find('.auto-login-checkbox').toggleClass('checked')
- // $parent.find('.auto-login-container').toggleClass('checked')
- // _this.chcekBindKeep(this)
- // 手机号验证码自动登录、手机号密码自动登录、微信 下次自动登录 状态同步
- $('.auto-login-checkbox').toggleClass('checked')
- $('.auto-login-container').toggleClass('checked')
- _this.bindKeepLoginQr()
- })
- $('.auto-login-container').on('mouseover', '.icon-tip-container,.j-tooltip',function () {
- var $parent = $(this).parents('.auto-login-container')
- $parent.find('.icon-tip').addClass('highlight')
- $parent.find('.j-tooltip').show()
- }).on('mouseleave', '.icon-tip-container,.j-tooltip',function () {
- var $parent = $(this).parents('.auto-login-container')
- $parent.find('.icon-tip').removeClass('highlight')
- $parent.find('.j-tooltip').hide()
- })
- },
- enterLoginAction: function () {
- $('.sms-login .enter-action-login').on('keydown', function (e) {
- if (e.keyCode === 13) {
- // 触发点击事件
- $('.sms-login .login-dig-submit-button[name=verify_submit]').trigger('click')
- }
- })
- $('.password-login .enter-action-login').on('keydown', function (e) {
- if (e.keyCode === 13) {
- // 触发点击事件
- $('.password-login .login-dig-submit-button[name=pass_submit]').trigger('click')
- }
- })
- }
- }
- $(function () {
- loginDialog.init()
- $('#bidLogin').on('hide.bs.modal', function () {
- backLogin(false)
- })
- })
|