index.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>主页</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <link rel="stylesheet" href="css/mui.min.css">
  10. <style>
  11. html,
  12. body {
  13. background-color: black;
  14. }
  15. .mui-tab-label {
  16. color: white;
  17. }
  18. .mui-active {
  19. background-color: #eb4f53;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <nav class="mui-bar mui-bar-tab" style="background-color: black;">
  25. <a id="one" class="mui-tab-item mui-active" href="main.html">
  26. <span class="mui-icon" style="background-image: url(images/dibutab/shouye.png);background-size: 24px;"></span>
  27. <span class="mui-tab-label">首页</span>
  28. </a>
  29. <a class="mui-tab-item" href="channel.html">
  30. <span class="mui-icon" style="background-image: url(images/dibutab/pindao.png);background-size: 24px;"></span>
  31. <span class="mui-tab-label">频道</span>
  32. </a>
  33. <a class="mui-tab-item" href="vip.html">
  34. <span class="mui-icon" style="background-image: url(images/dibutab/vip.png);background-size: 24px;"></span>
  35. <span class="mui-tab-label">vip</span>
  36. </a>
  37. <a class="mui-tab-item" href="personal.html">
  38. <span class="mui-icon" style="background-image: url(images/dibutab/wo.png);background-size: 24px;"></span>
  39. <span class="mui-tab-label">我</span>
  40. </a>
  41. </nav>
  42. <script src="js/mui.min.js"></script>
  43. <script type="text/javascript" charset="utf-8">
  44. //mui初始化
  45. mui.init({
  46. swipeBack: false //启用右滑关闭功能
  47. });
  48. var subpages = ['main.html', 'channel.html', 'vip.html', 'personal.html'];
  49. var subpage_style = {
  50. bottom: '51px'
  51. };
  52. var aniShow = {};
  53. //创建子页面,首个选项卡页面显示,其它均隐藏;
  54. mui.plusReady(function() {
  55. var self = plus.webview.currentWebview();
  56. for (var i = 0; i < 4; i++) {
  57. var temp = {};
  58. var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
  59. if (i > 0) {
  60. sub.hide();
  61. } else {
  62. temp[subpages[i]] = "true";
  63. mui.extend(aniShow, temp);
  64. }
  65. self.append(sub);
  66. }
  67. });
  68. //当前激活选项
  69. var activeTab = subpages[0];
  70. //选项卡点击事件
  71. mui('.mui-bar-tab').on('tap', 'a', function(e) {
  72. var targetTab = this.getAttribute('href');
  73. // var name = this.querySelector('.mui-tab-label').innerHTML;
  74. if (targetTab == activeTab) {
  75. return;
  76. }
  77. //显示目标选项卡
  78. //若为iOS平台或非首次显示,则直接显示
  79. if (mui.os.ios || aniShow[targetTab]) {
  80. plus.webview.show(targetTab);
  81. } else {
  82. //否则,使用fade-in动画,且保存变量
  83. var temp = {};
  84. temp[targetTab] = "true";
  85. mui.extend(aniShow, temp);
  86. plus.webview.show(targetTab, "fade-in", 300);
  87. }
  88. //隐藏当前;
  89. plus.webview.hide(activeTab);
  90. //更改当前活跃的选项卡
  91. activeTab = targetTab;
  92. });
  93. var backButtonPress = 0;
  94. mui.back = function(event) {
  95. backButtonPress++;
  96. if (backButtonPress > 1) {
  97. plus.runtime.quit();
  98. } else {
  99. plus.nativeUI.toast('再按一次退出应用');
  100. }
  101. setTimeout(function() {
  102. backButtonPress = 0;
  103. }, 1000);
  104. return false;
  105. };
  106. </script>
  107. </body>
  108. </html>