jump.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /** 跳转的代码 **/
  2. var jumpOldContent = $("#head").attr("content");
  3. var jumpcontent = "width=device-width, initial-scale=1,maximum-scale=1,minimum-scale=1";
  4. var report_info = $(".report_info").html();
  5. var pageCount = parseInt($(".get_page_count").html());
  6. var Page = parseInt($(".get_page").html());
  7. var PageInfo = $(".get_page_info").html();
  8. var error = ['已经是第一页了', '已经是最后一页了', '跳转页数超出的范围', '已经在当前页了无需跳转'];
  9. var url = "";
  10. if (report_info !== null && report_info !== undefined && report_info !== '') {
  11. var report_info_obj = eval("(" + report_info + ")");
  12. if (report_info_obj.url !== undefined && report_info_obj.url !== null && report_info_obj.url !== '') {
  13. url = report_info_obj.url;
  14. }
  15. }
  16. var transform = 0.84;
  17. var bottom = 20;
  18. var headers = {};
  19. var headerArr = jumpOldContent.split(',');
  20. headerArr.forEach(item => {
  21. if (item !== '') {
  22. var index = item.indexOf('=');
  23. var key = item.slice(0, index);
  24. key = key.trim();
  25. var value = item.slice(index + 1).trim();
  26. headers[key] = value;
  27. }
  28. })
  29. if (headers['initial-scale'] !== null && headers['initial-scale'] !== undefined) {
  30. var scale = parseFloat(headers['initial-scale']);
  31. if (scale !== 1) {
  32. transform = 0.84 / scale;
  33. bottom = 1 / scale * 20 + (1 / scale - 1) * 36 / 2;
  34. }
  35. }
  36. var pageDiv = ' <div class="page" style="transform:scale(' + transform + ');bottom:' + bottom + 'px;">\n' +
  37. ' <ul class="flex-between">\n' +
  38. ' <li id="prev_btn"><img src="' + url + '/reportForms/image/last_icon.png"></li>\n' +
  39. ' <li id="next_btn"><img src="' + url + '/reportForms/image/next_icon.png"></li>\n' +
  40. ' <li id="jump-phone"><img src="' + url + '/reportForms/image/tz_icon.png" id="jump-phone-img"></li>\n' +
  41. ' <li > <button class="table-serial-btn none">选择</button></li>' +
  42. ' </ul>\n' +
  43. ' </div>';
  44. $(".condition-box").append(pageDiv);
  45. var jump_interface_page = '<div class="jump-interface jump-interface-page none">\n' +
  46. ' <div class="jump-box">' +
  47. ' <ul>' +
  48. ' <li class="tip">跳转</li>' +
  49. ' <li>' +
  50. PageInfo +
  51. ' </li>' +
  52. ' <li>将跳转到' +
  53. ' <input class="jumpNumber" id="jumpNumber" type="text"' +
  54. ' value="1" onkeyup="checkLen2(this)" oninput="value=value.replace(/[^\\d]/g,\'\')">' +
  55. ' </li>' +
  56. ' <li class="jump-save-box">' +
  57. ' <button class="jump" id="jump">跳转</button>' +
  58. ' <button class="cancel" id="cancel">取消</button>' +
  59. ' </li>' +
  60. ' </ul>' +
  61. ' </div>' +
  62. '</div>';
  63. var jump_interface_error = '<div class="jump-interface jump-interface-error none">' +
  64. ' <div class="jump-box">' +
  65. ' <ul>' +
  66. ' <li class="tip">错误提示</li>' +
  67. ' <li class="tip-content">' +
  68. ' <div id="tip-content-div"></div>' +
  69. ' </li>' +
  70. ' <li class="jump-save-box">' +
  71. ' <button class="jump" id="esure">确定</button>' +
  72. ' <button class="cancel" id="esure-cancel">取消</button>' +
  73. ' </li>' +
  74. ' </ul>' +
  75. ' </div>' +
  76. '</div>';
  77. $("body").append(jump_interface_page);
  78. $("body").append(jump_interface_error);
  79. //上一页
  80. document.getElementById("prev_btn").onclick = function () {
  81. skip(0);
  82. };
  83. //下一页
  84. document.getElementById("next_btn").onclick = function () {
  85. skip(1);
  86. };
  87. //跳转功能代码
  88. function skip(type) {
  89. var jumpNumber = Page;
  90. var errorBool = false;
  91. if (type == 0) {
  92. Page = Page - 1;
  93. if (Page < 1) {
  94. errorBool = true;
  95. }
  96. } else if (type == 1) {
  97. Page = Page + 1;
  98. if (Page > pageCount) {
  99. errorBool = true;
  100. }
  101. } else {
  102. var PageValue = document.getElementById("jumpNumber").value;
  103. if (typeof PageValue == "undefined" || PageValue == null || PageValue == "") {
  104. errorBool = true;
  105. } else {
  106. Page = parseInt(PageValue);
  107. if (Page == null || Page < 1 || Page > pageCount) {
  108. errorBool = true;
  109. }
  110. if (jumpNumber == Page) {
  111. type = 3;
  112. errorBool = true;
  113. }
  114. }
  115. }
  116. if (errorBool) {
  117. Page = jumpNumber;
  118. document.getElementById("tip-content-div").innerHTML = error[type];
  119. $(".condition-box").addClass("none");
  120. $("#head").attr("content", content);
  121. $(".jump-interface-error").removeClass("none");
  122. } else {
  123. alert("JumpPage@" + Page);
  124. }
  125. }
  126. //自定义键盘
  127. var coolInput = new CoolInput({slt: '#jumpNumber'});
  128. //跳转界面
  129. document.getElementById("jump-phone-img").onclick = function () {
  130. jumpOldContent = $("#head").attr("content");
  131. $(".condition-box").addClass("none");
  132. $("#head").attr("content", jumpcontent);
  133. $(".jump-interface-page").removeClass("none");
  134. coolInput.cursorT = $("#jumpNumber").offset().top;
  135. };
  136. //跳转
  137. document.getElementById("jump").onclick = function () {
  138. $(".jump-interface-page").addClass("none");
  139. $("#head").attr("content", jumpOldContent);
  140. $(".condition-box").removeClass("none");
  141. skip(2);
  142. };
  143. document.getElementById("cancel").onclick = function () {
  144. $(".jump-interface-page").addClass("none");
  145. $("#head").attr("content", jumpOldContent);
  146. $(".condition-box").removeClass("none");
  147. };
  148. document.getElementById("esure").onclick = function () {
  149. $(".jump-interface-error").addClass("none");
  150. $("#head").attr("content", jumpOldContent);
  151. $(".condition-box").removeClass("none");
  152. };
  153. document.getElementById("esure-cancel").onclick = function () {
  154. $(".jump-interface-error").addClass("none");
  155. $("#head").attr("content", jumpOldContent);
  156. $(".condition-box").removeClass("none");
  157. };