succutil.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. $(function(){
  2. fog = getUrlParam("fog"),
  3. phone = getUrlParam("phone"),
  4. fes = getUrlParam("fes"),
  5. sou = getUrlParam("sou"),
  6. go('tt');
  7. window.history.pushState({}, "", "go.do?fes="+fes+"&sou="+sou);
  8. })
  9. var fog;
  10. var phone;
  11. var fes;
  12. var sou;
  13. //环形图
  14. var fw=$('.header1').width();
  15. $('.header1').height(fw);
  16. var c = document.getElementById('myCanvas');
  17. var ctx = c.getContext('2d');
  18. var process = 0;
  19. var w=parseInt($('#myCanvas').css('width'))
  20. var mW = c.width =w;
  21. var mH = c.height = w;
  22. var lineWidth = 5;
  23. var r = mW / 2;
  24. var cR = r - 4 * lineWidth; //圆半径
  25. var startAngle = -(1 / 2 * Math.PI); //开始角度
  26. var endAngle = startAngle + 2 * Math.PI; //结束角度
  27. var xAngle = 1 * (Math.PI / 180); //偏移角度量
  28. var fontSize = 35; //字号大小
  29. var tmpAngle = startAngle; //临时角度变量
  30. //渲染函数
  31. var rander = function(ctx,prs){
  32. ctx.clearRect(0, 0, mW, mH);
  33. ctx.beginPath();
  34. ctx.lineWidth = 25;
  35. ctx.strokeStyle = '#F86A5C';
  36. ctx.arc(r, r, cR, 0,Math.PI * 2);
  37. ctx.stroke();
  38. ctx.closePath();
  39. ctx.beginPath();
  40. ctx.lineWidth = 15;
  41. ctx.lineCap = 'round'
  42. ctx.strokeStyle = '#fff';
  43. ctx.arc(r, r, cR, Math.PI * (1.5 + 2 * prs/ 100 ),Math.PI * 1.5);
  44. ctx.stroke();
  45. ctx.closePath();
  46. };
  47. function animate(i){
  48. requestAnimationFrame(function (){
  49. process = process + 1;
  50. rander(ctx, process);
  51. if (process < i) {
  52. animate(i);
  53. }
  54. });
  55. }
  56. //弹窗
  57. function go(product){
  58. $("#go").removeAttr("onclick");
  59. $.ajax({
  60. type : "POST",
  61. contentType : "application/json; charset=utf-8",
  62. dataType : "Json",
  63. url : '/orderchannel/com/queryl',//目标地址
  64. data : JSON.stringify(GetFlowJsonData(product)),
  65. success : function(msg) {
  66. var resCode = eval(msg["resultCode"]);
  67. if (resCode == "0000") {
  68. var data = msg["date"];
  69. var usermob = data["phone"]
  70. $("#phone").text(usermob);
  71. var stu = data["stu"]
  72. if(stu==0){
  73. $("title").text("订购成功");//修改页面标题
  74. $("#sta").text("订购");
  75. }else{
  76. $("title").text("退订成功");//修改页面标题
  77. $("#sta").text("退订");
  78. $("#cancel").remove();
  79. $("#yuyueys").remove();
  80. }
  81. var productid = data["productid"]
  82. if(productid=='2017060802'){//页面为15元
  83. $("#ys").text("15/6G");
  84. }
  85. if(productid=='2018072301'){//页面为10元
  86. $("#ys").text("9/10G");
  87. }
  88. var flow = msg["queryflow"];
  89. var usedFlow = (flow["usedFlow"]/1024/1024).toFixed(2);//用户使用流量
  90. $("#usedFlow").text(usedFlow+"GB");
  91. var lodFlow = (flow["surplusFlow"]/1024/1024).toFixed(2);//剩余流量
  92. $("#lodFlow").text(lodFlow+"GB");
  93. var totalFlow = (flow["totalFlow"]/1024/1024).toFixed(2);//总流量
  94. $("#totalFlow").text(lodFlow+"GB");
  95. var couflow = totalFlow/100;//1%为多少kb
  96. var usedf = usedFlow/couflow;
  97. animate(usedf);
  98. //$("#go").attr("onclick","go('tt')"); //查询成功后不给与用户重新查询
  99. } else {
  100. if (resCode == "4015") {//本地为查询到用户订购关系
  101. gotorder();
  102. }else{
  103. animate(0);
  104. $("#go").attr("onclick","go('tt')");
  105. }
  106. }
  107. },
  108. error : function(XMLHttpRequest, textStatus, errorThrown) {
  109. animate(0);
  110. $("#go").attr("onclick","go('tt')");
  111. },
  112. });
  113. }