No Description

top10.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. var dataList=[]
  2. var content=''
  3. var index=0
  4. $().ready(function () {
  5. count_down('2019-1-1 00:00:00')
  6. getList()
  7. everyOneMoney();
  8. })
  9. function getList() {
  10. $.ajax({
  11. type: 'post',
  12. url: '/api/v2/pullTheNewUser/topList',
  13. success: function (res) {
  14. if (res && res.errno == 0) {
  15. content=""
  16. dataList=res.rst
  17. for(var i in dataList){
  18. if(dataList[i].nickname.length>5){
  19. dataList[i].nickname=dataList[i].nickname.substring(0, 4)+"..."
  20. }
  21. index++;
  22. if(index<=3){
  23. content+=`
  24. <tr>
  25. <td>
  26. <span class="num">
  27. <img class="medal" src="./img/gold.png" style="display:`+(index==1?'block':'none')+`">
  28. <img class="medal" src="./img/sliver.png" style="display:`+(index==2?'block':'none')+`">
  29. <img class="medal" src="./img/bronze.png" style="display:`+(index==3?'block':'none')+`">
  30. </span>
  31. </td>
  32. <td>
  33. <img class="head" src="`+dataList[i].headimgurl+`">
  34. </td>
  35. <td>`+dataList[i].nickname+`</td>
  36. <td>`+dataList[i].newUserNum+`</td>
  37. <td>`+dataList[i].money+`元</td>
  38. </tr>
  39. `
  40. }else {
  41. content+=`
  42. <tr>
  43. <td>
  44. <span class="num">
  45. `+index+`
  46. </span>
  47. </td>
  48. <td>
  49. <img class="head" src="`+dataList[i].headimgurl+`">
  50. </td>
  51. <td>`+dataList[i].nickname+`</td>
  52. <td>`+dataList[i].newUserNum+`</td>
  53. <td>`+dataList[i].money+`元</td>
  54. </tr>
  55. `
  56. }
  57. }
  58. $("#table").append(content)
  59. }
  60. },
  61. fail: function () {
  62. console.log("fail")
  63. }
  64. })
  65. }
  66. // 倒计时
  67. function count_down(o) {
  68. // $("#test").html(o);
  69. time = setTimeout(function () { count_down(o) }, 1000);
  70. var datatime = /^[\d]{4}-[\d]{1,2}-[\d]{1,2}( [\d]{1,2}:[\d]{1,2}(:[\d]{1,2})?)?$/ig, str = '', conn, s;
  71. if (!o.match(datatime)) {
  72. // alert('参数格式为2020-01-01[ 01:01[:01]].\r其中[]内的内容可省略');
  73. return false;
  74. }
  75. var sec = (new Date(o.replace(/-/ig, '/')).getTime() - new Date().getTime()) / 1000;
  76. // $("#test1").text(sec)
  77. if (sec == 0 || sec < 0) {
  78. html = `<img class="img" src="https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/shuangshiyi/chaojihongbao/yure_hongbao.png" />`
  79. $('.daojishi').html(html);
  80. $(".button").addClass('buttonActive');
  81. $(".button").click(function () {
  82. copyPassword();
  83. })
  84. clearTimeout(time);
  85. } else {
  86. s = { '天': sec / 24 / 3600, '时': Math.floor(sec / 3600 % 24), '分': Math.floor(sec / 60 % 60),'秒':Math.floor(sec%60) };
  87. for (i in s) {
  88. if (s[i] < 10) { s[i] = '0' + s[i] };
  89. if (i != '天') {
  90. str += '<span>' + s[i] + '</span>' + i;
  91. } else {
  92. str += '<span>' + parseInt(s[i]) + '</span>' + i;
  93. }
  94. }
  95. $("#count").html(str)
  96. }
  97. }
  98. function count_down(o) {
  99. // $("#test").html(o);
  100. time = setTimeout(function () { count_down(o) }, 1000);
  101. var datatime = /^[\d]{4}-[\d]{1,2}-[\d]{1,2}( [\d]{1,2}:[\d]{1,2}(:[\d]{1,2})?)?$/ig, str = '', conn, s;
  102. if (!o.match(datatime)) {
  103. // alert('参数格式为2020-01-01[ 01:01[:01]].\r其中[]内的内容可省略');
  104. return false;
  105. }
  106. var sec = (new Date(o.replace(/-/ig, '/')).getTime() - new Date().getTime()) / 1000;
  107. // $("#test1").text(sec)
  108. if (sec == 0 || sec < 0) {
  109. html = `<img class="img" src="https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/shuangshiyi/chaojihongbao/yure_hongbao.png" />`
  110. $('.daojishi').html(html);
  111. $(".button").addClass('buttonActive');
  112. $(".button").click(function () {
  113. copyPassword();
  114. })
  115. clearTimeout(time);
  116. } else {
  117. s = { '天': sec / 24 / 3600, '时': Math.floor(sec / 3600 % 24), '分': Math.floor(sec / 60 % 60),'秒':Math.floor(sec%60) };
  118. for (i in s) {
  119. if (s[i] < 10) { s[i] = '0' + s[i] };
  120. if (i != '天') {
  121. str += '<span>' + s[i] + '</span>' + i;
  122. } else {
  123. str += '<span>' + parseInt(s[i]) + '</span>' + i;
  124. }
  125. }
  126. $("#count").html(str)
  127. }
  128. }
  129. function everyOneMoney() {
  130. $.ajax({
  131. type: 'post',
  132. url: '/api/v2/pullTheNewUser/everyOneMoney',
  133. dataType: 'json',
  134. success: function (res) {
  135. if (res && res.errno == 0) {
  136. odometer.innerHTML = Number(res.rst.every_money);
  137. }else{
  138. $(".bottomPrice").html('')
  139. }
  140. },
  141. fail: function () {
  142. }
  143. })
  144. }