main.min.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. var Msize = $(".m-page").size(), page_n = 1, initP = null, moveP = null, firstP = null, newM = null, p_b = null, indexP = null, move = null, start = true, startM = null, position = null, DNmove = false, mapS = null, canmove = false, textNode = [], textInt = 1;
  2. audio_switch_btn = true, audio_btn = true, audio_loop = false, audioTime = null, audioTimeT = null, audio_interval = null, audio_start = null, audio_stop = null, mousedown = null, plugin_type = {"info_pic2": {num: 0, id: 0}, "info_nomore": {num: 0, id: 0}, "info_more": {num: 0, id: 0}, "multi_contact": {num: 0, id: 0}, "video": {num: 0, id: 0}, "input": {num: 0, id: 0}, "dpic": {num: 0, id: 0}};
  3. var v_h = null;
  4. var v_w = null;
  5. function init_pageH(b) {
  6. var e = function() {
  7. if (document.compatMode == "BackCompat") {
  8. var f = document.body
  9. } else {
  10. var f = document.documentElement
  11. }
  12. return Math.max(f.scrollHeight, f.clientHeight)
  13. };
  14. var c = function() {
  15. if (document.compatMode == "BackCompat") {
  16. var f = document.body
  17. } else {
  18. var f = document.documentElement
  19. }
  20. return Math.max(f.scrollWidth, f.clientWidth)
  21. };
  22. var d = e();
  23. var a = $(".m-page").height();
  24. d >= a ? v_h = d : v_h = a;
  25. v_w = c();
  26. $(".m-page").height(v_h);
  27. $(".p-index").height(v_h)
  28. }
  29. init_pageH();
  30. var lazyNode = $(".lazy-bk");
  31. lazyNode.each(function() {
  32. var a = $(this);
  33. if (a.is("img")) {
  34. a.attr("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC")
  35. } else {
  36. a.css({"background-image": "url(../images/loading.gif)", "background-size": "120px 120px"})
  37. }
  38. });
  39. setTimeout(function() {
  40. for (var a = 0; a < 3; a++) {
  41. var b = $(".m-page").eq(a);
  42. if (b.length == 0) {
  43. break
  44. }
  45. if (b.find(".lazy-bk").length != 0) {
  46. lazy_change(b)
  47. } else {
  48. continue
  49. }
  50. }
  51. }, 200);
  52. function lazy_bigP() {
  53. for (var a = 3; a <= 5; a++) {
  54. var b = $(".m-page").eq(page_n + a - 1);
  55. if (b.length == 0) {
  56. break
  57. }
  58. if (b.find(".lazy-bk").length != 0) {
  59. lazy_change(b)
  60. } else {
  61. continue
  62. }
  63. }
  64. }
  65. function lazy_change(b) {
  66. if (b.attr("data-yuyue") == "true") {
  67. $(".weixin-share").find(".lazy-bk").attr("src", $(".weixin-share").find(".lazy-bk").attr("data-bk"))
  68. }
  69. var a = b.find(".lazy-bk");
  70. a.each(function() {
  71. var c = $(this), d = c.attr("data-bk");
  72. $("<img />").on("load", function() {
  73. if (c.is("img")) {
  74. c.attr("src", d)
  75. } else {
  76. c.css({"background-image": "url(" + d + ")", "background-size": "cover"})
  77. }
  78. for (var e = 0; e < $(".m-page").size(); e++) {
  79. var f = $(".m-page").eq(e);
  80. if ($(".m-page").find(".lazy-bk").length == 0) {
  81. continue
  82. } else {
  83. lazy_change(f)
  84. }
  85. }
  86. }).attr("src", d);
  87. c.removeClass("lazy-bk")
  88. })
  89. }
  90. function changeOpen(a) {
  91. $(".v-page").on("mousedown touchstart", page_v_touchstart);
  92. $(".v-page").on("mousemove touchmove", page_v_touchmove);
  93. $(".v-page").on("mouseup touchend mouseout", page_v_touchend);
  94. $(".h-page").on("mousedown touchstart", page_h_touchstart);
  95. $(".h-page").on("mousemove touchmove", page_h_touchmove);
  96. $(".h-page").on("mouseup touchend mouseout", page_h_touchend)
  97. }
  98. function changeClose(a) {
  99. $(".v-page").off("mousedown touchstart");
  100. $(".v-page").off("mousemove touchmove");
  101. $(".v-page").off("mouseup touchend mouseout")
  102. }
  103. function page_v_touchstart(a) {
  104. if (a.type == "touchstart") {
  105. initP = window.event.touches[0].pageY
  106. } else {
  107. initP = a.y || a.pageY;
  108. mousedown = true
  109. }
  110. firstP = initP
  111. }
  112. function page_h_touchstart(a) {
  113. if (a.type == "touchstart") {
  114. initP = window.event.touches[0].pageX
  115. } else {
  116. initP = a.x || a.pageX;
  117. mousedown = true
  118. }
  119. firstP = initP
  120. }
  121. function V_start(a) {
  122. initP = a;
  123. mousedown = true;
  124. firstP = initP
  125. }
  126. function page_v_touchmove(b) {
  127. b.preventDefault();
  128. b.stopPropagation();
  129. if (page_n == Msize) {
  130. window.location.href = "http://game.ikongzhong.cn/games/zazhi/";
  131. return
  132. }
  133. if (start || startM) {
  134. startM = true;
  135. if (b.type == "touchmove") {
  136. moveP = window.event.touches[0].pageY;
  137. moveP2 = window.event.touches[0].pageX
  138. } else {
  139. if (mousedown) {
  140. moveP = b.y || b.pageY
  141. }
  142. if (mousedown) {
  143. moveP2 = b.x || b.pageX
  144. }
  145. }
  146. page_n == 1 ? indexP = false : indexP = true
  147. }
  148. if (moveP && startM) {
  149. if (!p_b) {
  150. p_b = true;
  151. position = moveP - initP > 0 ? true : false;
  152. if (position) {
  153. if (indexP) {
  154. newM = page_n - 1;
  155. $(".m-page").eq(newM - 1).addClass("active").css("top", -v_h);
  156. move = true
  157. } else {
  158. if (canmove) {
  159. move = true;
  160. newM = Msize;
  161. $(".m-page").eq(newM - 1).addClass("active").css("top", -v_h)
  162. } else {
  163. move = false
  164. }
  165. }
  166. } else {
  167. if (page_n != Msize) {
  168. if (!indexP) {
  169. $(".audio_txt").addClass("close")
  170. }
  171. newM = page_n + 1
  172. } else {
  173. newM = 1
  174. }
  175. $(".m-page").eq(newM - 1).addClass("active").css("top", v_h);
  176. move = true
  177. }
  178. }
  179. if (!DNmove) {
  180. if (move) {
  181. if ($("#car_audio").length > 0 && audio_switch_btn && Math.abs(moveP - firstP) > 100) {
  182. $("#car_audio")[0].play();
  183. audio_loop = true
  184. }
  185. start = false;
  186. var a = parseInt($(".m-page").eq(newM - 1).css("top"));
  187. $(".m-page").eq(newM - 1).css({"top": a + moveP - initP});
  188. initP = moveP
  189. } else {
  190. moveP = null
  191. }
  192. } else {
  193. moveP = null
  194. }
  195. }
  196. }
  197. function page_h_touchmove(b) {
  198. b.preventDefault();
  199. b.stopPropagation();
  200. if (page_n == Msize) {
  201. window.location.href = "http://game.ikongzhong.cn/games/zazhi/"
  202. }
  203. if (start || startM) {
  204. startM = true;
  205. if (b.type == "touchmove") {
  206. moveP = window.event.touches[0].pageX
  207. } else {
  208. if (mousedown) {
  209. moveP = b.x || b.pageX
  210. }
  211. }
  212. page_n == 1 ? indexP = false : indexP = true
  213. }
  214. if (moveP && startM) {
  215. if (!p_b) {
  216. p_b = true;
  217. position = moveP - initP > 0 ? true : false;
  218. if (position) {
  219. if (page_n != Msize) {
  220. if (!indexP) {
  221. $(".audio_txt").addClass("close")
  222. }
  223. newM = page_n + 1
  224. } else {
  225. newM = 1
  226. }
  227. $(".m-page").eq(newM - 1).addClass("active").css("left", -v_w);
  228. move = true
  229. } else {
  230. if (page_n != Msize) {
  231. if (!indexP) {
  232. $(".audio_txt").addClass("close")
  233. }
  234. newM = page_n + 1
  235. } else {
  236. newM = 1
  237. }
  238. $(".m-page").eq(newM - 1).addClass("active").css("left", v_w);
  239. move = true
  240. }
  241. }
  242. if (!DNmove) {
  243. if (move) {
  244. if ($("#car_audio").length > 0 && audio_switch_btn && Math.abs(moveP - firstP) > 100) {
  245. $("#car_audio")[0].play();
  246. audio_loop = true
  247. }
  248. start = false;
  249. var a = parseInt($(".m-page").eq(newM - 1).css("left"));
  250. $(".m-page").eq(newM - 1).css({"left": a + moveP - initP});
  251. initP = moveP
  252. } else {
  253. moveP = null
  254. }
  255. } else {
  256. moveP = null
  257. }
  258. }
  259. }
  260. function page_v_touchend(a) {
  261. startM = null;
  262. p_b = false;
  263. audio_close();
  264. var b;
  265. position ? b = moveP - firstP > 100 : b = firstP - moveP > 100;
  266. if (move) {
  267. if (b && Math.abs(moveP) > 5) {
  268. $(".m-page").eq(newM - 1).animate({"top": 0}, 300, "easeOutSine", function() {
  269. success()
  270. })
  271. } else {
  272. if (Math.abs(moveP) >= 5) {
  273. position ? $(".m-page").eq(newM - 1).animate({"top": -v_h}, 100, "easeOutSine") : $(".m-page").eq(newM - 1).animate({"top": v_h}, 100, "easeOutSine");
  274. $(".m-page").eq(newM - 1).removeClass("active");
  275. start = true
  276. }
  277. }
  278. }
  279. initP = null, moveP = null, firstP = null, mousedown = null;
  280. initP2 = null, moveP2 = null, firstP2 = null, mousedown2 = null
  281. }
  282. function page_h_touchend(a) {
  283. startM = null;
  284. p_b = false;
  285. audio_close();
  286. var b;
  287. position ? b = moveP - firstP > 100 : b = firstP - moveP > 100;
  288. if (move) {
  289. if (b && Math.abs(moveP) > 5) {
  290. $(".m-page").eq(newM - 1).animate({"left": 0}, 300, "easeOutSine", function() {
  291. success()
  292. })
  293. } else {
  294. if (Math.abs(moveP) >= 5) {
  295. position ? $(".m-page").eq(newM - 1).animate({"left": -v_w}, 100, "easeOutSine") : $(".m-page").eq(newM - 1).animate({"left": v_w}, 100, "easeOutSine");
  296. $(".m-page").eq(newM - 1).removeClass("active");
  297. start = true
  298. }
  299. }
  300. }
  301. initP = null, moveP = null, firstP = null, mousedown = null;
  302. initP2 = null, moveP2 = null, firstP2 = null, mousedown2 = null
  303. }
  304. function success() {
  305. $(".m-page").eq(page_n - 1).removeClass("show active").addClass("hide");
  306. $(".m-page").eq(newM - 1).removeClass("active hide").addClass("show");
  307. if ($(".m-page.show").hasClass("h-page")) {
  308. $(".u-arrow").css("display", "none")
  309. } else {
  310. $(".u-arrow").css("display", "block")
  311. }
  312. lazy_bigP();
  313. page_n = newM;
  314. start = true;
  315. if (page_n == Msize) {
  316. canmove = true
  317. }
  318. }
  319. function audio_close() {
  320. if (audio_btn && audio_loop) {
  321. audio_btn = false;
  322. audioTime = Number($("#car_audio")[0].duration - $("#car_audio")[0].currentTime) * 1000;
  323. if (audioTime < 0) {
  324. audioTime = 0
  325. }
  326. if (audio_start) {
  327. if (isNaN(audioTime)) {
  328. audioTime = audioTimeT
  329. } else {
  330. audioTime > audioTimeT ? audioTime = audioTime : audioTime = audioTimeT
  331. }
  332. }
  333. if (!isNaN(audioTime) && audioTime != 0) {
  334. audio_btn = false;
  335. setTimeout(function() {
  336. $("#car_audio")[0].pause();
  337. $("#car_audio")[0].currentTime = 0;
  338. audio_btn = true;
  339. audio_start = true;
  340. if (!isNaN(audioTime) && audioTime > audioTimeT) {
  341. audioTimeT = audioTime
  342. }
  343. }, audioTime)
  344. } else {
  345. audio_interval = setInterval(function() {
  346. if (!isNaN($("#car_audio")[0].duration)) {
  347. if ($("#car_audio")[0].currentTime != 0 && $("#car_audio")[0].duration != 0 && $("#car_audio")[0].duration == $("#car_audio")[0].currentTime) {
  348. $("#car_audio")[0].currentTime = 0;
  349. $("#car_audio")[0].pause();
  350. clearInterval(audio_interval);
  351. audio_btn = true;
  352. audio_start = true;
  353. if (!isNaN(audioTime) && audioTime > audioTimeT) {
  354. audioTimeT = audioTime
  355. }
  356. }
  357. }
  358. }, 20)
  359. }
  360. }
  361. }
  362. $(function() {
  363. var b = $(".fn-audio").find(".btn");
  364. b.on("click", a);
  365. function a() {
  366. if ($("#car_audio") == undefined) {
  367. return
  368. }
  369. if (audio_switch_btn) {
  370. $("#car_audio")[0].pause();
  371. audio_switch_btn = false;
  372. $("#car_audio")[0].currentTime = 0;
  373. b.find("span").eq(0).css("display", "none");
  374. b.find("span").eq(1).css("display", "inline-block")
  375. } else {
  376. audio_switch_btn = true;
  377. b.find("span").eq(1).css("display", "none");
  378. b.find("span").eq(0).css("display", "inline-block")
  379. }
  380. }}
  381. );