index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /**
  2. * Created by Nature on 16/1/22.
  3. */
  4. function hide(id) {
  5. var obj = typeof id == "string" ? document.getElementById(id) : id;
  6. obj.style.display = "none";
  7. }
  8. function show(id) {
  9. var obj = typeof id == "string" ? document.getElementById(id) : id;
  10. obj.style.display = "block";
  11. }
  12. function newsTab(dir) {
  13. var newsBox = document.getElementById("news-box");
  14. var lis = newsBox.getElementsByTagName("li");
  15. var _index;
  16. for (var i = 0, ln = lis.length; i < ln; i++) {
  17. lis[i].index = i;
  18. if (YEEPAY.hasClass(lis[i], "block")) {
  19. _index = i;
  20. }
  21. }
  22. if (dir == "pre") {
  23. if (_index == 0) {
  24. YEEPAY.removeClass(lis[_index], "block");
  25. YEEPAY.addClass(lis[lis.length - 1], "block");
  26. } else {
  27. YEEPAY.removeClass(lis[_index], "block");
  28. YEEPAY.addClass(lis[_index - 1], "block");
  29. }
  30. }
  31. if (dir == "next") {
  32. if (_index == lis.length - 1) {
  33. YEEPAY.removeClass(lis[_index], "block");
  34. YEEPAY.addClass(lis[0], "block");
  35. } else {
  36. YEEPAY.removeClass(lis[_index], "block");
  37. YEEPAY.addClass(lis[_index + 1], "block");
  38. }
  39. }
  40. }
  41. function pullShow() {
  42. var nav = document.getElementById("nav");
  43. var pullDown = YEEPAY.getElementByClass("pull-down", nav);
  44. var menuNav = YEEPAY.getElementByClass("menu-nav", nav);
  45. var navChild = YEEPAY.getElementByClass("nav-child" , nav);
  46. var width = document.documentElement.clientWidth || document.body.clientWidth;
  47. for (var i = 0, ln = pullDown.length; i < ln; i++) {
  48. pullDown[i].index = i;
  49. if(width <=1024){
  50. pullDown[i].onclick = function(){
  51. alert('1');
  52. if(this.classList.contains("active")){
  53. for (var j = 0, ln = menuNav.length; j < ln; j++) {
  54. YEEPAY.removeClass(pullDown[j] , "active");
  55. menuNav[j].style.display = "none";
  56. }
  57. }else{
  58. for (var j = 0, ln = menuNav.length; j < ln; j++) {
  59. menuNav[j].style.display = "none";
  60. pullDown[j].classList.remove("active");
  61. }
  62. YEEPAY.addClass(this, "active");
  63. menuNav[this.index].style.display = "block";
  64. }
  65. }
  66. }else{
  67. pullDown[i].onmouseover = function(){
  68. for (var j = 0, ln = menuNav.length; j < ln; j++) {
  69. menuNav[j].style.display = "none";
  70. }
  71. YEEPAY.addClass(this, "active");
  72. menuNav[this.index].style.display = "block";
  73. };
  74. pullDown[i].onmouseout = function(){
  75. for (var j = 0, ln = menuNav.length; j < ln; j++) {
  76. YEEPAY.removeClass(this, "active");
  77. menuNav[j].style.display = "none";
  78. }
  79. };
  80. }
  81. }
  82. for (var h = 0, ln = navChild.length; h < ln; h++) {
  83. if(width > 1024){
  84. navChild[h].onmouseover = function(){
  85. YEEPAY.addClass(this , "on");
  86. };
  87. navChild[h].onmouseout = function(){
  88. YEEPAY.removeClass(this , "on");
  89. }
  90. }else{}
  91. }
  92. }
  93. function login(){
  94. var login = document.getElementById("login");
  95. var width = document.documentElement.clientWidth || document.body.clientWidth;
  96. if(width <= 1024){
  97. login.onclick = function(){
  98. if(login.classList.contains("on")){
  99. this.classList.remove("on");
  100. hide("login-pull");
  101. }else{
  102. this.classList.add("on");
  103. show("login-pull");
  104. }
  105. }
  106. }else{
  107. login.onmouseover = function(){
  108. show("login-pull");
  109. };
  110. login.onmouseleave = function(){
  111. hide("login-pull");
  112. }
  113. }
  114. }
  115. function ewmShow() {
  116. var wx = document.getElementById("wx");
  117. var ewm = document.getElementById("ewm");
  118. var ico = document.getElementById("ico");
  119. var width = document.documentElement.clientWidth || document.body.clientWidth;
  120. if(width <= 1024){
  121. wx.onclick = function(){
  122. if(ico.classList.contains("active")){
  123. ewm.style.display = "none";
  124. YEEPAY.removeClass(ico, "active");
  125. }else{
  126. ewm.style.display = "block";
  127. YEEPAY.addClass(ico, "active");
  128. }
  129. };
  130. }else{
  131. wx.onmouseover = function () {
  132. ewm.style.display = "block";
  133. YEEPAY.addClass(ico, "active");
  134. };
  135. wx.onmouseleave = function () {
  136. ewm.style.display = "none";
  137. YEEPAY.removeClass(ico, "active");
  138. }
  139. }
  140. }
  141. function toggle() {
  142. document.querySelector(".nav-btn").classList.toggle("nav-btn-active");
  143. document.querySelector(".pull-nav").classList.toggle("h-auto");
  144. document.querySelector(".mask").classList.toggle("mask-on");
  145. }
  146. function nav(){
  147. var showBtn = document.querySelectorAll(".showBtn");
  148. var childNav = document.querySelectorAll(".child-nav");
  149. for(var i=0, ln=showBtn.length; i<ln; i++){
  150. showBtn[i].onclick = function(){
  151. var nextNode = this.nextElementSibling;
  152. if(this.classList.contains("active")){
  153. this.classList.remove("active");
  154. nextNode.classList.remove("h-auto");
  155. }else{
  156. for(var i=0, ln=showBtn.length; i<ln; i++){
  157. showBtn[i].classList.remove("active");
  158. childNav[i].classList.remove("h-auto");
  159. }
  160. this.classList.add("active");
  161. nextNode.classList.add("h-auto");
  162. }
  163. }
  164. }
  165. for(var i=0, ln=childNav.length; i<ln; i++){
  166. childNav[i].onclick = function(){
  167. var childs = this.children;
  168. var _target = event.target;
  169. for(var j=0 , ln=childs.length; j<ln; j++){
  170. childs[j].classList.remove("click");
  171. }
  172. _target.classList.add("click");
  173. }
  174. }
  175. }
  176. function carousel() {
  177. /*广告位初始化开始*/
  178. var carousel = document.getElementById("carousel");
  179. var bannerInfoData = getBannerInfo().data;
  180. for (var i = 0, ln = bannerInfoData.length; i < ln; i++) {
  181. var li = document.createElement("li");
  182. if(i == 0){
  183. //li.setAttribute("class", "front");
  184. YEEPAY.addClass(li,"front");
  185. }
  186. var a = document.createElement("a");
  187. a.setAttribute("target", "_blank");
  188. a.setAttribute("href", bannerInfoData[i].href);
  189. var img = document.createElement("img");
  190. img.setAttribute("src", bannerInfoData[i].imgSrc);
  191. if(bannerInfoData[i].href==null||trim(bannerInfoData[i].href)===""){
  192. li.appendChild(img);
  193. }else{
  194. a.appendChild(img);
  195. li.appendChild(a);
  196. }
  197. carousel.appendChild(li);
  198. }
  199. /*广告位初始化结束*/
  200. var script = document.createElement("script");
  201. script.type = "text/javascript";
  202. var width = document.documentElement.clientWidth || document.body.clientWidth;
  203. if (width <= 700) {
  204. /*公告栏初始化开始*/
  205. var noticeLink = document.getElementById("mobile_noticeLink");
  206. var noticeInfoData = getNoticeInfo().data;
  207. var noticeIndex = 0;
  208. noticeLink.setAttribute("target", "_blank");
  209. noticeLink.setAttribute("href", noticeInfoData[noticeIndex].url);
  210. noticeLink.innerHTML=noticeInfoData[noticeIndex++].title;
  211. window.setInterval(function (){
  212. noticeLink.setAttribute("target", "_blank");
  213. noticeLink.setAttribute("href", noticeInfoData[noticeIndex].url);
  214. noticeLink.innerHTML=noticeInfoData[noticeIndex].title;
  215. if(++noticeIndex >= noticeInfoData.length){
  216. noticeIndex = 0 ;
  217. }
  218. },5000);
  219. /*公告栏初始化结束*/
  220. script.src = "/js/carousel.js";
  221. nav();
  222. } else {
  223. /*公告栏初始化开始*/
  224. var noticeList = document.getElementById("news-list");
  225. var noticeInfoData = getNoticeInfo().data;
  226. for (var i = 0, ln = noticeInfoData.length; i < ln; i++) {
  227. var li = document.createElement("li");
  228. if(i == 0){
  229. YEEPAY.addClass(li,"block");
  230. }
  231. var a = document.createElement("a");
  232. a.setAttribute("target", "_blank");
  233. a.setAttribute("href", noticeInfoData[i].url);
  234. a.innerHTML=noticeInfoData[i].title;
  235. li.appendChild(a);
  236. noticeList.appendChild(li);
  237. }
  238. /*公告栏初始化结束*/
  239. /*易宝动态初始化开始*/
  240. var newsBox = document.getElementById("news-box");
  241. var newsInfoData = getNewsInfo().data;
  242. for (var i = 0, ln = newsInfoData.length; i < ln; i++) {
  243. var li = document.createElement("li");
  244. if(i == 0){
  245. //li.setAttribute("class", "block");
  246. YEEPAY.addClass(li,"block");
  247. }
  248. var a = document.createElement("a");
  249. a.setAttribute("target", "_blank");
  250. a.setAttribute("href", newsInfoData[i].url);
  251. a.innerHTML = "虎付动态 :" + newsInfoData[i].title;
  252. var span = document.createElement("span");
  253. span.innerHTML = newsInfoData[i].retime;
  254. li.appendChild(a);
  255. li.appendChild(span);
  256. newsBox.appendChild(li);
  257. }
  258. /*易宝动态初始化结束*/
  259. //加入轮播
  260. window.setInterval(function (){
  261. newsTab('next');
  262. },5000);
  263. script.src = "/js/wrapper.js";
  264. }
  265. document.body.appendChild(script);
  266. }
  267. //carousel();
  268. pullShow();
  269. ewmShow();
  270. login();
  271. (function() {
  272. var newsBox = document.getElementById("news-list");
  273. var lis = newsBox.getElementsByTagName("li");
  274. var preBtn = document.getElementById("pre");
  275. var nextBtn = document.getElementById("next");
  276. var _index;
  277. var tt = null;
  278. function pre(){
  279. for (var i = 0, ln = lis.length; i < ln; i++) {
  280. if (YEEPAY.hasClass(lis[i], "block")) {
  281. _index = i;
  282. }
  283. }
  284. if (_index == 0) {
  285. YEEPAY.removeClass(lis[_index], "block");
  286. YEEPAY.addClass(lis[lis.length - 1], "block");
  287. } else {
  288. YEEPAY.removeClass(lis[_index], "block");
  289. YEEPAY.addClass(lis[_index - 1], "block");
  290. }
  291. }
  292. function next(){
  293. for (var i = 0, ln = lis.length; i < ln; i++) {
  294. if (YEEPAY.hasClass(lis[i], "block")) {
  295. _index = i;
  296. }
  297. }
  298. if (_index == lis.length - 1) {
  299. YEEPAY.removeClass(lis[_index], "block");
  300. YEEPAY.addClass(lis[0], "block");
  301. } else {
  302. YEEPAY.removeClass(lis[_index], "block");
  303. YEEPAY.addClass(lis[_index + 1], "block");
  304. }
  305. }
  306. function autoPlay(){
  307. tt = setTimeout(function(){
  308. next();
  309. tt = setTimeout(arguments.callee , 3000);
  310. } , 3000);
  311. }
  312. function stopPlay(){
  313. clearTimeout(tt);
  314. }
  315. autoPlay();
  316. YEEPAY.addHandler(preBtn , "mouseover" , stopPlay);
  317. YEEPAY.addHandler(preBtn , "mouseout" , autoPlay);
  318. YEEPAY.addHandler(preBtn , "click" , pre);
  319. YEEPAY.addHandler(nextBtn , "mouseover" , stopPlay);
  320. YEEPAY.addHandler(nextBtn , "mouseout" , autoPlay);
  321. YEEPAY.addHandler(nextBtn , "click" , next);
  322. })();
  323. (function(){
  324. var searchBtn = document.getElementById("search-btn");
  325. searchBtn.onclick = function(){
  326. show("search");
  327. $('#search-text').val(" 网银支付 一键支付 商户后台");
  328. $("#search-text").css("color","#AAAAAA");
  329. window.onclick = function(event){
  330. var target = YEEPAY.getTarget(event);
  331. if(YEEPAY.hasClass(target , "search-a")){
  332. var val = document.getElementById("search-text").value;
  333. if(val != ""){
  334. $('#isHidden').val("");
  335. }else{
  336. $('#search-text').val(" 网银支付 一键支付 商户后台");
  337. $("#search-text").css("color","#AAAAAA");
  338. hide("search");
  339. }
  340. }else{
  341. while (target.nodeName.toLowerCase() != "div" && target.nodeName.toLowerCase() != "html") {
  342. target = target.parentNode;
  343. }
  344. if (target.nodeName.toLowerCase() == "html" || (target.nodeName.toLowerCase() == "div" && !YEEPAY.hasClass(target , "search-box") && !YEEPAY.hasClass(target , "search"))) {
  345. hide("search");
  346. }
  347. }
  348. };
  349. };
  350. var searchText = document.getElementById("search-text");
  351. searchText.onfocus = (function(){
  352. $('#search-text').val("");
  353. $('#search-text').css("color","#000000");
  354. });
  355. //searchText.onkeydown = (function(){
  356. // $('#isHidden').val("v");
  357. //});
  358. //searchText.onblur = (function(){
  359. // if(document.getElementById("search-text").value.color=='rgb(170,170,170)'){
  360. // $('#isHidden').val('v');
  361. // }
  362. // $('#search-text').val("支付");
  363. // $("#search-text").css("color", "#AAAAAA");
  364. //
  365. //});
  366. })();