$(function(){ fog = getUrlParam("fog"), phone = getUrlParam("phone"), go('tt'); $("#useraccount_tt").attr("value",getUrlParam("use")); window.history.pushState({}, "", getRootPath() + "-s1api" + "/go.do?fes="+fes+"&sou=" + sou); }) var fog; var phone; //环形图 var fw=$('.header1').width(); $('.header1').height(fw); var c = document.getElementById('myCanvas'); var ctx = c.getContext('2d'); var process = 0; var w=parseInt($('#myCanvas').css('width')) var mW = c.width =w; var mH = c.height = w; var lineWidth = 5; var r = mW / 2; var cR = r - 4 * lineWidth; //圆半径 var startAngle = -(1 / 2 * Math.PI); //开始角度 var endAngle = startAngle + 2 * Math.PI; //结束角度 var xAngle = 1 * (Math.PI / 180); //偏移角度量 var fontSize = 35; //字号大小 var tmpAngle = startAngle; //临时角度变量 //渲染函数 var rander = function(ctx,prs){ ctx.clearRect(0, 0, mW, mH); ctx.beginPath(); ctx.lineWidth = 25; ctx.strokeStyle = '#F86A5C'; ctx.arc(r, r, cR, 0,Math.PI * 2); ctx.stroke(); ctx.closePath(); ctx.beginPath(); ctx.lineWidth = 15; ctx.lineCap = 'round' ctx.strokeStyle = '#fff'; ctx.arc(r, r, cR, Math.PI * (1.5 + 2 * prs/ 100 ),Math.PI * 1.5); ctx.stroke(); ctx.closePath(); }; function animate(i){ requestAnimationFrame(function (){ process = process + 1; rander(ctx, process); if (process < i) { animate(i); } }); } var usedf; var sta = 0; //弹窗 function go(product){ if(sta==0){ $("#go").removeAttr("onclick"); $.ajax({ type : "POST", contentType : "application/json; charset=utf-8", dataType : "Json", url : getRootPath() + "-s1api" + '/com/queryl',//目标地址 data : JSON.stringify(GetFlowJsonData(product)), success : function(msg) { var resCode = eval(msg["resultCode"]); if (resCode == "0000") { var data = msg["date"]; var usermob = data["phone"] $("#phone").text(usermob); var stu = data["stu"] if(stu==0){ $("title").text("订购成功");//修改页面标题 $("#sta").text("订购"); }else{ $("title").text("退订成功");//修改页面标题 $("#sta").text("退订"); $("#cancel").remove(); $("#yuyueys").remove(); } var productid = data["productid"] if(productid=='2017060802'){//页面为15元 $("#ys").text("15/6G"); } if(productid=='2018072301'){//页面为10元 $("#ys").text("9/10G"); $("#yuyueys").remove(); } var flow = msg["queryflow"]; var usedFlow = (flow["usedFlow"]/1024/1024).toFixed(2);//用户使用流量 $("#usedFlow").text(usedFlow+"GB"); var lodFlow = (flow["surplusFlow"]/1024/1024).toFixed(2);//剩余流量 $("#lodFlow").text(lodFlow+"GB"); var totalFlow = (flow["totalFlow"]/1024/1024).toFixed(2);//总流量 $("#totalFlow").text(lodFlow+"GB"); var couflow = totalFlow/100;//1%为多少kb usedf = usedFlow/couflow; animate(usedf); sta = 1;//说明查询成功 $("#go").attr("onclick","go('tt')"); //查询成功后不给与用户重新查询 } else { if (resCode == "4015") {//本地为查询到用户订购关系 //gotorder(); }else{ animate(0); $("#go").attr("onclick","go('tt')"); } } }, error : function(XMLHttpRequest, textStatus, errorThrown) { animate(0); $("#go").attr("onclick","go('tt')"); }, }); }else { process = 0; animate(usedf); } }