slide.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <title>title</title>
  8. <link rel="stylesheet" type="text/css" href="css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="css/swiper.min.css" />
  10. <style>
  11. html, body{
  12. height:100%;box-sizing:border-box;background:#ffffff;
  13. }
  14. .swiper-container {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. .swiper-slide {
  19. text-align: center;
  20. font-size: 18px;
  21. background: #ffffff;
  22. height:100%;
  23. position: relative;
  24. width: 100%;
  25. }
  26. .swiper-slide .img{
  27. width: 100%;
  28. height: 100%;
  29. background-repeat: no-repeat;
  30. background-size:cover;
  31. background-position: center;
  32. }
  33. .swiper-pagination-bullet {
  34. opacity: .8;
  35. }
  36. .swiper-pagination-bullet-active {
  37. background: #d9251c;
  38. }
  39. </style>
  40. <script>
  41. (function(w, d, m) {
  42. function r() {
  43. var t = 100,
  44. o = 750,
  45. e = d.documentElement.clientWidth || w.innerWidth,
  46. n = m.max(m.min(e, 480), 320),
  47. h = 50;
  48. 320 >= n && (h = m.floor(n / o * t * .99)),
  49. n > 320 && 362 >= n && (h = m.floor(n / o * t * 1)),
  50. n > 362 && 375 >= n && (h = m.floor(n / o * t * 1)),
  51. n > 375 && (h = m.floor(n / o * t * .97)),
  52. d.querySelector("html").style.fontSize = h + "px"
  53. };
  54. r();
  55. w.onresize = function() {
  56. r()
  57. }
  58. })(window, document, Math);
  59. </script>
  60. </head>
  61. <body>
  62. <div class="swiper-container">
  63. <div class="swiper-wrapper">
  64. </div>
  65. <div class="swiper-pagination" style="font-size: 0;bottom: 22px;"></div>
  66. </div>
  67. </body>
  68. <script type="text/javascript" src="script/api.js"></script>
  69. <script type="text/javascript" src="script/swiper.min.js"></script>
  70. <script type="text/javascript" src="script/jquery.min.js"></script>
  71. <script type="text/javascript" src="script/jquery.tap.js"></script>
  72. <script type="text/javascript">
  73. apiready = function() {
  74. getRouteData();
  75. api.addEventListener({
  76. name: 'keyback'
  77. }, function(ret, err) {
  78. api.toast({
  79. msg: '再按一次返回键退出' + api.appName,
  80. duration: 2000,
  81. location: 'bottom'
  82. });
  83. });
  84. };
  85. $(".swiper-wrapper").on("tap", "#go-to", function() {
  86. api.openWin({
  87. name: 'index',
  88. url: 'index.html',
  89. bounces: false
  90. })
  91. $api.setStorage("isSlide", "1");
  92. // setTimeout("api.closeWin();", 500);
  93. api.closeWin();
  94. return false;
  95. })
  96. function getRouteData() {
  97. $.ajax({
  98. url: siteurl + 'v2/entry/siteConfig',//'?do=getslide',
  99. data: {},
  100. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  101. dataType: 'json',
  102. type: 'post',
  103. success: function(datas) {
  104. if (datas.result) {
  105. $.each(datas.data.slide, function(index, item) {
  106. console.log(JSON.stringify(item));
  107. if (index == (datas.data.slide.length-1)) {
  108. $(".swiper-wrapper").append(`
  109. <div class="swiper-slide" id="go-to">
  110. <div class="img" style="background-image: url(${siteurl}uploads/home/adv/${item.adv_code})"></div>
  111. </div>`);
  112. } else {
  113. $(".swiper-wrapper").append(`
  114. <div class="swiper-slide">
  115. <div class="img" style="background-image: url(${siteurl}uploads/home/adv/${item.adv_code})"></div>
  116. </div>`);
  117. }
  118. });
  119. var swiper = new Swiper('.swiper-container', {
  120. allowSlidePrev: true,
  121. pagination: {
  122. el: '.swiper-pagination',
  123. },
  124. });
  125. } else {
  126. errcode(datas, datas.code);
  127. }
  128. },
  129. error:function(err){
  130. console.log(JSON.stringify(err));
  131. }
  132. });
  133. }
  134. </script>
  135. </html>