var MSG_BAR_Slider=function(opts){var init=function(opts){this.conf=this._extends({wrap:'slider',itemClass:'slider_item',startOn:0,slideBy:1,speed:6,isVertical:false,isLoop:true,autoPlay:true,autoInterval:3,onReady:function(states){},onAniStart:function(states){},onAniEnd:function(states){},onEdge:function(states){}},opts);this._initDoms();this._initStates();this._initEvents();this._launch()};init.prototype={_id:function(id){return document.getElementById(id)},_class:function(searchClass,node,tag){var classElements=[],els,elsLen,pattern;if(node===null)node=document.body;if(tag===null)tag='*';if(node.getElementsByClassName){return node.getElementsByClassName(searchClass)}els=node.getElementsByTagName('*');elsLen=els.length;pattern=new RegExp("(^|\\s)"+searchClass+"(\\s|$)");for(i=0;i'+inner+''+inner+''):inner;initStr='
'+itemsStr+'
';wrap.innerHTML=initStr;aniWrap=wrap.getElementsByTagName('div')[0];aniWrap.style.position='relative';items=this._class(c.itemClass,wrap);for(var i=0,itemsLen=items.length;i30){this.prev();s.deltaDis1=0}else{this._slideToCss3(s.curIdx)}s.touched=false},_moveToEle:function(to,isOffset,onMoveEnd){var that=this,c=this.conf,d=this.doms,s=this.states,curIdx=s.curIdx,toIdx=isOffset?curIdx+to:to,aniWrap=d.aniWrap,items=d.items,toItem=items[toIdx],css3Prop=this._css3Prop(),toPos,toPosStr;if(to!==curIdx){c.onIndexChanged&&c.onIndexChanged.call(this,to)}toPos=-s.itemPos[toIdx];toPosStr=c.isVertical?('translate3d(0,'+toPos+'px,0)'):('translate3d('+toPos+'px,0,0)');if(css3Prop.vendor!==false){if(s.animating){aniWrap.removeEventListener(css3Prop.transitionEnd,s.onTransitionEnd,false)}aniWrap.style[css3Prop.transition]='all 0s ease-out';aniWrap.style[css3Prop.transform]=toPosStr;s.curIdx=toIdx;setTimeout(function(){onMoveEnd&&onMoveEnd.call(that)},20)}else{aniWrap.style[s.cssProterty]=toPos+'px';s.curIdx=toIdx;onMoveEnd&&onMoveEnd.call(this)}},_moveToPX:function(toPX,isOffset,onMoveEnd){var that=this,c=this.conf,d=this.doms,s=this.states,aniWrap=d.aniWrap,items=d.items,toItem=items[toIdx],css3Prop=this._css3Prop(),toPos,toPosStr},_slideToCss3:function(fIndex){var that=this,c=this.conf,d=this.doms,s=this.states,items=d.items,aniWrap=d.aniWrap,css3Prop=this._css3Prop(),toPos,toPosStr;aniWrap.style[css3Prop.transition]=s.transitionAni;toPos=c.isVertical?-items[fIndex].offsetTop:-items[fIndex].offsetLeft;toPosStr=c.isVertical?('translate3d(0,'+toPos+'px,0)'):('translate3d('+toPos+'px,0,0)');aniWrap.style[css3Prop.transform]=toPosStr;if(s.animating){aniWrap.removeEventListener(css3Prop.transitionEnd,s.onTransitionEnd,false)}aniWrap.style[css3Prop.transform]=toPosStr;aniWrap.addEventListener(css3Prop.transitionEnd,s.onTransitionEnd,false);s.curIdx=fIndex},_slideToTdt:function(to){var that=this,c=this.conf,d=this.doms,s=this.states,aniWrap=d.aniWrap,cssProterty=s.cssProterty,duration=s.duration*1000,now=s.now,wrapSize=s.wrapSize,movedPos;if(s.to===null||s.to==to){s.fromPos=-s.curIdx*wrapSize}else{s.fromPos=s.movedPos;s.now=0}if(duration-now<20){aniWrap.style[cssProterty]=-to*wrapSize+'px';s.curIdx=to;clearTimeout(this.aniInterval);this.aniInterval=null;s.now=0;s.to=null;s.fromPos=-s.curIdx*wrapSize;s.movedPos=null;c.onAniEnd&&c.onAniEnd.call(this);s.animating=false;return}movedPos=this._easeOut(now,s.fromPos,-to*wrapSize-s.fromPos,duration);aniWrap.style[cssProterty]=movedPos+'px';s.now+=20;s.movedPos=movedPos;this.aniInterval=setTimeout(function(){that._slideToTdt(to)},20)},prev:function(){var c=this.conf,d=this.doms,s=this.states,curIdx=s.curIdx,toIdx;if(c.isLoop&&curIdx===0){this._moveToEle(s.total/2,false,function(){toIdx=s.curIdx-c.slideBy;this.slideTo(toIdx)})}else{toIdx=s.curIdx-c.slideBy;this.slideTo(toIdx)}},next:function(){var c=this.conf,d=this.doms,s=this.states,curIdx=s.curIdx,toIdx;if(c.isLoop&&curIdx===s.total-1){this._moveToEle(s.total/2-1,false,function(){toIdx=s.curIdx+c.slideBy;this.slideTo(toIdx)})}else{toIdx=s.curIdx+c.slideBy;this.slideTo(toIdx)}},slideByEle:function(offset){var toIdx=this.states.curIdx+offset;this.slideTo(toIdx)},slideTo:function(i){var that=this,c=this.conf,d=this.doms,s=this.states,curIdx=s.curIdx,total=s.total,css3Prop=this._css3Prop(),fnlIndex,cssProterty;fnlIndex=(i>total-1)?i%total:(i<0?(total+i%total):i);if(fnlIndex===curIdx){return}c.onIndexChanged&&c.onIndexChanged.call(this,fnlIndex);s.animating=true;if(c.autoPlay){this.autoSlide(true)}c.onAniStart&&c.onAniStart.call(this);if(css3Prop.vendor!==false){this._slideToCss3(fnlIndex)}else{this._slideToTdt(fnlIndex)}},autoSlide:function(enable){var that=this;if(this._auto){clearInterval(this._auto);this._auto=null}if(enable){this._auto=setInterval(function(){that.next()},this.conf.autoInterval*1000)}},refresh:function(conf){var that=this,c=this.conf,d=this.doms,s=this.states,css3Prop=this._css3Prop(),wrapSize;wrapSize=c.isVertical?this._getElSize(d.wrap).h:this._getElSize(d.wrap).w;s.slidePX=wrapSize*c.slideBy;if(s.animating){s.onTransitionEnd()}d.aniWrap.style[css3Prop.transition]='all 0s ease-out';this._moveToEle(s.curIdx)},destroy:function(){}};return init}(); //增加广播机制 var SFA__EventCenter = { events: {}, on: function(eventName, callback) { if (!this.events[eventName]) { this.events[eventName] = []; } this.events[eventName].push(callback); }, trigger: function(eventName, data) { if (this.events[eventName]) { this.events[eventName].forEach(function(callback) { callback(data); }); } } }; //特殊卡片 // (function(){ // var style = document.createElement('style'); // // 定义样式规则 // style.innerHTML = ` // .new-promt-banner img { // width: 100%; // display:block; // } // .new-promt-banner{ // margin-top: 20px; // box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); // margin-bottom:20px!important; // } // `; // document.head.appendChild(style); // // 创建一个新的div元素 // var newDiv = document.createElement('div'); // newDiv.className = 'new-promt-banner'; // // 创建一个新的img元素 // var newImg = document.createElement('img'); // // 设置img元素的src属性,这里需要替换为你想要的图片地址 // newImg.src = 'https://n.sinaimg.cn/finance/cece9e13/20250514/newBanner.png'; // // 将img元素添加到div元素中 // newDiv.appendChild(newImg); // // 获取class为main-article-body的元素,这里假设页面上只有一个这样的元素 // var mainArticleBody = document.body.querySelector('.main-article-body'); // // 如果main-article-body存在,则将新创建的div插入到最后 // if (mainArticleBody) { // // mainArticleBody.appendChild(newDiv); // mainArticleBody.insertAdjacentElement('afterend', newDiv); // //增加曝光 // try { // //添加callupbrowser // var _bname = SinaFinanceCallUp.util.checkUA.getCallupBrowserName(); // var _callupbname = {callupbrowser:_bname}; // var _json = JSON.stringify(_callupbname); // // 创建一个 Intersection Observer 实例 // const observer = new IntersectionObserver((entries) => { // entries.forEach(entry => { // if (entry.isIntersecting) { // SinaFinanceCallUp.Track.sendSudaExt({ // uaTrackKey:'callup_finance_app', // uaTrackValue:'cj_j10banner_exp', // uaTrackExt:_json // }) // } else { // } // }); // }, { // root: null, // 默认为视口 // rootMargin: '0px', // threshold: 0.6 // 目标元素可见比例达到 10% 时触发回调 // }); // // 选择要观察的目标元素 // const target = document.querySelector('.new-promt-banner'); // // 开始观察目标元素 // observer.observe(target); // // SUDA.uaTrack('callup_finance_app','cj_j10banner_exp') // } catch (error) { // } // newDiv.onclick = function() { // var sfc = new SinaFinanceCallUp.CallUpSinaFinance({ // needOpenSource: false, // eventid: 'callup_finance_app' // }); // sfc.tryDirectCall({ // callpagetype: '17', // url: 'https://finance.sina.cn/2025-05-14/detail-inewpmqu9250914.d.html', // position: 'cj_j10banner' // }); // }; // } // })(); //头条APP 新闻弹窗 (function() { var API = 'https://interface.sina.cn/finance/cjtop/app_tt_topnews.d.json'; function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } function dTos(d_, joinStr, isUTC_, ny_, nm_, nd_) { void 0 === joinStr && (joinStr = "-"); var arr = []; return ny_ || arr.push(d_[isUTC_ ? "getUTCFullYear" : "getFullYear"]()), nm_ || (ny_ = d_[isUTC_ ? "getUTCMonth" : "getMonth"]() + 1, arr.push(ny_ < 10 ? "0" + ny_ : ny_)), nd_ || (nm_ = d_[isUTC_ ? "getUTCDate" : "getDate"](), arr.push(nm_ < 10 ? "0" + nm_ : nm_)), arr.join(joinStr) } function newCallup() { new SinaFinanceCallUp.CallUpSinaFinance({ eventid: "callup_finance_app", uatrackKey: "callup_finance_app", needOpenSource: !1 }).tryDirectCall({ newSchemaParams: { client_path: "/app/home", tab: 'news',//不可修改, subTab: 'news_focus',//头条, }, position: "news_popa_click" }) } function getJSONP(url, data, callbackName) { const finalCallbackName = callbackName || `callback${(Math.random() * 1e12).toFixed(0)}` return new Promise((resolve) => { var script = document.createElement('script') url += `?callback=${finalCallbackName}` if (data) { Object.keys(data).forEach(key => { url += `&${key}=${data[key]}` }) } script.src = url document.head.appendChild(script) window[finalCallbackName] = function (data) { resolve(data) } script.parentNode.removeChild(script) }) } function parseDateInfo(dateStr) { // 创建 Date 对象(自动识别 ISO 格式) const date = new Date(dateStr); // 检查是否为有效日期 if (isNaN(date.getTime())) { throw new Error('无效的日期字符串'); } // 获取月和日,补零处理 const month = String(date.getMonth() + 1).padStart(2, '0'); // getMonth() 返回 0-11 const day = String(date.getDate()).padStart(2, '0'); // 构造 MM/dd 字符串 const mmdd = `${month}/${day}`; // 星期映射数组(getDay() 返回 0=星期日, 1=星期一, ..., 6=星期六) const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; const weekday = weekdays[date.getDay()]; return { mmdd, weekday }; } function init() { var ed = JSON.parse(window.localStorage.getItem("toutiaocjpage")); const _curEd = dTos(new Date); if (!/doubao/i.test(navigator.userAgent.toLocaleLowerCase())){ if (ed&&ed.date === _curEd) { SFA__EventCenter.trigger('no_toutiao_cj_page'); } else{ getJSONP(API, { // __jsonp:true }).then((d) => { console.log(d); if(d&&d.result&&d.result.data&&d.result.data.length>0){ console.log(parseDateInfo(d.result.time)); const __parseDateInfo = parseDateInfo(d.result.time); const __mmdd = __parseDateInfo.mmdd; const __weekday = __parseDateInfo.weekday; const htmlTemplate = '
  • @index@@title@
  • '; let htmlOutput = ''; d.result.data.forEach((item, index) => { htmlOutput += htmlTemplate.replace('@index@', index + 1).replace('@title@', item.title); }); // 插入 CSS 样式 var style = document.createElement('style'); style.innerHTML = `/* 遮罩层 */ .SFA--TTCJ--modal-mask {display: block; /* 默认隐藏 */ position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.3); z-index: 100002;} /* 弹窗容器 */ .SFA--TTCJ--modal-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 5.74rem; max-width: 400px; background:linear-gradient(180deg, #FFD8D8, #ffffff) top / 100% 1.26rem no-repeat, #ffffff; border-radius: .24rem; padding: .4rem; z-index: 9999; box-sizing: border-box; } /* 头部:标题 + 日期 */ .SFA--TTCJ--header { display: flex; justify-content: space-between; align-items: flex-start; } .SFA--TTCJ--title { font-size: .34rem; font-weight: bold; color: #333; } .SFA--TTCJ--date { text-align: right; color: #666; } .SFA--TTCJ--md { display: block; font-size: .3rem; color: #333; font-weight: bold; } .SFA--TTCJ--week { font-size: .2rem; color: #8F8F8F; margin-top: .1rem;display:block;} /* 搜索栏 */ .SFA--TTCJ--search-bar { display: flex; align-items: center; background-color: #F40000; width: 3.46rem; height: .54rem; border-radius: .27rem; box-sizing: border-box; margin-bottom: .26rem; } .SFA--TTCJ--search-bar img{width: 100%;} .SFA--TTCJ--search-logo { width: 24px; height: 24px; margin-right: 6px; } .SFA--TTCJ--search-input { width: 1.95rem; height: .42rem; box-sizing: border-box; flex-grow: 1; border: none; border-radius: 15px; background-color: white; color: #333; font-size: 14px; outline: none; } .SFA--TTCJ--search-icon { color: white; font-size: 18px; margin-left: 6px; } /* 新闻列表 */ .SFA--TTCJ--news-list { list-style: none; padding: 0; margin: 0; } .SFA--TTCJ--news-item { background-color: #F7F7F7; padding: .2rem .28rem; margin-bottom: .2rem; border-radius: .11rem; display: flex; align-items: center; height: 1.2rem; box-sizing: border-box; } .SFA--TTCJ--news-item:last-child{margin-bottom: 0;} .SFA--TTCJ--number { font-size: .36rem; font-weight: bold; text-align: center; margin-right: .28rem; } .SFA--TTCJ--news-item:nth-child(1) .SFA--TTCJ--number { color: #FB2F3B; } .SFA--TTCJ--news-item:nth-child(2) .SFA--TTCJ--number { color: #FF7500; } .SFA--TTCJ--news-item:nth-child(3) .SFA--TTCJ--number { color: #FFB237; } .SFA--TTCJ--news-text { font-size: 15px; line-height: 1.4; color: #333; word-break: break-word; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } /* 按钮 */ .SFA--TTCJ--action-btn { width: 100%; background-color: #F40000; color: white; font-size: .34rem; font-weight: bold; height: .8rem; line-height: .8rem; border: none; border-radius: .4rem; cursor: pointer; margin-top: .4rem; } .SFA--TTCJ--action-btn:hover { background-color: #d00000; } .sft-popup1-close { background-image: url(//n.sinaimg.cn/finance/cece9e13/20251021/pop_main_close_2x.png); background-repeat: no-repeat; background-size: .6rem auto; width: .6rem; height: .6rem; right: 0rem; top: -.8rem; position: absolute; }`; document.body.appendChild(style); const temp = document.createElement("div"); temp.innerHTML = `
    今日热点聚焦
    ${__mmdd} ${__weekday}
      ${htmlOutput}
    `; //遍历data,生成 ul内容 document.body.appendChild(temp); sendSuda('callup_finance_app','news_popa_exp'); ed = { date:_curEd } window.localStorage.setItem("toutiaocjpage", JSON.stringify(ed)), !function() { const panel = document.querySelector(".SFA--TTCJ--modal-mask"); document.querySelector(".sft-popup1-close").addEventListener("click", function(event) { event.stopPropagation(); sendSuda('callup_finance_app','news_popa_off'); panel.style.display = "none" }); document.querySelector(".SFA--TTCJ--modal-container").addEventListener("click", function() { newCallup() }) }() } }); } } } window.__TOUTIAO__CJ__PAGE = {}; __TOUTIAO__CJ__PAGE.init = init; })(); //站内信卡片 (function(){ /* 根据域名、浏览器控制出现位置、样式、插入元素位置 */ //var API = '//app.finance.sina.com.cn/wap/push/list'; // var API = '//push.cj.sina.cn/msg/wap/push/list'; // var API = '//push.cj.sina.cn/msg/wap/push/v2/list' var API = '//hq.sinajs.cn/format=text&list=wap_push_list' var TITID = 'wap_msg_tit'; var WAPID = 'w-afc488ca5783e605'; var txtID = 'wap_msg_txt_'; var btnID = 'wap_msg_btn_'; var CloseID = 'wap_msg_close_btn'; var MSG_UNREAD = 'SFA_WapMsgUnread'; var Click_ID = 'SFA_WapMsgClickID'; //卡片样式Dom var TPL= '
    \ \ \
    \

    @title@

    \

    @source@@time@

    \
    \ \
    '; //底部小卡Dom var TPL_small = '
    \
    \
    快讯
    \

    @title@

    \

    @time@

    \
    \
    '; //轮播的DOM var TPL_item = '
    \ \
    \

    @title@

    \

    @source@@time@@cmnt@

    \
    \ \
    ' //轮播的外层DOM var TPL_WAP = '\
    @c-98edbb4cb9566d03Item@
    \
    '; //2024.8.12 新版卡片,百度内使用 var TPL_item_baidu = '
    \
    \

    APP专享@title@

    \

    @source@@time@@cmnt@

    \
    \
    ' var TPL_WAP_baidu = '
    \
    @c-98edbb4cb9566d03Item@
    \
    '; //顶部出现卡片的css var $css = '.s-71678c9f46d6a250{position: fixed; left: 50%; right: 0; width: 100vw; z-index: 100000;@posValue@;transition-duration:.5s;transition-timing-function: ease;max-width: var(--page-max-width);transform: translateX(-50%);} .wap-msg-bar{position: relative; display: flex; height: 1.68rem; background: #fff; box-shadow: 0 0.08rem .16rem rgba(0,0,0,.1);align-items: center;} .wap-msg-bar-logo{margin-left: 0rem; width: 0.8rem; height: .8rem; background: url(//n.sinaimg.cn/finance/cj/kandian/images/logo.png) no-repeat center center; background-size: 0.8rem 0.8rem;position:relative;} .wap-msg-bar-con{margin-left: 0.24rem;max-width: 4.3rem;display: flex;flex-direction: column;align-items: flex-start;text-align: justify;justify-content: center;padding-bottom:.15rem;} .wap-msg-bar-con .wap-msg-bar-tit{display: -webkit-box;width: 4.4rem;text-align: left; -webkit-line-clamp: 1; /* 限制高度 */ -webkit-box-orient: vertical; overflow-y: hidden; /* 超出就隐藏 */font-size: .26rem;line-height: .44rem;color: #333;} .wap-msg-bar-btn{position: absolute; top: 50%; margin-top: -0.31rem; right: 0.24rem;} .wap-msg-bar-btn .open-sfa-btn{display: block; width: 1.5rem; height: 0.62rem; line-height: .62rem; background: #508CEE; border-radius: 999px; text-align: center; font-family: PingFangSC-Medium; font-size: .26rem; color: #fff; font-weight: 500;} .wap-msg-bar-show{top: 0;}.w-39497a62f1f0c7fb{width:.28rem;display: flex;justify-content: center;align-items: center;position:absolute;top:0;left:0;z-index:1;}.close-msgbar-btn{background: url(//n.sinaimg.cn/finance/cece9e13/20240506/close-msgbar-btn3.png) no-repeat center center; background-size: 0.32rem 0.32rem;width:.28rem;height:.28rem;display:block;text-indent:-999em;}.wap-msg-bar-info{font-size:.2rem;color:#9A9EAD;margin-top:.1rem;}.wap-msg-bar-time{margin-left:.2rem;}.unread-num{display:block;height:.16rem;border-radius:.2rem;padding:0 0.09rem;color:#fff;font-size:.2rem;line-height:.16rem;right:-.03rem;top:-.03rem;position:absolute;background-color:#FD4331;font-weight:bold;text-align:center;}.hide-unread-num{display:none;}.unread-num-round{border-radius:50%;padding:0;width:.16rem;text-align:center;}.m-stock-scroll{display:none!important;}.s-71678c9f46d6a250-bottom{box-shadow: 0 -0.08rem .16rem rgba(0,0,0,.1)}.c-98edbb4cb9566d03{position:relative;width:100vw;height:1.26rem;overflow:hidden;max-width: var(--page-max-width);}.c-98edbb4cb9566d03 .wap-msg-bar{float:left;width:100vw;height:1.26rem;-webkit-transform:translate3d(0,0,0);padding:0.2rem;box-sizing:border-box;width:100vw;max-width:var(--page-max-width)}.hd_slider_dot{height:.1rem;position:absolute;bottom:.12rem;text-align:center;width:100%;}.hd_slider_dot .dot_list{display:inline-block;background:#E5E6F2;width:.2rem;height:.04rem;border-radius:.1rem;margin:04px;}.hd_slider_dot .dot_list_cur{background:#9A9EAD;}.js-guss-caijing{bottom:1.8rem!important;}'; //底部卡片的css var $css_bottom = '.s-71678c9f46d6a250{position: fixed; left: 50%; right: 0; width: 100vw; z-index: 100001;@posValue@;transition-duration:.5s;transition-timing-function: ease;max-width: var(--page-max-width);transform: translateX(-50%);} .wap-msg-bar{position: relative; display: flex; height: 1.68rem; background: #fff; box-shadow: 0 -0.08rem .16rem rgba(0,0,0,.1);align-items: center;} .wap-msg-bar-logo{margin-left: 0rem; width: 0.8rem; height: .8rem; background: url(//n.sinaimg.cn/finance/cj/kandian/images/logo.png) no-repeat center center; background-size: 0.8rem 0.8rem;position:relative;} .wap-msg-bar-con{margin-left: 0.24rem;max-width: 4.3rem;display: flex;flex-direction: column;align-items: flex-start;text-align: justify;justify-content: center;padding-bottom:.15rem;} .wap-msg-bar-con .wap-msg-bar-tit{display: -webkit-box;width: 4.4rem;text-align: left; -webkit-line-clamp: 1; /* 限制高度 */ -webkit-box-orient: vertical; overflow-y: hidden; /* 超出就隐藏 */font-size: .26rem;line-height: .44rem;color: #333;} .wap-msg-bar-btn{position: absolute; top: 50%; margin-top: -0.31rem; right: 0.24rem;} .wap-msg-bar-btn .open-sfa-btn{display: block; width: 1.5rem; height: 0.62rem; line-height: .62rem; background: #508CEE; border-radius: 999px; text-align: center; font-family: PingFangSC-Medium; font-size: .26rem; color: #fff; font-weight: 500;} .wap-msg-bar-show{top: 0;}.w-39497a62f1f0c7fb{width:.28rem;display: flex;justify-content: center;align-items: center;position:absolute;top:0;left:0;z-index:1;}.close-msgbar-btn{background: url(//n.sinaimg.cn/finance/cece9e13/20240506/close-msgbar-btn3.png) no-repeat center center; background-size: 0.32rem 0.32rem;width:.28rem;height:.28rem;display:block;text-indent:-999em;}.wap-msg-bar-info{font-size:.2rem;color:#9A9EAD;margin-top:.1rem;}.wap-msg-bar-time{margin-left:.2rem;}.unread-num{display:block;height:.16rem;border-radius:.2rem;padding:0 0.09rem;color:#fff;font-size:.2rem;line-height:.16rem;right:-.03rem;top:-.03rem;position:absolute;background-color:#FD4331;font-weight:bold;text-align:center;}.hide-unread-num{display:none;}.unread-num-round{border-radius:50%;padding:0;width:.16rem;text-align:center;}.m-stock-scroll{display:none!important;}.js-guss-caijing{bottom:2.1rem!important;}.s-71678c9f46d6a250-bottom{box-shadow: 0 -0.08rem .16rem rgba(0,0,0,.1)}.c-98edbb4cb9566d03{position:relative;width:100vw;height:1.26rem;overflow:hidden;max-width: var(--page-max-width);}.c-98edbb4cb9566d03 .wap-msg-bar{float:left;width:100vw;height:1.26rem;-webkit-transform:translate3d(0,0,0);padding:0.2rem;box-sizing:border-box;width:100vw;max-width:var(--page-max-width)}.hd_slider_dot{height:.1rem;position:absolute;bottom:.12rem;text-align:center;width:100%;}.hd_slider_dot .dot_list{display:inline-block;background:#E5E6F2;width:.2rem;height:.04rem;border-radius:.1rem;margin:04px;}.hd_slider_dot .dot_list_cur{background:#9A9EAD;}'; //baidu 的css var $css_baidu = '.s-71678c9f46d6a250{position: relative; left: 50%; right: 0; width: 100vw; z-index: 99;max-width: var(--page-max-width);transform: translateX(-50%);} .wap-msg-bar{position: relative; display: flex; height: 1.68rem; background: #fff; align-items: center;border-radius:.08rem;} .wap-msg-bar-logo{margin-left: 0rem; width: 0.8rem; height: .8rem; background: url(//n.sinaimg.cn/finance/cj/kandian/images/logo.png) no-repeat center center; background-size: 0.8rem 0.8rem;position:relative;} .wap-msg-bar-con{margin-left: 0rem;display: flex;flex-direction: column;align-items: flex-start;text-align: justify;justify-content: center;} .wap-msg-bar-con .wap-msg-bar-tit{width: 6.4rem;text-align: left;font-size: .26rem;line-height: .44rem;color: #333;margin-bottom:0!important;} .wap-msg-bar-btn{position: absolute; top: 50%; margin-top: -0.31rem; right: 0.24rem;} .wap-msg-bar-btn .open-sfa-btn{display: block; width: 1.5rem; height: 0.62rem; line-height: .62rem; background: rgba(252,44,8,.1); border-radius: 999px; text-align: center; font-family: PingFangSC-Medium; font-size: .26rem; color: #FC2C08; font-weight: 500;} .wap-msg-bar-show{top: 0;}.w-39497a62f1f0c7fb{width:.28rem;display: flex;justify-content: center;align-items: center;position:absolute;top:0;left:0;z-index:1;}.close-msgbar-btn{background: url(//n.sinaimg.cn/finance/cece9e13/20240506/close-msgbar-btn3.png) no-repeat center center; background-size: 0.32rem 0.32rem;width:.28rem;height:.28rem;display:block;text-indent:-999em;}.wap-msg-bar-info{font-size:.2rem;color:#9A9EAD;text-indent:1.1rem;line-height:.28rem}.wap-msg-bar-time{margin-left:.2rem;}.unread-num{display:block;height:.16rem;border-radius:.2rem;padding:0 0.09rem;color:#fff;font-size:.2rem;line-height:.16rem;right:-.03rem;top:-.03rem;position:absolute;background-color:#FD4331;font-weight:bold;text-align:center;}.hide-unread-num{display:none;}.unread-num-round{border-radius:50%;padding:0;width:.16rem;text-align:center;}.m-stock-scroll{display:none!important;}.s-71678c9f46d6a250-bottom{box-shadow: 0 -0.08rem .16rem rgba(0,0,0,.1)}.c-98edbb4cb9566d03{position:relative;width:100vw;height:1.26rem;overflow:hidden;margin-bottom:0!important;max-width: var(--page-max-width);}.c-98edbb4cb9566d03 .wap-msg-bar{float:left;width:6.9rem;height:1.26rem;-webkit-transform:translate3d(0,0,0);padding:0.2rem;box-sizing:border-box;width:100vw;max-width:var(--page-max-width)}.hd_slider_dot{height:.34rem;position:absolute;bottom:0rem;text-align:center;width:100%;line-height:.34rem}.hd_slider_dot .dot_list{display:inline-block;background:#E7E7E7;width:.1rem;height:.1rem;border-radius:.1rem;margin:0.05rem;}.hd_slider_dot .dot_list_cur{background:#ED4F3D;}.js-guss-caijing{bottom:1.8rem!important;}.tag-jx{font-style:normal;background:#FF5400;color:#fff;font-size:.2rem;font-weight:bold;border-radius:.06rem;display:inline-block;width:.96rem;height:.3rem;line-height:.3rem;text-align:center;margin-right:.1rem;}.c-98edbb4cb9566d03 div{margin-bottom:0!important;}.module-article{padding-bottom:.25rem;}.s-71678c9f46d6a250-inside-guba{width:100vw;left:50%;transform:translateX(-50%);overflow:hidden;margin-bottom:.2rem;}.s-71678c9f46d6a250-inside-guba .wap-msg-bar{width:100vw;border-radius:0;}.s-71678c9f46d6a250-inside-guba .wap-msg-bar-con .wap-msg-bar-tit{width:6.9rem;text-overflow: ellipsis;}.span-ellipsis{white-space:nowrap;text-overflow:ellipsis;display:block;overflow:hidden;}.s-71678c9f46d6a250-inside{position:relative;}.s-71678c9f46d6a250-inside .c-98edbb4cb9566d03{width:6.9rem;}'; //底部小卡的css var $css_small = '.m-stock-scroll{display:none!important;} .s-71678c9f46d6a250{position: fixed;bottom: -.1rem;left: 0;right: 0;width: 100%;height: .84rem;box-shadow: 0 -4px 8px 0 rgba(0,0,0,0.07);background-color: #fff;transition-duration:.5s;transition-timing-function: ease;} .wap-msg-bar-con{display: flex;justify-content: space-between;padding: 0 .2rem;align-items: center;height: .84rem;} .wap-msg-bar-con .wap-msg-bar-tit{display: block;width: 4.8rem;text-align: left; font-size: .28rem;color: #333;overflow: hidden;text-overflow: ellipsis;margin-left: .15rem;white-space: nowrap;} .wap-msg-bar-con .wap-msg-bar-tag{display: inline-block;background: linear-gradient(to right,#4D74FD,#A6B0FF);width: .72rem;height: .4rem;border-radius: .06rem;text-align: center;line-height: .4rem;color: #fff;font-size: .24rem;font-weight: bold;position: relative;} .wap-msg-bar-con .wap-msg-bar-tag::after{display: block;content: "";position: absolute;width: .12rem;height: .12rem;background-color: #FD4331;border-radius: 50%;right: -0.04rem;top: -0.04rem;} .wap-msg-bar-info{font-size:.24rem;color:#9A9EAD;margin-left: .24rem;}.module-article .m-guss-caijing{bottom:2.1rem!important;}.wap-msg-bar-time{white-space: nowrap;}' //20241022 增加ipad兼容 /* $css = $css + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-71678c9f46d6a250,.m-sentiment-blk {\ transform:scale(0.73);-ms-transform:scale(0.73);-moz-transform:scale(0.73);-webkit-transform:scale(0.73);-o-transform:scale(0.73);\ }\ }' $css_bottom = $css_bottom + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-71678c9f46d6a250,.m-sentiment-blk {\ transform:scale(0.73);-ms-transform:scale(0.73);-moz-transform:scale(0.73);-webkit-transform:scale(0.73);-o-transform:scale(0.73);\ }\ }' $css_baidu = $css_baidu + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-71678c9f46d6a250,.m-sentiment-blk {\ transform:scale(0.73);-ms-transform:scale(0.73);-moz-transform:scale(0.73);-webkit-transform:scale(0.73);-o-transform:scale(0.73);\ }\ }' */ function loadCss(css){ var $cssdom = document.createElement("style") $cssdom.innerHTML = css; document.body.appendChild($cssdom) } function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } function getJSONP(url, data, callbackName) { const finalCallbackName = callbackName || `callback${(Math.random() * 1e12).toFixed(0)}` return new Promise((resolve) => { var script = document.createElement('script') url += `?callback=${finalCallbackName}` if (data) { Object.keys(data).forEach(key => { url += `&${key}=${data[key]}` }) } script.src = url document.head.appendChild(script) window[finalCallbackName] = function (data) { resolve(data) } script.parentNode.removeChild(script) }) } function loadScript(url, config){ return new Promise((resolve, reject) => { var _script=document.createElement("script"); _script.type="text/javascript"; _script.src=url; var _timeout = setTimeout(function(){ reject('timeout') },config.timeout||5000); _script.onload = function(){ clearTimeout(_timeout); document.getElementsByTagName("head")[0].removeChild(_script); resolve(); } _script.onerror = function(){ reject(); } document.getElementsByTagName("head")[0].appendChild(_script); }) } function checkMsg(id){ var _tit = document.getElementById(TITID); var _id = _tit.getAttribute('data-msgid'); var ret = false; if(id==_id){ ret = true; }else{ ret = false; } return ret; } function animate(element, property, targetValue, duration, callback) { var startValue = parseFloat(getComputedStyle(element)[property]); var distance = targetValue - startValue; var startTime = null; function step(currentTime) { if (!startTime) { startTime = currentTime; } var elapsedTime = currentTime - startTime; var progress = Math.min(elapsedTime / duration, 1); var currentValue = startValue + distance * progress; element.style[property] = currentValue + 'px'; if (progress < 1) { requestAnimationFrame(step); } else { callback(); } } requestAnimationFrame(step); } //手指上滑 function bindSlideUp(ele,id){ var element = ele; var startY, currentY; element.addEventListener('touchstart', function(event) { startY = event.touches[0].clientY; }); element.addEventListener('touchmove', function(event) { currentY = event.touches[0].clientY; var distanceY = currentY - startY; if((distanceY<0&&msgCardInfo.slideHide=='up')||(distanceY>0&&msgCardInfo.slideHide=='down')){ element.style.transform = 'translateY(' + distanceY + 'px)'; } }); element.addEventListener('touchend', function(event) { //如果移动大于一半隐藏 var height = element.offsetHeight; var translateY = parseInt(element.style.transform.replace('translateY(', '').replace('px)', '')); if (Math.abs(translateY) > height / 2) { element.style.transform = 'translateY(-' + height + 'px)'; setTimeout(function() { SetClickId(id); element.style.display = 'none'; // element.parentNode.removeChild(element); }, 500); } else { element.style.transform = 'translateY(0)'; } }); }; //添加一个消息卡片 function appendCard(d,id){ var _TPL = msgCardInfo.tpl; var _mid = d.data.mid || ''; // var _msgId = d.data.id; var _msgId = id; var _res_time = new Date(d.res_time.replace(/-/g,'/')); var _pushTime = new Date(d.data.pushTime.replace(/-/g,'/')); var _time = formatTimeDiff(_pushTime,_res_time); var _source = d.data.source || '新浪财经快讯'; var _unread = getUnreadMessageCount(d.res_time.split(' ')[0]); var _formatUnread = _unread<=0?'':_unread>99?'99+':_unread; var _unreadClass= _unread==0?'hide-unread-num':_unread<10?'unread-num-round':''; var _tempTitle = ''; _tempTitle = d.data.type-0==19?d.data.content:d.data.title; _title = _TPL.replace(/@title@/g,_tempTitle).replace(/@id@/g,d.data.id).replace(/@type@/g,d.data.type).replace(/@url@/g,d.data.url).replace(/@mid@/g,_mid).replace(/@time@/g,_time).replace(/@source@/g,_source).replace(/@unread@/g,_formatUnread).replace(/@unreadClass@/g,_unreadClass); var $div = document.createElement("div"); $div.innerHTML = _title; $div.className = 's-71678c9f46d6a250'+' s-71678c9f46d6a250-'+msgCardInfo.cssName; $div.id = WAPID+'_'+_msgId; if(msgCardInfo.targetObj==document.body){ document.body.appendChild($div); }else{ msgCardInfo.targetObj.parentNode.insertBefore($div, msgCardInfo.targetObj); } // if(msgCardInfo.type=='small'){ // var targetElement = document.getElementById('m_stock_scroll'); // 获取目标元素 // if(targetElement){ // // 在目标元素之前插入新的div元素 // } // } SetClickId(id); } //添加消息轮播 function appendCardList(d,id){ var _Wap_TPL,_TPL; if(isBaidu()){ _Wap_TPL = TPL_WAP_baidu; _TPL = TPL_item_baidu; }else{ _Wap_TPL = TPL_WAP; _TPL = TPL_item; } var _title = ''; var _slideDom = ''; if(d&&d.data&&d.data.length>0){ for(var i=0;i99?'99+':_unread; var _unreadClass= _unread==0?'hide-unread-num':_unread<10?'unread-num-round':''; var _cmnt = _tempDataItem.comment==0?'':_tempDataItem.comment+'条评论' var _tempTitle = ''; _tempTitle = _tempDataItem.type-0==19?_tempDataItem.content:_tempDataItem.title; _title += _TPL.replace(/@title@/g,_tempTitle).replace(/【/g,'').replace(/】/g,'').replace(/@id@/g,_tempDataItem.id).replace(/@type@/g,_tempDataItem.type).replace(/@url@/g,_tempDataItem.url).replace(/@mid@/g,_mid).replace(/@time@/g,_time).replace(/@source@/g,_source).replace(/@unread@/g,_formatUnread).replace(/@unreadClass@/g,_unreadClass).replace(/@cmnt@/g,_cmnt); } } _slideDom = _Wap_TPL.replace(/@c-98edbb4cb9566d03Item@/g,_title).replace(/@id@/g,id); var $div = document.createElement("div"); $div.innerHTML = _slideDom; $div.className = 's-71678c9f46d6a250'+' s-71678c9f46d6a250-'+msgCardInfo.cssName; $div.id = WAPID+'_'+_msgId; //20240812 增加插入dom的形式 if(msgCardInfo.appendPosition=='notFixed'){ msgCardInfo.targetObj.insertAdjacentElement('afterend',$div); }else{ if(msgCardInfo.targetObj==document.body){ document.body.appendChild($div); }else{ msgCardInfo.targetObj.parentNode.insertBefore($div, msgCardInfo.targetObj); } } var slide_01 = new MSG_BAR_Slider({ wrap : 'c-98edbb4cb9566d03_'+id, itemClass : 'wap-msg-bar', startOn : 0, // startOnPX : 300, slideBy : 1, // slidePX : 400, speed : 3, isVertical : false, isLoop : true, autoPlay : true, autoInterval : 5, onReady : function () { var that = this, total = this.conf.isLoop ? this.states.total / 2 : this.states.total, dots = this._id('hd_slider_dot_'+id), dotCls = '', dotsStr = ''; // 点阵 for(var i = 0; i < total; i ++){ dotCls = i == 0 ? 'dot_list dot_list_cur' : 'dot_list'; dotsStr += ''; } dots.innerHTML = dotsStr; this.doms.dots = dots.getElementsByTagName('span'); }, onAniStart : function () {}, onAniEnd : function () {}, onIndexChanged : function (index) { var that = this, dots = this.doms.dots, total = this.conf.isLoop ? this.states.total / 2 : this.states.total; for(var i = 0; i < total; i ++){ dots[i].className = 'dot_list'; } dots[index % total].className = 'dot_list dot_list_cur'; }, onEdge : function (isLeft) {} }); // if(msgCardInfo.type=='small'){ // var targetElement = document.getElementById('m_stock_scroll'); // 获取目标元素 // if(targetElement){ // // 在目标元素之前插入新的div元素 // } // } SetClickId(id); } // 获取当天未读消息数量 function getUnreadMessageCount(dataStr) { var _storageName = MSG_UNREAD+dataStr; var count = localStorage.getItem(_storageName); return count ? parseInt(count) : 0; } // 增加当天未读消息数量 function increaseUnreadMessageCount(dataStr,type) { var _storageName = MSG_UNREAD+dataStr; var count = getUnreadMessageCount(dataStr); var _dif = type=='add'?1:-1; if(type=='all'){ _dif = 0-count; } localStorage.setItem(_storageName, count + _dif); } //记录当前ID function SetClickId(id) { var _storageName = Click_ID; localStorage.setItem(_storageName, id); } function GetClickId() { var _storageName = Click_ID; var _clickId = localStorage.getItem(_storageName); return _clickId; } // 清除昨天未读消息数量 // function clearYesterdayUnreadMessageCount(dataStr) { // var yesterday = new Date(dataStr); // yesterday.setDate(yesterday.getDate() - 1); // var year = yesterday.getFullYear(); // var month = yesterday.getMonth() + 1; // var day = yesterday.getDate(); // var yesterdayStr = year + '-' + month + '-' + day; // var _storageName = MSG_UNREAD+yesterdayStr; // localStorage.removeItem(_storageName); // } function clearYesterdayUnreadMessageCount(dataStr) { try { Object.keys(localStorage).forEach(key => { if (key.indexOf(MSG_UNREAD)==0) { // 提取日期部分(假设格式为 MSG_UNREADYYYY-M-D) const storageDateStr = key.replace(MSG_UNREAD, ''); const storageDate = new Date(storageDateStr.replace(/-/g,'/')); const today = new Date(dataStr); if (storageDate < today) { // 如果是今天之前的日期 localStorage.removeItem(key); } } }); } catch (error) { } } function setTitleShow(ele,callback){ var _des = 0; //曝光打点 try { sendSuda('callup_finance_app','exp_wap_message') } catch (error) {} if(msgCardInfo.targetObj != document.body){ _des = msgCardInfo.targetObj.offsetHeight; } // var _tit = document.querySelector('.s-71678c9f46d6a250'); animate(ele,msgCardInfo.cssName,_des,500,function(){ //console.log('done'); callback&&callback(); }) } function hideTitleShow(ele,callback){ var height = ele.offsetHeight; //曝光打点 try { sendSuda('callup_finance_app','hide_wap_message') } catch (error) {} // var _tit = document.querySelector('.s-71678c9f46d6a250'); animate(ele,msgCardInfo.cssName,0-height,500,function(){ //console.log('done'); callback&&callback(); }) } function formatTimeDiff(startTime, endTime) { var diff = Math.floor((endTime - startTime) / 1000); // 将时间差转换为秒数 if (diff < 60) { return diff + '秒前'; } else if (diff < 3600) { return Math.floor(diff / 60) + '分钟前'; } else if (diff < 86400) { return Math.floor(diff / 3600) + '小时前'; } else { return Math.floor(diff / 86400) + '天前'; } } //获取数据,如果id改变则插入一个新的消息卡片,单卡片暂时用不到 function getWapMsgData(){ var _title = ''; getJSONP(API, { __jsonp:true }).then((d) => { if(d&&d.status==true&&d.data){ if(d.data.title&&d.data.title!=''){ //插入 try { var _mid = d.data.mid || ''; var _msgId = d.data.id; var _clickId = GetClickId(); // var _msgId = new Date().getTime(); if(document.getElementById(WAPID+'_'+_msgId)!=null||(_clickId&&_clickId==_msgId)){ }else{ if(msgCardInfo.showUnread==true){ //获取当前的日期; var _curDate = d.res_time; var _curDateStr = _curDate.split(' ')[0]; clearYesterdayUnreadMessageCount(_curDateStr); //未读数+1 increaseUnreadMessageCount(_curDateStr,'add'); } //插入一条 appendCard(d,_msgId); var _newCard = document.getElementById(WAPID+'_'+_msgId); setTitleShow(_newCard,function(){ var _oldCard = document.querySelectorAll('.s-71678c9f46d6a250'); if(_oldCard.length>0){ for(var i =0;i<_oldCard.length;i++){ if(_oldCard[i].id!=WAPID+'_'+_msgId){ _oldCard[i].parentNode.removeChild(_oldCard[i]); } } } }); _newCard.addEventListener('click', function(event) { // 获取触发事件的元素 var target = event.target; // 判断是否是目标元素 if (target.matches('.js-msg-callup')) { if(msgCardInfo.showUnread==true){ // 处理事件 increaseUnreadMessageCount(_curDateStr,'all'); // 全部清空 //修改dom var _unread = getUnreadMessageCount(_curDateStr); var _formatUnread = _unread<=0?'':_unread>99?'99+':_unread; var _unreadObj = document.querySelector('#'+WAPID+'_'+_msgId+' .unread-num'); if(_formatUnread==''){ _unreadObj.className = 'unread-num hide-unread-num'; }else{ _unreadObj.className = 'unread-num'; _unreadObj.innerHTML = _formatUnread; } } callupSFA(TITID+'_'+d.data.id); SetClickId(d.data.id); if(msgCardInfo.hideAfterClick==true){ hideTitleShow(_newCard,function(){ var _newCard = document.getElementById(WAPID+'_'+_msgId); _newCard.style.display = 'none'; }); } } }); if(msgCardInfo.slideHide!=''){ //绑定滑动事件 bindSlideUp(_newCard,d.data.id); } if(msgCardInfo.showClose==true){ //关闭窗口 var _closeBtn = document.getElementById(CloseID+'_'+d.data.id); if(_closeBtn){ _closeBtn.onclick = function(){ increaseUnreadMessageCount(_curDateStr,'all'); hideTitleShow(_newCard,function(){ var _newCard = document.getElementById(WAPID+'_'+_msgId); SetClickId(_msgId); _newCard.style.display = 'none'; }); } } } } } catch (error) { //console.log(error) } } } }); } //20240430 获取多条数据 function getWapMsgDataList(){ //外层不再有id,因为常在 var _title = ''; loadScript(API, { // __jsonp:true }).then(() => { var d = wap_push_list; if(d&&d.data&&d.data.length>0){ //插入外层 try { // var _msgId = d.data.id; var _clickId = GetClickId(); var _msgId = new Date().getTime(); if(document.getElementById(WAPID+'_'+_msgId)!=null||(_clickId&&_clickId==_msgId)){ }else{ if(msgCardInfo.showUnread==true){ //获取当前的日期; var _curDate = d.res_time; var _curDateStr = _curDate.split(' ')[0]; clearYesterdayUnreadMessageCount(_curDateStr); //未读数+1 increaseUnreadMessageCount(_curDateStr,'add'); } //插入一条 var _newCard; if(!isBaidu()){ appendCardList(d,_msgId); _newCard = document.getElementById(WAPID+'_'+_msgId); setTitleShow(_newCard,function(){ var _oldCard = document.querySelectorAll('.s-71678c9f46d6a250'); if(_oldCard.length>0){ for(var i =0;i<_oldCard.length;i++){ if(_oldCard[i].id!=WAPID+'_'+_msgId){ _oldCard[i].parentNode.removeChild(_oldCard[i]); } } } }); }else{ var _oldCard = document.querySelectorAll('.s-71678c9f46d6a250'); if(_oldCard.length>0){ for(var i =0;i<_oldCard.length;i++){ if(_oldCard[i].id!=WAPID+'_'+_msgId){ _oldCard[i].parentNode.removeChild(_oldCard[i]); } } } appendCardList(d,_msgId); _newCard = document.getElementById(WAPID+'_'+_msgId); } _newCard.addEventListener('click', function(event) { // 获取触发事件的元素 var target = event.target; var _newsId = target.getAttribute('data-msgid'); // 判断是否是目标元素 if (target.matches('.js-msg-callup')) { if(msgCardInfo.showUnread==true){ // 处理事件 increaseUnreadMessageCount(_curDateStr,'all'); // 全部清空 //修改dom var _unread = getUnreadMessageCount(_curDateStr); var _formatUnread = _unread<=0?'':_unread>99?'99+':_unread; var _unreadObj = document.querySelector('#'+WAPID+'_'+_msgId+' .unread-num'); if(_formatUnread==''){ _unreadObj.className = 'unread-num hide-unread-num'; }else{ _unreadObj.className = 'unread-num'; _unreadObj.innerHTML = _formatUnread; } } callupSFA(TITID+'_'+_newsId); // callupSFA(target.id); SetClickId(_msgId); if(msgCardInfo.hideAfterClick==true){ hideTitleShow(_newCard,function(){ var _newCard = document.getElementById(WAPID+'_'+_msgId); _newCard.style.display = 'none'; }); } } }); if(msgCardInfo.slideHide!=''){ //绑定滑动事件 // bindSlideUp(_newCard,d.data.id); } if(msgCardInfo.showClose==true){ //关闭窗口 var _closeBtn = document.getElementById(CloseID+'_'+_msgId); if(_closeBtn){ _closeBtn.onclick = function(){ increaseUnreadMessageCount(_curDateStr,'all'); hideTitleShow(_newCard,function(){ var _newCard = document.getElementById(WAPID+'_'+_msgId); SetClickId(_msgId); _newCard.style.display = 'none'; }); } } } } } catch (error) { //console.log(error) } } }); } //呼端 function callupSFA(id){ var _tit = document.getElementById(id); //console.log(id); var _url = _tit.getAttribute('data-url'); var _type = _tit.getAttribute('data-type'); // var _id = _tit.getAttribute('data-msgid'); var _position = msgCardInfo.simaPosition; var _config = {}; if(_type==1){ _config = { position: _position, newSchemaParams: { client_path: '/news/newsdetails', //不可修改, url: _url, //不可修改, } } }else{ var _mid = _tit.getAttribute('data-mid'); _config = { position: _position, newSchemaParams: { client_path: '/news/newsdetails', //不可修改, mid: _mid, //不可修改, } } } sfc.tryDirectCall(_config); } var sfc = new SinaFinanceCallUp.CallUpSinaFinance({ needOpenSource: false, eventid: 'callup_finance_app' }); //safari不执行 function isSafari() { var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('safari') !== -1 && ua.indexOf('chrome') === -1; } function isWeixin(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('micromessenger') !== -1 ; } function isWeibo(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('weibo') !== -1 ; } function isSinaFinance(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('sinafinance') !== -1 ; } function isBaidu(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('baidu') !== -1 ; } function isToutiao(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('newsarticle') !== -1 ; } function canShowMsgBar(){ /*展示逻辑: 1、若cj正文页有相关股票模块(如浏览器访问cj正文页),替换为WAP-push(cj正文页样式) 2、若cj正文页无相关股票模块(如微信、微博),WAP-push用第一版,只不过从底部弹出 3、WAP-push第一版从顶部弹出的样式,沿用在股市汇首页、详情页,wap.cj域名页面 eventid:callup_finance_app position:wap_message pos_name:wap站内信(guba/wap.cj域名顶部弹出) 【cj正文页的点】 eventid:callup_finance_app position:wap_message_cj pos_name:wap站内信(浏览器访问cj正文页) 【底部弹出的点】 eventid:callup_finance_app position:wap_message_bottom pos_name:wap站内信(底部弹出-微博微信cj正文页) */ //返回对象:是否可以展示,展示类型,对象dom var ret = {}; ret.refreshTime = 60; ret.canShow = false; var _host = window.location.host; // if(_host=='10.222.38.57'){ // var isTest = true; // ret.refreshTime = 60; // } if((_host=='cj.sina.cn')&&!isWeixin()&&!isWeibo()&&!isSinaFinance()&&!isBaidu()&&!isToutiao()){ //头条文章 非微信 非微博,小卡片 底部 // ret.tpl = TPL_small; // ret.css = $css_small; ret.tpl = TPL_item; ret.css = $css_bottom; ret.showUnread = true; ret.showClose = true; ret.slideHide = ''; // ret.targetObj = document.querySelector('.module-comment-bar'); ret.targetObj = document.body; // ret.posValue = ''; ret.posValue = '-1.9rem;'; ret.cssName = 'bottom'; ret.hideAfterClick = false; ret.canShow = true; ret.simaPosition = 'wap_message_cj'; } if((_host=='cj.sina.cn')&&(isWeixin()||isWeibo())&&!isSinaFinance()&&!isBaidu()&&!isToutiao()){ //头条文章 微信 微博,大卡片形式,底部弹出 ret.tpl = TPL; ret.css = $css; ret.showUnread = true; ret.showClose = true; ret.slideHide = 'down'; ret.targetObj = document.body; // ret.type = 'small'; ret.posValue = '-1.9rem;'; ret.cssName = 'bottom'; ret.hideAfterClick = true; ret.canShow = true; ret.simaPosition = 'wap_message_bottom'; } if((_host=='wap.cj.sina.cn'||_host=='guba.sina.cn')&&!isSinaFinance()&&!isBaidu()){ //顶部出现,大卡片形式 ret.tpl = TPL; ret.css = $css; ret.showUnread = true; ret.showClose = true; ret.slideHide = 'down'; ret.targetObj = document.body; // ret.type = 'normal'; ret.posValue = '-1.9rem;'; ret.cssName = 'bottom'; ret.hideAfterClick = true; ret.canShow = false;//20240829 隐藏 ret.simaPosition = 'wap_message'; } if((_host=='finance.sina.cn')&&!isSinaFinance()){ //财首底部出现,大卡片形式 ret.tpl = TPL; ret.css = $css; ret.showUnread = true; ret.showClose = true; ret.slideHide = 'down'; ret.targetObj = document.body; // ret.type = 'normal'; ret.posValue = '-1.9rem;'; ret.cssName = 'bottom'; ret.hideAfterClick = true; ret.canShow = true;//20240829 隐藏 0919 恢复 ret.simaPosition = 'wap_message_cs'; } //20240812 百度app内展示卡片型 站内信 if((_host=='cj.sina.cn')&&isBaidu()){ //财首底部出现,大卡片形式 ret.tpl = TPL; ret.css = $css_baidu; ret.showUnread = false; ret.showClose = false; ret.slideHide = ''; ret.targetObj = document.querySelector('.main-article-body'); // ret.type = 'normal'; ret.posValue = ''; ret.cssName = 'inside'; ret.hideAfterClick = false; ret.canShow = true; ret.simaPosition = 'wap_message_page'; //20240812 新增 ret.appendPosition = 'notFixed'; } //20240820 guba // if((_host=='guba.sina.cn')&&isBaidu()&&(location.href.indexOf('//guba.sina.cn/list_')>-1)){ if((_host=='guba.sina.cn')&&isBaidu()&&(location.href.indexOf('list_')>-1)){ //财首底部出现,大卡片形式 ret.tpl = TPL; ret.css = $css_baidu; ret.showUnread = false; ret.showClose = false; ret.slideHide = ''; ret.targetObj = document.querySelector('.s-tabs.s-tabs-1'); // ret.type = 'normal'; ret.posValue = ''; ret.cssName = 'inside-guba'; ret.hideAfterClick = false; ret.canShow = true; ret.simaPosition = 'wap_message_page'; //20240812 新增 ret.appendPosition = ''; } return ret; }; try { var msgCardInfo = canShowMsgBar(); var _currentCss = msgCardInfo.css; if(msgCardInfo.posValue!=''&&msgCardInfo.css){ _currentCss = msgCardInfo.css.replace(/@posValue@/g,msgCardInfo.cssName+':'+msgCardInfo.posValue); } loadCss(_currentCss); if(msgCardInfo.canShow){ try { document.getElementById('subPage_bottom_callup_btn').style.bottom = '2.1rem'; } catch (error) { } getWapMsgDataList(); setInterval(function(){ try { getWapMsgDataList(); } catch (error) { //console.log(error) } },1000*msgCardInfo.refreshTime); } } catch (error) { } })(); //新版本弹窗 ~(function(doc, win) { try { function __isToutiao__() { return /newsarticle/i.test(navigator.userAgent.toLowerCase()) } // function __isDouyin__() { // return /bytedance/i.test(navigator.userAgent.toLowerCase()) // } function __isByteDance__() { return /bytedance/i.test(navigator.userAgent.toLowerCase()) } function __isDouyin__() { var _isByteDance = __isByteDance__(), _isNewsArticle = __isToutiao__(); //var ua = this._UA; if (_isByteDance&&!_isNewsArticle) { return true; } else { return false; } // return /bytedance/i.test(navigator.userAgent.toLowerCase()) } var __blackLists__ = [ "google.com", "bing.com", "baidu.com", "sogou.com", "sm.cn", "m.sm.cn", "so.com", "so.m.sm.cn", "so.toutiao.com", "easou.com" ]; var __toutiaoLists__ = [ "so.toutiao.com" ] function __isCheckReferrer__(list_) { return new RegExp(list_.join("|")).test(document.referrer); } function isPcAndScreenWidthGreaterThan750() { // 判断是否为PC端 var isPc = !navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i); // 获取屏幕宽度 var screenWidth = window.innerWidth; // 判断是否为PC端且屏幕宽度大于750像素 if (isPc && screenWidth > 750) { return true; // 是PC端且屏幕宽度大于750像素 } else { return false; // 不是PC端或屏幕宽度不大于750像素 } } //20240808 function getSystem() { var ua = navigator.userAgent.toLowerCase(); if (ua.match(/iphone|ipod|ipad/ig)) { return 'ios'; } else if(ua.match(/android/ig)){ return 'android'; }else{ return 'other'; } } var cookieUtil = { escape: function(s_) { return s_.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1"); }, get: function(key_) { var value = document.cookie.match( "(?:^|;)\\s*" + this.escape(key_) + "=([^;]*)" ); return value ? value[1] || "" : ""; }, set: function(k_, v_, op_) { !op_ && (op_ = {}); if (!v_) { v_ = ""; op_.expires = -1; } var expires = ""; if ( op_.expires && (Number(op_.expires) || op_.expires.toUTCString) ) { var date; if (Number(op_.expires)) { date = new Date(); date.setTime(date.getTime() + op_.expires * 1000); } else { date = op_.expires; } expires = "; expires=" + date.toUTCString(); } var path = op_.path ? "; path=" + op_.path : ""; var domain = op_.domain ? "; domain=" + op_.domain : ""; var secure = op_.secure ? "; secure" : ""; document.cookie = [k_, "=", v_, expires, path, domain, secure].join( "" ); } }; var cookieName = 'SFA_version'; var mk = "mk" //window.__market__?window.__market__:"hs" var $dom = ''; var $domBottomBar = ''; // if(!isBottomTPL()){ $dom = ''; // }else{ //baidu 底部弹窗形式dom $domBottomBar = ''; // } var $css = ''; var $cssBottomBar = ''; // if(!isBottomTPL()){ if(isPcAndScreenWidthGreaterThan750()==true){ $css = '.s-55a5528c72fe53b2{background:rgba(0,0,0,0.70);position:fixed;top:0;bottom:0;left:0;right:0;z-index:100022} .s-55a5528c72fe53b2 .snp-container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);background:url(//n.sinaimg.cn/finance/cece9e13/20230419/wap_pop_main_back.png) 0 0 no-repeat;border-radius:.2rem;width:5.4rem;height:6.68rem;background-size: 5.4rem auto;box-sizing: border-box;padding-top: 1.24rem;} .s-55a5528c72fe53b2 .snp-container .snp-tit{width:100%;height:.67rem;padding-left:.32rem;display: flex;justify-content: flex-start;align-items: center;} .s-55a5528c72fe53b2 .snp-container .snp-app-new{font-size: .34rem;font-weight: bold;} .s-55a5528c72fe53b2 .snp-container .snp-app-ver{font-size: .2rem;font-weight: bold;color: #fff;background-color: #598AFD;height: .4rem;line-height: .4rem;padding: 0 .15rem;border-radius: .2rem;margin-left: .1rem;} .s-55a5528c72fe53b2 .snp-container .snp-new-tip{padding: 0 .4rem;margin-top: .34rem;height: 3rem;overflow-y: auto;} .s-55a5528c72fe53b2 .snp-container .snp-tip-text{text-align: justify;font-size: .28rem;line-height: .44rem;color: #333;} .s-55a5528c72fe53b2 .container .snp-bar{margin-top:.3rem;width:100%;height:.8rem;line-height:.8rem;display:flex;display:-webkit-flex;justify-content:center;align-items:center;text-align:center} .s-55a5528c72fe53b2 .snp-container .snp-bar{margin-top: .24rem;} .s-55a5528c72fe53b2 .snp-container .snp-bar .snp-btn-download-new{border-radius:.4rem;width:4.6rem;height:.76rem;color:#fff;background-color: #598AFD;font-size: .3rem;line-height: .76rem;text-align: center;margin: 0 auto;} .snp-btn-close-new{display: block;background: url(//n.sinaimg.cn/finance/cece9e13/20230419/pop_main_close_2x.png) 0 0 no-repeat;width: .24rem;height: .24rem;background-size: .24rem auto;position: absolute;right: .28rem;top: .28rem;text-indent: -999em;}.item-update{display: block;line-height: .4rem;position: relative;margin-bottom:.2rem}'; $css = $css + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-55a5528c72fe53b2 .snp-container {\ transform:translate(-50%,-50%) scale(0.7);-ms-transform:translate(-50%,-50%) scale(0.7);-moz-transform:translate(-50%,-50%) scale(0.7);-webkit-transform:translate(-50%,-50%) scale(0.7);-o-transform:translate(-50%,-50%) scale(0.7);\ }\ }' }else{ $css = '.s-55a5528c72fe53b2{background:rgba(0,0,0,0.70);position:fixed;top:0;bottom:0;left:0;right:0;z-index:100022} .s-55a5528c72fe53b2 .snp-container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);background:url(//n.sinaimg.cn/finance/cece9e13/20230419/wap_pop_main_back.png) 0 0 no-repeat;border-radius:2.6666666666666665vw;width:72vw;height:89.06666666666666vw;background-size: 72vw auto;box-sizing: border-box;padding-top: 16.533333333333335vw;} .s-55a5528c72fe53b2 .snp-container .snp-tit{width:100%;height:8.933333333333334vw;padding-left:4.266666666666667vw;display: flex;justify-content: flex-start;align-items: center;} .s-55a5528c72fe53b2 .snp-container .snp-app-new{font-size: 4.533333333333333vw;font-weight: bold;} .s-55a5528c72fe53b2 .snp-container .snp-app-ver{font-size: 2.6666666666666665vw;font-weight: bold;color: #fff;background-color: #598AFD;height: 5.333333333333333vw;line-height: 5.333333333333333vw;padding: 0 2vw;border-radius: 2.6666666666666665vw;margin-left: 1.3333333333333333vw;} .s-55a5528c72fe53b2 .snp-container .snp-new-tip{padding: 0 5.333333333333333vw;margin-top: 4.533333333333333vw;height: 40vw;overflow-y: auto;} .s-55a5528c72fe53b2 .snp-container .snp-tip-text{text-align: justify;font-size: 3.733333333333334vw;line-height: 5.866666666666666vw;color: #333;} .s-55a5528c72fe53b2 .container .snp-bar{margin-top:4vw;width:100%;height:10.666666666666666vw;line-height:10.666666666666666vw;display:flex;display:-webkit-flex;justify-content:center;align-items:center;text-align:center} .s-55a5528c72fe53b2 .snp-container .snp-bar{margin-top: 3.2vw;} .s-55a5528c72fe53b2 .snp-container .snp-bar .snp-btn-download-new{border-radius:5.333333333333333vw;width:61.33333333333332vw;height:10.133333333333333vw;color:#fff;background-color: #598AFD;font-size: 4vw;line-height: 10.133333333333333vw;text-align: center;margin: 0 auto;} .snp-btn-close-new{display: block;background: url(//n.sinaimg.cn/finance/cece9e13/20230419/pop_main_close_2x.png) 0 0 no-repeat;width: 3.2vw;height: 3.2vw;background-size: 3.2vw auto;position: absolute;right: 3.733333333333334vw;top: 3.733333333333334vw;text-indent: -999em;}.item-update{display: block;position: relative;margin-bottom:2.6666666666666665vw}'; //20241022 增加ipad横屏兼容 $css = $css + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-55a5528c72fe53b2 .snp-container {\ transform:translate(-50%,-50%) scale(0.7);-ms-transform:translate(-50%,-50%) scale(0.7);-moz-transform:translate(-50%,-50%) scale(0.7);-webkit-transform:translate(-50%,-50%) scale(0.7);-o-transform:translate(-50%,-50%) scale(0.7);\ }\ }' } // }else{ //baidu里的样式 $cssBottomBar = '.baiduApp_css .m-sentiment-blk {transform: translateX(0px);}.snp-bottom-bar{width: 100%;height:.98rem;background-color: #fff;display:flex;align-items: center;box-shadow: 0 -.1rem .12rem rgba(0,0,0,.08);position: fixed;bottom: 0;z-index: 99999;box-sizing: border-box;padding: 0 .2rem;justify-content: space-between;transition-duration: .5s;transition-timing-function: ease;bottom: -1rem;max-width: var(--page-max-width);transform: translateX(-50%);}.snp-ba-logo{width: 2.62rem;}.snp-ba-logo img{width: 100%;}.snp-ba-ver{width: 1.22rem;height: .4rem;border-radius:.2rem;background-color: #508CEE;color: #fff;font-size: .24rem;font-weight: bold;text-align: center;line-height: .4rem;position:relative;margin-left:auto;margin-right:.2rem;}.snp-ba-txt{margin:0 .2rem;font-size: .3rem;font-weight: bold;margin-left:auto;}.snp-ba-arrowup{background: url(//n.sinaimg.cn/finance/cece9e13/20240821/iocn_arrow_up.png) 0 0 no-repeat;width: .44rem;height: .44rem;background-size: .44rem auto;}.s-55b65e3c9db1ba12{position:fixed;bottom:0;left:50%;right:0;z-index:100001;} .s-55b65e3c9db1ba12 .snp-container{box-shadow: 0 -0.12rem .1rem rgba(0, 0, 0, 0.2);position:absolute;left:0;transform:translate(-50%,0);-ms-transform:translate(-50%,0);-moz-transform:translate(-50%,0);-webkit-transform:translate(-50%,0);-o-transform:translate(-50%,0);background:url(//n.sinaimg.cn/finance/cece9e13/20230419/wap_pop_main_back.png) 0 0 no-repeat;border-radius:.2rem .2rem 0 0;width:6.54rem;height:6.68rem;background-size: 6.54rem auto;box-sizing: border-box;padding-top: 1.24rem;bottom: -7rem;transition-duration: .5s;transition-timing-function: ease;}.s-55b65e3c9db1ba12 .snp-container .snp-tit{width:100%;height:.67rem;padding-left:.32rem;display: flex;justify-content: flex-start;align-items: center;}.s-55b65e3c9db1ba12 .snp-container .snp-app-new{font-size: .34rem;font-weight: bold;}.s-55b65e3c9db1ba12 .snp-container .snp-app-ver{font-size: .2rem;font-weight: bold;color: #fff;background-color: #598AFD;height: .4rem;line-height: .4rem;padding: 0 .15rem;border-radius: .2rem;margin-left: .1rem;}.s-55b65e3c9db1ba12 .snp-container .snp-new-tip{padding: 0 .4rem;margin-top: .64rem;height: 2.7rem;overflow-y: auto;}.s-55b65e3c9db1ba12 .snp-container .snp-tip-text{text-align:justify;font-size:.28rem;line-height:.44rem;color:#333;}.s-55b65e3c9db1ba12 .container .snp-bar{margin-top:.3rem;width:100%;height:.8rem;line-height:.8rem;display:flex;display:-webkit-flex;justify-content:center;align-items:center;text-align:center;}.s-55b65e3c9db1ba12 .snp-container .snp-bar{margin-top:0.24rem;}.s-55b65e3c9db1ba12 .snp-container .snp-bar .snp-btn-download-new{border-radius:.4rem;width:4.6rem;height:.76rem;color:#fff;background-color:#598AFD;font-size:.3rem;line-height:.76rem;text-align:center;margin: 0 auto;}.s-55b65e3c9db1ba12 .snp-btn-close-new{display:block;background:url(//n.sinaimg.cn/finance/cece9e13/20240821/iocn_arrow_down.png) 0 0 no-repeat;width:0.44rem;height:0.44rem;background-size:.44rem auto;position:absolute;right:0.28rem;top:0.28rem;text-indent:-999em;}.item-update{display:block;line-height:0.4rem;position:relative;margin-bottom:0.2rem;}.snp-ba-ver em{position:absolute;width:.14rem;height.14rem;border-radius:.2rem;background:#FF4848;top:0;right:0;display:block;height:.14rem;}'; $cssBottomBar = $cssBottomBar + '@media only screen and (orientation: landscape) and (min-width: 600px) {\ .s-55a5528c72fe53b2 .snp-container {\ transform:translate(-50%,-50%) scale(0.7);-ms-transform:translate(-50%,-50%) scale(0.7);-moz-transform:translate(-50%,-50%) scale(0.7);-webkit-transform:translate(-50%,-50%) scale(0.7);-o-transform:translate(-50%,-50%) scale(0.7);\ }\ }' // } //20240927 补充css if(((location.href.indexOf('//quotes.sina.cn/')>-1||location.href.indexOf('//gu.sina.cn/')>-1)&&location.href.indexOf('quotes')>-1)||location.href.indexOf('//gu.sina.cn/ft/hq')>-1){ $cssBottomBar = $cssBottomBar + 'body{padding-bottom:1rem}.btn-subpage-bottom-callup{bottom:2.2rem!important;}'; } //2024.8.19 增加百度dom var $cssdom = doc.createElement("style"); $cssdom.innerHTML = $css; document.body.appendChild($cssdom); var $div = doc.createElement("div"); $div.innerHTML = $dom; document.body.appendChild($div); if(isBottomTPL()){ var $cssdomBottomBar = doc.createElement("style"); $cssdomBottomBar.innerHTML = $cssBottomBar; document.body.appendChild($cssdomBottomBar); var $divBottomBar = doc.createElement("div"); $divBottomBar.innerHTML = $domBottomBar; document.body.appendChild($divBottomBar); } var $script = document.createElement('script'); window.hqCenterPopup = function() {}; function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } //20241128增加sendSudaExt function sendSudaExt(key,value,ext) { var _self = this; try { var _ext = ext || {}; var _obj = { uaTrackKey:key, uaTrackValue:value, uaTrackExt:JSON.stringify(_ext) } // console.log('sudaObj',_obj); SinaFinanceCallUp.Track.sendSudaExt(_obj); } catch (error) {} } var pop_isShow_wap,pop_version,pop_content,pop_releasedate; //20240808获取不同系统的参数 if(getSystem()=='ios'){ //ios 获取不同参数 pop_isShow_wap = 'isShow_wap_ios'; pop_version = 'version_ios'; pop_content = 'content_ios'; pop_releasedate = 'releasedate_ios'; }else{ pop_isShow_wap = 'isShow_wap'; pop_version = 'version'; pop_content = 'content'; pop_releasedate = 'releasedate'; } function initPop(isLocalUser){ try { $script.src = "https://finance.sina.com.cn/api/hq_popup_api.json"; document.head.appendChild($script); hqCenterPopup = function(res) { if (res.result) { // if(res&&res.result&&res.result.data&&res.result.data.isShow==true&&res.result.data.isShow_wap==0){ if(res&&res.result&&res.result.data&&res.result.data.isShow==true&&res.result.data[pop_isShow_wap]==1){ var _ver = res.result.data[pop_version]; var _content = res.result.data[pop_content]; var _contentArray = _content.split('||'); var _contentStr = ''; for(var i = 0 ;i<_contentArray.length;i++){ _contentStr+=''+(i+1)+'.'+_contentArray[i]+'' } var _ext = { callupbrowser:SinaFinanceCallUp.util.checkUA.getCallupBrowserName(), search:SinaFinanceCallUp.util.getReferrerType() } if(checkCookie(res.result.data,isLocalUser)){ document.getElementById('SNP_ver').innerHTML = _ver; document.getElementById('SNP_text').innerHTML = _contentStr; //20241128 增加ext // sendSuda("wap_hqcenter_callup", "exp_wap_hqcenter_tk"); sendSudaExt("wap_hqcenter_callup", "exp_wap_hqcenter_tk",_ext); bindEvent(res.result.data); document.getElementById("e3f72b423948a17c").style.display = "block"; //重绘 var __a = document.getElementById('e3f72b423948a17c').offsetHeight; //console.log(__a) }else{ //用户未点过,展示 document.getElementById("e3f72b423948a17c").style.display = "none"; SFA__EventCenter.trigger('no_update_pop'); } if(isBottomTPL()){ document.getElementById('SNP_ver_bottombar').innerHTML = _ver; document.getElementById('SNP_text_bottombar').innerHTML = _contentStr; //20241128 增加ext // sendSuda("wap_hqcenter_callup", "tk_cjbottom_exp"); sendSudaExt("wap_hqcenter_callup", "tk_cjbottom_exp",_ext); bindEventBottomBar(res.result.data); document.getElementById("4d1a7b0f58105f99").style.display = "block"; document.getElementById('SNP_ver1').innerHTML = _ver; document.getElementById('SNP_bottom_bar').style.bottom = 0; } }else{ } $script.remove(); } } } catch (e) { } } function bindEventBottomBar(data){ var _ext = { callupbrowser:SinaFinanceCallUp.util.checkUA.getCallupBrowserName(), search:SinaFinanceCallUp.util.getReferrerType() } document.getElementById("SFA_newVersion_download_bottombar").addEventListener("click", function() { var _position = 'bottom_tkdownload'; var cfg = { eventid: 'wap_hqcenter_callup', uatrackKey: 'wap_hqcenter_callup', subname: _position, needOpenSource: false, wmcode:'33000_0103' }, app = new SinaFinanceCallUp.CallUpSinaFinance(cfg); document.getElementById("SNP_bottom_bar").style.bottom = '0'; document.getElementById("SNP_container_bottombar").style.bottom = '-7rem'; app.tryDirectCall({ callpagetype: '23', subtype: '5', position: _position }); }); document.getElementById("SNP_bottom_bar").addEventListener("click", function() { document.getElementById("SNP_bottom_bar").style.bottom = '-1rem'; document.getElementById("SNP_container_bottombar").style.bottom = 0; sendSuda("wap_hqcenter_callup", "tkdownload_cjin"); }); document.getElementById("SFA_newVersion_close_bottombar").addEventListener("click", function() { document.getElementById("SNP_bottom_bar").style.bottom = '0'; document.getElementById("SNP_container_bottombar").style.bottom = '-7rem'; sendSudaExt("wap_hqcenter_callup", "tkcancel",_ext); }); } function bindEvent(data){ var _pub = data.pubtime; //以当前版本号作为cookie name var _COOKIENAME = cookieName+data[pop_version].replace(/V/g,'').replace(/v/g,''); var _COOKIENAMECLICK = _COOKIENAME+'_click'; setC(_COOKIENAME,_pub,30); var _ext = { callupbrowser:SinaFinanceCallUp.util.checkUA.getCallupBrowserName(), search:SinaFinanceCallUp.util.getReferrerType() } document.getElementById("SFA_newVersion_download").addEventListener("click", function() { var _curCookie = cookieUtil.get(_COOKIENAMECLICK)-0; setC(_COOKIENAMECLICK,_curCookie+1,30); var _position = 'tkdownload'; var cfg = { eventid: 'wap_hqcenter_callup', uatrackKey: 'wap_hqcenter_callup', subname: _position, needOpenSource: false, wmcode:'33000_0103' }, app = new SinaFinanceCallUp.CallUpSinaFinance(cfg); app.tryDirectCall({ callpagetype: '23', subtype: '5', position: _position }); }) document.getElementById("SFA_newVersion_close").addEventListener("click", function() { var _curCookie = cookieUtil.get(_COOKIENAMECLICK)-0; document.getElementById("e3f72b423948a17c").style.display = "none" sendSudaExt("wap_hqcenter_callup", "tkcancel",_ext); // setC('close',1) setC(_COOKIENAMECLICK,_curCookie+1,30) }); } //日期格式化 function dateFormat(date,fmt){ var o = { "M+" : date.getMonth()+1, //月份 "d+" : date.getDate(), //日 "h+" : date.getHours(), //小时 "m+" : date.getMinutes(), //分 "s+" : date.getSeconds(), //秒 "q+" : Math.floor((date.getMonth()+3)/3), //季度 "S" : date.getMilliseconds() //毫秒 }; if(/(y+)/.test(fmt)) fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o) if(new RegExp("("+ k +")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); return fmt; } //日期比较 function dateDiffInDays(date1, date2) { // 将日期字符串转换为日期对象 const d1 = new Date(date1.replace(/\-/g,'/')); const d2 = new Date(date2.replace(/\-/g,'/')); // 计算两个日期的时间戳差值 const diffInMs = Math.abs(d2 - d1); // 将时间戳转换为天数 const diffInDays = Math.round(diffInMs / (1000 * 60 * 60 * 24)); return diffInDays; } function checkCookie(data,isLocalUser){ //不存在cookie,展示 //存在cookie,时间不是同一天,展示 var ret = false; var closeTime = isLocalUser == true?2:3; var _COOKIENAME = cookieName+data[pop_version].replace(/V/g,'').replace(/v/g,''); var _COOKIENAMECLICK = _COOKIENAME+'_click'; var _curCookie = cookieUtil.get(_COOKIENAME); var _curCookieClick = cookieUtil.get(_COOKIENAMECLICK); var _releaseDate = data[pop_releasedate]; var _pubtime = data.pubtime; //判断接口返回的当前时间 和 发布时间,7天内 返回true,并记录一天的cookie var _diff_pub_release = dateDiffInDays(_pubtime,_releaseDate); if(_curCookie!=''){ //如果微信不判断时间 if(isWeixin()&&location.href.indexOf('cj.sina.cn/article')>-1){ ret = false; }else{ //当前version存在cookie. 需要判断 当前时间 和 点击次数 var _diff_pub_cookieDate = dateDiffInDays(_pubtime,_curCookie); if(_diff_pub_cookieDate==0||_diff_pub_cookieDate<0){ //存在cookie 并且是当天 ret = false; }else{ if(_curCookieClick-0>closeTime){ ret = false; }else{ ret = true; } } } }else{ //当前版本没有cookie,可以曝光 ret = true; } return ret; } function getC() { return cookieUtil.get("hq_" + mk + "_detail"); } // 清朗 - 7 , 非 - 1 function setC(cn,cookieValue,day) { cookieUtil.set( cn, cookieValue, { expires: 60 * 60 * 24 * day, domain: '.sina.cn', path: '/' } ) } function isLastDigitOdd(str) { // 获取字符串的最后一位字符 var lastChar = str.charAt(str.length - 1); // 将最后一位字符转换为数字 var lastDigit = parseInt(lastChar, 10); // 判断最后一位数字是否为奇数 if (lastDigit % 2 !== 0) { return true; // 是奇数 } else { return true; // 不是奇数 } } // 清朗 // if(window.paperCode){ // 头条App function isWeixin(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('micromessenger') !== -1 ; } function isWeibo(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('weibo') !== -1 ; } function isSinaFinance(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('sinafinance') !== -1 ; } function isBaidu(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('baidu') !== -1 ; } function isPCWeixin(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('windowswechat') !== -1 || ua.indexOf('macwechat') !== -1; } var _sinaglobal = cookieUtil.get('SINAGLOBAL'); var _host = window.location.host; function canPop(){ //可以弹窗 var _host = window.location.host; var ret = false; if((isLastDigitOdd(_sinaglobal)==true&&_host=='cj.sina.cn')||_host!='cj.sina.cn'){ ret = true; } /*if(window.location.href.indexOf('//guba.sina.cn/list_')>-1||window.location.href.indexOf('//guba.sina.cn/h5/?a=hotBars')>-1){ ret = false; }*/ return ret; } function displayPage(){ var ret = 0; var _url = window.location.href; const regex = /^https?:\/\/guba\.sina\.cn(?!\/list)/;//股吧首页 if(_url.indexOf('//gu.sina.cn/m')>-1||_url.indexOf('//wap.cj.sina.cn/')>-1||regex.test(_url)){ ret = 1; }else if((_url.indexOf('//gu.sina.cn')>-1||_url.indexOf('//quotes.sina.cn')>-1||_url.indexOf('//finance.sina.cn')>-1||_url.indexOf('//guba.sina.cn/list_')>-1)&&_url.indexOf('//gu.sina.cn/fx/hq/quotes.php')<0){ ret = 2; }else if(_url.indexOf('//cj.sina.cn')>-1){ // }else if(_url.indexOf('cj.sina.cn.html')>-1){ // console.log(111) ret = 3; } return ret; } function toutiaoCheck(){ //2025.1.17 头条外 true, 头条内 行情首页、wap.cj、guba 显示,其他不显示 var _host = window.location.host; var _url = window.location.href; const __pageType = displayPage(); var ret = false; if(!__isToutiao__()){ ret = true; }else{ //在抖音app内 if(__pageType==1){ ret = true; }else if(__pageType==2){ ret = true; }else if(__pageType==3){ //触发 新版弹窗 // SFA__EventCenter.trigger('toutiao_cj_page'); // ret = false; //2025.12.31 恢复 ret = true; }else{ ret = false } } return ret; } //20240822 使用底部模版 function isBottomTPL(){ var _host = window.location.host; var ret = false; if(_host=='cj.sina.cn'&&isBaidu()){ ret = true; } if(_host!='cj.sina.cn'){ ret = true; } if(_host=='finance.sina.cn'){ ret = false; } //20240828 先恢复 // ret = false; return ret; } SFA__EventCenter.on('no_HQ_update_pop',function(){ if (toutiaoCheck()==true&&!__isDouyin__() && !__isCheckReferrer__(__toutiaoLists__)&&canPop()==true&&!isSinaFinance()) { //20250108 try { const __pageType = displayPage(); var $sfanvpop_script = document.createElement('script'); window.sfanvpop = function() {}; $sfanvpop_script.src = "https://interface.sina.cn/finance/data_nvpop_ipc.d.json?callback=sfanvpop"; document.head.appendChild($sfanvpop_script); sfanvpop = function(res) { var _href = window.location.href; var _isLocalUser = res.isLocalUser; if(typeof(_isLocalUser)!='undefined'&&_isLocalUser==true){ if(!isPCWeixin()){ //test // if(__isToutiao__()==true&&__pageType==3){ // SFA__EventCenter.trigger('toutiao_cj_page'); // }else{ // initPop(_isLocalUser); // } initPop(_isLocalUser); } }else{ if(_href.indexOf('//fund.sina.cn/fund')>-1&&isBaidu()){ if(res.data_ipc_ts==true){ initPop(); } }else{ if(__isToutiao__()==true){ if(__pageType==1){ initPop(); }else if(__pageType==2||__pageType==3){ if(res.data_ipc_ts==true){ initPop(); } } // else if(__pageType==3){ // SFA__EventCenter.trigger('toutiao_cj_page'); // } }else{ initPop(); } } //2025.05.26 } } } catch (error) { } } }); SFA__EventCenter.on('toutiao_cj_page',function(){ try { __TOUTIAO__CJ__PAGE.init(); } catch (error) { } }); //20250527 guba 底部浮层 //检测当前浏览器,替换Logo var iconList = { 'safari':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-safari.png', 'name':'Safari浏览器' }, 'chrome':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-chrome.png', 'name':'Chrome浏览器' }, 'firefox':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-firefox.png', 'name':'Firefox浏览器' }, 'toutiao':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-toutiao.png', 'name':'头条浏览器' }, 'UCbrowser':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-uc.png', 'name':'UC浏览器' }, 'baidu':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-baidu.png', 'name':'百度浏览器' }, '360browser':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-360.png', 'name':'360浏览器' }, 'quark':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-quark.png', 'name':'夸克浏览器' }, 'edge':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-edge.png', 'name':'Edge浏览器' }, 'QQbrowser':{ 'logo':'//n.sinaimg.cn/finance/cece9e13/20250528/icon-qq.png', 'name':'QQ浏览器' } } var _browserName = SinaFinanceCallUp.util.checkUA.getCallupBrowserName(); var _system = SinaFinanceCallUp.util.checkUA._system(); var iconUrl = '',iconName = ''; if(_browserName&&iconList[_browserName]){ iconUrl = iconList[_browserName].logo; iconName = iconList[_browserName].name; }else{ //如果没有获取到浏览器名称,则默认为Safari 或者chrome if(_system=='ios'){ iconUrl = iconList['safari'].logo; iconName = iconList['safari'].name; }else{ iconUrl = iconList['chrome'].logo; iconName = iconList['chrome'].name; } } var $continueDom = ''; $continueDom = `
    继续浏览内容
    新浪财经APP
    资讯 行情 股吧 芝麻AI
    打开APP
    ${iconName}
    继续
    `; var $continueCSS = ''; $continueCSS = `.SFA-continue-pop{background-color: #fff;border-radius: .28rem .28rem 0 0;position: absolute;bottom: 0;width: 100%;box-sizing: border-box;padding-top: .4rem;z-index: 100003;} .SFA-item-browser{height: 1.62rem;display: flex;justify-content: space-between;align-items: center;padding: .32rem .4rem;box-sizing: border-box;} .SFA-continue-title{font-size: .28rem;color: #333;padding-left: .4rem;} .SFA-continue-info{display: flex;justify-content: flex-start;align-items: center;} .SFA-continue-info .sci-icon{width: .9rem;height: .9rem;margin-right: .24rem;} .SFA-continue-info .sci-icon img{width: 100%;} .SFA-continue-info .sci-name{font-size: .32rem;color: #333;} .SFA-continue-info .sci-name-info{font-size: .24rem;margin-top: .16rem;} .sib-split{width: 6.78rem;height: .01rem;background-color: #EEEEEE;margin: 0 auto;} .SFA-continue-btn{width: 1.6rem;height: .6rem;border-radius: .3rem;color: #666666;font-size: .28rem;text-align: center;line-height: .6rem;background-color: #F7F7F7;} .SFA-continue-btn-active{background-color: #508CEE;color: #fff;} .scpm-780E52ABF7C3A24E{background: rgba(0, 0, 0, 0.70); position: fixed; top: 0; left: 0; z-index: 100002;width:100%;height:100%;}`; //2025.05.27 增加底部继续弹窗 var $continueCSSDom = doc.createElement("style"); $continueCSSDom.innerHTML = $continueCSS; document.body.appendChild($continueCSSDom); var $continueDiv = doc.createElement("div"); $continueDiv.className = 'scpm-780E52ABF7C3A24E'; $continueDiv.id = '89806E3926E6F23E'; $continueDiv.style.display= 'none'; $continueDiv.innerHTML = $continueDom; document.body.appendChild($continueDiv); //绑定事件 document.getElementById('SFA_continueBtn_callup').addEventListener("click", function() { try { //唤起财经客户端 var cfg = { eventid: 'callup_finance_app', needOpenSource: false, }, app = new SinaFinanceCallUp.CallUpSinaFinance(cfg); /* 二级 newSchemaParams: { client_path: '/stock/comment/stock-comment-list',//不可修改, market: 'cn',//市场, symbol: 'sh600519',//股票代码 } 三级 newSchemaParams: { client_path: '/stock/comment/stock-comment-detail',//不可修改, market: 'cn',//市场, symbol: 'sh600519',//股票代码, bid: '240',//评论列表id(股票的id), tid: '601171',//评论id } client_path=/app/home&tab=hq&topTab=hq_hangqing&subTab=cn' */ var _domainKey = getCookieNameAndCount().cookieName; if(_domainKey=='gu_home'){ app.tryDirectCall({ newSchemaParams: { client_path: '/app/home',//不可修改, tab: 'hq',//市场, topTab: 'hq_hangqing', subTab:'cn' }, position: 'continue_tk_openbtn' }); } if(_domainKey=='wapcj_all'&&typeof(SFA_WAPCJ_callupConfig)!='undefined'){ var callupConfig = SFA_WAPCJ_callupConfig; var _url = window.location.href; var __callupParams = { newSchemaParams: { client_path: '/app/home', tab: 'news', subTab: 'news_focus', }, position:'wap_bottom_default' }; for(var i =0;i< callupConfig.length;i++){ var _itemConfig = callupConfig[i]; if(_itemConfig.pageKey&&_itemConfig.pageKey!=''&&_url.indexOf(_itemConfig.pageKey)>-1){ __callupParams = typeof(_itemConfig.callupParams)=='function'? _itemConfig.callupParams():_itemConfig.callupParams; } } app.tryDirectCall(__callupParams) } if(_domainKey=='guba_l2'){ var _stockMarket = PAGE_CONFIG.stockMarket; var _stockType = PAGE_CONFIG.stockType; var _stockCode = PAGE_CONFIG.stockCode; var _symbol = _stockType=='cn'?_stockMarket+_stockCode:_stockCode; app.tryDirectCall({ newSchemaParams: { client_path: '/stock/comment/stock-comment-list',//不可修改, market: _stockType,//市场, symbol: _symbol,//股票代码 }, position: 'continue_tk_openbtn' }); } if(_domainKey=='guba_l3'){ var _stockMarket = PAGE_CONFIG.stockMarket; var _stockType = PAGE_CONFIG.stockType; var _stockCode = PAGE_CONFIG.stockCode; var _bid = PAGE_CONFIG.bid; var _tid = PAGE_CONFIG.tid; var _symbol = _stockType=='cn'?_stockMarket+_stockCode:_stockCode; app.tryDirectCall({ newSchemaParams: { client_path: '/stock/comment/stock-comment-detail',//不可修改, market: _stockType,//市场, symbol: _symbol,//股票代码, bid: _bid,//评论列表id(股票的id), tid: _tid,//评论id }, position: 'continue_tk_openbtn' }); } } catch (error) { } }); document.getElementById('SFA_continueBtn').addEventListener("click", function() { //隐藏浮层 document.getElementById('89806E3926E6F23E').style.display = 'none'; }); function isSecondPage(){ /*股吧详情页-3级页面(url:https://guba.sina.cn/view_9279_4794584.html) 股吧详情页-2级页面(url:https://guba.sina.cn/list_sh000001.html)*/ var ret = false; var _url = window.location.href; ret = _url.indexOf('//guba.sina.cn/list_')>-1; return ret; } function isThirdPage(){ var ret = false; var _url = window.location.href; ret = _url.indexOf('//guba.sina.cn/view_')>-1; return ret; } // 2025 0610 根据域名返回 cookie标识 和 应该展示的次数 function getCookieNameAndCount(){ var ret = {}; var _url = window.location.href; if(_url.indexOf('//gu.sina.cn/m/')>-1){ // if(_url.indexOf('gu_sina_cn')>-1){ //行情首页 ret = { cookieName:'gu_home', count:1 }; }else if(_url.indexOf('//wap.cj.sina.cn/')>-1){ // }else if(_url.indexOf('wap_cj_fund')>-1){ ret = { cookieName:'wapcj_all', count:1 }; }else if(_url.indexOf('//guba.sina.cn/list_')>-1){ // }else if(_url.indexOf('guba.list_usXIACY')>-1){ ret = { cookieName:'guba_l2', count:1 }; }else if(_url.indexOf('//guba.sina.cn/view_')>-1){ // }else if(_url.indexOf('guba.view_9279_4794584')>-1){ ret = { cookieName:'guba_l3', count:3 }; }else{ ret = null; } return ret; } function sumProperties(obj) { let sum = 0; for (let key in obj) { if (key !== 'datatime' && typeof obj[key] === 'number') { sum += obj[key]; } } return sum; } function checkPopContinueCookie(){ //不存在cookie,展示 //存在cookie,时间不是同一天,展示 // cookieName:{ // date:'2025-05-27 23:21', // click:3 // } var ret = false; var _COOKIENAME = 'SFA_continue_pop_v2'; var _curCookie = cookieUtil.get(_COOKIENAME); //_curCookie转为json ,获取对应cookiename的次数 var CookieNameAndCount = getCookieNameAndCount(); var _currentCount = 0; var sumOfValues = 0; var countJson = {} var _diff_pub_cookieDate = 0; if(CookieNameAndCount!==null){ var _domainName = CookieNameAndCount.cookieName;//域名对应存储的cookie标识 var _domainCount = CookieNameAndCount.count;//域名配置后的弹出次数 //当前域名可以弹窗 // var _diff_pub_cookieDate = dateDiffInDays(_pubtime,_curCookie); if(_curCookie!=''){ //尝试把数据json化 try { //_curCookie转为json,获取对应cookiename的次数 var _cookieContent = JSON.parse(_curCookie); if(_cookieContent){ countJson = _cookieContent; var _cookieDate = _cookieContent['datetime']; if(_cookieDate){ _diff_pub_cookieDate = dateDiffInDays(dateFormat(new Date(),'yyyy/MM/dd'),_cookieDate); } if(_cookieContent[_domainName]){ _currentCount = _cookieContent[_domainName]-0; } sumOfValues = sumProperties(_cookieContent); if(_diff_pub_cookieDate==0){ //当天 if(_currentCount<_domainCount&&sumOfValues < 3){ // 当前域名弹出次数及总次数都满足 ret = true } }else{ ret = true; } } } catch (error) { //无法解析 ret = false; } }else{ //当前版本没有cookie,可以曝光 ret = true; } if(ret==true){ //格式化次数json并写入cookie countJson[_domainName] = _currentCount+1; countJson['datetime'] = dateFormat(new Date(),'yyyy/MM/dd'); setC(_COOKIENAME,JSON.stringify(countJson),1) } } // if(isSecondPage()||isThirdPage()){ // if(_curCookie!=''){ // _curCookie = _curCookie -0; // if(isSecondPage()&&_curCookie<1){ // ret = true; // } // if(isThirdPage()&&_curCookie<3){ // ret = true; // } // }else{ // //当前版本没有cookie,可以曝光 // ret = true; // } // if(ret==true){ // setC(_COOKIENAME,_curCookie+1,1) // } // } return ret; } function PopupContinue(){ var _ext = { callupbrowser:SinaFinanceCallUp.util.checkUA.getCallupBrowserName(), search:SinaFinanceCallUp.util.getReferrerType() } sendSudaExt("callup_finance_app", "continue_tk_exp",_ext); document.getElementById('89806E3926E6F23E').style.display = 'block'; } function canPopupContinue(){ /* 在股吧详情页(二级页面、三级页面)底部增加“继续浏览内容”弹窗;增加日间版、夜间版适配;* 弹窗规则: 1、保留新版本弹窗,优先级最高,若“新版本弹窗”和“继续浏览内容”弹窗同时出现,新版本弹窗高亮——“继续浏览内容弹窗在新版本弹窗遮罩下方”; 2、进入股吧三级页面,每次进入均弹“继续浏览内容”弹窗,一天3次; 3、进入股吧二级页面,一天1次; 4、兜底说明 (1)、若ios系统无法识别当前浏览器,默认浏览器显示“Safari浏览器”; (2)、若安卓系统无法识别当前浏览器,默认浏览器显示“Chrome浏览器” 应用浏览器: 百度、华为、Safari */ var ret = false; if(checkPopContinueCookie()){ ret = true; } return ret; } if(canPopupContinue()){ PopupContinue(); } } catch (error) { } })(document, window); //行情红包 (function(doc, win){ var _sinaglobal = getCookie('SINAGLOBAL'); var _actId = 128; var cfg = { eventid: 'callup_finance_app', uatrackKey: 'callup_finance_app', needOpenSource: false, }, call_app = new SinaFinanceCallUp.CallUpSinaFinance(cfg); var APIS = { joinNum:'//support.finance.sina.cn/draw/api/openapi.php/WapRedPacketService.getJoinNum', hasHB:'//support.finance.sina.cn/draw/api/openapi.php/WapRedPacketService.wapIndex' } var $dom = ''; $dom = ''+ ''+ '
    '+ '
    '+ '
    领取红包
    '+ '
    已有人领取
    '+ '
    '+ '
    ' var $css = ''; $css = '.hongbao-hq-btn{background: url(//n.sinaimg.cn/finance/cece9e13/20241130/wap-hongbao-back.png) 0 0 no-repeat;background-size: 2.2rem auto;color: #fff;text-align: center;width: 2.2rem;height: .6rem;line-height: .6rem;font-size: .24rem;font-weight: bold;position: fixed;z-index: 100001;right: 6px;bottom: 20%;overflow:hidden;}\ .wap-hongbao-pop{background: url(//n.sinaimg.cn/finance/cece9e13/20241130/wap_pop_hongbao_back.png) 0 0 no-repeat;width: 5rem;height: 6.58rem;background-size: 5rem auto;position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 100004;}\ .wap-hongbao-pop-mask{position: fixed;top: 0;left: 0;bottom: 0;right: 0;background-color: rgba(0, 0, 0, .8);background-image: url(//n.sinaimg.cn/finance/cece9e13/20241130/wap_pop_light.png);background-repeat: no-repeat;background-size: 7.5rem auto;background-position: center center;z-index: 100003;}\ .wap-hongbao-pop-btn{background: url(//n.sinaimg.cn/finance/cece9e13/20241130/wap_btn_pop_hongbao.png) 0 0 no-repeat;width: 2.56rem;height: .8rem;background-size: 2.56rem auto;position: absolute;top: 4.4rem;left: 50%;margin-left:-1.28rem;}\ .hongbao-btn-inner{transition: margin-top .5s;}\ .hongbao-btn-wrap{display:flex;justify-content: center;align-items: center;}\ .hongbao-btn-icon{background: url(//n.sinaimg.cn/finance/cece9e13/20241130/wap-hongbao.png) 0 0 no-repeat;background-size: .29rem auto;width:.29rem;height:.36rem;margin-right:.12rem;}\ @keyframes tada {from {transform: scale3d(1, 1, 1);}10%, 20% {transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg);}30%, 50%, 70%, 90% {transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);}40%, 60%, 80% {transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);}to {transform: scale3d(1, 1, 1);}}\ .tada {animation: tada 1.2s;-webkit-animation-iteration-count: infinite;animation-iteration-count: infinite;}\ .wap-hongbao-close{position:absolute;background: url(//n.sinaimg.cn/finance/cece9e13/20241202/wap_pop_hb_close.png) 0 0 no-repeat;background-size: .24rem auto;width:.24rem;height:.24rem;right:.32rem;top:.55rem;}\ '; function appendWapHqHB(){ var $cssdom = doc.createElement("style"); $cssdom.innerHTML = $css; document.body.appendChild($cssdom); var $div = doc.createElement("div"); $div.innerHTML = $dom; document.body.appendChild($div); } function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } //cookie方法 function getCookie(name) { name = name.replace(/([\.\[\]\$])/g, '\\\$1'); var rep = new RegExp(name + '=([^;]*)?;', 'i'); var co = document.cookie + ';'; var res = co.match(rep); if (res) { return unescape(res[1]) || ""; } else { return ""; } // var value = document.cookie.match( // "(?:^|;)\\s*" + this.escape(name) + "=([^;]*)" // ); // return value ? value[1] || "" : ""; } function getJSONP(url, data, callbackName) { const finalCallbackName = callbackName || `callback${(Math.random() * 1e12).toFixed(0)}` return new Promise((resolve) => { var script = document.createElement('script') url += `?callback=${finalCallbackName}` if (data) { Object.keys(data).forEach(key => { url += `&${key}=${data[key]}` }) } script.src = url document.head.appendChild(script) window[finalCallbackName] = function (data) { resolve(data) } script.parentNode.removeChild(script) }) } function ajaxGet(url, data) { return new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest(); var queryString = ''; if (data) { queryString = Object.keys(data).map(key => key + '=' + data[key]).join('&'); url = url + '?' + queryString; } xhr.open('GET', url, true); xhr.withCredentials = true; // 支持跨域请求时携带凭据 xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { resolve(JSON.parse(xhr.responseText)); } else { reject(xhr.statusText); } } }; xhr.send(); }); } function formatNumber(num) { if (num >= 100000) { return (num / 10000).toFixed(1).replace(/0+$/, '') + '万+'; } else if (num >= 10000) { return (num / 10000).toFixed(1).replace(/0+$/, '') + '万'; } else if (num >= 1000) { return (num / 1000).toFixed(1).replace(/0+$/, '') + '千'; } else { return num; } } //获取膨胀人数 function getJoinNum(){ getJSONP(APIS.joinNum, { __jsonp:true }).then((d) => { if(d&&d.result&&d.result.data){ var _num = formatNumber(d.result.data.num-0) document.getElementById('SFA-hongbao-num').innerHTML = _num+''; } }); } function initHongBaoPop(){ //请求接口,判断是否可以显示红包 try { ajaxGet(APIS.hasHB, {global_id:_sinaglobal}) .then(function(d) { if(d&&d.result&&d.result.data&&d.result.data.status-0==1){ appendWapHqHB(); getJoinNum(); bindEvent(); sendSuda("callup_finance_app", "wap_hb_exp"); SFA__EventCenter.trigger('has_waphb_pop'); }else{ // // troggleHongbaoPop(0) } }) .catch(function(error) { // console.error('Error:', error); }); } catch (error) { } } function _getFirstChild(child_) { let c = child_.firstChild; while (c.nodeType != 1) { c = c.nextSibling; } return c; } function bindEvent(data){ document.getElementById("hongbaoPopBtn").addEventListener("click", function() { toApp(); }); document.getElementById("wapHongbaoPopClose").addEventListener("click", function() { troggleHongbaoPop(0) }); document.getElementById("wapHongbaoPopMask").addEventListener("click", function() { troggleHongbaoPop(0) }); document.getElementById("hongbaoHqBtn").addEventListener("click", function() { troggleHongbaoPop(1) sendSuda("callup_finance_app", "wap_hb_click"); }); scrollVertical(); } function toApp(){ var _position = 'wap_hbpop_click'; call_app.tryDirectCall({ callpagetype: '20', url: 'https://finance.sina.cn/app/2023_wb_act_redp.shtml?act_id='+_actId+'&global_id='+_sinaglobal, position: _position }); } function toWapPage(){ window.location.href = ''; } function scrollVertical(){ //垂直滚动 try { var mScroll = document.querySelector('.j-mScroll-wrap'); var mScrollHeight = mScroll.clientHeight/2; var _timeOut = 2000 mScroll.addEventListener('transitionend', () => { mScroll.appendChild(_getFirstChild(mScroll)); mScroll.style.transition = 'none'; mScroll.style.marginTop = 0; setTimeout(() => { mScroll.style.transition = 'margin-top .5s'; mScroll.style.marginTop = '-'+mScrollHeight+'px'; }, _timeOut); }); const moving = () => { setTimeout(() => { mScroll.style.marginTop = '-'+mScrollHeight+'px'; }, _timeOut); }; moving(); } catch (error) { } } function troggleHongbaoPop(type){ if(type==1){ //打开 document.getElementById("wapHongbaoPop").style.display = "block"; document.getElementById("wapHongbaoPopMask").style.display = "block"; sendSuda("callup_finance_app", "wap_hbpop_exp"); }else{ //关闭 document.getElementById("wapHongbaoPop").style.display = "none"; document.getElementById("wapHongbaoPopMask").style.display = "none"; sendSuda("callup_finance_app", "wap_hbpop_off"); } } function isSinaFinance(){ var ua = navigator.userAgent.toLowerCase(); return ua.indexOf('sinafinance') !== -1 ; } function __isToutiao__() { return /newsarticle/i.test(navigator.userAgent.toLowerCase()) } function __isByteDance__() { return /bytedance/i.test(navigator.userAgent.toLowerCase()) } function __isDouyin__() { var _isByteDance = __isByteDance__(), _isNewsArticle = __isToutiao__(); //var ua = this._UA; if (_isByteDance&&!_isNewsArticle) { return true; } else { return false; } // return /bytedance/i.test(navigator.userAgent.toLowerCase()) } function canPop(){ /* 1、A股:https://quotes.sina.cn/hs/company/quotes/view/sh000001?autocallup=no&isfromsina=yes 2、期货:https://gu.sina.cn/ft/hq/hf.php?symbol=CL&autocallup=no&isfromsina=yes 3、外汇:https://gu.sina.cn/fx/hq/quotes.php?code=USDCNY&autocallup=no&isfromsina=yes 4、美股:https://gu.sina.cn/us/hq/quotes.php?code=dji&autocallup=no&isfromsina=yes 5、港股:https://quotes.sina.cn/hk/company/quotes/view/HSI?autocallup=no&isfromsina=yes */ //可以弹窗 var _href = window.location.href; var ret = false; // if(_host=='quotes.sina.cn'||_host=='gu.sina.cn'){ // ret = true; // } //QQ浏览器、UC浏览器先不展示 var isQQ = SinaFinanceCallUp.util.checkUA.isQQBrowswer(); var isUc = SinaFinanceCallUp.util.checkUA.isUC(); if(_href.indexOf('//quotes.sina.cn/hs')>-1||_href.indexOf('//gu.sina.cn/ft')>-1||_href.indexOf('//gu.sina.cn/us')>-1||_href.indexOf('//quotes.sina.cn/hk')>-1){ ret = true; } if(isQQ||isUc){ ret = false; } return ret; } if (!__isToutiao__()&&!__isDouyin__() &&canPop()==true&&!isSinaFinance()) { //2025.5.27 行情红包下线 // initHongBaoPop(); } SFA__EventCenter.on('no_update_pop',function(){ SFA__EventCenter.on('has_waphb_pop',function(){ // troggleHongbaoPop(1); }); }); })(document, window); //行情升级 (function() { function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } function dTos(d_, joinStr, isUTC_, ny_, nm_, nd_) { void 0 === joinStr && (joinStr = "-"); var arr = []; return ny_ || arr.push(d_[isUTC_ ? "getUTCFullYear" : "getFullYear"]()), nm_ || (ny_ = d_[isUTC_ ? "getUTCMonth" : "getMonth"]() + 1, arr.push(ny_ < 10 ? "0" + ny_ : ny_)), nd_ || (nm_ = d_[isUTC_ ? "getUTCDate" : "getDate"](), arr.push(nm_ < 10 ? "0" + nm_ : nm_)), arr.join(joinStr) } function newCallup() { let code = paperCode; switch (__market__.toLowerCase()) { case "cn": break; case "hf": code = code.replace("hf_", ""); break; case "nf": code = code.replace("nf_", "") } new SinaFinanceCallUp.CallUpSinaFinance({ eventid: "hq_callup_app", uatrackKey: "hq_callup_app", needOpenSource: !1 }).tryDirectCall({ newSchemaParams: { client_path: "/stockDetail/stockDetails", symbol: code, market: __callMarket__, tabname: "news_type" }, position: "popup_gold" }) } function init() { var ed = JSON.parse(window.localStorage.getItem("hqdetailnewb")); const _curEd = dTos(new Date); if (!/doubao/i.test(navigator.userAgent.toLocaleLowerCase())) if (ed&&ed.date === _curEd) { SFA__EventCenter.trigger('no_HQ_update_pop'); } else { // 插入 CSS 样式 var style = document.createElement('style'); style.innerHTML = `.sft-popup1-bgimg { background-image: url(//n.sinaimg.cn/finance/cece9e13/20251030/bg_gold.png); background-repeat: no-repeat; width: 5.74rem; height: 9.52rem;} .sft-popup1-close { background-image: url(//n.sinaimg.cn/finance/cece9e13/20251021/pop_main_close_2x.png); background-repeat: no-repeat; background-size: .6rem auto; width: .6rem; height: .6rem; right: 0rem; top: -.8rem;}`; document.body.appendChild(style); ed = document.createElement("div"), ed = (ed.id = "__new_b_page", document.body.appendChild(ed), ed.innerHTML = `
    `, { date: dTos(new Date) }); sendSuda('hq_callup_app','popup_gold_exp'); window.localStorage.setItem("hqdetailnewb", JSON.stringify(ed)), !function() { const panel = document.querySelector(".sft-popup1"); document.querySelector(".sft-popup1-close").addEventListener("click", function(event) { event.stopPropagation(); sendSuda('hq_callup_app','popup_gold_off'); // _p_utils && _p_utils.log("upgrade_popup_off"), panel.style.display = "none" }); // document.querySelector(".sft-continue").addEventListener("click", function() { // _p_utils && _p_utils.log("upgrade_popup_wap"), // newCallup() // }), document.querySelector(".sft-popup1-bg").addEventListener("click", function() { newCallup() }) }() } } if(/toutiaomicroapp|bytedance|newsarticle/i.test(navigator.userAgent.toLocaleLowerCase())){ //2025 0530 SFA__EventCenter.trigger('no_HQ_update_pop'); }else{ // SFA__EventCenter.on('no_update_pop',function(){ try { if(typeof(__callMarket__)!=='undefined'&&typeof(__market__)!=='undefined'){ init() }else{ SFA__EventCenter.trigger('no_HQ_update_pop'); } } catch (error) { } // }); } })(); // 黄金推广 (function(){ var API = 'https://vote.finance.sina.cn/api/polls/plaza'; function sendSuda(key,value){ try { SinaFinanceCallUp.Track.sendUATrack(key,value) } catch (error) { } } function sendSudaExt(key,value,ext) { var _self = this; try { var _ext = ext || {}; var _obj = { uaTrackKey:key, uaTrackValue:value, uaTrackExt:JSON.stringify(_ext) } // console.log('sudaObj',_obj); SinaFinanceCallUp.Track.sendSudaExt(_obj); } catch (error) {} } function ajaxGet(url, data) { return new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest(); var queryString = ''; if (data) { queryString = Object.keys(data).map(key => key + '=' + data[key]).join('&'); url = url + '?' + queryString; } xhr.open('GET', url, true); xhr.withCredentials = true; // 支持跨域请求时携带凭据 xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { resolve(JSON.parse(xhr.responseText)); } else { reject(xhr.statusText); } } }; xhr.send(); }); } // function findGoldVoteCode(data) { // const items = data.result.data.items; // for (const item of items) { // if (item.info.title.includes('黄金')) { // return item.info.code; // } // } // return null; // 如果没找到 // } function findGoldVoteCode(data) { const items = data.result.data.items; // 1. 定义关键字到类型的映射(每个类型对应多个关键词) const keywordToType = [ { type: 'gold', keywords: ['黄金', '金'] }, { type: 'silver', keywords: ['白银', '银'] }, { type: 'oil', keywords: ['原油'] } ]; // 2. 预设每种类型的活动文案 const activityTitles = { gold: '猜金价赢好礼,预测黄金价格走势,赢取京东卡!', silver: '银价怎么走?来猜一波!猜对有机会赢取京东卡!', oil: '原油价格是冲高还是回调?参与原油价格预测,京东卡限时放送!' }; // 3. 遍历每个 item for (const item of items) { const title = item.info.title; // 4. 查找命中的类型 for (const { type, keywords } of keywordToType) { if (keywords.some(kw => title.includes(kw))) { return { type, code: item.info.code, activityTitle: activityTitles[type] }; } } } return null; // 未找到匹配项 } function init() { ajaxGet(API, { page:1, size:20, state:1 }).then((d) => { if(d&&d.result&&d.result.data&&d.result.data.items&&d.result.data.items.length>0){ let _voteInfo = null; _voteInfo = findGoldVoteCode(d); //遍历data,生成 ul内容 const appHeader = document.getElementById('appHeader'); if (appHeader&&_voteInfo) { // 插入 CSS 样式 var style = document.createElement('style'); style.innerHTML = ` .SFA--gold-hot-bar {display: block;width: 100vw; height: .66rem; background-color: #FFF6E4;padding-left:.24rem;padding-right:.20rem;display: flex;align-items: center;box-sizing: border-box;justify-content: space-between;overflow: hidden;white-space: nowrap;} .SFA--gold-hot-bar a,.SFA--gold-hot-bar a:link{color:#EF6207;font-size:.28rem;} .SFA--gold-hot-bar a:visited{color:#EF6207;font-size:.28rem;text-decoration: none;} .SFA--gold-hot-bar a:hover{color:#EF6207;font-size:.28rem;text-decoration: none;} .SFA--gold-hot-bar-close{width:.28rem;} .SFA--gold-hot-bar-close img{width:100%;display:block;} .marquee-wrapper {flex: 1;overflow: hidden;position: relative;} .marquee {display: inline-block;animation: scroll-left 10s linear infinite;padding-right: 20px;} @keyframes scroll-left {0%,10% {transform: translateX(0);}100% {transform: translateX(-100%);}}`; document.body.appendChild(style); const temp = document.createElement("div"); temp.innerHTML = `
    `; appHeader.insertAdjacentElement('afterend', temp); } sendSuda('callup_finance_app','news_popa_exp'); !function() { const panel = document.querySelector(".SFA--gold-hot-bar"); document.querySelector(".SFA--gold-hot-bar-close").addEventListener("click", function(event) { event.stopPropagation(); sendSuda('callup_finance_app','news_popa_off'); panel.style.display = "none" }); }() } }); } // window.__TOUTIAO__CJ__PAGE = {}; // __TOUTIAO__CJ__PAGE.init = init; if(window.location.href.indexOf('//gu.sina.cn/ft/hq')>0){ init(); } })();