You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

153 lines
4.3 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Hello MUI</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  7. <link rel="stylesheet" href="css/mui.min.css">
  8. <link rel="stylesheet" href="css/style.css">
  9. <link rel="stylesheet" href="css/icons-extra.css">
  10. <style>
  11. html,
  12. body {
  13. background-color: #efeff4;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <style>
  19. .mui-control-content .mui-loading {
  20. margin-top: 50px;
  21. }
  22. </style>
  23. <header class="mui-bar mui-bar-nav">
  24. <h1 id="title" class="mui-title"><img style="max-width:220px; height: 33px; padding-top: 8px;" src="images/h_logo.png"></h1>
  25. </header>
  26. <nav class="mui-bar mui-bar-tab">
  27. <a class="mui-tab-item mui-active" href="interact.html">
  28. <span class="mui-icon mui-icon mui-icon-chat"></span>
  29. <span class="mui-tab-label">互动</span>
  30. </a>
  31. <a id="defaultTab" class="mui-tab-item" href="enrolstudents.html">
  32. <span class="mui-icon mui-icon-extra mui-icon-extra-peoples"></span>
  33. <span class="mui-tab-label">招生</span>
  34. </a>
  35. <a class="mui-tab-item" href="personage.html">
  36. <span class="mui-icon mui-icon-contact"></span>
  37. <span class="mui-tab-label">个人</span>
  38. </a>
  39. <a class="mui-tab-item" href="index.html">
  40. <span class="mui-icon mui-icon-extra mui-icon-extra-class"></span>
  41. <span class="mui-tab-label">学院</span>
  42. </a>
  43. </nav>
  44. <script src="js/mui.min.js"></script>
  45. <script type="text/javascript">
  46. var subpages = ['interact.html', 'enrolstudents.html', 'personage.html', 'index.html'];
  47. var subpage_style = {
  48. top: '45px',
  49. bottom: '51px'
  50. };
  51. var aniShow = {};
  52. //创建子页面,首个选项卡页面显示,其它均隐藏;
  53. mui.plusReady(function() {
  54. try {
  55. plus.webview.currentWebview().opener().close();
  56. }catch(e){}
  57. var B = window.plus.bridge;
  58. var Yuntx = {
  59. Logout: function(successCallback, errorCallback) {
  60. var success = typeof successCallback !== 'function' ? null : function(args) {
  61. successCallback(args);
  62. },
  63. fail = typeof errorCallback !== 'function' ? null : function(code) {
  64. errorCallback(code);
  65. },
  66. callbackID = B.callbackId(success, fail);
  67. return B.exec("Yuntx", "Logout", [callbackID]);
  68. }
  69. };
  70. window.plus.Yuntx = Yuntx;
  71. var self = plus.webview.currentWebview();
  72. for(var i = 0; i < 4; i++) {
  73. var temp = {};
  74. var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
  75. if(i > 0) {
  76. sub.hide();
  77. } else {
  78. temp[subpages[i]] = "true";
  79. mui.extend(aniShow, temp);
  80. }
  81. self.append(sub);
  82. }
  83. var defaultTab = document.getElementById("defaultTab");
  84. //模拟首页点击
  85. mui.trigger(defaultTab, 'tap');
  86. //切换选项卡高亮
  87. var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
  88. if(defaultTab !== current) {
  89. current.classList.remove('mui-active');
  90. defaultTab.classList.add('mui-active');
  91. }
  92. });
  93. //当前激活选项
  94. var activeTab = subpages[0];
  95. var title = document.getElementById("title");
  96. //选项卡点击事件
  97. mui('.mui-bar-tab').on('tap', 'a', function(e) {
  98. var targetTab = this.getAttribute('href');
  99. if(targetTab == activeTab) {
  100. return;
  101. }
  102. //更换标题
  103. title.innerHTML = this.querySelector('.mui-tab-label').innerHTML;
  104. //显示目标选项卡
  105. //若为iOS平台或非首次显示,则直接显示
  106. if(mui.os.ios || aniShow[targetTab]) {
  107. plus.webview.show(targetTab);
  108. } else {
  109. //否则,使用fade-in动画,且保存变量
  110. var temp = {};
  111. temp[targetTab] = "true";
  112. mui.extend(aniShow, temp);
  113. plus.webview.show(targetTab);
  114. }
  115. //隐藏当前;
  116. plus.webview.hide(activeTab);
  117. //更改当前活跃的选项卡
  118. activeTab = targetTab;
  119. });
  120. var backButtonPress = 0;
  121. mui.back = function(event) {
  122. backButtonPress++;
  123. if(backButtonPress > 1) {
  124. //logout yuntx
  125. plus.Yuntx.Logout(
  126. function(contact) { //成功
  127. },
  128. function(status) { //失败
  129. });
  130. plus.runtime.quit();
  131. } else {
  132. plus.nativeUI.toast('再按一次退出应用');
  133. }
  134. setTimeout(function() {
  135. backButtonPress = 0;
  136. }, 1000);
  137. return false;
  138. };
  139. </script>
  140. </body>
  141. </html>