123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>主页</title>
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <!--标准mui.css-->
- <link rel="stylesheet" href="css/mui.min.css">
- <!--App自定义的css-->
- <link rel="stylesheet" type="text/css" href="../css/app.css" />
- <style>
- .title {
- margin: 20px 15px 10px;
- color: #6d6d72;
- font-size: 15px;
- }
- .oa-contact-cell.mui-table .mui-table-cell {
- padding: 11px 0;
- vertical-align: middle;
- }
- .oa-contact-cell {
- position: relative;
- margin: -11px 0;
- }
- .oa-contact-avatar {
- width: 75px;
- }
- .oa-contact-avatar img {
- border-radius: 50%;
- }
- .oa-contact-content {
- width: 100%;
- }
- .oa-contact-name {
- margin-right: 20px;
- }
- .oa-contact-name,
- oa-contact-position {
- float: left;
- }
- body {
- background-color: #efeff4;
- }
- h5 {
- padding-top: 8px;
- padding-bottom: 8px;
- text-indent: 12px;
- }
- .mui-table-view.mui-grid-view .mui-table-view-cell .mui-media-body {
- font-size: 15px;
- margin-top: 8px;
- color: #333;
- }
- .my-mui-media-body {
- height: 30px !important;
- font-size: 18px !important;
- line-height: 30px !important;
- }
- .mui-media-object {
- width: 80% !important;
- }
- .mui-table-view-cell {
- padding-right:10px !important;
- }
- </style>
- </head>
- <body>
- <header class="mui-bar mui-bar-nav">
- <a id="search-id" class="mui-icon mui-icon-search mui-pull-right" style="display: none;"></a>
- <h1 class="mui-title">石油书吧</h1>
- </header>
- <nav class="mui-bar mui-bar-tab" id='menu-nav-id'>
- <a class="mui-tab-item mui-active" href="#tabbar">
- <span class="mui-icon mui-icon-contact" style="font-weight: bolder"></span>
- <span class="mui-tab-label" style="font-weight: bolder">书 吧</span>
- </a>
- <a data-search='true' class="mui-tab-item" href="#tabbar-with-chat">
- <span class="mui-icon mui-icon-email" style="font-weight: bolder"></span>
- <span class="mui-tab-label" style="font-weight: bolder">书 架</span>
- </a>
- <a class="mui-tab-item" href="#tabbar-with-map">
- <span class="mui-icon mui-icon-gear" style="font-weight: bolder"></span>
- <span class="mui-tab-label" style="font-weight: bolder">设 置</span>
- </a>
- </nav>
- <div class="mui-content">
- <!--
- 描述:书吧
- -->
- <div id="tabbar" class="mui-control-content mui-active">
- <div id="pullrefresh" class="mui-content mui-scroll-wrapper">
- <div class="mui-scroll" style="margin-top: 15px;">
- <ul id="books-id" class="mui-table-view mui-table-view-chevron">
- <li id="loading-id" class="mui-table-view-cell mui-media">
- <div style="text-align: center;margin-right: -60px;">加载中...</div>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <!--
- 描述:书架
- -->
- <div id="tabbar-with-chat" class="mui-control-content">
- <ul id="book-list-id" class="mui-table-view mui-grid-view mui-grid-9">
-
- </ul>
- </div>
- <!--
- 描述:设置
- -->
- <div id="tabbar-with-map" class="mui-control-content">
- <div class="mui-scroll-wrapper">
- <div class="mui-scroll">
- <ul class="mui-table-view" style="margin-top: 20px;">
- <li class="mui-table-view-cell">
- <a id="tel" class="mui-navigate-right">
- 客服电话
- </a>
- </li>
- <li class="mui-table-view-cell" >
- <a id="feedback-btn" data-href="app/feedback.html" class="mui-navigate-right">
- 问题反馈
- </a>
- </li>
- </ul>
- <ul class="mui-table-view" style="margin-top: 20px;">
- <li class="mui-table-view-cell">
- <a id="update" class="mui-navigate-right">检查更新</a>
- </li>
- </ul>
- <ul class="mui-table-view" style="margin-top: 25px;">
- <li class="mui-table-view-cell">
- <a id="logout" data-href="logout" style="text-align: center;color: #FF3B30;">
- 退出登录
- </a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </body>
- <script id="book-temp-id" type="text/html">
- <div class="mui-slider-right mui-disabled">
- <div class="mui-btn mui-btn-red" data-id='{id}'>删除</div>
- </div>
- <div class="mui-slider-handle">
- <a data-id='{id}' data-is-dowanload='{isDownload}' download-start='false' data-html-name='{htmlName}'>
- <img id="img-{id}" class="mui-media-object mui-pull-left">
- <div class="mui-media-body">
- {name}
- <p class='mui-ellipsis'>{desc}</p>
- </div>
- </a>
- </div>
- </script>
- <script type="text/html" id="category-temp-id">
- <!--<li class="mui-table-view-cell mui-media mui-col-xs-6">-->
- <a href="javascript:void(0)" data-title='{name}' data-id='{id}'>
- <img class="mui-media-object" id="img-category-{id}" style="width:130px !important;height: 80px !important;">
- <div class="mui-media-body my-mui-media-body">{name}</div>
- </a>
- <!--</li>-->
- </script>
- <!--
- 作者:52529860@qq.com
- 时间:2015-09-14
- 描述:主页
- -->
- <script type="text/javascript" src="js/jquery.min.js" type="text/javascript" charset="UTF-8"></script>
- <script type="text/javascript" src="http://182.92.109.194:8080/rpc/helper.js" type="text/javascript" charset="UTF-8"></script>
- <script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/routes.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/update.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/app.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/db/service.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/hzc.rpc.js" type="text/javascript" charset="utf-8"></script>
- <script>
- mui.init({
- swipeBack: false,
- pullRefresh: {
- container: '#pullrefresh',
- up: {
- contentrefresh: '正在加载...',
- callback: pullupRefresh
- }
- }
- });
- mui.plusReady(function() {
- // plus.screen.lockOrientation("portrait");
- loadBooks(1);
- initCategory();
- openBook();
- saveBookIds();
- openList();
- callPhone();
- checkUpdate();
- feedback();
- navTab();
- doSearch();
- deleteBook();
- logout();
- });
- /**
- * 删除图书
- */
- function deleteBook() {
- mui('#books-id').on('tap', '.mui-btn', function() {
- var elem = this;
- var btnArray = ['确认', '取消'];
- mui.confirm('确认删除该条记录?', '', btnArray, function(e) {
- if (e.index == 0) {
- var bookId = elem.getAttribute('data-id');
- deleteBooks(bookId, function() {
- saveBookIds(function() {})
- var li = elem.parentElement.parentElement;
- var p = li.parentElement;
- p.removeChild(li);
- console.log(p.children.length);
- if (p.children.length == 0) {
- var li = document.createElement('li');
- li.className = 'mui-table-view-cell mui-media';
- li.innerHTML = '<div style="text-align: center;">没有相关图书</div>';
- //p.appendChild('<li id="loading-id" class="mui-table-view-cell mui-media"><div style="text-align: center;margin-right: -60px;">加载中...</div></li>');
- p.appendChild(li);
- }
- });
- }
- });
- });
- }
- /**
- * 初始化图书分类
- */
- function initCategory() {
- listCategoryRpc(function(data) {
- // console.log(JSON.stringify(data));
- var htmlStr = '';
- // <li class="mui-table-view-cell mui-media"><div style="text-align: center;margin-right: -60px;">数据加载中...</div></li>
- if (data.length < 1) {
- htmlStr = '<div style="text-align: center;">没有相关数据</div>';
- $id('book-list-id').innerHTML = htmlStr;
- return;
- }
- $id('book-list-id').innerHTML = '';
- var tempHtml = $id('category-temp-id').innerHTML;
- for (var i = 0; i < data.length; i++) {
- var category = data[i];
- // console.log(JSON.stringify(category))
- var li = document.createElement('li');
- li.className = 'mui-table-view-cell mui-media mui-col-xs-6';
- li.innerHTML = render(tempHtml, category);
- $id('book-list-id').appendChild(li);
- category.imgPath = Routes.urls.book.bookUrl + category.img_path;
- setImg('img-category-' + category.id, category.imgPath);
- }
- });
- }
- window.count = 0;
- //分页查询我的book
- window.start = 0;
- /**
- * 上拉加载具体业务实现
- */
- function pullupRefresh() {
- setTimeout(function() {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh((++window.count > 50)); //参数为true代表没有更多数据了。
- loadBooks(2);
- }, 1000);
- }
- /**
- * 加载图书
- * @param {Object} source:来源:1,初始化,2,上拉刷新
- */
- function loadBooks(source) {
- getMyBooks(window.start, function(data) {
- toastNetworkInfo('当前网络不可用');
- if (data.length < 1) {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
- if (source == 1) {
- $id('books-id').innerHTML = '<li class="mui-table-view-cell mui-media"><div style="text-align: center;">没有相关图书</div></li>';
- } else {
- mui.toast('没有更多数据了');
- }
- return;
- }
- window.start += 5;
- var tempHtml = $id('book-temp-id').innerHTML;
- try {
- $id('loading-id').style.display = 'none';
- $id('loading-id').parentElement.removeChild($id('loading-id'))
- } catch (e) {}
- if (toastNetworkInfo('当前网络不可用')) {
- listDelPdfId(function(delData) {
- var delDataStr = delData.toString();
- // console.log(delDataStr)
- for (var i = 0; i < data.length; i++) {
- var book = data[i];
- if (delDataStr && !delDataStr.indexOf(book.id) > 0) {
- updateBookStatus(book.id, '0', function() {});
- continue;
- }
- var li = document.createElement('li');
- li.className = 'mui-table-view-cell mui-media';
- li.innerHTML = render(tempHtml, book);
- $id('books-id').appendChild(li);
- book.imgPath = Routes.urls.book.bookUrl + book.imgPath;
- setImg('img-' + book.id, book.imgPath);
- }
- });
- } else {
- for (var i = 0; i < data.length; i++) {
- var book = data[i];
- var li = document.createElement('li');
- li.className = 'mui-table-view-cell mui-media';
- li.innerHTML = render(tempHtml, book);
- $id('books-id').appendChild(li);
- book.imgPath = Routes.urls.book.bookUrl + book.imgPath;
- setImg('img-' + book.id, book.imgPath);
- }
- }
- });
- }
- /**
- * 打开书
- */
- function openBook() {
- mui('#books-id').on('tap', 'a', function() {
- var self = this;
- var htmlName = self.getAttribute('data-html-name');
- var bookPath = DOWNLOADPATH + htmlName;
- var absoluteBookPath = convertToAbsoluteURL(bookPath);
- mui.openWindow({
- id: 'book-id',
- url: 'app/book.html',
- extras: {
- href: absoluteBookPath
- },
- show: {
- duration: 200
- }
- })
- });
- }
- /**
- * 打开图书列表
- */
- function openList() {
- mui('#book-list-id').on('tap', 'a', function() {
- var title = this.getAttribute('data-title');
- var categoryId = this.getAttribute('data-id');
- if (toastNetworkInfo('当前网络不可用')) {
- var oldWin = plus.webview.getWebviewById('book-list-id-' + categoryId);
- if (oldWin) {
- oldWin.show();
- // plus.webview.getWebviewById('tab-webview-main-id').reload();
- return;
- }
- mui.openWindow({
- id: 'book-list-id-' + categoryId,
- url: 'app/book-list.html',
- extras: {
- title: title,
- categoryId: categoryId
- },
- show: {
- duration: 350
- }
- });
- // plus.webview.getWebviewById('tab-webview-main-id').reload();
- }
- });
- }
- //客服电话
- function callPhone() {
- document.getElementById("tel").addEventListener('tap', function() {
- plus.device.dial("114");
- });
- }
- function feedback() {
- document.getElementById("feedback-btn").addEventListener('tap', function() {
- mui.openWindow({
- id: 'feedback-id',
- url: this.getAttribute('data-href'),
- show: {
- duration: 200
- }
- })
- })
- }
- //检查更新
- function checkUpdate() {
- document.getElementById("update").addEventListener('tap', function() {
- update("inner");
- });
- }
- /**
- * 退出
- */
- function logout() {
- document.getElementById("logout").addEventListener('tap', function() {
- var btnArray = ['是', '否'];
- mui.confirm('确定要退出登录吗?', '', btnArray, function(e) {
- if (e.index == 0) {
- plus.downloader.clear();
- setLoginStatus('false');
- mui.openWindow({
- id: 'login-id',
- url: 'login.html',
- show: {
- duration: 200
- }
- });
- setTimeout(function() {
- plus.webview.getWebviewById('tab-webview-main-id').close();
- }, 2000);
- }
- });
- });
- }
- /**
- * 显示收藏
- */
- function navTab() {
- mui('#menu-nav-id').on('tap', 'a', function() {
- var data = this.getAttribute('data-search');
- if (data == 'true') {
- $id('search-id').style.display = 'block';
- } else {
- $id('search-id').style.display = 'none';
- }
- })
- }
- /**
- * 点击搜索
- */
- function doSearch() {
- document.getElementById("search-id").addEventListener('tap', function() {
- if (toastNetworkInfo('当前网络不可用')) {
- mui.openWindow({
- id: 'search-id',
- url: 'app/search.html',
- show: {
- duration: 200
- }
- });
- }
- });
- }
- //退出
- var backButtonPress = 0;
- mui.back = function(event) {
- backButtonPress++;
- if (backButtonPress > 1) {
- plus.downloader.clear();
- plus.runtime.quit();
- } else {
- plus.nativeUI.toast('再按一次退出应用');
- }
- setTimeout(function() {
- backButtonPress = 0;
- }, 1000);
- return false;
- };
- </script>
- </html>
|