function evil(fn) { var fn = function; //一个变量指向function,防止有些前端编译工具报错 return new fn('return ' + fn)(); } function init1(lang,stock,code,chart){ var stk_name,opt_title,opt_legend,opt_serious,p_close; $.ajax({ type: "get", url: "//qt.gtimg.cn/q=" + stock + code, datatype:"script", cache:"false", success:function(){ var res = evil("v_" + stock + code); stk_name = res.split("~")[1]; showforlang(lang); $(".price_l .stc_name").html(stk_name); $(".price_l .stk-data").find(".stc-name").html(stk_name + "「" + code + "」"); res = res.split('~'); var zdnum,cjnum,zdhtm; var zznum,zzhtml; p_close = res[4]; //日期时间 var dtstr = res[30]; var dt_format = ""; if(stock == 'sh'){ dt_format = dtstr.substring(0,4) + "/" + dtstr.substring(4,6) + "/" + dtstr.substring(6,8) + " " + dtstr.substring(8,10) + ":" + dtstr.substring(10,12) + ":" + dtstr.substring(12) }else{ dt_format = dtstr } $('.price_l .stk-data').find('.st_date').html(dt_format); //价格 $('.price_l .stk-data').find('.st_price').html(todecimal(res[3])); // 最新股价 $('.price_l .stk-data').find('.stc_current').html(todecimal(res[3])); // 最高价 $('.price_l .stk-data').find('.stc_max').html(todecimal(res[33])); // 最低价 $('.price_l .stk-data').find('.stc_min').html(todecimal(res[34])); // (+/-)涨跌 $('.price_l .stk-data').find('.stc_updown').html(todecimal(res[31])); zznum = todecimal(res[31]); // 涨跌幅% $('.price_l .stk-data').find('.stc_rate_ud').html(todecimal(res[32])); zdnum = todecimal(res[32]) // 买入价 $('.price_l .stk-data').find('.stc_buy').html(todecimal(res[9])); // 卖出价 $('.price_l .stk-data').find('.stc_sell').html(todecimal(res[19])); // 成交量(手) $('.price_l .stk-data').find('.stc_amount').html(showm(lang,res[36])); cjnum = showm(lang,res[36]) if(zdnum <= 0){ $('.price_l .stk-data').find('.stc_updown').removeclass('zd_up').addclass('zd_down') $('.price_l .stk-data').find('.st_price').parent().removeclass('zd_up').addclass('zd_down') $('.price_l .stk-data').find('.st_price').removeclass('zd_up').addclass('zd_down') $(".price_l .sh_icon").css("transform","rotate(180deg)"); $(".price_l .sh_icon").attr("src","https://omo-oss-image.thefastimg.com/portal-saas/ngc202305220003/cms/image/b11594b6-4d28-4f91-a017-6cc67879b4ed.png"); $(".price_l").addclass("die").removeclass("zhang"); $('.price_l .stk-data').find('.st_price').siblings('i').html('') $('.price_l .stk-data').find('.st_zd').removeclass('zd_up').addclass('zd_down'); zdhtm = zdnum+'%' zzhtml = zznum; }else{ $('.price_l .stk-data').find('.stc_updown').removeclass('zd_down').addclass('zd_up') $('.price_l .stk-data').find('.st_price').parent().removeclass('zd_down').addclass('zd_up') $('.price_l .stk-data').find('.st_price').removeclass('zd_down').addclass('zd_up') $(".price_l .sh_icon").css("transform","rotate(0deg)"); $(".price_l .sh_icon").attr("src","https://omo-oss-image.thefastimg.com/portal-saas/ngc202305220003/cms/image/63b50fa1-3832-44d8-98f9-804a016b5b3a.png"); $(".price_l").addclass("zhang").removeclass("die"); $('.price_l .stk-data').find('.st_price').siblings('i').html('') $('.price_l .stk-data').find('.st_zd').removeclass('zd_down').addclass('zd_up') zdhtm ='+'+zdnum+'%' zzhtml ='+'+ zznum; } //涨幅 $('.price_l .stk-data').find('.st_zd').html(zdhtm); $('.price_l .stk-data').find('.stc_updown').html(zzhtml); //成交数 $('.price_l .stk-data').find('.st_cj').html(cjnum); optforlang(lang,stock,code,stk_name,chart,p_close); } }); $(".price_l .stc-lang").find("a").each(function(){ $(this).on("click",function(){ $(this).addclass("now").siblings("a").removeclass("now"); var ilang = $(this).data("val") showforlang(ilang); var getvol = $(".price_l .stc-left.active").find(".st_cj").text(); if(getvol.indexof("万") > 0){ getvol = parsefloat(getvol) * 10000 }else if(getvol.indexof("k") > 0){ getvol = parsefloat(getvol) * 1000 }else if(getvol.indexof("mil") > 0){ getvol = parsefloat(getvol) * 1000000 }; $(".price_l .stc-left.active").find(".st_cj").text(showm(ilang,getvol)); $(".price_l .stc_amount").text(showm(ilang,getvol)) optforlang(ilang,stock,code,stk_name,chart,p_close) }) }); $(".price_l .kke_menus_tab_normal").each(function(index,tab){ $(this).on("click",function(){ $(this).addclass("kke_menus_tab_active").siblings().removeclass("kke_menus_tab_active"); var myid = $(this).data("id"); var lang = $(".price_l .stc-lang").find("a.now").data("val"); if(chart){ // 清空当前实例 chart.clear(); }; var ilang = $(".price_l .stc-lang").find("a.now").data("val"); if(ilang === "cn"){ switch(stock){ case "hushen": opt_title = ""; break; case "hk": opt_title = ""; break; }; }else{ switch(stock){ case "hushen": opt_title = "ssec"; break; case "hk": opt_title = "hsi"; break; }; }; switch(myid){ case "t1": t1(stock,code,stk_name,lang,opt_title,p_close); break; case "t5": if(stock == "hk"){ t5_hk(code,stk_name,lang,opt_title); }else{ t5(stock,code,stk_name,lang,opt_title); } break; case "kd": if(lang === "cn"){ opt_serious = "日k"; }else{ opt_serious = "1d"; } dk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "kw": if(lang === "cn"){ opt_serious = "周k"; }else{ opt_serious = "1w"; } wk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "km": if(lang === "cn"){ opt_serious = "月k"; }else{ opt_serious = "1m"; } mk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "ky": if(lang === "cn"){ opt_serious = "年k"; }else{ opt_serious = "1y"; } yk(stock,code,stk_name,lang,opt_title,opt_serious); break; } }) }) } function init2(lang,stock,code,chart){ var stk_name,opt_title,opt_legend,opt_serious,p_close; $.ajax({ type: "get", url: "//qt.gtimg.cn/q=" + stock + code, datatype:"script", cache:"false", success:function(){ var res = evil("v_" + stock + code); stk_name = res.split("~")[1]; showforlang(lang); $(".price_r .stc_name").html(stk_name); $(".price_r .stk-data").find(".stc-name").html(stk_name + "「" + code + "」"); res = res.split('~'); var zdnum,cjnum,zdhtm; var zznum,zzhtml; p_close = res[4]; //日期时间 var dtstr = res[30]; var dt_format = ""; if(stock == 'sh'){ dt_format = dtstr.substring(0,4) + "/" + dtstr.substring(4,6) + "/" + dtstr.substring(6,8) + " " + dtstr.substring(8,10) + ":" + dtstr.substring(10,12) + ":" + dtstr.substring(12) }else{ dt_format = dtstr } $('.price_r .stk-data').find('.st_date').html(dt_format); //价格 $('.price_r .stk-data').find('.st_price').html(todecimal(res[3])); // 最新股价 $('.price_r .stk-data').find('.stc_current').html(todecimal(res[3])); // 最高价 $('.price_r .stk-data').find('.stc_max').html(todecimal(res[33])); // 最低价 $('.price_r .stk-data').find('.stc_min').html(todecimal(res[34])); // (+/-)涨跌 $('.price_r .stk-data').find('.stc_updown').html(todecimal(res[31])); zznum = todecimal(res[31]); // 涨跌幅% $('.price_r .stk-data').find('.stc_rate_ud').html(todecimal(res[32])); zdnum = todecimal(res[32]) // 买入价 $('.price_r .stk-data').find('.stc_buy').html(todecimal(res[9])); // 卖出价 $('.price_r .stk-data').find('.stc_sell').html(todecimal(res[19])); // 成交量(手) $('.price_r .stk-data').find('.stc_amount').html(showm(lang,res[36])); cjnum = showm(lang,res[36]) if(zdnum <= 0){ $('.price_r .stk-data').find('.stc_updown').removeclass('zd_up').addclass('zd_down') $('.price_r .stk-data').find('.st_price').parent().removeclass('zd_up').addclass('zd_down') $('.price_r .stk-data').find('.st_price').removeclass('zd_up').addclass('zd_down') $(".price_r .sh_icon").css("transform","rotate(180deg)"); $(".price_r .sh_icon").attr("src","https://omo-oss-image.thefastimg.com/portal-saas/ngc202305220003/cms/image/b11594b6-4d28-4f91-a017-6cc67879b4ed.png"); $(".price_r").addclass("die").removeclass("zhang"); $('.price_r .stk-data').find('.st_price').siblings('i').html('') $('.price_r .stk-data').find('.st_zd').removeclass('zd_up').addclass('zd_down'); zdhtm = zdnum+'%' zzhtml = zznum; }else{ $('.price_r .stk-data').find('.stc_updown').removeclass('zd_down').addclass('zd_up') $('.price_r .stk-data').find('.st_price').parent().removeclass('zd_down').addclass('zd_up') $('.price_r .stk-data').find('.st_price').removeclass('zd_down').addclass('zd_up') $(".price_r .sh_icon").css("transform","rotate(0deg)"); $(".price_r .sh_icon").attr("src","https://omo-oss-image.thefastimg.com/portal-saas/ngc202305220003/cms/image/63b50fa1-3832-44d8-98f9-804a016b5b3a.png"); $(".price_r").addclass("zhang").removeclass("die"); $('.price_r .stk-data').find('.st_price').siblings('i').html('') $('.price_r .stk-data').find('.st_zd').removeclass('zd_down').addclass('zd_up') zdhtm ='+'+zdnum+'%' zzhtml ='+'+ zznum; } //涨幅 $('.price_r .stk-data').find('.st_zd').html(zdhtm); $('.price_r .stk-data').find('.stc_updown').html(zzhtml); //成交数 $('.price_r .stk-data').find('.st_cj').html(cjnum); optforlang(lang,stock,code,stk_name,chart,p_close); } }); $(".price_r .stc-lang").find("a").each(function(){ $(this).on("click",function(){ $(this).addclass("now").siblings("a").removeclass("now"); var ilang = $(this).data("val") showforlang(ilang); var getvol = $(".price_r .stc-left.active").find(".st_cj").text(); if(getvol.indexof("万") > 0){ getvol = parsefloat(getvol) * 10000 }else if(getvol.indexof("k") > 0){ getvol = parsefloat(getvol) * 1000 }else if(getvol.indexof("mil") > 0){ getvol = parsefloat(getvol) * 1000000 }; $(".price_r .stc-left.active").find(".st_cj").text(showm(ilang,getvol)); $(".price_r .stc_amount").text(showm(ilang,getvol)) optforlang(ilang,stock,code,stk_name,chart,p_close) }) }); $(".price_r .kke_menus_tab_normal").each(function(index,tab){ $(this).on("click",function(){ $(this).addclass("kke_menus_tab_active").siblings().removeclass("kke_menus_tab_active"); var myid = $(this).data("id"); var lang = $(".price_r .stc-lang").find("a.now").data("val"); if(chart){ // 清空当前实例 chart.clear(); }; var ilang = $(".price_r .stc-lang").find("a.now").data("val"); if(ilang === "cn"){ switch(stock){ case "hushen": opt_title = ""; break; case "hk": opt_title = ""; break; }; }else{ switch(stock){ case "hushen": opt_title = "ssec"; break; case "hk": opt_title = "hsi"; break; }; }; switch(myid){ case "t1": t1(stock,code,stk_name,lang,opt_title,p_close); break; case "t5": if(stock == "hk"){ t5_hk(code,stk_name,lang,opt_title); }else{ t5(stock,code,stk_name,lang,opt_title); } break; case "kd": if(lang === "cn"){ opt_serious = "日k"; }else{ opt_serious = "1d"; } dk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "kw": if(lang === "cn"){ opt_serious = "周k"; }else{ opt_serious = "1w"; } wk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "km": if(lang === "cn"){ opt_serious = "月k"; }else{ opt_serious = "1m"; } mk(stock,code,stk_name,lang,opt_title,opt_serious); break; case "ky": if(lang === "cn"){ opt_serious = "年k"; }else{ opt_serious = "1y"; } yk(stock,code,stk_name,lang,opt_title,opt_serious); break; } }) }) } function showforlang(lang){ if(lang == "cn"){ $(".stc-left-cn").addclass("active"); $(".stc-left-en").removeclass("active"); $(".pc_tb").find(".thead_cn").addclass("active"); $(".pc_tb").find(".thead_en").removeclass("active"); $(".wap_tb").find(".thead_cn").addclass("active"); $(".wap_tb").find(".thead_en").removeclass("active"); $(".kke_menus_tab_edage.tab_cn").addclass("active"); $(".kke_menus_tab_edage.tab_en").removeclass("active"); }else{ $(".stc-left-cn").removeclass("active"); $(".stc-left-en").addclass("active"); $(".pc_tb").find(".thead_cn").removeclass("active"); $(".pc_tb").find(".thead_en").addclass("active"); $(".wap_tb").find(".thead_cn").removeclass("active"); $(".wap_tb").find(".thead_en").addclass("active"); $(".kke_menus_tab_edage.tab_cn").removeclass("active"); $(".kke_menus_tab_edage.tab_en").addclass("active"); }; } function optforlang(lang,stock,code,name,chart,close){ if(lang === "cn"){ switch(stock){ case "sh": opt_title = ""; break; case "sz": opt_title = ""; break; case "hk": opt_title = ""; break; }; opt_legend = ['日k','5日均线','10日均线', '20日均线', '30日均线'], opt_serious = "日k"; }else{ switch(stock){ case "sh": opt_title = "ssec"; break; case "sz": opt_title = "ssec"; break; case "hk": opt_title = "hsi"; break; }; opt_legend = ['1d', 'ma5', 'ma10', 'ma20', 'ma30'] opt_serious = "1d"; }; if(chart){ // 清空当前实例 chart.clear(); }; $(".kke_menus_tab_edage.active").find(".kke_menus_tab_normal").each(function(){ if($(this).hasclass("kke_menus_tab_active")){ var getid = $(this).data("id"); switch(getid){ case "t1": t1(stock,code,name,lang,opt_title,close); break; case "t5": if(stock == "hk"){ t5_hk(code,name,lang,opt_title); }else{ t5(code,name,lang,opt_title); } break; case "kd": if(lang === "cn"){ opt_serious = "日k"; }else{ opt_serious = "1d"; } dk(stock,code,name,lang,opt_title,opt_serious); break; case "kw": if(lang === "cn"){ opt_serious = "周k"; }else{ opt_serious = "1w"; } wk(stock,code,name,lang,opt_title,opt_serious); break; case "km": if(lang === "cn"){ opt_serious = "月k"; }else{ opt_serious = "1m"; } mk(stock,code,name,lang,opt_title,opt_serious); break; case "ky": if(lang === "cn"){ opt_serious = "年k"; }else{ opt_serious = "1y"; } yk(stock,code,name,lang,opt_title,opt_serious); break; } } }) }; function getstock(lang,stock,precode,code){ $.ajax({ type: "get", url: "//qt.gtimg.cn/q=" + stock + code, datatype:"script", cache:"false", success:function(){ var res = evil("v_" + stock + code); stk_name = res.split("~")[1]; showforlang(lang); $(".price_r .stc_name").html(stk_name); $(".price_r .stk-data").find(".stc-name").html(stk_name + "「" + code + "」"); // ---------------------> res = res.split('~'); var zdnum,cjnum,zdhtm; var zznum,zzhtml; //日期时间 var dtstr = res[30]; var dt_format = ""; if(stock == 'sh'){ dt_format = dtstr.substring(0,4) + "/" + dtstr.substring(4,6) + "/" + dtstr.substring(6,8) + " " + dtstr.substring(8,10) + ":" + dtstr.substring(10,12) + ":" + dtstr.substring(12) }else{ dt_format = dtstr } $('.price_r .stk-data').find('.st_date').html(dt_format); //价格 $('.price_r .stk-data').find('.st_price').html(todecimal(res[3])); // 最新股价 $('.price_r .stk-data').find('.stc_current').html(todecimal(res[3])); // 最高价 $('.price_r .stk-data').find('.stc_max').html(todecimal(res[33])); // 最低价 $('.price_r .stk-data').find('.stc_min').html(todecimal(res[34])); // (+/-)涨跌 $('.price_r .stk-data').find('.stc_updown').html(todecimal(res[31])); zznum = todecimal(res[31]); // 涨跌幅% $('.price_r .stk-data').find('.stc_rate_ud').html(todecimal(res[32])); zdnum = todecimal(res[32]) // 买入价 $('.price_r .stk-data').find('.stc_buy').html(todecimal(res[9])); // 卖出价 $('.price_r .stk-data').find('.stc_sell').html(todecimal(res[19])); // 成交量(手) $('.price_r .stk-data').find('.stc_amount').html(showm(lang,res[36])); cjnum = showm(lang,res[36]) if(zdnum <= 0){ $('.price_r .stk-data').find('.stc_updown').removeclass('zd_up').addclass('zd_down') $('.price_r .stk-data').find('.st_price').parent().removeclass('zd_up').addclass('zd_down') $('.price_r .stk-data').find('.st_price').removeclass('zd_up').addclass('zd_down') $('.price_r .stk-data').find('.st_price').siblings('i').html('') $('.price_r .stk-data').find('.st_zd').removeclass('zd_up').addclass('zd_down'); zdhtm = zdnum+'%' zzhtml = zznum; }else{ $('.price_r .stk-data').find('.stc_updown').removeclass('zd_down').addclass('zd_up') $('.price_r .stk-data').find('.st_price').parent().removeclass('zd_down').addclass('zd_up') $('.price_r .stk-data').find('.st_price').removeclass('zd_down').addclass('zd_up') $('.price_r .stk-data').find('.st_price').siblings('i').html('') $('.price_r .stk-data').find('.st_zd').removeclass('zd_down').addclass('zd_up') zdhtm ='+'+zdnum+'%' zzhtml ='+'+ zznum; } //涨幅 $('.price_r .stk-data').find('.st_zd').html(zdhtm); $('.price_r .stk-data').find('.stc_updown').html(zzhtml); //成交数 $('.price_r .stk-data').find('.st_cj').html(cjnum); } }); }