common.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //JS操作cookies方法!
  2. //写cookies
  3. function setCookie(name, value) {
  4. var Days = 1;
  5. var exp = new Date();
  6. exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
  7. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  8. }
  9. function getCookie(name) {
  10. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  11. if (arr = document.cookie.match(reg))
  12. return unescape(arr[2]);
  13. else
  14. return null;
  15. }
  16. var lotLists = [];
  17. $(function () {
  18. isFold()
  19. //设置高频彩 刷新页面时当前的状态
  20. var hotId = getCookie('hotId');
  21. if (!hotId) {
  22. initLotList();
  23. } else {
  24. $(".hot-lot-lable").removeClass("active")
  25. $(".hot-lot-btn-box").find('[name="'+hotId+'"]').addClass("active");
  26. var hotIndex = $(".hot-lot-btn-box").find('[name="' + hotId + '"]').index();
  27. $(".hot-lottery-content").removeClass("active").eq(hotIndex).addClass("active");
  28. refreshLotList(hotId);
  29. }
  30. $(".hot-lot-lable").click(function () {
  31. var id = $(this).attr("name");
  32. var index = $(".hot-lot-lable").index(this);
  33. $(".hot-lot-lable").removeClass("active").eq(index).addClass("active");
  34. $(".hot-lottery-content").removeClass("active").eq(index).addClass("active");
  35. refreshLotList(id);
  36. //存储id
  37. setCookie('hotId',id);
  38. })
  39. $(".wfgz-lable").click(function () {
  40. var index = $(".wfgz-lable").index(this);
  41. $(".wfgz-lable").removeClass("active").eq(index).addClass("active");
  42. $(".wfgz-content").removeClass("active").eq(index).addClass("active");
  43. })
  44. $(".lot-title").click(function () {
  45. var index = $(".lot-title").index(this);
  46. if ($(this).hasClass("active")) {
  47. $(this).removeClass("active");
  48. $(".lot-list-wrapper").eq(index).removeClass("active");
  49. }
  50. else {
  51. $(".lot-title").removeClass("active").eq(index).addClass("active");
  52. $(".lot-list-wrapper").removeClass("active").eq(index).addClass("active");
  53. }
  54. })
  55. })
  56. function initLotList() {
  57. if (lotLists.length > 0) {
  58. for (var i = 0; i < lotLists.length; i++) {
  59. lotLists[i].dele();
  60. }
  61. }
  62. lotLists = [];
  63. $(".typecell-list").each(function (i, e) {
  64. var c = $(e).children(".lotCode:eq(0)").val();
  65. var t = $(e).children(".time:eq(0)").val();
  66. lotLists[i] = new Balljump(e, c, t);
  67. })
  68. }
  69. function refreshLotList(name) {
  70. $.ajax({
  71. type: "post",
  72. url: "/Template/Home_Tab",
  73. data: {
  74. czTypeEnum: name
  75. },
  76. success: function (res) {
  77. var next = $("#GPC-box").next("section");
  78. $("#GPC-box").remove();
  79. next.before(res)
  80. initLotList();
  81. }
  82. });
  83. }
  84. function IsPC() {
  85. var userAgentInfo = navigator.userAgent;
  86. var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
  87. var flag = true;
  88. for (var v = 0; v < Agents.length; v++) {
  89. if (userAgentInfo.indexOf(Agents[v]) > 0) {
  90. flag = false;
  91. break;
  92. }
  93. }
  94. return flag;
  95. }
  96. function isFold() {
  97. var PC = IsPC();
  98. if (!PC) {
  99. $(".main").addClass('pon')
  100. } else {
  101. $(".main").removeClass('pon')
  102. }
  103. }