/*!stogram2024-12-25*/ const token=localStorage.getItem("user-token"),api={...stogram.api,token:token,baseURL:"/openapi",response:function(t){if(200!==t.code)throw stogram.msg.error(t.msg),new Error("获取失败");return t.data}},lang=(document.querySelectorAll(".js-inquire").forEach(s=>{s.addEventListener("submit",()=>{var t=s.dataset["pluginId"],e=stogram.plugins[t],a=e.getValues();e.validAll()&&(stogram.msg.loading("正在提交..."),api.upload("/inquire/submit",new FormData(s)).then(t=>{stogram.msg.success("提交成功!"),setTimeout(function(){location.href="?submit=ok"},1e3)}).catch(t=>{stogram.msg.error("提交失败!")}),console.log(a)),console.log(t,e)})}),e=>{try{return LANG[e.toUpperCase()]?LANG[e.toUpperCase()]:e}catch(t){return e}}),fmt={bignum:function(t,e=0){var a,s=t;switch(1e4{var t=await api.post("/snippet/getStockIndex"),e=[];for(const i in t){var a,s,o,r=[...t[i]],n=t[i].shift(),c=t[i].pop();r.length&&(a=r.map(t=>t.timestamp),s=r.map(t=>t["收盘价"]),o=0{stogram.msg.loading("加载中...");t=await api.post("/snippet/getStockList",{market:t,sortby:e,page:a});return stogram.msg.success("加载完成"),t},fetchChart=async(a,s,o)=>{stogram.msg.loading("加载中...");a=await api.get("/snippet/getStockChart",{code:a,market:s,type:o});if(a){stogram.msg.success("加载完成");let t,e;e="idx"==s?(t=a.map(t=>t["日期"]),a.map(t=>[t["开盘价"],t["收盘价"],t["最低价"],t["最高价"]])):(t=a.map(t=>t.timestamp),a.map(t=>[t["开盘"],t["收盘"],t["最低"],t["最高"]]));o=(t,e)=>{for(var a=[],s=0,o=t.length;s{var t=await fetchStockIndex();$(".js-stock-index").empty(),t.map((t,e)=>{$(".js-stock-index").append(`
${t.vol1} ${t.name} ${t.vol2} ${t.vol3}%
`),echarts.init(a.querySelector(".ec-chart-"+e)).setOption(t.ec)})}),document.querySelectorAll(".js-stock-list").forEach(async a=>{var t=await fetchStockList(a.dataset.market,a.dataset.sortby,1);$(".js-stock-list").empty(),t.map((t,e)=>{$(".js-stock-list").append(` ${e+1} ${t["名称"]}${t["代码"]} ${fmt.chg(t["涨跌幅"])}% ${t["最新价"].toFixed(2)} ${fmt.bignum(t["成交量"])} 加自选 `)})}),document.querySelectorAll(".js-stock-chart").forEach(async t=>{t=await fetchChart(t.dataset.code,t.dataset.market,t.dataset.type);console.log(t),echarts.init(document.querySelector(".ec-chart")).setOption(t)}),document.querySelectorAll(".js-stock-chart-opts a").forEach(async t=>{t.addEventListener("click",t=>{$(t.target).addClass("active"),$(t.target).siblings().removeClass("active");const e=document.querySelector(".js-stock-chart"),a=t.target.dataset.type;(async()=>{var t=await fetchChart(e.dataset.code,e.dataset.market,a);echarts.init(document.querySelector(".ec-chart")).setOption(t)})()})});