course.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. <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/app.js"></script>
  13. <script src="../js/service.js"></script>
  14. <style>
  15. html,
  16. body {
  17. background-color: #efeff4;
  18. }
  19. .title {
  20. margin: 35px 15px 10px;
  21. margin-bottom: 20px;
  22. font-size: 24px;
  23. font-weight: 700;
  24. color: green;
  25. }
  26. .title+.content {
  27. margin: 10px 15px 35px;
  28. color: #bbb;
  29. text-indent: 1em;
  30. font-size: 14px;
  31. line-height: 24px;
  32. }
  33. #list {
  34. /*避免导航边框和列表背景边框重叠,看起来像两条边框似得;*/
  35. margin-top: -1px;
  36. }
  37. #topPopover {
  38. position: fixed;
  39. top: 16px;
  40. right: 6px;
  41. width: 150px !important;
  42. z-index: 2;
  43. top: 60px !important;
  44. }
  45. #topPopover .mui-popover-arrow {
  46. left: auto;
  47. right: 6px;
  48. }
  49. .mui-popover {
  50. height: 100px;
  51. }
  52. .kaishi {
  53. width: 100px;
  54. height: 30px;
  55. border-radius: 4px;
  56. margin-left: auto;
  57. margin-right: auto;
  58. padding-top: 6px;
  59. background-color: #EA5555;
  60. color: white;
  61. font-size: 14px;
  62. }
  63. .biaoti {
  64. word-wrap: break-word;
  65. word-break: normal;
  66. white-space: normal;
  67. height: 90px;
  68. padding-top: 20px;
  69. padding-left: 15px;
  70. padding-right: 15px;
  71. font-size: 18px;
  72. }
  73. .zhang {
  74. height: 140px;
  75. width: 90%;
  76. margin: 0 auto;
  77. border: 1px solid lightgray;
  78. background-color: #F8F8F8;
  79. border-radius: 6px;
  80. }
  81. .zhang:active {
  82. background-color: #95DECA;
  83. border: 1px solid #95DECA;
  84. }
  85. .mui-media-li-self {
  86. margin-top: 30px;
  87. }
  88. .jindulan {
  89. height: 100%;
  90. background-color: #428bca;
  91. border-bottom-left-radius: 4px;
  92. border-top-left-radius: 4px;
  93. }
  94. .jindu {
  95. text-align: center;
  96. font-size: 12px;
  97. margin: 0 auto;
  98. width: 78%;
  99. height: 25px;
  100. border-radius: 4px;
  101. background-color: #E2E6E5;
  102. }
  103. .my-course-img-1 {
  104. /*margin-top: 50px !important;*/
  105. padding-top: 110px !important;
  106. padding-bottom: 80px !important;
  107. /*background-image: url(images/kuaiji.png);*/
  108. background-size: 100% 150px;
  109. background-repeat: no-repeat;
  110. }
  111. .my-course-active {
  112. width: 3px;
  113. height: 100%;
  114. background-color: red;
  115. position: absolute;
  116. margin-top: -32px;
  117. margin-left: -10px;
  118. }
  119. .my-mui-navigate-right {
  120. background-color: red !important;
  121. }
  122. .my-mui-table-view {
  123. background-color: #EBEBEB !important;
  124. }
  125. </style>
  126. </head>
  127. <body style="margin: 0;padding: 0;">
  128. <header class="mui-bar mui-bar-nav">
  129. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  130. <h1 id="title-id" class="mui-title"></h1>
  131. <a id="info" class="mui-icon mui-pull-right"><i class="icon iconfont">&#xe730;</i></a>
  132. </header>
  133. <div id="offCanvasContentScroll" class="mui-content">
  134. <div class="mui-scroll" id="my-scroll">
  135. <ul id="list" class="mui-table-view mui-grid-view my-course-img-1 my-mui-table-view">
  136. </ul>
  137. </div>
  138. </div>
  139. <!--右上角弹出菜单-->
  140. <div id="topPopover" class="mui-popover">
  141. <div class="mui-scroll-wrapper">
  142. <div class="mui-scroll">
  143. <ul class="mui-table-view">
  144. <li class="mui-table-view-cell">
  145. <a id="cuotiben" data-course-id="" data-href="review-chapter.html" data-type='2' style="color: red;">
  146. <i class="mui-icon icon iconfont icon-zhangben" style="margin-right: 10px;"></i>错题本
  147. </a>
  148. </li>
  149. <li class="mui-table-view-cell">
  150. <a id="shoucangben" data-course-id="" data-href="review-chapter.html" data-type='1' style="color: blue;">
  151. <i class="mui-icon icon iconfont icon-shu" style="margin-right: 10px;"></i>收藏本
  152. </a>
  153. </li>
  154. </ul>
  155. </div>
  156. </div>
  157. </div>
  158. <script type="text/html" id="template-course-id">
  159. <li class="mui-table-view-cell">
  160. <a class="mui-navigate-right" data-id="{code}" data-href="../dragIndex.html">{name}</a>
  161. </li>
  162. </script>
  163. <script type="text/html" id="template-chapter-id">
  164. <li class="mui-table-view-cell mui-media mui-col-xs-12 mui-media-li-self">
  165. <a href="section.html" data-title="{name}" data-chapter-id='{code}'>
  166. <div class="zhang">
  167. <div class=" biaoti">
  168. {name}
  169. </div>
  170. <div class="jindu" style="text-align: center;">
  171. <div class="jindulan" style="width: {progress}%;">
  172. </div>
  173. <div style="margin-top:-22px;font-size: 12px;color: #4D4D4D;">已完成{progress}%</div>
  174. </div>
  175. </div>
  176. </a>
  177. </li>
  178. </script>
  179. <script>
  180. /**
  181. * 初始化章
  182. */
  183. function initChapterDom() {
  184. queryCategory(window.self.courseId, function(rows) {
  185. var scriptCourse = document.getElementById('template-chapter-id');
  186. var template = scriptCourse.innerHTML;
  187. var htmlStr = '';
  188. for (var i = 0; i < rows.length; i++) {
  189. var row = rows[i];
  190. htmlStr += render(template, row);
  191. }
  192. var ct = document.getElementById('list');
  193. ct.innerHTML = htmlStr;
  194. // document.getElementById("list").style.backgroundImage = window.myimage; TODO 这里已删除,等需要背景图片的时候再打开吧
  195. });
  196. }
  197. /**
  198. * 设置背景图片
  199. */
  200. function setBackgrounImage() {
  201. if (window.self.courseTitle == "会计基础") {
  202. window.myimage = 'url(../images/kuaiji.png)';
  203. } else if (window.self.courseTitle == "财经法规") {
  204. window.myimage = 'url(../images/caijing.png)';
  205. } else {
  206. window.myimage = 'url(../images/diansuanhua.png)';
  207. }
  208. }
  209. /**
  210. * 点击章时间
  211. */
  212. function chapterTapEvent() {
  213. mui('#list').on('tap', 'a', function() {
  214. var chapterTitle = this.getAttribute('data-title');
  215. var chapterId = this.getAttribute('data-chapter-id');
  216. mui.openWindow({
  217. id: 'section-win-' + chapterId,
  218. url: this.href,
  219. waiting: {
  220. autoShow: true
  221. },
  222. extras: {
  223. chapterTitle: chapterTitle,
  224. chapterId: chapterId
  225. }
  226. })
  227. });
  228. }
  229. //右上角菜单点击事件(收藏本、错题本)
  230. function rightBarTapEvent() {
  231. mui('#topPopover').on('tap', 'a', function() {
  232. var courseId = this.getAttribute('data-course-id');
  233. var href = this.getAttribute('data-href');
  234. var type = this.getAttribute('data-type');
  235. var title = this.innerHTML;
  236. mui.openWindow({
  237. id: 'bar-' + courseId,
  238. url: href,
  239. waiting: {
  240. autoShow: true
  241. },
  242. extras: {
  243. barTitle: title,
  244. courseId: courseId,
  245. type: type
  246. }
  247. })
  248. mui("#topPopover").popover("toggle");
  249. });
  250. }
  251. /**
  252. * 更新标题
  253. */
  254. function updateTitle() {
  255. var courseTitle = window.self.courseTitle;
  256. if (courseTitle) {
  257. var titleDom = document.getElementById('title-id');
  258. titleDom.innerHTML = courseTitle;
  259. }
  260. setBackgrounImage();
  261. }
  262. /**
  263. * 点击应用,打开收藏本、错题本
  264. */
  265. function infoTapEvent() {
  266. document.getElementById('info').addEventListener('tap', function() {
  267. mui("#topPopover").popover("toggle");
  268. });
  269. }
  270. mui.plusReady(function() {
  271. window.self = plus.webview.currentWebview();
  272. updateTitle();
  273. initChapterDom();
  274. infoTapEvent();
  275. rightBarTapEvent();
  276. chapterTapEvent();
  277. });
  278. var old_back = mui.back;
  279. mui.back = function() {
  280. var self = plus.webview.currentWebview();
  281. self.opener().evalJS('initDenglu();');
  282. //执行mui封装好的窗口关闭逻辑;
  283. old_back();
  284. }
  285. </script>
  286. </body>
  287. </html>