login.js 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346
  1. /**统一登录js文件**/
  2. var loginfg='';//websocket请求标识
  3. var bIE9=false;
  4. if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/[6789]./i)) {
  5. bIE9=true
  6. }
  7. var wsUrl = "ws"+(!bIE9&&"https:"==document.location.protocol?"s":"")+"://"+window.location.host+"/ws";
  8. var ws = null;
  9. var openid = "";
  10. var jylgi = 0;
  11. var loginflag = false;//登录状态
  12. // 使用模版提供是否登录,默认值
  13. if (window.goTemplateData && window.goTemplateData.params && window.goTemplateData.params.login) {
  14. loginflag = Boolean(window.goTemplateData.params.login)
  15. }
  16. var mynum = "";//页面参数num
  17. var keysorpname = "";//项目名称
  18. var thurl = "";//url
  19. var semnum = "";//SEM
  20. var ldpnum = "";//落地页扫码后调整标识
  21. var ldmold = "";//落地页扫码后调整标识
  22. var pageshareid = "";
  23. var kopshareid = "";
  24. var oldshareid = "";
  25. var encryptId = null;
  26. var qr_type = "s";
  27. var unseatflag = false;//未登录情况下,用户点击超级搜索等开启按钮或者功能,根据此状态看是否弹出二维码
  28. var unseatzbqyflag = false;//未登录情况下,用户点击中标企业等开启按钮或者功能,根据此状态看是否弹出二维码
  29. var sendMsgInterval = null;
  30. var entjumpflag = false;
  31. var isBindPage = false; // 是否是绑定手机号页面功能
  32. var _reconnectedConf = {
  33. count: 0, // ws重连了几次
  34. max: 10, // ws最大重连次数,重连max次后不再重连
  35. }
  36. //轮询查询
  37. var LoginPolling = {
  38. isPostLoginPolling: true,//是否发起轮询请求
  39. loginPollingInterval: null,
  40. initInterval: null,
  41. init: function(){
  42. //防止重复调用
  43. if(this.initInterval != null){
  44. return;
  45. }
  46. //先发一个消息,保存session
  47. this.postShareid();
  48. this.initInterval = setInterval(this.postShareid,3000);
  49. },
  50. postShareid: function(){
  51. if(WSpolling.isPageHidden || pageshareid == "" || kopshareid == ""){
  52. return;
  53. }
  54. $.ajax({
  55. type: "POST",
  56. url: "/front/ajaxPolling",
  57. data: {reqType: 1,shareIds: pageshareid+"___"+kopshareid},
  58. dataType: "json",
  59. timeout: 3000,
  60. success: function(r){
  61. clearInterval(LoginPolling.initInterval);
  62. LoginPolling.initInterval = null;
  63. }
  64. });
  65. },
  66. start: function(){
  67. //防止重复调用
  68. if(this.loginPollingInterval != null){
  69. return;
  70. }
  71. this.init();
  72. //定时器,定时请求看是否扫码登录,返回用户信息,登录
  73. this.loginPollingInterval = setInterval(function(){
  74. //如果浏览器不支持webscoket,走ajax轮询方式
  75. if(WSpolling.isPageHidden || !LoginPolling.isPostLoginPolling){
  76. return;
  77. }
  78. $.ajax({
  79. type: "POST",
  80. url: "/front/ajaxPolling",
  81. data: {reqType:2},
  82. dataType: "json",
  83. timeout: 3000,
  84. success: function(r){
  85. if(!jQuery.isEmptyObject(r)){
  86. logic(r,mynum);
  87. }
  88. }
  89. });
  90. },5000);
  91. },
  92. stop: function(){
  93. clearInterval(this.loginPollingInterval);
  94. this.loginPollingInterval = null;
  95. this.isPostLoginPolling = false;
  96. this.initInterval = null;
  97. }
  98. }
  99. var webSocketHeartCheck = new WebSocketHeartCheck(LoginPolling);
  100. //创建websocket连接
  101. var createWebSocket = function(){
  102. if("WebSocket" in window){
  103. try{
  104. ws = new WebSocket(wsUrl);//实例化websocket对象
  105. initEventHandle();
  106. }catch(e){
  107. reconnect();
  108. //console.log(e)
  109. }
  110. }else{
  111. LoginPolling.isPostLoginPolling = true;
  112. }
  113. }
  114. //
  115. var initEventHandle = function(){
  116. ws.onmessage = function(e){
  117. //接收消息正常,就不再发ajax轮询
  118. LoginPolling.isPostLoginPolling = false;
  119. if(e.data==""){
  120. return
  121. }else if(e.data=="HeartBeat"){//心跳检测
  122. //如果获取到消息,心跳检测重置
  123. //拿到任何消息都说明当前连接是正常的
  124. webSocketHeartCheck.reset().start(ws,loginflag);
  125. return;
  126. }
  127. //用户登录
  128. logic($.parseJSON(e.data),mynum);
  129. }
  130. ws.onerror = function(e){
  131. //console.info("onerror");
  132. reconnect();
  133. }
  134. ws.onclose = function(e) {
  135. //console.info("onclose");
  136. reconnect();
  137. }
  138. ws.onopen = function(e) {
  139. SendMsg();
  140. //心跳检测重置
  141. webSocketHeartCheck.reset().start(ws,loginflag);
  142. }
  143. }
  144. // 更新头像/昵称/手机号等信息
  145. function updateUserInfo (data) {
  146. if (data.update) {
  147. $.post("/jypay/user/getSimpleData", {}, function(result) {
  148. if (result && result.userId) {
  149. var userName = result.name ? (result.name === result.phone ? '' : result.name) : ''
  150. updateUserInfo({
  151. update: false,
  152. name: userName,
  153. phone: result.phone,
  154. avatar: result.headImage || ''
  155. })
  156. }
  157. })
  158. }
  159. $('#public-nav *[data-user-name]').text(data.name || '')
  160. $('#public-nav *[data-user-phone]').text(data.phone || '')
  161. $('#public-nav img[data-user-avatar]').attr('src', data.avatar || '/common-module/public/image/auto.png')
  162. $('#public-nav img[data-user-avatar]').on('error', function () {
  163. if ($(this).attr('src').indexOf('/common-module/public/image/auto.png') === -1) {
  164. $(this).attr('src', '/common-module/public/image/auto.png')
  165. }
  166. })
  167. }
  168. // 切换登录/未登录展示元素
  169. function toggleLoginDom (type) {
  170. if (type) {
  171. $("#login .loginBtn").hide()
  172. $("#public-nav .nav-avatar").show()
  173. $("#public-nav .work-link").show()
  174. $("#public-nav .fl").addClass('fix-work')
  175. // 客服入口显示
  176. $('#go-customer-4').show()
  177. } else {
  178. $("#public-nav .nav-avatar").hide()
  179. $("#public-nav .work-link").hide()
  180. $("#public-nav .fl").removeClass('fix-work')
  181. $("#login .loginBtn").show()
  182. // 客服入口隐藏
  183. $('#go-customer-4').hide()
  184. }
  185. }
  186. //
  187. function reconnect() {
  188. if(webSocketHeartCheck.lockReconnect || loginflag){
  189. return;
  190. }
  191. // 达到最大重连次数后,不再重连
  192. if (_reconnectedConf.count >= _reconnectedConf.max) {
  193. console.log('ws重连达到最大次数,不再重连')
  194. return
  195. }
  196. LoginPolling.isPostLoginPolling = true;
  197. webSocketHeartCheck.lockReconnect = true;
  198. LoginPolling.init();
  199. //没连接上会一直重连,设置延迟避免请求过多
  200. setTimeout(function () {
  201. _reconnectedConf.count++;
  202. console.log('ws第' + _reconnectedConf.count + '次重连')
  203. createWebSocket();
  204. webSocketHeartCheck.lockReconnect = false;
  205. }, 2000);
  206. }
  207. //websocket查看用户是否登录
  208. var JYLogin = function(num){
  209. clearInterval(loginfg)
  210. loginfg = setInterval(function(){
  211. jylgi++;
  212. //console.log(jylgi+"-----")
  213. if(jylgi>120*60){
  214. getNewShareId(num,false);
  215. jylgi = 0;
  216. }
  217. },1000)
  218. }
  219. var SendMsg = function(){
  220. if(pageshareid==""||kopshareid==""){
  221. return;
  222. }
  223. if(ws!=null&&ws.readyState==1){
  224. //console.log("发送:"+pageshareid+"___"+kopshareid)
  225. ws.send(pageshareid+"___"+kopshareid);
  226. }else{
  227. LoginPolling.isPostLoginPolling = true;
  228. }
  229. }
  230. //生成页面二维码,不同页面处理逻辑
  231. var getNewShareId = function(num,isFirst){
  232. mynum = num;
  233. pageType = "T"
  234. var rref = document.referrer;
  235. if (localStorage.getItem("oldshareid")!=null){
  236. oldshareid=localStorage.getItem("oldshareid");
  237. }
  238. //console.log("num:"+num)
  239. $.post("/front/getLoginNum/"+num,{rref:rref,oid:oldshareid},function(data){
  240. if($("#bidLogin").attr("data-rec")=="sjdc"){
  241. window.location.href = "/front/dataExport/toSieve";
  242. return;
  243. }
  244. if(data&&data.num){
  245. pageshareid = data.num;
  246. kopshareid = data.numot;
  247. mynum = num;
  248. if(!loginflag){
  249. if(isFirst){
  250. LoginPolling.start();
  251. createWebSocket();
  252. }else if(!isFirst){
  253. LoginPolling.init();
  254. SendMsg();
  255. }
  256. }
  257. localStorage.setItem("oldshareid", pageshareid);
  258. //redisUserInfo(pageshareid,kopshareid);
  259. $(".jyhead_qr img").attr("src","/front/share/"+pageshareid);
  260. $("#bottomimg").attr("src","/front/share/"+pageshareid);
  261. $("*[data-share-img]").attr("src","/front/share/"+pageshareid);
  262. $("#layerImg-login").attr("src","/front/share/"+pageshareid);
  263. $("#layerImg-zbsq").attr("src","/front/share/"+pageshareid);
  264. switch(num){
  265. case "10"://首页
  266. //$("#layerImg").attr("src","/front/share/"+pageshareid);
  267. //$("#sy-shareimg img").attr("src","/front/share/"+pageshareid);
  268. $(".wxlinkdiv").attr("src","/front/share/"+pageshareid);
  269. break;
  270. case "11"://订阅页面
  271. $("#vipCode").attr("src","/front/share/"+kopshareid);
  272. break;
  273. case "12"://搜索列表页
  274. $("#layerImg").attr("src","/front/share/"+pageshareid);
  275. $("#wxCode").attr("src","/front/share/"+pageshareid);
  276. $("#keyImg").attr("src","/front/share/"+kopshareid);
  277. if(keysorpname!=undefined&&keysorpname!=""){
  278. var ref = document.referrer;
  279. if(ref != ""&&ref.indexOf("jianyu360.com")<0||ref.indexOf("qmx.top")<0){
  280. $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
  281. }
  282. }
  283. break;
  284. case "13": case "130"://快照页
  285. $("#layerImg").attr("src","/front/share/"+pageshareid);
  286. $("#wxCode").attr("src","/front/share/"+kopshareid);
  287. //生成二维码
  288. if(keysorpname!=undefined&&keysorpname!=""){
  289. $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
  290. }
  291. break;
  292. case "14"://标签页面
  293. $("#bottomimg").attr("src","/front/share/"+pageshareid);
  294. $("*[data-share-img]").attr("src","/front/share/"+pageshareid);
  295. $("#layerImg").attr("src","/front/share/"+pageshareid);
  296. $("#keyImg").attr("src","/front/share/"+pageshareid);
  297. break;
  298. case "15"://博客列表和内容页面
  299. break;
  300. case "16"://关于我们页面
  301. break;
  302. case "18"://扫码关注企业18
  303. $("#layerImg").attr("src","/front/share/"+pageshareid);
  304. var company = $.trim($("#zbSeatchT input[name='keywords']").val());
  305. if(company != "" && company != null && company.length >0){
  306. $("#keyImg").attr("src","/front/share/"+kopshareid);
  307. $.post("/front/rediskw",{"skw":company,"num":kopshareid});
  308. }else{
  309. $("#keyImg").attr("src","/front/share/"+pageshareid);
  310. }
  311. break;
  312. case "19"://拟建项目
  313. $("#layerImg").attr("src","/front/share/"+pageshareid);
  314. $("#wxCode").attr("src","/front/share/"+pageshareid);
  315. $("#keyImg").attr("src","/front/share/"+kopshareid);
  316. if(keysorpname!=undefined&&keysorpname!=""){
  317. $.post("/front/rediskw",{"skw":keysorpname,"num":kopshareid});
  318. }
  319. break;
  320. case "17"://1808新落地页
  321. $(".ewm1").attr("src","/front/share/"+pageshareid);
  322. $(".ewm2").attr("src","/front/share/"+kopshareid);
  323. $("#kwewm").attr("src","/front/share/"+kopshareid);
  324. $(".ecode_img img").attr("src","/front/share/"+kopshareid).css("display","");
  325. break;
  326. case "23"://数据导出
  327. break;
  328. }
  329. JYLogin(num);
  330. }
  331. },'json');
  332. }
  333. //
  334. var redisUserInfo = function(pid,kid){
  335. var rurl = window.location.href;
  336. var rref = document.referrer;
  337. if (localStorage.getItem("oldshareid")!=null){
  338. oldshareid=localStorage.getItem("oldshareid");
  339. }
  340. $.post("/front/followinfo",{pid:pid,kid:kid,rurl:rurl,rref:rref,oid:oldshareid},function(data){
  341. if(data&&data.result=="ok"){
  342. localStorage.setItem("oldshareid", pid);
  343. }
  344. })
  345. }
  346. // (必要!)优先获取用户权限,不管用户有没有登陆,以便在页面中更早的拿到权限
  347. ajaxGetUserPower()
  348. function ajaxGetUserPower (conf) {
  349. conf = conf || {}
  350. var success = conf.success
  351. var complete = conf.complete
  352. $.ajax({
  353. type: 'post',
  354. url: '/bigmember/use/isAdd',
  355. success: function (res) {
  356. if (res && res.data) {
  357. window.memberStatus = res.data.memberStatus
  358. window.memberPower = res.data.power
  359. window.customers = res.data.customers
  360. window.vipStatus = res.data.vipStatus // 是否是超级订阅用户
  361. window.isFree = res.data.isFree // 是否是免费用户
  362. window.freeFile = res.data.freeFile // 免费用户 是否体验过 0:未体验过 -1:体验过
  363. window.viper = res.data.viper // 是否是超级订阅老用户 false:老用户 true: 新用户
  364. window.entniche = res.data.entniche // 商机管理用户
  365. window.fileNum = res.data.fileNum // 超级订阅用户可下载附件次数
  366. window.isLogin = true // 用于其他页面判断是否已登录
  367. window.isNewEntNiche = res.data.entIsNew
  368. window.isEntService = res.data.isEntService
  369. sessionStorage.setItem('bidPower', JSON.stringify(res.data.power))
  370. success && success(res)
  371. }
  372. },
  373. complete: function () {
  374. complete && complete()
  375. }
  376. })
  377. }
  378. function checkBigStatus () {
  379. ajaxGetUserPower({
  380. success: function (res) {
  381. try {
  382. setUserFree()
  383. } catch (error) {}
  384. if (res.data.memberStatus > 0) {
  385. $(".myorderDiv.lastBox").show()
  386. }
  387. if (res.data.viper) {
  388. $(".myorderDiv.ent-search").show()
  389. }
  390. if(res.data.power && res.data.power.length) {
  391. if (res.data.power.indexOf(4) == -1 && res.data.vipStatus>0&&res.data.viper) {
  392. $(".myorderDiv.entPortraitRecord").show()
  393. }
  394. if (res.data.power.indexOf(5) == -1 && res.data.vipStatus>0&&res.data.viper) {
  395. $(".myorderDiv.buyerPortraitRecord").show()
  396. }
  397. }
  398. if (res.data.memberStatus<=0&&res.data.vipStatus>0&&res.data.viper){
  399. $(".myorderDiv.portraitRecord").show()
  400. }
  401. if (res.data.memberStatus > 0 && res.data.vipStatus > 0 && res.data.viper && res.data.power.indexOf(3) === -1) {
  402. $('.fileRecord').show()
  403. }
  404. if (res.data.memberStatus <= 0 && res.data.vipStatus > 0 && res.data.viper) {
  405. $('.fileRecord').show()
  406. }
  407. if ($.isArray(res.data.power)) {
  408. // 大会员没有附加下载包权限用户且新版超级订阅用户
  409. if (res.data.memberStatus > 0 && res.data.vipStatus > 0 && res.data.viper && res.data.power.indexOf(3) === -1) {
  410. $('.fileRecord').show()
  411. }
  412. }
  413. },
  414. complete: function () {
  415. try {
  416. getPowerComplete && getPowerComplete()
  417. } catch (error) {}
  418. }
  419. })
  420. }
  421. // 查询商机管理PC权限
  422. function checkMenuForEnt () {
  423. $.ajax({
  424. type: 'get',
  425. url: '/entbase/ent/mySelectent?t=' + new Date().getTime(),
  426. success: function (er) {
  427. $.ajax({
  428. type: 'get',
  429. url: '/front/entExportAuth/getAuth?t=' + new Date().getTime(),
  430. success: function (r) {
  431. $(".myorderDiv[data-ent-menu]").remove()
  432. var tempHtml = ''
  433. if(er.data!=null && er.data.status==1){
  434. tempHtml += "<div data-ent-menu class=\"myorderDiv\" onclick=\"window.location.href='/orgpc/myent'\">"
  435. +"<span>我的企业</span>"
  436. +"</div>"
  437. }
  438. if(r.entnicheMenu == true){
  439. if (r.isNew == true) {
  440. tempHtml+= "<div data-ent-menu class=\"myorderDiv\" id=\"entDiv\">"
  441. +"<span>商机管理</span>"
  442. +"</div>"
  443. } else {
  444. tempHtml+= "<div data-ent-menu id=\"entDiv\" class=\"myorderDiv\">"
  445. +"<span>商机管理</span>"
  446. +"</div>"
  447. }
  448. }
  449. if(r.privatedata){
  450. tempHtml+= "<div data-ent-menu class=\"myorderDiv\" onclick=\"window.location.href='/swordfish/page_big_pc/free/custom_search'\">"
  451. +"<span>画像分析系统</span>"
  452. +"</div>"
  453. }
  454. $(".infoList .lastBox").before(tempHtml)
  455. $('#entDiv').click(function () {
  456. $.ajax({
  457. type:'POST',
  458. url:'/entnicheNew/buy/whetherbuy',
  459. success:function () {
  460. if(r.entnicheMenu == true){
  461. if (r.isNew == true) {
  462. window.location.href='/entpc/newBus'
  463. } else {
  464. window.location.href='/entpc/bus'
  465. }
  466. }
  467. }
  468. })
  469. })
  470. }
  471. })
  472. }
  473. })
  474. }
  475. var msgTimer = null
  476. function toReaded(ids, type, url) {
  477. var _this = this
  478. $.ajax({
  479. type: 'POST',
  480. url:'/jymessageCenter/markRead',
  481. data: {
  482. msgId: ids,
  483. msgType: type
  484. },
  485. success:function () {
  486. if (url) {
  487. location.href = url
  488. } else {
  489. return
  490. }
  491. }
  492. })
  493. }
  494. /**
  495. * @date 2023/1/4 消息通知改为 webscoket 获取并调用浏览器消息通知
  496. */
  497. // 查看是否有新消息
  498. function checkCounts() {
  499. try {
  500. // 非工作台模式下需要重建链接,工作台嵌入页面不需要额外初始化
  501. if (!goTemplateData.inIframe) {
  502. getMsgBuoyActive.listenNotification()
  503. }
  504. } catch (e) {}
  505. }
  506. //查询用户信息,响应页面登录信息
  507. var logic = function(data,num){
  508. if(data.result=="ok"){
  509. //判断是否需要设置cookie
  510. if(data.cValue){
  511. afterLoginSetCookit(data.cName,data.cValue,data.expires)
  512. }
  513. clearInterval(loginfg);
  514. // loginflag置为true后在调用回调
  515. loginflag = true;
  516. // TODO login callback
  517. try {
  518. // header专用回调。
  519. loginCallbackHeader(data)
  520. } catch (e) {}
  521. try {
  522. // 页面专用回调
  523. loginCallback(data)
  524. } catch (e) {}
  525. clearLoginStorage(/-login-clear/)
  526. //$(".QRLogin").hide();
  527. $("#bidLogin").modal("hide")
  528. $("#bidcommunity").modal("hide")
  529. if(!data.phone && data.openid) {
  530. window.location.href = '/swordfish/frontPage/userMerge/sess/bind'
  531. }
  532. processpage(data,num);
  533. //登录成功,停止轮询
  534. LoginPolling.stop();
  535. //登录成功,停止心跳监测
  536. webSocketHeartCheck.reset();
  537. if(ws && ws.readyState==1){
  538. ws.send("close");
  539. ws.close();
  540. }
  541. encryptId = data.encryptId
  542. if(data.s_nickname.length>11){
  543. data.s_nickname = data.s_nickname.substring(0,11);
  544. data.s_nickname = data.s_nickname + "...";
  545. }
  546. toggleLoginDom(true)
  547. updateUserInfo({
  548. update: true,
  549. name: data.s_nickname || '',
  550. phone: '',
  551. avatar: data.s_headimage || ''
  552. })
  553. var skipInit = location.href.indexOf('/notin/page') !== -1
  554. if (!skipInit && typeof window.GuideIntroDialog === 'function') {
  555. window.guideIntroDialog = new GuideIntroDialog()
  556. }
  557. try{
  558. checkBigStatus()
  559. infoListCss();
  560. message.init()
  561. checkCounts()
  562. if (typeof window.initIndexMsgList === 'function') {
  563. initIndexMsgList()
  564. }
  565. } catch (e) {
  566. console.warn(e)
  567. }
  568. }
  569. }
  570. //登录后处理页面逻辑
  571. var processpage = function(item,num){
  572. var backToUrl = getParam('backTo')
  573. if (backToUrl) {
  574. return location.replace(decodeURIComponent(backToUrl))
  575. }
  576. var toHref=$("#bidLogin").attr("data-rec")
  577. switch (toHref) {
  578. case "sjdc":
  579. window.location.href = "/front/dataExport/toSieve";
  580. return;
  581. case "jydocs":
  582. window.location.href = "/swordfish/docs";
  583. return;
  584. }
  585. // 未登录标签页注册后重定向首页
  586. if (location.href.indexOf('/tags/') > -1) {
  587. window.location.replace('/')
  588. } else if (location.href.indexOf('/nologin/content') > -1 || location.href.indexOf('/demand/detail') > -1) {
  589. // 未登录三级页注册后刷新(后端重定向到登陆后的三级页)
  590. // /demand/detail 供应搜索三级页登录后刷新
  591. window.location.reload()
  592. }
  593. clearInterval(loginfg);
  594. switch(num){
  595. case "10"://10首页
  596. var ful = $("#myModal").attr("aria-hidden");
  597. if(ful=="true"){
  598. break;
  599. }
  600. $("#myModal").modal("hide");
  601. // if(dataListId!=""){
  602. // setTimeout(function(){
  603. // window.open("/article/content/"+dataListId+".html");
  604. // },500)
  605. // }
  606. break;
  607. case "11"://11订阅页面
  608. //$("#myModal-01").click();
  609. $(".modal").click();
  610. break;
  611. case "12"://12搜索列表
  612. var ful = $("#myModal").attr("aria-hidden");
  613. if(ful=="true"){
  614. break;
  615. }
  616. $("#myModal").modal("hide");
  617. $("#labModal").modal("hide");
  618. if(dataId!=""){
  619. setTimeout(function(){
  620. //$('a[dataId="'+ dataId +'"]').click();
  621. var aHref = "";
  622. if(searchvalue != ""){
  623. aHref += '.html?kds='+searchvalue;
  624. }else{
  625. aHref += '.html';
  626. }
  627. window.open("/article/content/"+dataId+aHref);
  628. },500);
  629. }
  630. break;
  631. case "13": case "130"://13快照页
  632. if(thurl!=""&&thurl!="D"){
  633. window.location.href=thurl;
  634. }else if(thurl==""){
  635. window.location.href="/";
  636. }
  637. break;
  638. case "14"://14标签页面
  639. var ful = $("#myModal").attr("aria-hidden");
  640. if(ful=="true"){
  641. break;
  642. }
  643. $("#myModal").click();
  644. if(dataId!=""){
  645. setTimeout(function(){
  646. window.open("/article/content/"+dataId+".html");
  647. },500);
  648. }
  649. break;
  650. case "15"://15剑鱼标讯博客页面
  651. break;
  652. case "16"://关于我们页面16
  653. break;
  654. case "18"://中标企业搜索
  655. var ful = $("#myModal").attr("aria-hidden");
  656. if(ful=="true"){
  657. break;
  658. }
  659. $("#myModal").modal("hide");
  660. $("#labModal").modal("hide");
  661. if(dataId!=""){
  662. setTimeout(function(){
  663. //$('a[dataId="'+ dataId +'"]').click();
  664. var aHref = "";
  665. if(searchvalue != ""){
  666. aHref += '.html?kds='+searchvalue;
  667. }else{
  668. aHref += '.html';
  669. }
  670. window.open("/article/content/"+dataId+aHref);
  671. },500);
  672. }
  673. break;
  674. break;
  675. case "19"://拟建项目
  676. var ful = $("#myModal").attr("aria-hidden");
  677. if(ful=="true"){
  678. break;
  679. }
  680. $("#myModal").modal("hide");
  681. $("#labModal").modal("hide");
  682. if(dataId!=""){
  683. setTimeout(function(){
  684. var aHref = "";
  685. if(searchvalue != ""){
  686. aHref += '.html?kds='+searchvalue;
  687. }else{
  688. aHref += '.html';
  689. }
  690. window.open("/article/content/"+dataId+aHref);
  691. },500);
  692. }
  693. break;
  694. case "17"://落地页
  695. $("#bidLogin").modal("hide");
  696. $(".close").click();
  697. if(ldpnum=="0"){
  698. window.open('/jylab/supsearch/index.html', '_self')
  699. }else if(ldpnum=="1"){
  700. window.open('/front/subscribe.html', '_self')
  701. }else if(ldpnum=="2"){
  702. window.open('/jylab/supsearch/proposedProject.html', '_self')
  703. }else if(ldpnum=="3"){
  704. if(ldmold!=""){
  705. window.open('/list/stype/'+ldmold+'.html', '_self')
  706. }else{
  707. window.open('/jylab/supsearch/index.html', '_self')
  708. }
  709. }else if(ldpnum=="4"){
  710. if(ldmold!=""){
  711. window.open('/list/area/'+ldmold+'.html', '_self')
  712. }else{
  713. window.open('/jylab/supsearch/index.html', '_self')
  714. }
  715. }else if(ldpnum=="5"){
  716. if(ldmold){
  717. window.open('/article/content/'+ldmold+'.html')
  718. }else{
  719. window.open('/jylab/supsearch/index.html')
  720. }
  721. }else if(ldpnum=="6"){
  722. window.open('/front/dataExport/toSieve')
  723. }
  724. break;
  725. case "24"://百度SEM-p 快照页推广-落地页
  726. window.open(semHref, '_self')
  727. break
  728. }
  729. }
  730. /**
  731. * 检查是否需要前往新用户兴趣设置
  732. * @returns {boolean}
  733. */
  734. function checkNeedGoNewUserSettingPage () {
  735. // 同步请求判断是否新用户,需要跳转兴趣设置页面
  736. // 首页不走这个逻辑打开。首页登录后会刷新数据,会走首页重定向。
  737. // if (location.pathname === '/') return
  738. var goPage
  739. $.ajax({
  740. type: 'post',
  741. async: false,
  742. url: '/salesLeads/appIsNewUerSales',
  743. success: function (res) {
  744. if (res && res.data) {
  745. goPage = '/swordfish/frontPage/user/sess/set_favorite'
  746. }
  747. }
  748. })
  749. if (goPage) {
  750. window.open(goPage)
  751. return true
  752. }
  753. return false
  754. }
  755. function clearObjKeyForRegFn (obj, reg) {
  756. if (obj) {
  757. for(var k in obj) {
  758. if (reg.test(k)) {
  759. obj.removeItem(k)
  760. }
  761. }
  762. }
  763. }
  764. function clearLoginStorage (reg) {
  765. clearObjKeyForRegFn(sessionStorage, reg)
  766. clearObjKeyForRegFn(localStorage, reg)
  767. }
  768. var removeLocalStorage = function(){
  769. // 移除userId (大会员中标预测历史记录用到)
  770. localStorage.removeItem('BIGMEMBER_PC')
  771. }
  772. //退出登录
  773. var signout = function(){
  774. clearInterval(loginfg);
  775. loginflag = false;
  776. unseatflag = false;
  777. unseatzbqyflag = false;
  778. toggleLoginDom(false)
  779. loginBtnType();
  780. $(".control-tabBtn>a:first>font").text("招标搜索");
  781. $(".control-tabBtn>a:eq(2)").addClass("hidden");
  782. $(".control-tabBtn>a:eq(3)").addClass("hidden");
  783. $(".superSearch").show();
  784. $.post("/front/signOut",function(data){
  785. if(data=="ok"){
  786. $('#noticed').hide()
  787. clearLoginStorage(/-login-clear/)
  788. afterSignoutClearCookit();
  789. // window.location.href="/";
  790. var pt = new RegExp("^/article/content/.+$|^/front/dataExport/.+$|^/front/common(Footer|Header)|^/front/course/codePay$|^/front/course/orderPay$|^/entpc/.+$|^/bid/pc/page/.+$");
  791. if(pt.test(window.location.pathname)){
  792. window.location.href="/";
  793. }else{
  794. window.location.reload();
  795. /*LoginPolling.start();
  796. createWebSocket();
  797. getNewShareId(mynum,true);*/
  798. }
  799. window.localStorage.removeItem('bus-key-group-SCOPE')
  800. window.localStorage.removeItem('noMesg')
  801. clearInterval(msgTimer)
  802. // 移除浏览器缓存
  803. removeLocalStorage()
  804. }
  805. })
  806. }
  807. var afterSignoutClearCookit = function(){
  808. try{
  809. $.cookie("userid_secure","",{expires:-1,path:"/",domain:document.domain.replace(/[^.]+/,"")});
  810. $.cookie("klcn_value","",{expires:-1,path:"/",domain:document.domain.replace(/[^.]+/,"")});
  811. }catch(e){
  812. document.cookie = "userid_secure=;expires=-1;path=/";
  813. document.cookie = "klcn_value=;expires=-1;path=/";
  814. }
  815. }
  816. var afterLoginSetCookit = function(name,value,time){
  817. var expires = new Date(time)
  818. try{
  819. $.cookie(name,value,{expires:expires.toGMTString(),path:"/",domain:document.domain.replace(/[^.]+/,"")});
  820. }catch(e){
  821. document.cookie = name+"="+value+";expires="+expires.toGMTString()+";path=/;domain="+document.domain.replace(/[^.]+/,"");
  822. }
  823. }
  824. //查看用户是否已经登录
  825. var haslogin = function(num,kyorpn,url){
  826. mynum = num;//页面logid
  827. keysorpname = kyorpn;//其他参数
  828. thurl = url;//列表也跳转快照页url
  829. $.ajax({
  830. url: '/front/hasSign',
  831. method: 'post',
  832. success: function (data) {
  833. if(data){
  834. if(data.resetpwd){
  835. afterSignoutClearCookit();
  836. window.location.href = "/?nol=2";
  837. return;
  838. }
  839. // loginflag置为true后在调用回调
  840. loginflag = true;
  841. // TODO login callback
  842. try {
  843. // header专用回调。
  844. loginCallbackHeader(data)
  845. } catch (e) {}
  846. try {
  847. // 页面专用回调
  848. loginCallback(data)
  849. } catch (e) {}
  850. encryptId = data.encryptId
  851. if(data.s_nickname!=null&&data.s_nickname.length>11){
  852. data.s_nickname = data.s_nickname.substring(0,11);
  853. data.s_nickname = data.s_nickname + "...";
  854. }
  855. toggleLoginDom(true)
  856. updateUserInfo({
  857. update: true,
  858. name: data.s_nickname || '',
  859. phone: '',
  860. avatar: data.s_headimage || ''
  861. })
  862. try{
  863. checkBigStatus()
  864. infoListCss();
  865. message.init()
  866. checkCounts()
  867. if (typeof window.initIndexMsgList === 'function') {
  868. initIndexMsgList()
  869. }
  870. } catch (e) {
  871. console.warn(e)
  872. }
  873. } else{
  874. toggleLoginDom(false)
  875. loginBtnType();
  876. //pc限制登陆
  877. var nosess = getParam("nol");
  878. if (nosess && (!loginflag)){
  879. openLoginDig();
  880. }
  881. window.localStorage.setItem('noMesg', 0)
  882. }
  883. getNewShareId(num,true);
  884. },
  885. complete: function () {
  886. // TODO login callback
  887. try {
  888. checkLoginCallback()
  889. } catch (e) {}
  890. }
  891. })
  892. }
  893. function loginBtnType(){
  894. var href = window.location.pathname;
  895. var curTheme =$("#public-nav").attr('data-theme')
  896. 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/"){
  897. if(curTheme == 'dark'){
  898. $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
  899. $(".loginBtn").attr("onmouseout","this.style.borderColor='#fff'; this.style.color='#fff';");
  900. }else{
  901. $(".loginBtn").css({"border-color":"#e0e0e0","color":"rgb(37, 38, 39)"});
  902. $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
  903. $(".loginBtn").attr("onmouseout","this.style.borderColor='#e0e0e0'; this.style.color='#252627';");
  904. }
  905. }else if(href.indexOf("topics")>-1){
  906. $(".loginBtn").css({"border":"none"});
  907. }else{
  908. $(".loginBtn").css({"border-color":"#e0e0e0","color":"rgb(37, 38, 39)"});
  909. $(".loginBtn").attr("onmouseover","this.style.borderColor='#2cb7ca'; this.style.color='#2cb7ca';");
  910. $(".loginBtn").attr("onmouseout","this.style.borderColor='#e0e0e0'; this.style.color='#252627';");
  911. }
  912. }
  913. ///////////////////////////////
  914. // ajax部分匿名函数自执行,防止泄露全局变量
  915. window.__wait_listen_modal__ = false
  916. $(function(){
  917. function goBackOrigin (cb) {
  918. var backOrigin = $.cookie('article')
  919. if (backOrigin) {
  920. location.replace(backOrigin)
  921. } else {
  922. typeof cb === 'function' ? cb() : window.close()
  923. }
  924. }
  925. var Direct = {
  926. verify: {},
  927. forge: {},
  928. loginInfo: {},
  929. instance: {},
  930. ajaxSms: function (e, type) {
  931. var _this = this;
  932. switch (type) {
  933. case 'verify': {
  934. //手机号验证码登录 - 发送登录短信验证码
  935. $.post("/phone/login",{
  936. reqType:"sendIdentCode",
  937. phone:$("#bidLogin .login-dig-input-box [name='verify_phone']").val(),
  938. // isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
  939. code:$("#bidLogin .login-dig-input-box [name='verify_code']").val()
  940. },function(r){
  941. if(r.status==-1){
  942. _this.verify.phone.showError('手机号格式错误');
  943. }else if(r.status==-2){//图形验证码错误
  944. _this.verify.code.showError('图形验证码输入错误');
  945. $("#bidLogin .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  946. }else if(r.status==-3){//图形验证码错误
  947. _this.verify.phone.showError('手机号已被注册');
  948. $("#bidLogin .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  949. }else{
  950. sessionStorage.setItem('login-verify-start-time', new Date().getTime())
  951. startTimeDown(type)
  952. }
  953. });
  954. break
  955. }
  956. case 'register': {
  957. //手机号验证码登录(注册) - 发送登录短信验证码
  958. $.post("/phone/login",{
  959. reqType:"sendIdentCode",
  960. register: 'true',
  961. phone:$(".register-form-box .login-dig-input-box [name='register_phone']").val(),
  962. // isAutoLogin: $('.sms-login .auto-login-checkbox').hasClass('checked'),
  963. code:$(".register-form-box .login-dig-input-box [name='register_code']").val()
  964. },function(r){
  965. if(r.status==-1){
  966. _this.register.phone.showError('手机号格式错误');
  967. }else if(r.status==-2){//图形验证码错误
  968. _this.register.code.showError('图形验证码输入错误');
  969. $(".register-form-box .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  970. }else if(r.status==-3){
  971. _this.register.phone.showError('手机号已被注册');
  972. $(".register-form-box .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  973. }else{
  974. sessionStorage.setItem('login-verify-start-time', new Date().getTime())
  975. startTimeDown(type)
  976. }
  977. });
  978. break
  979. }
  980. case 'forge': {
  981. $.post("/phone/forgetPwd",{
  982. reqType:"sendIdentCode",
  983. phone:$(".forgetpwd_page .login-dig-input-box [name='forge_phone']").val(),
  984. code:$(".forgetpwd_page .login-dig-input-box [name='forge_code']").val()
  985. },function(r){
  986. if(r.status=="phoneError"){
  987. _this.forge.phone.showError('手机号格式错误');
  988. }else if(r.status=="codeError"){
  989. _this.forge.code.showError('图形验证码输入错误');
  990. $(".forgetpwd_page .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  991. }else if(r.status=="phoneNotExists"){
  992. _this.forge.phone.showError('手机号尚未注册');
  993. $(".forgetpwd_page .verify-img").attr("src","/front/landpage/captcha?v="+new Date().getTime());
  994. }else if(r.status=="y"){
  995. sessionStorage.setItem('login-verify-start-time', new Date().getTime())
  996. startTimeDown(type)
  997. }
  998. });
  999. break
  1000. }
  1001. case 'bind-phone': {
  1002. $.post("/jypay/user/phone/bind",{
  1003. step: 1,
  1004. phone:$("#bidLogin .login-dig-input-box [name='verify_phone']").val(),
  1005. code:$("#bidLogin .login-dig-input-box [name='verify_code']").val()
  1006. },function(r){
  1007. if (r && r.error_code > -1) {
  1008. sessionStorage.setItem('login-verify-start-time', new Date().getTime())
  1009. startTimeDown(type)
  1010. } else {
  1011. if (r.error_msg === '图形验证码错误') {
  1012. if (_this.verify.code.value !== "HIDE") {
  1013. _this.verify.code.showError(r.error_msg || '发送错误,请稍后再试');
  1014. }
  1015. getNewVerify()
  1016. } else if (r.error_msg === '手机号已被使用') {
  1017. _this.verify.phone.showError('该手机号已被绑定,请更换手机号');
  1018. } else {
  1019. _this.verify.sms.showError(r.error_msg || '发送错误,请稍后再试');
  1020. }
  1021. }
  1022. });
  1023. break
  1024. }
  1025. }
  1026. },
  1027. // 忘记密码
  1028. ajaxStepOne: function (e, arr) {
  1029. $.post("/phone/forgetPwd",{reqType:"nextStep",identCode:arr[2].value},function(r){
  1030. e.setAttribute('data-loading', 'false');
  1031. if(r.status=="identCodeError"){
  1032. arr[2].showError('短信验证码错误');
  1033. }else if(r.status=="y"){
  1034. toggleStep(false);
  1035. }
  1036. });
  1037. },
  1038. ajaxStepTwo: function (e, arr) {
  1039. $.post("/phone/forgetPwd",{reqType:"save",password:arr[1].value},function(r){
  1040. e.setAttribute('data-loading', 'false');
  1041. if(r.status=="passwordError"){
  1042. arr[0].showError('密码格式错误');
  1043. }else if(r.status=="passwordRepeat"){
  1044. arr[0].showError('新密码不能与之前设置过的密码重复');
  1045. }else{
  1046. var toast = document.querySelector('.login-dig-success-toast')
  1047. toast.classList.add('is-show')
  1048. setTimeout(function () {
  1049. toast.classList.remove('is-show')
  1050. if(sessionStorage){
  1051. sessionStorage.reLogin=1;
  1052. }
  1053. window.history.back();
  1054. }, 1500);
  1055. }
  1056. });
  1057. },
  1058. // 设置密码
  1059. ajaxSetPassword: function (e, arr) {
  1060. var payload = {
  1061. password: arr[0].value
  1062. };
  1063. $.ajax({
  1064. url: "/publicapply/password/update",
  1065. type: "POST",
  1066. contentType: "application/json",
  1067. data: JSON.stringify(payload),
  1068. success: function(r) {
  1069. e.setAttribute('data-loading', 'false');
  1070. if (r) {
  1071. // 密码保存成功,走登录成功步骤
  1072. logic(Direct.loginInfo.userInfo, mynum);
  1073. } else {
  1074. arr[1].showError('密码保存失败');
  1075. }
  1076. }
  1077. });
  1078. },
  1079. // 手机号+密码登录
  1080. ajaxLoginPass: function (e, arr) {
  1081. var payload = {
  1082. reqType:"phoneLogin",
  1083. isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
  1084. phone:arr[0].value,
  1085. password: arr[1].value
  1086. }
  1087. $.post("/phone/login",payload,function(r){
  1088. e.setAttribute('data-loading', 'false')
  1089. switch (r.status) {
  1090. case -1: {
  1091. arr[0].showError('手机号或账号名输入错误')
  1092. break
  1093. }
  1094. case 1: {
  1095. logic(r.userInfo,mynum);
  1096. break
  1097. }
  1098. case -2: {
  1099. arr[1].showError('密码输入错误')
  1100. break
  1101. }
  1102. }
  1103. });
  1104. },
  1105. ajaxLoginSms: function (e, arr) {
  1106. if ($('#bidLogin').attr('data-name') === 'bind-phone') {
  1107. $.post("/jypay/user/phone/bind",{
  1108. step: 2,
  1109. phone: arr[0].value,
  1110. code: arr[2].value,
  1111. mode: isBindPage ? 'mergeBind' : ''
  1112. },function(r){
  1113. e.setAttribute('data-loading', 'false')
  1114. if (r && r.error_code > -1) {
  1115. if(r.data.state==1){
  1116. var backToUrl = getParam('backTo')
  1117. if (backToUrl) {
  1118. return location.replace(decodeURIComponent(backToUrl))
  1119. }
  1120. if (isBindPage) {
  1121. if (history.length === 1) {
  1122. goBackOrigin()
  1123. } else {
  1124. if (document.referrer === location.href) {
  1125. goBackOrigin(function () {
  1126. location.href = '/'
  1127. })
  1128. } else {
  1129. checkNeedGoNewUserSettingPage()
  1130. history.back()
  1131. }
  1132. }
  1133. return
  1134. }
  1135. if (r.data.needMerge) {
  1136. location.href = '/swordfish/frontPage/userMerge/sess/merge?token=' + r.data.mergeToken
  1137. return
  1138. } else {
  1139. checkNeedGoNewUserSettingPage()
  1140. $("#bidLogin").modal("hide")
  1141. sessionStorage.setItem('bind-phone', arr[0].value.trim())
  1142. typeof window.callBindPhoneSuccess === 'function' && window.callBindPhoneSuccess(true)
  1143. }
  1144. } else if (r.data.state==2){
  1145. location.replace('/swordfish/frontPage/userMerge/sess/merge?token=' + r.data.token)
  1146. }
  1147. } else {
  1148. arr[2].showError(r.error_msg || '绑定错误,请稍后再试')
  1149. }
  1150. });
  1151. } else {
  1152. var source = getParam("source");//百度SEM
  1153. if (source!=null){
  1154. var pathname = window.location.pathname;
  1155. if (pathname=="/front/structed/pc_index.html"){//结构化数据
  1156. source+="_structed";
  1157. }else if (pathname=="/bid/pc/page/bidfile_landpage"){//招标文件解读
  1158. source+="_bidfile";
  1159. }else if (pathname=="/big/page/index"){//大会员
  1160. source+="_member";
  1161. }
  1162. }else{
  1163. source="";
  1164. }
  1165. var payload = {
  1166. reqType:"identCodeLogin",
  1167. identCode:arr[2].value,
  1168. isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
  1169. source:source
  1170. }
  1171. // 短信验证码登录
  1172. $.post("/phone/login",payload,function(r){
  1173. e.setAttribute('data-loading', 'false')
  1174. if(r.status==1){
  1175. if (r.userInfo.isNewUser) {
  1176. trackClick('注册行为-打开设置密码弹窗')
  1177. Direct.showSetPassModule(true)
  1178. Direct.loginInfo = r
  1179. } else {
  1180. logic(r.userInfo,mynum);
  1181. }
  1182. }else if(r.status==-1){
  1183. arr[2].showError('短信验证码输入错误')
  1184. }else if(r.status==-4){
  1185. arr[2].showError('系统错误,请重试')
  1186. }
  1187. });
  1188. }
  1189. },
  1190. // 新用户设置密码
  1191. showSetPassModule: function (type) {
  1192. 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']
  1193. var setPassArr = ['.login-dig-tabbar-content.set-password', '.login-dig-tabbar-navbar.set-pass-module', '.set-pass-bottom', '.set-pass-title']
  1194. for(var i=0;i<otherArr.length;i++){
  1195. if (document.querySelector(otherArr[i])) {
  1196. document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
  1197. }
  1198. }
  1199. for(var i=0;i<setPassArr.length;i++){
  1200. if (document.querySelector(setPassArr[i])) {
  1201. document.querySelector(setPassArr[i]).style.display = (type ? 'block' : 'none')
  1202. }
  1203. }
  1204. },
  1205. ajaxRegister: function (e, arr) {
  1206. var source = getParam("source");//百度SEM
  1207. if (source!=null){
  1208. var pathname = window.location.pathname;
  1209. if (pathname=="/front/structed/pc_index.html"){//结构化数据
  1210. source+="_structed";
  1211. }else if (pathname=="/bid/pc/page/bidfile_landpage"){//招标文件解读
  1212. source+="_bidfile";
  1213. }else if (pathname=="/big/page/index"){//大会员
  1214. source+="_member";
  1215. }
  1216. }else{
  1217. source="";
  1218. }
  1219. var payload = {
  1220. reqType:"identCodeLogin",
  1221. s_entname: arr[3].value,
  1222. identCode:arr[2].value,
  1223. source:source,
  1224. isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
  1225. email: arr[4].value
  1226. }
  1227. // 短信验证码登录
  1228. $.post("/phone/login",payload,function(r){
  1229. e.setAttribute('data-loading', 'false')
  1230. if(r.status==1){
  1231. logic(r.userInfo,mynum);
  1232. var toast = document.querySelector('.login-dig-success-toast')
  1233. toast.classList.add('is-show')
  1234. setTimeout(function () {
  1235. toast.classList.remove('is-show')
  1236. window.history.back();
  1237. }, 1500);
  1238. }else if(r.status==-1){
  1239. arr[2].showError('短信验证码输入错误')
  1240. }
  1241. });
  1242. }
  1243. }
  1244. // Direct.showSetPassModule(true) // 模拟显示 设置密码弹框
  1245. // openLoginDigForReg() // 模拟显示注册弹框
  1246. // openBindPhoneDig() // 模拟显示绑定手机号弹框
  1247. // @手机号绑定以及账号合并 2021/1/25
  1248. function toggleNeedVerifyInput (f, src) {
  1249. var verifyInput = $(".login-dig-tabbar-content.is-active .login-dig-input-box:eq(1)")
  1250. if (($('#bidLogin').attr('data-name') === 'bind-phone')) {
  1251. if (f) {
  1252. if (verifyInput.find('input').val() === 'HIDE') {
  1253. verifyInput.find('input').val('')
  1254. Direct.verify.code.showError()
  1255. }
  1256. verifyInput.find('.verify-img').attr('src', src)
  1257. verifyInput.show()
  1258. } else {
  1259. verifyInput.find('input').val('HIDE')
  1260. Direct.verify.code.skip('HIDE')
  1261. verifyInput.hide()
  1262. }
  1263. }
  1264. }
  1265. var oldNeedStatus = false
  1266. window.getBindVerify = getNewVerify
  1267. function getNewVerify (cb) {
  1268. if (!oldNeedStatus) {
  1269. toggleNeedVerifyInput(false)
  1270. }
  1271. $.ajax({
  1272. url: '/jypay/user/phone/imgCaptcha?t=' + new Date().getTime(),
  1273. success: function (r) {
  1274. console.log(r)
  1275. if (r && r.data) {
  1276. oldNeedStatus = r.data.needVerify
  1277. if (r.data.needVerify) {
  1278. toggleNeedVerifyInput(true, 'data:image/png;base64,' + r.data.imageData)
  1279. typeof cb === 'function' ? cb('data:image/png;base64,' + r.data.imageData) : null
  1280. } else {
  1281. toggleNeedVerifyInput(false)
  1282. }
  1283. }
  1284. }
  1285. })
  1286. }
  1287. // 初始化弹窗
  1288. try{
  1289. initDirect()
  1290. }catch(e){}
  1291. // 初始化忘记密码
  1292. initForgetDirect()
  1293. initRegisterDirect()
  1294. if(sessionStorage&&sessionStorage.reLogin==1){
  1295. sessionStorage.removeItem("reLogin");
  1296. $(".login-dig-tabbar-navbar>[name='pass']").click();
  1297. openLoginDig();
  1298. }
  1299. window.__wait_listen_modal__ = true
  1300. $("#bidLogin").on("show.bs.modal", function () {
  1301. if ($('#bidLogin').attr('data-name') === 'bind-phone') {
  1302. getNewVerify()
  1303. } else {
  1304. var verify_path = "/front/landpage/captcha?v="
  1305. $("#bidLogin .verify-img").attr("src", verify_path + new Date().getTime());
  1306. }
  1307. });
  1308. $("#bidLogin").on("hidden.bs.modal", function () {
  1309. window.needToWork = false
  1310. $(".public-nav").css({"padding-right":""});
  1311. if($("#bidLogin").attr("data-rec")){
  1312. $("#bidLogin").removeAttr("data-rec");
  1313. }
  1314. if(Direct.loginInfo.userInfo && Direct.loginInfo.userInfo.result === 'ok') {
  1315. location.reload()
  1316. }
  1317. });
  1318. function startTimeDown (type) {
  1319. var nowCount = 60
  1320. if (sessionStorage.getItem('login-verify-start-time')) {
  1321. var cCount = parseInt((new Date().getTime() - sessionStorage.getItem('login-verify-start-time')) / 1000)
  1322. if (cCount >= 0 & cCount <= 60) {
  1323. nowCount -= cCount
  1324. } else {
  1325. sessionStorage.removeItem('login-verify-start-time')
  1326. return
  1327. }
  1328. } else {
  1329. return
  1330. }
  1331. var nowQ = 'span[data-name="verify_get_sms"]'
  1332. var otherQ = 'span[data-name="forge_get_sms"]'
  1333. if (type === 'forge') {
  1334. var tempQ = nowQ
  1335. nowQ = otherQ
  1336. otherQ = tempQ
  1337. }
  1338. if (type === 'register') {
  1339. nowQ = 'span[data-name="register_get_sms"]'
  1340. otherQ = 'span[data-name="verify_get_sms"]'
  1341. }
  1342. var Ele = document.querySelector(nowQ)
  1343. var otherEle = document.querySelector(otherQ)
  1344. var defalutIT = '重新获取('+ --nowCount +'s)'
  1345. if (Ele) Ele.innerText = defalutIT
  1346. if (otherEle) otherEle.innerText = defalutIT
  1347. var nowSS = window.setInterval(function () {
  1348. if (nowCount === 1 || !sessionStorage.getItem('login-verify-start-time')) {
  1349. clearInterval(nowSS)
  1350. if (Ele) Ele.innerText = '获取验证码'
  1351. if (Ele) Ele.classList.remove('is-stop')
  1352. if (otherEle) otherEle.innerText = '获取验证码'
  1353. sessionStorage.removeItem('login-verify-start-time')
  1354. return
  1355. }
  1356. var iT = '重新获取('+ --nowCount +'s)'
  1357. if (Ele) Ele.classList.add('is-stop')
  1358. if (Ele) Ele.innerText = iT
  1359. if (otherEle) otherEle.classList.add('is-stop')
  1360. if (otherEle) otherEle.innerText = iT
  1361. }, 1000)
  1362. }
  1363. function getSMSCode (e) {
  1364. if (e.classList.contains('is-stop')) return
  1365. var verifyStartTime = new Date().getTime()
  1366. var oldTime = sessionStorage.getItem('login-verify-start-time') || verifyStartTime - 70000
  1367. if (verifyStartTime - oldTime >= 60000) {
  1368. var nowQ = e.getAttribute('data-name') === 'forge_get_sms' ? 'forge' : 'verify'
  1369. if ($("#bidLogin").attr('data-name') === 'bind-phone') {
  1370. nowQ = 'bind-phone'
  1371. // getNewVerify()
  1372. }
  1373. if (e.getAttribute('data-name') === 'verify_get_sms' && !isBindPage) {
  1374. nowQ = 'verify'
  1375. trackClick('注册行为-验证码登录/注册-获取验证码')
  1376. }
  1377. if(isBindPage) {
  1378. trackClick('绑定-发送验证码')
  1379. }
  1380. Direct.ajaxSms(e, nowQ)
  1381. }
  1382. }
  1383. // 表单规则
  1384. function ruleForPhoneOrName (data, type) {
  1385. return true
  1386. }
  1387. function ruleForPhone (data, type) {
  1388. var phoneReg = /^[1][3-9][0-9]{9}$/.test(data.value);
  1389. var createPhoneReg =/^[1][0][0][0-9]{8}$/.test(data.value);
  1390. var checkStatus = phoneReg || createPhoneReg;
  1391. if (type === 'input') {
  1392. return data.value.length >= 11 ? checkStatus : true
  1393. }
  1394. if (type === 'blur') {
  1395. return data.value.length ? checkStatus : true
  1396. }
  1397. return checkStatus
  1398. }
  1399. function ruleForCode (data, type) {
  1400. var checkStatus = /^\S{4}$/.test(data.value)
  1401. if (type === 'blur') {
  1402. return data.value.length ? checkStatus : true
  1403. }
  1404. if (type === 'input') {
  1405. return data.value.length == 4 ? checkStatus : true
  1406. }
  1407. return checkStatus
  1408. }
  1409. function ruleForEnt (data, type) {
  1410. var checkStatus = /^\S{4,100}$/.test(data.value)
  1411. if (type === 'blur') {
  1412. return data.value.length ? checkStatus : true
  1413. }
  1414. if (type === 'input') {
  1415. return data.value.length < 4 ? checkStatus : true
  1416. }
  1417. return checkStatus
  1418. }
  1419. function ruleForSms (data, type) {
  1420. var checkStatus = /^\S{6}$/.test(data.value)
  1421. if (type === 'blur') {
  1422. return data.value.length ? checkStatus : true
  1423. }
  1424. if (type === 'input') {
  1425. return data.value.length == 6 ? checkStatus : true
  1426. }
  1427. return checkStatus
  1428. }
  1429. function ruleForPass (data, type) {
  1430. var checkStatus = /^\S{6,}$/.test(data.value)
  1431. if (type === 'blur') {
  1432. return data.value.length ? checkStatus : true
  1433. }
  1434. if (type === 'input') {
  1435. return data.value.length >= 6 ? checkStatus : true
  1436. }
  1437. return checkStatus
  1438. }
  1439. function createFormStauts (formOption) {
  1440. var nowEle = document.querySelector(formOption.el)
  1441. var errClass = 'is-error'
  1442. // 实时状态
  1443. var nowData = {
  1444. status: null,
  1445. next: formOption.next || false,
  1446. value: null,
  1447. el: nowEle,
  1448. skip: function (value) {
  1449. this.status = true
  1450. this.next = true
  1451. this.value = value
  1452. formOption.upStatus()
  1453. },
  1454. showError: function (error) {
  1455. this.status = false
  1456. this.next = false
  1457. formOption.upStatus()
  1458. if (error) {
  1459. this.el.parentNode.setAttribute('data-error', error)
  1460. this.el.parentNode.classList.add(errClass)
  1461. showToast(error)
  1462. }
  1463. }
  1464. }
  1465. // 错误提示
  1466. if (formOption.errorTip && formOption.errorTip !== '') {
  1467. nowEle.parentNode.setAttribute('data-error', formOption.errorTip)
  1468. showToast(formOption.errorTip)
  1469. }
  1470. // 校验规则
  1471. if (typeof formOption.rule !== "function") {
  1472. formOption.rule = function (data) {
  1473. return true
  1474. }
  1475. }
  1476. // 状态变动通知回调
  1477. if (typeof formOption.upStatus !== "function") {
  1478. formOption.upStatus = function (data) {
  1479. return true
  1480. }
  1481. }
  1482. // 监听事件
  1483. var events = formOption.event;
  1484. for(var i=0;i<events.length;i++){
  1485. if (nowEle) nowEle.addEventListener(events[i],function (e) {
  1486. // input
  1487. var nowTarget = e.target
  1488. var errorTarget = nowTarget.parentNode
  1489. // 移除错误提示
  1490. errorTarget.classList.remove(errClass)
  1491. // 更新状态
  1492. nowData.value = nowTarget.value
  1493. nowData.status = formOption.rule(nowData, e.type)
  1494. nowData.next = formOption.rule(nowData, 'next')
  1495. formOption.upStatus()
  1496. // 更新错误提示
  1497. if (nowData.status) {
  1498. errorTarget.classList.remove(errClass)
  1499. } else {
  1500. errorTarget.classList.add(errClass)
  1501. var errorMsg = errorTarget.getAttribute('data-error')
  1502. showToast(errorMsg, 4000)
  1503. }
  1504. })
  1505. }
  1506. /*formOption.event.forEach(function(v){
  1507. if (nowEle) nowEle.addEventListener(v,function (e) {
  1508. // input
  1509. var nowTarget = e.target
  1510. var errorTarget = nowTarget.parentNode
  1511. // 移除错误提示
  1512. errorTarget.classList.remove(errClass)
  1513. // 更新状态
  1514. nowData.value = nowTarget.value
  1515. nowData.status = formOption.rule(nowData, v)
  1516. nowData.next = formOption.rule(nowData, 'next')
  1517. formOption.upStatus()
  1518. // 更新错误提示
  1519. if (nowData.status) {
  1520. errorTarget.classList.remove(errClass)
  1521. } else {
  1522. errorTarget.classList.add(errClass)
  1523. }
  1524. })
  1525. });*/
  1526. return nowData
  1527. }
  1528. // 事件
  1529. function installInputEvent () {
  1530. // verify img event for click
  1531. var s1 = document.querySelectorAll('.login-dig-input-box .verify-img');
  1532. for(var i=0;i<s1.length;i++){
  1533. s1[i].addEventListener('click', function (e) {
  1534. var verify_path = "/front/landpage/captcha?v="
  1535. if ($('#bidLogin').attr('data-name') === 'bind-phone') {
  1536. getNewVerify(function (src) {
  1537. e.target.src = src
  1538. })
  1539. } else {
  1540. e.target.src = verify_path+new Date().getTime();
  1541. }
  1542. })
  1543. }
  1544. var s2 = document.querySelectorAll('.login-dig-input-box .l-get-sms');
  1545. for(var i=0;i<s2.length;i++){
  1546. s2[i].addEventListener('click', function (e) {
  1547. getSMSCode(e.target)
  1548. })
  1549. }
  1550. var s3 = document.querySelectorAll('.login-dig-input-box input');
  1551. for(var i=0;i<s3.length;i++){
  1552. s3[i].addEventListener('focus', function (e) {
  1553. var nowInput = e.target
  1554. nowInput.parentNode.classList.add('is-focus')
  1555. })
  1556. s3[i].addEventListener('blur', function (e) {
  1557. var nowInput = e.target
  1558. nowInput.parentNode.classList.remove('is-focus')
  1559. })
  1560. }
  1561. }
  1562. // E-公用
  1563. // 忘记密码
  1564. function toggleStep (type) {
  1565. var nowArr = ['.forget-form-box[data-step="1"]', '.forget-step-title[data-step="1"]']
  1566. var otherArr = ['.forget-form-box[data-step="2"]', '.forget-step-title[data-step="2"]']
  1567. for(var i=0;i<otherArr.length;i++){
  1568. if (document.querySelector(otherArr[i])) document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
  1569. }
  1570. for(var i=0;i<nowArr.length;i++){
  1571. if (document.querySelector(nowArr[i])) document.querySelector(nowArr[i]).style.display = (type ? '' : 'none')
  1572. }
  1573. }
  1574. // 弹窗登录
  1575. function installAddEventListener () {
  1576. // tabbar toggle event
  1577. document.querySelector('.login-dig-tabbar-navbar').addEventListener('click', function (e) {
  1578. if (e.target.nodeName !== "SPAN") return
  1579. if (e.target.classList.contains('is-active')) {
  1580. return
  1581. }
  1582. if(e.target.innerText === '密码登录') {
  1583. // $('.code-bottom').hide()
  1584. $('.pass-bottom').show()
  1585. $('.line-box').addClass('pass-line-box')
  1586. } else {
  1587. $('.pass-bottom').hide()
  1588. // $('.code-bottom').show()
  1589. $('.line-box').removeClass('pass-line-box')
  1590. }
  1591. var SelectName = e.target.getAttribute('name')
  1592. document.querySelector('.login-dig-tabbar-navbar span.is-active').classList.toggle('is-active')
  1593. e.target.classList.toggle('is-active')
  1594. // content toggle
  1595. document.querySelector('.login-dig-tabbar-content.is-active').classList.toggle('is-active')
  1596. document.querySelector('.login-dig-tabbar-content[data-name="'+ SelectName +'"]').classList.toggle('is-active')
  1597. if (SelectName === 'pass' && Direct.instance.password) {
  1598. $('.login-dig-footer-box p').addClass('passTip')
  1599. var myEvent = new Event('blur')
  1600. Direct.instance.password.arr[0].el.dispatchEvent(myEvent)
  1601. Direct.instance.password.arr[1].el.dispatchEvent(myEvent)
  1602. } else {
  1603. $('.login-dig-footer-box p').removeClass('passTip')
  1604. }
  1605. })
  1606. installInputEvent()
  1607. }
  1608. // 初始化
  1609. function isCheckInit(type) {
  1610. if (type === 'forge') {
  1611. return document.querySelector('button[name="forge_submit_phone"]')
  1612. } else {
  1613. return document.querySelector('button[name="register_submit_phone"]')
  1614. }
  1615. }
  1616. function initDirect () {
  1617. // 初始化事件
  1618. installAddEventListener()
  1619. // 初始化倒计时
  1620. startTimeDown()
  1621. // 验证码登录
  1622. var verifySubmit = {
  1623. el: 'button[name="verify_submit"]',
  1624. arr: [],
  1625. init: function (arr) {
  1626. this.arr = arr
  1627. this.check()
  1628. var submitEle = document.querySelector(this.el)
  1629. submitEle.addEventListener('click', this.submit)
  1630. },
  1631. submit: function (e) {
  1632. var e = e.target
  1633. if (e.getAttribute('data-loading') === 'true') return
  1634. e.setAttribute('data-loading', 'true')
  1635. if(isBindPage){
  1636. trackClick('绑定-立即绑定')
  1637. } else {
  1638. trackClick('注册行为-登录/注册')
  1639. }
  1640. Direct.ajaxLoginSms(e, verifySubmit.arr)
  1641. },
  1642. check: function () {
  1643. var submitEle = document.querySelector(this.el)
  1644. var checkStauts = false
  1645. for(var i=0;i<this.arr.length;i++){
  1646. if (!this.arr[i].next) {
  1647. checkStauts = true
  1648. }
  1649. }
  1650. if (checkStauts) {
  1651. submitEle.setAttribute('disabled', checkStauts)
  1652. } else {
  1653. submitEle.removeAttribute('disabled')
  1654. }
  1655. }
  1656. }
  1657. var verifySendSms = {
  1658. el: '.login-dig-input-box span[data-name="verify_get_sms"]',
  1659. update: function (type) {
  1660. var Ele = document.querySelector(this.el)
  1661. if (type) {
  1662. Ele.classList.remove('is-stop')
  1663. } else {
  1664. if(isBindPage) {
  1665. Ele.classList.remove('is-stop')
  1666. } else {
  1667. Ele.classList.add('is-stop')
  1668. }
  1669. }
  1670. }
  1671. }
  1672. var verifyPhone = createFormStauts({
  1673. el: '.login-dig-input-box input[name="verify_phone"]',
  1674. rule: ruleForPhone,
  1675. event: ['input', 'blur'],
  1676. upStatus: function () {
  1677. verifySubmit.check()
  1678. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1679. }
  1680. })
  1681. var verifyCode = createFormStauts({
  1682. el: '.login-dig-input-box input[name="verify_code"]',
  1683. rule: ruleForCode,
  1684. event: ['input', 'blur'],
  1685. upStatus: function () {
  1686. verifySubmit.check()
  1687. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1688. }
  1689. })
  1690. var verifySms = createFormStauts({
  1691. el: '.login-dig-input-box input[name="verify_sms"]',
  1692. rule: ruleForSms,
  1693. event: ['input', 'blur'],
  1694. upStatus: function () {
  1695. verifySubmit.check()
  1696. }
  1697. })
  1698. verifySubmit.init([verifyPhone, verifyCode, verifySms])
  1699. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1700. Direct.verify = {
  1701. phone: verifyPhone,
  1702. code: verifyCode,
  1703. sms: verifySms
  1704. }
  1705. // 密码登录
  1706. var passSubmit = {
  1707. el: 'button[name="pass_submit"]',
  1708. arr: [],
  1709. init: function (arr) {
  1710. this.arr = arr
  1711. this.check()
  1712. var submitEle = document.querySelector(this.el)
  1713. submitEle.addEventListener('click', this.submit)
  1714. },
  1715. submit: function (e) {
  1716. var e = e.target
  1717. if (e.getAttribute('data-loading') === 'true') return
  1718. e.setAttribute('data-loading', 'true')
  1719. Direct.ajaxLoginPass(e, passSubmit.arr)
  1720. },
  1721. check: function () {
  1722. var submitEle = document.querySelector(this.el)
  1723. var checkStauts = false
  1724. for(var i=0;i<this.arr.length;i++){
  1725. if (!this.arr[i].next) {
  1726. checkStauts = true
  1727. }
  1728. }
  1729. if (checkStauts) {
  1730. submitEle.setAttribute('disabled', checkStauts)
  1731. } else {
  1732. submitEle.removeAttribute('disabled')
  1733. }
  1734. }
  1735. }
  1736. var passPhone = createFormStauts({
  1737. el: '.login-dig-input-box input[name="pass_phone"]',
  1738. rule: ruleForPhoneOrName,
  1739. event: ['input', 'blur'],
  1740. upStatus: function () {
  1741. passSubmit.check()
  1742. }
  1743. })
  1744. var passPass = createFormStauts({
  1745. el: '.login-dig-input-box input[name="pass_pass"]',
  1746. rule: ruleForPass,
  1747. event: ['input', 'blur'],
  1748. upStatus: function () {
  1749. passSubmit.check()
  1750. }
  1751. })
  1752. passSubmit.init([passPhone, passPass])
  1753. Direct.instance.password = passSubmit
  1754. // 设置密码
  1755. var setPassSubmit = {
  1756. el: 'button[name="set_pass_submit"]',
  1757. init: function (arr) {
  1758. this.arr = arr
  1759. this.check()
  1760. var submitEle = document.querySelector(this.el)
  1761. submitEle.addEventListener('click', this.submit)
  1762. },
  1763. submit: function (e) {
  1764. var e = e.target
  1765. if (e.getAttribute('data-loading') === 'true') return
  1766. trackClick('注册行为-设置密码-确定')
  1767. Direct.ajaxSetPassword(e, setPassSubmit.arr)
  1768. // e.setAttribute('data-loading', 'true')
  1769. // Direct.ajaxLoginPass(e, passSubmit.arr)
  1770. },
  1771. check: function () {
  1772. var submitEle = document.querySelector(this.el)
  1773. var checkStauts = false
  1774. for(var i=0;i<this.arr.length;i++){
  1775. if (!this.arr[i].next) {
  1776. checkStauts = true
  1777. }
  1778. }
  1779. if (checkStauts) {
  1780. submitEle.setAttribute('disabled', checkStauts)
  1781. } else {
  1782. if (this.arr[0].value !== this.arr[1].value) {
  1783. this.arr[1].showError('两次密码输入不一致')
  1784. } else {
  1785. submitEle.removeAttribute('disabled')
  1786. }
  1787. }
  1788. }
  1789. }
  1790. // 暂不设置密码,走登录成功步骤
  1791. var setPassCancel = {
  1792. el: 'button[name="set_pass_cancel"]',
  1793. init: function () {
  1794. var submitEle = document.querySelector(this.el)
  1795. submitEle.addEventListener('click', this.submit)
  1796. },
  1797. submit: function (e) {
  1798. trackClick('注册行为-设置密码-暂不订阅')
  1799. logic(Direct.loginInfo.userInfo,mynum);
  1800. },
  1801. }
  1802. var setInitPass = createFormStauts({
  1803. el: '.login-dig-input-box input[name="init_pass"]',
  1804. rule: ruleForPass,
  1805. event: ['input', 'blur'],
  1806. upStatus: function () {
  1807. setPassSubmit.check()
  1808. }
  1809. })
  1810. var setCheckPass = createFormStauts({
  1811. el: '.login-dig-input-box input[name="check_pass"]',
  1812. rule: ruleForPass,
  1813. event: ['input', 'blur'],
  1814. upStatus: function () {
  1815. setPassSubmit.check()
  1816. }
  1817. })
  1818. setPassSubmit.init([setInitPass, setCheckPass])
  1819. setPassCancel.init()
  1820. }
  1821. function initForgetDirect () {
  1822. // 判断是否需要初始化
  1823. if (!isCheckInit('forge')) return
  1824. // 初始化显示
  1825. toggleStep(true)
  1826. // 初始化倒计时
  1827. startTimeDown('forge')
  1828. // 手机验证
  1829. var verifySubmit = {
  1830. el: 'button[name="forge_submit_phone"]',
  1831. arr: [],
  1832. init: function(arr) {
  1833. this.arr = arr
  1834. this.check()
  1835. var submitEle = document.querySelector(this.el)
  1836. if (!submitEle) return
  1837. submitEle.addEventListener('click', this.submit)
  1838. },
  1839. submit: function (e) {
  1840. var e = e.target
  1841. if (e.getAttribute('data-loading') === 'true') return
  1842. e.setAttribute('data-loading', 'true')
  1843. Direct.ajaxStepOne(e, verifySubmit.arr)
  1844. },
  1845. check: function () {
  1846. var submitEle = document.querySelector(this.el)
  1847. if (!submitEle) return
  1848. var checkStauts = false
  1849. for(var i=0;i<this.arr.length;i++){
  1850. if (!this.arr[i].next) {
  1851. checkStauts = true
  1852. }
  1853. }
  1854. if (checkStauts) {
  1855. submitEle.setAttribute('disabled', checkStauts)
  1856. } else {
  1857. submitEle.removeAttribute('disabled')
  1858. }
  1859. }
  1860. }
  1861. var verifySendSms = {
  1862. el: '.login-dig-input-box span[data-name="forge_get_sms"]',
  1863. update: function(type) {
  1864. var Ele = document.querySelector(this.el)
  1865. if (type) {
  1866. Ele.classList.remove('is-stop')
  1867. } else {
  1868. Ele.classList.add('is-stop')
  1869. }
  1870. }
  1871. }
  1872. var verifyPhone = createFormStauts({
  1873. el: '.login-dig-input-box input[name="forge_phone"]',
  1874. rule: ruleForPhone,
  1875. event: ['input', 'blur'],
  1876. upStatus: function () {
  1877. verifySubmit.check()
  1878. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1879. }
  1880. })
  1881. var verifyCode = createFormStauts({
  1882. el: '.login-dig-input-box input[name="forge_code"]',
  1883. rule: ruleForCode,
  1884. event: ['input', 'blur'],
  1885. upStatus: function () {
  1886. verifySubmit.check()
  1887. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1888. }
  1889. })
  1890. var verifySms = createFormStauts({
  1891. el: '.login-dig-input-box input[name="forge_sms"]',
  1892. rule: ruleForSms,
  1893. event: ['input', 'blur'],
  1894. upStatus: function () {
  1895. verifySubmit.check()
  1896. }
  1897. })
  1898. verifySubmit.init([verifyPhone, verifyCode, verifySms])
  1899. verifySendSms.update(verifyCode.next && verifyPhone.next)
  1900. // 密码重置
  1901. var passSubmit = {
  1902. el: 'button[name="forge_submit_pass"]',
  1903. arr: [],
  1904. init: function(arr) {
  1905. this.arr = arr
  1906. this.check()
  1907. var submitEle = document.querySelector(this.el)
  1908. submitEle.addEventListener('click', this.submit)
  1909. },
  1910. submit: function (e) {
  1911. var e = e.target
  1912. if (e.getAttribute('data-loading') === 'true') return
  1913. e.setAttribute('data-loading', 'true')
  1914. Direct.ajaxStepTwo(e, passSubmit.arr)
  1915. },
  1916. check: function () {
  1917. var submitEle = document.querySelector(this.el)
  1918. var checkStauts = false
  1919. for(var i=0;i<this.arr.length;i++){
  1920. if (!this.arr[i].next) {
  1921. checkStauts = true
  1922. }
  1923. }
  1924. if (checkStauts) {
  1925. submitEle.setAttribute('disabled', checkStauts)
  1926. } else {
  1927. if (this.arr[0].value !== this.arr[1].value) {
  1928. this.arr[1].showError('两次密码输入不一致')
  1929. } else {
  1930. submitEle.removeAttribute('disabled')
  1931. }
  1932. }
  1933. }
  1934. }
  1935. var passPhone = createFormStauts({
  1936. el: '.login-dig-input-box input[name="forge_pass_one"]',
  1937. rule: ruleForPass,
  1938. event: ['input', 'blur'],
  1939. upStatus: function () {
  1940. passSubmit.check()
  1941. }
  1942. })
  1943. var passPass = createFormStauts({
  1944. el: '.login-dig-input-box input[name="forge_pass_two"]',
  1945. rule: ruleForPass,
  1946. event: ['input', 'blur'],
  1947. upStatus: function () {
  1948. passSubmit.check()
  1949. }
  1950. })
  1951. passSubmit.init([passPhone, passPass])
  1952. Direct.forge = {
  1953. phone: verifyPhone,
  1954. code: verifyCode
  1955. }
  1956. }
  1957. function initRegisterDirect () {
  1958. // 判断是否需要初始化
  1959. if (!isCheckInit('register')) return
  1960. // 初始化倒计时
  1961. startTimeDown('register')
  1962. // 手机验证
  1963. var verifySubmit = {
  1964. el: 'button[name="register_submit_phone"]',
  1965. arr: [],
  1966. init: function(arr) {
  1967. this.arr = arr
  1968. this.check()
  1969. var submitEle = document.querySelector(this.el)
  1970. if (!submitEle) return
  1971. submitEle.addEventListener('click', this.submit)
  1972. },
  1973. submit: function (e) {
  1974. var e = e.target
  1975. if (e.getAttribute('data-loading') === 'true') return
  1976. e.setAttribute('data-loading', 'true')
  1977. trackClick('注册行为-立即注册')
  1978. Direct.ajaxRegister(e, verifySubmit.arr)
  1979. },
  1980. check: function () {
  1981. var submitEle = document.querySelector(this.el)
  1982. if (!submitEle) return
  1983. var checkStauts = false
  1984. for(var i=0;i<this.arr.length;i++){
  1985. if (!this.arr[i].next) {
  1986. checkStauts = true
  1987. }
  1988. }
  1989. if (checkStauts) {
  1990. submitEle.setAttribute('disabled', checkStauts)
  1991. } else {
  1992. submitEle.removeAttribute('disabled')
  1993. }
  1994. }
  1995. }
  1996. var verifySendSms = {
  1997. el: '.login-dig-input-box span[data-name="register_get_sms"]',
  1998. update: function(type) {
  1999. var Ele = document.querySelector(this.el)
  2000. if (type) {
  2001. Ele.classList.remove('is-stop')
  2002. } else {
  2003. Ele.classList.add('is-stop')
  2004. }
  2005. }
  2006. }
  2007. var verifyPhone = createFormStauts({
  2008. el: '.login-dig-input-box input[name="register_phone"]',
  2009. rule: ruleForPhone,
  2010. event: ['input', 'blur'],
  2011. upStatus: function () {
  2012. verifySubmit.check()
  2013. verifySendSms.update(verifyCode.next && verifyPhone.next && verifyEnt.next)
  2014. }
  2015. })
  2016. var verifyCode = createFormStauts({
  2017. el: '.login-dig-input-box input[name="register_code"]',
  2018. rule: ruleForCode,
  2019. event: ['input', 'blur'],
  2020. upStatus: function () {
  2021. verifySubmit.check()
  2022. verifySendSms.update(verifyCode.next && verifyPhone.next)
  2023. }
  2024. })
  2025. var verifySms = createFormStauts({
  2026. el: '.login-dig-input-box input[name="register_sms"]',
  2027. rule: ruleForSms,
  2028. event: ['input', 'blur'],
  2029. upStatus: function () {
  2030. verifySubmit.check()
  2031. }
  2032. })
  2033. var verifyEnt = createFormStauts({
  2034. el: '.login-dig-input-box input[name="verify_entname"]',
  2035. rule: ruleForEnt,
  2036. event: ['input', 'blur'],
  2037. upStatus: function () {
  2038. verifySubmit.check()
  2039. verifySendSms.update()
  2040. }
  2041. })
  2042. var verifyEmail = createFormStauts({
  2043. el: '.login-dig-input-box .register_email',
  2044. event: ['input', 'blur'],
  2045. next: true,
  2046. upStatus: function () {
  2047. verifySubmit.check()
  2048. }
  2049. })
  2050. verifySubmit.init([verifyPhone, verifyCode, verifySms, verifyEnt, verifyEmail])
  2051. verifySendSms.update(verifyCode.next && verifyPhone.next && verifyEnt.next)
  2052. Direct.register = {
  2053. phone: verifyPhone,
  2054. code: verifyCode
  2055. }
  2056. }
  2057. });
  2058. // 注册埋点
  2059. function trackClick (c_type) {
  2060. if (!c_type) return
  2061. try {
  2062. clab_tracker.track('c_register', {
  2063. c_platform: 'pc',
  2064. c_type: c_type,
  2065. date: new Date()
  2066. })
  2067. } catch (error) {
  2068. console.dir(error)
  2069. }
  2070. }
  2071. // type: true登录后直接跳转工作桌面
  2072. function openLoginDig(type, redirectUrl,Logincallback) {
  2073. $('#bidLogin .logo').hide()
  2074. $('#bidLogin .bind-phone-head').hide()
  2075. $(".login-dig-tabbar-content.is-active .login-dig-input-box").show()
  2076. $('.login-auto-card').show()
  2077. if ($('#bidLogin').attr('data-name') === 'bind-phone') {
  2078. $("#bidLogin").removeAttr('data-name')
  2079. $('.login-dig-submit-button').removeClass('bindphonebtn')
  2080. $('.login-dig-submit-button:disabled').css('background', '#E0E0E0')
  2081. $('.login-dig-submit-button:disabled').css('opacity', '0.5')
  2082. $('.login-dig-submit-button').css('margin-bottom', '0')
  2083. $("#bidLogin .login-dig-submit-button[name='verify_submit']").text('登 录')
  2084. $(".login-dig-tabbar-content[data-name='code'] .login-dig-input-box").removeClass('is-error').children('input').val('')
  2085. }
  2086. var href = window.location.href;
  2087. var sourceStr =""
  2088. if (href.indexOf("/front/structed/pc_index.html?source=baidusem")>-1){//结构化数据
  2089. sourceStr="结构化数据-pc-baidusem";
  2090. }else if (href.indexOf("/bid/pc/page/bidfile_landpage?source=baidusem")>-1){//招标文件解读
  2091. sourceStr="招标文件解读-pc-baidusem";
  2092. }
  2093. if (sourceStr!=""){
  2094. try {
  2095. _hmt.push(['_trackEvent',sourceStr, 'click', "登录"]);
  2096. } catch (e) {
  2097. console.log('未初始化百度统计', e);
  2098. }
  2099. }
  2100. if (!window.__wait_listen_modal__) {
  2101. var verify_path = "/front/landpage/captcha?v="
  2102. $("#bidLogin .verify-img").attr("src", verify_path + new Date().getTime());
  2103. }
  2104. $("#bidLogin").modal("show");
  2105. try {
  2106. var injectLogic = logic
  2107. var link = [
  2108. '/jylab/supsearch/index.html',
  2109. '/jylab/entSearch/index.html',
  2110. '/jylab/purSearch/index.html',
  2111. '/search/issued'
  2112. ]
  2113. console.info(location)
  2114. logic = function (data, num) {
  2115. window.needToWork = Boolean(type)
  2116. if (data.result === 'ok') {
  2117. //判断是否需要设置cookie
  2118. if(data.cValue){
  2119. afterLoginSetCookit(data.cName,data.cValue,data.expires)
  2120. }
  2121. // 判断是否绑定手机号
  2122. if(!data.phone && data.openid) {
  2123. window.location.href = '/swordfish/frontPage/userMerge/sess/bind'
  2124. return
  2125. }
  2126. // 检查是否需要新窗口打开<新用户兴趣偏好设置页面>
  2127. checkNeedGoNewUserSettingPage()
  2128. try{
  2129. if(Logincallback){
  2130. Logincallback(data, num)
  2131. }
  2132. }catch(e){
  2133. }
  2134. // p415: 如果是在首页登录,需要刷新页面,以刷新页面用户信息卡片数据以及页面登录未登录下链接
  2135. // 改为跳转工作桌面,此处注释掉
  2136. // if (location.pathname === '/') {
  2137. // return location.reload()
  2138. // }
  2139. // p525 如果是豆丁过来的 跳转到工作桌面
  2140. if (getParam("partner")==="docin") {
  2141. location.href = '/page_workDesktop/'
  2142. return
  2143. }
  2144. if (redirectUrl === 'reload') {
  2145. return location.reload()
  2146. }
  2147. // 需要登陆后重定向的页面
  2148. if(redirectUrl){
  2149. location.href = redirectUrl
  2150. return
  2151. }
  2152. // 搜索页登录后返回当前页面
  2153. if(link.indexOf(location.pathname) > -1) {
  2154. location.href = location.pathname + location.search
  2155. return
  2156. }
  2157. if (needToWork) {
  2158. location.href = '/page_workDesktop/'
  2159. return
  2160. }
  2161. }
  2162. injectLogic(data, num)
  2163. }
  2164. } catch (e) {}
  2165. // 埋点
  2166. trackClick('注册行为-登录或注册弹窗')
  2167. }
  2168. function openBindPhoneDig() {
  2169. openLoginDigForWx(false);
  2170. $('#bidLogin .logo').hide()
  2171. $('#bidLogin .bind-phone-head').show()
  2172. $('.login-auto-card').hide()
  2173. if ($('#bidLogin').attr('data-name') !== 'bind-phone') {
  2174. $("#bidLogin").attr('data-name', 'bind-phone')
  2175. // $('.login-dig-submit-button:disabled').css('background', '#2CB7CA')
  2176. // $('.login-dig-submit-button:disabled').css('opacity', '0.5')
  2177. $('.login-dig-submit-button').css('margin-bottom', '12px')
  2178. $('.login-dig-submit-button').addClass('bindphonebtn')
  2179. $("#bidLogin .login-dig-submit-button[name='verify_submit']").text('立即绑定')
  2180. $(".login-dig-tabbar-content[data-name='code'] .login-dig-input-box").removeClass('is-error').children('input').val('')
  2181. $('.login-auto-card').show()
  2182. }
  2183. $("#bidLogin").modal("show");
  2184. }
  2185. // 密码切换显示/隐藏
  2186. function switchPassShow (e, str) {
  2187. e.preventDefault()
  2188. const type = $(str).attr('type')
  2189. if(type === 'password') {
  2190. $(str).attr('type', 'text')
  2191. } else {
  2192. $(str).attr('type', 'password')
  2193. }
  2194. }
  2195. function closeLoginDig() {
  2196. $("#bidLogin").modal("hide");
  2197. // window.location.reload()
  2198. }
  2199. function openLoginDigForWx (type) {
  2200. 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']
  2201. var wxArr = ['.login-dig-wx-qrcode-box', '.login-dig-top-back-box', '.code-bottom']
  2202. for(var i=0;i<otherArr.length;i++){
  2203. if (document.querySelector(otherArr[i])) {
  2204. document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
  2205. }
  2206. }
  2207. for(var i=0;i<wxArr.length;i++){
  2208. document.querySelector(wxArr[i]).style.display = (type ? '' : 'none')
  2209. }
  2210. $('.login-dig-footer-box p').removeClass('passTip')
  2211. }
  2212. function openLoginDigForReg (type) {
  2213. document.querySelector('.login-dig-tabbar-content').style.display = 'none'
  2214. document.querySelector('.login-dig-tabbar-content.is-active').style.display = 'none'
  2215. $('.login-dig-wx-qrcode-box').hide()
  2216. $('.login-dig-tabbar-navbar').hide()
  2217. $('.login-dig-reg').show()
  2218. $('.login-dig-footer-box').hide()
  2219. $('.login-auto-card').hide()
  2220. // 埋点
  2221. trackClick('注册行为-登录或注册弹窗')
  2222. }
  2223. function backLogin (type) {
  2224. 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']
  2225. for(var i=0;i<otherArr.length;i++){
  2226. if (document.querySelector(otherArr[i])) {
  2227. document.querySelector(otherArr[i]).style.display = (type ? 'none' : '')
  2228. }
  2229. }
  2230. $('.login-dig-reg').hide()
  2231. }
  2232. // 共三种登录。选择器要添加 sms-login / password-login / wx-qr-login 类名前缀限制
  2233. var loginDialog = {
  2234. init: function () {
  2235. this.initEvnets()
  2236. },
  2237. initEvnets: function () {
  2238. this.bindAutoLoginCheckboxEvent()
  2239. this.enterLoginAction()
  2240. },
  2241. bindKeepLoginQr: function () {
  2242. var payload = {
  2243. isAutoLogin: $('.auto-login-checkbox').hasClass('checked'),
  2244. // pageshareid: pageshareid,
  2245. // kopshareid: kopshareid,
  2246. loginER: [pageshareid, kopshareid].join('___')
  2247. }
  2248. $.ajax({
  2249. url: '/free/setKeepLogin',
  2250. method: 'POST',
  2251. async: true,
  2252. data: payload
  2253. })
  2254. },
  2255. chcekBindKeep: function (dom) {
  2256. var $parent = $(dom).parents('.login-module-card')
  2257. var isWxQrLogin = $parent.hasClass('wx-qr-login')
  2258. if (isWxQrLogin) {
  2259. this.bindKeepLoginQr()
  2260. }
  2261. },
  2262. bindAutoLoginCheckboxEvent: function () {
  2263. var _this = this
  2264. $('.auto-login-container').on('click', 'label, .auto-login-checkbox',function () {
  2265. // 手机号验证码自动登录、手机号密码自动登录、微信 下次自动登录 状态分离
  2266. // var $parent = $(this).parents('.auto-login-container')
  2267. // $parent.find('.auto-login-checkbox').toggleClass('checked')
  2268. // $parent.find('.auto-login-container').toggleClass('checked')
  2269. // _this.chcekBindKeep(this)
  2270. // 手机号验证码自动登录、手机号密码自动登录、微信 下次自动登录 状态同步
  2271. $('.auto-login-checkbox').toggleClass('checked')
  2272. $('.auto-login-container').toggleClass('checked')
  2273. _this.bindKeepLoginQr()
  2274. })
  2275. $('.auto-login-container').on('mouseover', '.icon-tip-container,.j-tooltip',function () {
  2276. var $parent = $(this).parents('.auto-login-container')
  2277. $parent.find('.icon-tip').addClass('highlight')
  2278. $parent.find('.j-tooltip').show()
  2279. }).on('mouseleave', '.icon-tip-container,.j-tooltip',function () {
  2280. var $parent = $(this).parents('.auto-login-container')
  2281. $parent.find('.icon-tip').removeClass('highlight')
  2282. $parent.find('.j-tooltip').hide()
  2283. })
  2284. },
  2285. enterLoginAction: function () {
  2286. $('.sms-login .enter-action-login').on('keydown', function (e) {
  2287. if (e.keyCode === 13) {
  2288. // 触发点击事件
  2289. $('.sms-login .login-dig-submit-button[name=verify_submit]').trigger('click')
  2290. }
  2291. })
  2292. $('.password-login .enter-action-login').on('keydown', function (e) {
  2293. if (e.keyCode === 13) {
  2294. // 触发点击事件
  2295. $('.password-login .login-dig-submit-button[name=pass_submit]').trigger('click')
  2296. }
  2297. })
  2298. }
  2299. }
  2300. $(function () {
  2301. loginDialog.init()
  2302. $('#bidLogin').on('hide.bs.modal', function () {
  2303. backLogin(false)
  2304. })
  2305. })