index.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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>
  8. <link rel="stylesheet" type="text/css" href="../../css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="../../css/style.css" />
  10. <style>
  11. header{ background-color: #f2f2f2; }
  12. header ul li { height: 50px; line-height: 50px; text-align: center; display: none; color: #323237; position: relative;font-size: 18px; }
  13. header ul li.active{ display: block; }
  14. #footer ul li.active{ color: #D9251C; }
  15. #footer ul li:nth-child(1){ background-image: url(../../image/bottombtn0101.png); }
  16. #footer ul li:nth-child(2){ background-image: url(../../image/bottombtn0301.png); }
  17. #footer ul li:nth-child(3){ background-image: url(../../image/bottombtn0201.png); }
  18. #footer ul li:nth-child(4){ background-image: url(../../image/bottombtn0401.png); }
  19. #footer ul li:nth-child(1).active{ background-image: url(../../image/bottombtn0102.png); }
  20. #footer ul li:nth-child(2).active{ background-image: url(../../image/bottombtn0302.png); }
  21. #footer ul li:nth-child(3).active{ background-image: url(../../image/bottombtn0202.png); }
  22. #footer ul li:nth-child(4).active{ background-image: url(../../image/bottombtn0402.png); }
  23. .flex-con{
  24. overflow: auto
  25. }
  26. </style>
  27. <script>
  28. (function(w, d, m) {
  29. function r() {
  30. var t = 100,
  31. o = 750,
  32. e = d.documentElement.clientWidth || w.innerWidth,
  33. n = m.max(m.min(e, 480), 320),
  34. h = 50;
  35. 320 >= n && (h = m.floor(n / o * t * .99)),
  36. n > 320 && 362 >= n && (h = m.floor(n / o * t * 1)),
  37. n > 362 && 375 >= n && (h = m.floor(n / o * t * 1)),
  38. n > 375 && (h = m.floor(n / o * t * .97)),
  39. d.querySelector("html").style.fontSize = h + "px"
  40. };
  41. r();
  42. w.onresize = function() {
  43. r()
  44. }
  45. })(window, document, Math);
  46. </script>
  47. </head>
  48. <body>
  49. <div id="wrap" class="flex-wrap flex-vertical">
  50. <header style="display: none;">
  51. <ul>
  52. <li class="border-b active"></li>
  53. <li class="border-b"></li>
  54. <li class="border-b"></li>
  55. <li class="border-b"></li>
  56. </ul>
  57. </header>
  58. <div id="main" class="flex-con">
  59. </div>
  60. <div id="footer" class="border-t">
  61. <ul class="flex-wrap">
  62. <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">首页</li>
  63. <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">订单</li>
  64. <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">发现</li>
  65. <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
  66. </ul>
  67. </div>
  68. </div>
  69. </body>
  70. </html>
  71. <script type="text/javascript" src="../../script/api.js"></script>
  72. <script type="text/javascript">
  73. apiready = function() {
  74. $api.fixStatusBar($api.dom('header'));
  75. api.setStatusBarStyle({
  76. style: 'dark',
  77. color: '#fff'
  78. });
  79. funIniGroup();
  80. setBackDisable();
  81. //$api.setStorage("storeid",2);
  82. }
  83. function funIniGroup() {
  84. var eHeaderLis = $api.domAll('header li'),
  85. frames = [];
  86. for (var i = 0, len = eHeaderLis.length; i < len; i++) {
  87. if (i == 0) {
  88. frames.push({
  89. name: 'frame' + i,
  90. url: './frame' + i + '.html',
  91. bgColor: 'rgba(0,0,0,.2)',
  92. customRefreshHeader: 'UIPullRefresh',
  93. bounces: true,
  94. vScrollBarEnabled: false,
  95. hScrollBarEnabled: false,
  96. slidBackEnabled: false
  97. })
  98. } else {
  99. frames.push({
  100. name: 'frame' + i,
  101. url: './frame' + i + '.html',
  102. bgColor: 'rgba(0,0,0,.2)',
  103. bounces: false,
  104. vScrollBarEnabled: false,
  105. hScrollBarEnabled: false,
  106. slidBackEnabled: false
  107. })
  108. }
  109. }
  110. api.openFrameGroup({
  111. name: 'group',
  112. scrollEnabled: false,
  113. rect: {
  114. x: 0,
  115. // y: $api.dom('header').offsetHeight,
  116. y: document.querySelector( 'header' ).offsetHeight,
  117. // w: 'auto',//api.winWidth,
  118. // h: 'auto'//$api.dom('#main').offsetHeight
  119. h: api.winHeight - document.querySelector( 'header' ).offsetHeight
  120. },
  121. index: 0,
  122. frames: frames
  123. }, function(ret, err) {
  124. });
  125. }
  126. function set_height() {
  127. api.setFrameGroupAttr({
  128. name: 'group',
  129. rect: {
  130. x: 0,
  131. y: $api.dom('header').offsetHeight,
  132. w: api.winWidth,
  133. h: $api.dom('#main').offsetHeight
  134. }
  135. })
  136. }
  137. // 随意切换按钮
  138. function randomSwitchBtn(tag) {
  139. if (tag == $api.dom('#footer li.active')) return;
  140. var eFootLis = $api.domAll('#footer li'),
  141. eHeaderLis = $api.domAll('header li'),
  142. index = 0;
  143. for (var i = 0, len = eFootLis.length; i < len; i++) {
  144. if (tag == eFootLis[i]) {
  145. index = i;
  146. } else {
  147. $api.removeCls(eFootLis[i], 'active');
  148. $api.removeCls(eHeaderLis[i], 'active');
  149. }
  150. }
  151. $api.addCls(eFootLis[index], 'active');
  152. $api.addCls(eHeaderLis[index], 'active');
  153. api.setFrameGroupIndex({
  154. name: 'group',
  155. index: index
  156. });
  157. }
  158. </script>