section.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>section</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. <link rel="stylesheet" href="../css/iconfont.css">
  11. <script src="../js/mui.min.js"></script>
  12. <script src="../js/routes.js"></script>
  13. <script src="../js/app.js"></script>
  14. <script src="../js/service.js"></script>
  15. <style type="text/css">
  16. #list {
  17. /*避免导航边框和列表背景边框重叠,看起来像两条边框似得;*/
  18. margin-top: -1px;
  19. }
  20. .kaishi {
  21. width: 70px;
  22. height: 25px;
  23. border-radius: 3px;
  24. margin-left: auto;
  25. margin-right: auto;
  26. padding-top: 3px;
  27. background-color: #EA5555;
  28. color: white;
  29. font-size: 14px;
  30. }
  31. .biaoti {
  32. word-wrap: break-word;
  33. word-break: normal;
  34. white-space: normal;
  35. height: 50px;
  36. padding-left: 5px;
  37. padding-right: 5px;
  38. }
  39. .jie {
  40. height: 100px;
  41. width: 100%;
  42. min-width: 70px;
  43. padding-top: 10px;
  44. text-align: center;
  45. border: 1px solid lightgray;
  46. background-color: #FBF8F8;
  47. border-radius: 2px;
  48. font-size: 17px;
  49. }
  50. .my-li-active:active {
  51. background-color: #95DECA;
  52. }
  53. .suo {
  54. background-color: green;
  55. background-clip: padding-box;
  56. color: white;
  57. z-index: 9999;
  58. border-radius: 35px;
  59. width: 40px;
  60. height: 40px;
  61. position: absolute;
  62. top: 40px;
  63. padding-top: 9px;
  64. position: absolute;
  65. left: 50%;
  66. margin-left: -12px;
  67. }
  68. .zhezhao {
  69. position: absolute;
  70. width: 100%;
  71. height: 100px;
  72. z-index: 99;
  73. background-color: black;
  74. top: 10px;
  75. opacity: 0.4;
  76. }
  77. .mui-table-view:before {
  78. height: 0px !important;
  79. }
  80. .mui-table-view:after {
  81. height: 0px !important;
  82. }
  83. </style>
  84. </head>
  85. <body>
  86. <header class="mui-bar mui-bar-nav">
  87. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  88. <h1 id="title" class="mui-title">标题</h1>
  89. </header>
  90. <div class="mui-content">
  91. <ul id="list" class="mui-table-view mui-grid-view" style="padding-top: 10px;margin-bottom: 0px;height: 100%;">
  92. </ul>
  93. </div>
  94. <script type="text/html" id="template-section-yes-id">
  95. <li class="mui-table-view-cell mui-media mui-col-xs-6">
  96. <a href="question.html" data-section-id="{code}">
  97. <div class="jie my-li-active">
  98. <div class="biaoti">
  99. {name}
  100. </div>
  101. <div class="kaishi">
  102. 开始
  103. </div>
  104. </div>
  105. </a>
  106. </li>
  107. </script>
  108. <script type="text/html" id="template-section-no-id">
  109. <li class="mui-table-view-cell mui-media mui-col-xs-6">
  110. <a data-section-id="{code}">
  111. <div class="jie">
  112. <div class="biaoti" style="color: black;">
  113. {name}
  114. </div>
  115. <div class="kaishi">
  116. 开始
  117. </div>
  118. <div class="zhezhao">
  119. </div>
  120. <span class="suo"><span class=" icon iconfont icon-suo1"></span></span>
  121. </div>
  122. </a>
  123. </li>
  124. </script>
  125. <script>
  126. function initDom() {
  127. var chapterId = window.self.chapterId;
  128. var ct = document.getElementById('list');
  129. ct.innerHTML = '';
  130. queryCategory(chapterId, function(rows) {
  131. var scriptSectionNo = document.getElementById('template-section-no-id');
  132. var scriptSectionYes = document.getElementById('template-section-yes-id');
  133. var noTemplate = scriptSectionNo.innerHTML;
  134. var yesTemplate = scriptSectionYes.innerHTML;
  135. var htmlStr = '';
  136. for (var i = 0; i < rows.length; i++) {
  137. var row = rows[i];
  138. if (row.status == 1) { // 不锁住
  139. htmlStr += render(yesTemplate, row);
  140. } else if (row.status == -1) { // 锁住
  141. htmlStr += render(noTemplate, row);
  142. }
  143. }
  144. ct.innerHTML = htmlStr;
  145. });
  146. }
  147. function chapterTapEvent() {
  148. mui('#list').on('tap', 'a', function() {
  149. var name = this.getAttribute('name');
  150. var sectionId = this.getAttribute('data-section-id');
  151. var myhref = this.href;
  152. var cantSee = !!window.localStorage.getItem("__cant_see");
  153. console.log('------------------>是否可以用:'+cantSee)
  154. if (checkIsContinue(sectionId)) { // 可以免费看的内容
  155. mui.openWindow({
  156. id: 'question-win-' + sectionId,
  157. url: myhref,
  158. waiting: {
  159. autoShow: false
  160. },
  161. extras: {
  162. name: name,
  163. sectionId: sectionId
  164. }
  165. });
  166. } else {
  167. alreadyLogin(function() {
  168. if (cantSee) {
  169. // mui.toast('使用时间已超出您购买的时长,请先续费');
  170. mui.toast('此内容需要购买,我们会在24小时之内电话联系您进行购买');
  171. } else {
  172. mui.openWindow({
  173. id: 'question-win-' + sectionId,
  174. url: myhref,
  175. waiting: {
  176. autoShow: false
  177. },
  178. extras: {
  179. name: name,
  180. sectionId: sectionId
  181. }
  182. });
  183. }
  184. }, function() {
  185. mui.openWindow({
  186. id: 'login-win-' + window.chapterId,
  187. url: 'login.html',
  188. waiting: {
  189. autoShow: false
  190. },
  191. extras: {
  192. title: window.chapterTitle,
  193. sectionId: window.chapterId,
  194. chapterId: window.chapterId,
  195. gotoUrl: 'section.html'
  196. }
  197. });
  198. });
  199. }
  200. });
  201. }
  202. //只有ios支持的功能需要在Android平台隐藏;
  203. if (mui.os.android) {
  204. var list = document.querySelectorAll('.ios-only');
  205. if (list) {
  206. for (var i = 0; i < list.length; i++) {
  207. list[i].style.display = 'none';
  208. }
  209. }
  210. }
  211. mui.plusReady(function() {
  212. window.self = plus.webview.currentWebview();
  213. window.isFromLoginPage = window.self.isFromLoginPage;
  214. window.chapterId = self.chapterId;
  215. window.chapterTitle = self.chapterTitle;
  216. initDom();
  217. chapterTapEvent();
  218. var titleElem = document.getElementById("title")
  219. titleElem.innerHTML = self.chapterTitle;
  220. titleElem.className = "mui-title mui-fadein";
  221. // 获取所有Webview窗口
  222. var wvs=plus.webview.all();
  223. for(var i=0;i<wvs.length;i++){
  224. console.log("webview"+i+": "+wvs[i].id);
  225. }
  226. });
  227. var index = null; //主页面
  228. function openMenu() {
  229. !index && (index = mui.currentWebview.parent());
  230. mui.fire(index, "menu:open");
  231. }
  232. //在android4.4.2中的swipe事件,需要preventDefault一下,否则触发不正常
  233. window.addEventListener('dragright', function(e) {
  234. e.detail.gesture.preventDefault();
  235. });
  236. //监听右滑事件,若侧滑菜单未显示,右滑要显示菜单;
  237. window.addEventListener("swiperight", function(e) {
  238. //默认滑动角度在-45度到45度之间,都会触发右滑菜单,为避免误操作,可自定义限制滑动角度;
  239. if (Math.abs(e.detail.angle) < 4) {
  240. openMenu();
  241. }
  242. });
  243. var old_back = mui.back;
  244. mui.back = function() {
  245. var self = plus.webview.currentWebview();
  246. try {
  247. self.opener().evalJS('try{updateDengluMenu();}catch(e){} try{initChapterDom();}catch(e){} try{mui.back=old_back;}catch(e){}');
  248. } catch (e) {}
  249. if (window.isFromLoginPage) {
  250. try {
  251. var wv = plus.webview;
  252. var chapterId = window.chapterId;
  253. wv.close('login-win');
  254. wv.close('verifyCode-win');
  255. wv.show('dragIndex-win');
  256. } catch (e) {
  257. console.log(JSON.stringify(e))
  258. }
  259. } else {
  260. //执行mui封装好的窗口关闭逻辑;
  261. old_back();
  262. }
  263. }
  264. </script>
  265. </body>
  266. </html>