lookImage.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title>Hello MUI</title>
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <!--标准mui.css-->
  9. <link rel="stylesheet" href="../css/mui.min.css">
  10. <link rel="stylesheet" href="../css/mescroll.min.css">
  11. <link rel="stylesheet" href="../css/iconfont.css">
  12. <link rel="stylesheet" href="../css/reset.css">
  13. <link rel="stylesheet" href="../css/common.css">
  14. <!--App自定义的css-->
  15. <style type="text/css">
  16. .mui-preview-image.mui-fullscreen {
  17. position: fixed;
  18. z-index: 20;
  19. background-color: #000;
  20. }
  21. .mui-preview-header,
  22. .mui-preview-footer {
  23. position: absolute;
  24. width: 100%;
  25. left: 0;
  26. z-index: 10;
  27. }
  28. .mui-preview-header {
  29. height: 44px;
  30. top: 0;
  31. }
  32. .mui-preview-footer {
  33. height: 50px;
  34. bottom: 0px;
  35. }
  36. .mui-preview-header .mui-preview-indicator {
  37. display: block;
  38. line-height: 25px;
  39. color: #fff;
  40. text-align: center;
  41. margin: 15px auto 4;
  42. width: 70px;
  43. background-color: rgba(0, 0, 0, 0.4);
  44. border-radius: 12px;
  45. font-size: 16px;
  46. }
  47. .mui-preview-image {
  48. display: none;
  49. -webkit-animation-duration: 0.5s;
  50. animation-duration: 0.5s;
  51. -webkit-animation-fill-mode: both;
  52. animation-fill-mode: both;
  53. }
  54. .mui-preview-image.mui-preview-in {
  55. -webkit-animation-name: fadeIn;
  56. animation-name: fadeIn;
  57. }
  58. .mui-preview-image.mui-preview-out {
  59. background: none;
  60. -webkit-animation-name: fadeOut;
  61. animation-name: fadeOut;
  62. }
  63. .mui-preview-image.mui-preview-out .mui-preview-header,
  64. .mui-preview-image.mui-preview-out .mui-preview-footer {
  65. display: none;
  66. }
  67. .mui-zoom-scroller {
  68. position: absolute;
  69. display: -webkit-box;
  70. display: -webkit-flex;
  71. display: flex;
  72. -webkit-box-align: center;
  73. -webkit-align-items: center;
  74. align-items: center;
  75. -webkit-box-pack: center;
  76. -webkit-justify-content: center;
  77. justify-content: center;
  78. left: 0;
  79. right: 0;
  80. bottom: 0;
  81. top: 0;
  82. width: 100%;
  83. height: 100%;
  84. margin: 0;
  85. -webkit-backface-visibility: hidden;
  86. }
  87. .mui-zoom {
  88. -webkit-transform-style: preserve-3d;
  89. transform-style: preserve-3d;
  90. }
  91. .mui-slider .mui-slider-group .mui-slider-item img {
  92. width: auto;
  93. height: auto;
  94. max-width: 100%;
  95. max-height: 100%;
  96. }
  97. .mui-android-4-1 .mui-slider .mui-slider-group .mui-slider-item img {
  98. width: 100%;
  99. }
  100. .mui-android-4-1 .mui-slider.mui-preview-image .mui-slider-group .mui-slider-item {
  101. display: inline-table;
  102. }
  103. .mui-android-4-1 .mui-slider.mui-preview-image .mui-zoom-scroller img {
  104. display: table-cell;
  105. vertical-align: middle;
  106. }
  107. .mui-preview-loading {
  108. position: absolute;
  109. width: 100%;
  110. height: 100%;
  111. top: 0;
  112. left: 0;
  113. display: none;
  114. }
  115. .mui-preview-loading.mui-active {
  116. display: block;
  117. }
  118. .mui-preview-loading .mui-spinner-white {
  119. position: absolute;
  120. top: 50%;
  121. left: 50%;
  122. margin-left: -25px;
  123. margin-top: -25px;
  124. height: 50px;
  125. width: 50px;
  126. }
  127. .mui-preview-image img.mui-transitioning {
  128. -webkit-transition: -webkit-transform 0.5s ease, opacity 0.5s ease;
  129. transition: transform 0.5s ease, opacity 0.5s ease;
  130. }
  131. @-webkit-keyframes fadeIn {
  132. 0% {
  133. opacity: 0;
  134. }
  135. 100% {
  136. opacity: 1;
  137. }
  138. }
  139. @keyframes fadeIn {
  140. 0% {
  141. opacity: 0;
  142. }
  143. 100% {
  144. opacity: 1;
  145. }
  146. }
  147. @-webkit-keyframes fadeOut {
  148. 0% {
  149. opacity: 1;
  150. }
  151. 100% {
  152. opacity: 0;
  153. }
  154. }
  155. @keyframes fadeOut {
  156. 0% {
  157. opacity: 1;
  158. }
  159. 100% {
  160. opacity: 0;
  161. }
  162. }
  163. p img {
  164. max-width: 100%;
  165. height: auto;
  166. }
  167. .mui-media-object{
  168. max-height: 120px;
  169. }
  170. /*操作*/
  171. .mui-table-view.mui-grid-view .mui-table-view-cell.operateRight{
  172. /*padding-left: 0;*/
  173. }
  174. .mui-table-view-cell p {
  175. text-align: left;
  176. padding-left: 20px;
  177. font-size: 16px;
  178. line-height: 24px;
  179. overflow: hidden;
  180. white-space: nowrap;
  181. text-overflow: ellipsis;
  182. }
  183. .mui-table-view-cell p:last-child {
  184. font-size: 15px;
  185. }
  186. .activeBj{
  187. background: #eee;
  188. }
  189. .mui-table-view-cell p i {
  190. margin-right: 15px;
  191. color: #007AFF;
  192. }
  193. .nullData {
  194. top: 45px;
  195. }
  196. </style>
  197. </head>
  198. <body>
  199. <header class="mui-bar mui-bar-nav">
  200. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  201. <h1 class="mui-title" id="title"></h1>
  202. </header>
  203. <div class="mui-content">
  204. <div id="scrollPlace" class="mescroll"> <!--id可以改,而"mescroll"的class不能删-->
  205. <ul id="dataList" class="mui-table-view mui-grid-view">
  206. <!--<li class="item">
  207. <div class="mui-table-view-cell mui-col-xs-6">
  208. <img class="mui-media-object" src="../images/shuijiao.jpg" data-preview-src="" data-preview-group="1">
  209. </div>
  210. <div class="mui-table-view-cell mui-col-xs-6 operateRight">
  211. <p class="delBtn">
  212. <i class="iconfont">&#xe65c;</i>删除
  213. </p>
  214. <p class="lookDetial">
  215. <i class="iconfont">&#xe723;</i>查看描述
  216. </p>
  217. <p class=""><i class="iconfont" >&#xe62d;</i>识别</p>
  218. <p class="addDetial">
  219. <i class="iconfont">&#xe69b;</i>添加描述
  220. </p>
  221. <p class="itemTime">2017-6-12 10:09</p>
  222. </div>
  223. </li>-->
  224. </ul>
  225. </div>
  226. </div>
  227. </body>
  228. <script src="../js/jquery-2.1.0.js"></script>
  229. <script src="../js/mui.min.js"></script>
  230. <script src="../js/mui.zoom.js"></script>
  231. <script src="../js/mescroll.min.js" charset="utf-8"></script>
  232. <script src="../js/mui.previewimage.js"></script>
  233. <script>
  234. var equipId;
  235. var startPage = 1;
  236. var totalPage = 0;
  237. var username;
  238. var isuser;
  239. var disc;
  240. mui.plusReady(function() {
  241. var self = plus.webview.currentWebview();
  242. equipId = self.equipId;
  243. console.log(equipId)
  244. isuser = plus.storage.getItem('isuser');
  245. //默认第一次加载数据
  246. // requestData();
  247. username = plus.storage.getItem('username');
  248. mescroll = new MeScroll("scrollPlace", {
  249. up: {
  250. callback: getListData, //上拉回调,此处可简写; 相当于 callback: function (page) { getListData(page); }
  251. isBounce: false, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10
  252. clearEmptyId: "dataList", //1.下拉刷新时会自动先清空此列表,再加入数据; 2.无任何数据时会在此列表自动提示空
  253. toTop:{ //配置回到顶部按钮
  254. src : "../images/totop.png", //默认滚动到1000px显示,可配置offset修改
  255. offset : 700
  256. },
  257. empty: {
  258. //列表第一页无任何数据时,显示的空提示布局; 需配置warpId才显示
  259. warpId: "dataList", //父布局的id (1.3.5版本支持传入dom元素)
  260. icon: "../images/listNull.png", //图标,默认null,支持网络图
  261. tip: "暂无相关数据~" //提示
  262. },
  263. htmlNodata: '<p class="upwarp-nodata">-- 没有更多内容了 --</p>',
  264. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于5才显示无更多数据;
  265. lazyLoad: {
  266. use: true // 是否开启懒加载,默认false
  267. }
  268. }
  269. });
  270. })
  271. /*联网加载列表数据 page = {num:1, size:10}; num:当前页 从1开始, size:每页数据条数 */
  272. function getListData(page){
  273. //联网加载数据
  274. getListDataFromNet(page.num, page.size, function(curPageData,totalSize){
  275. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  276. //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
  277. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  278. mescroll.endSuccess(totalSize);
  279. //设置列表数据,因为配置了emptyClearId,第一页会清空dataList的数据,所以setListData应该写在最后;
  280. setListData(curPageData);
  281. }, function(){
  282. //联网失败的回调,隐藏下拉刷新和上拉加载的状态;
  283. mescroll.endErr();
  284. mui.toast('数据请求失败');
  285. });
  286. }
  287. /*设置列表数据*/
  288. function setListData(curPageData){
  289. var html = '';
  290. var dat = curPageData;
  291. // var dat = data.img;
  292. for(var i = 0; i<dat.length; i++){
  293. html += '<li class="item" data-id="'+dat[i].id+'"><div class="mui-table-view-cell mui-col-xs-6">' +
  294. '<img class="mui-media-object" src="'+dat[i].addr+'" data-preview-src="" data-preview-group="1">' +
  295. '</div><div class="mui-table-view-cell mui-col-xs-6 operateRight"><p class="delBtn"><i class="iconfont" >&#xe65c;</i>删除' +
  296. '</p><p class="lookDetial"><i class="iconfont" >&#xe723;</i>查看描述</p>';
  297. if((isuser == 'admin' || disc == '1') && localStorage.getItem('possess') == '1'){
  298. html += '<p class="discern"><i class="iconfont" >&#xe62d;</i>识别</p>';
  299. }
  300. html += '<p class="addDetial"><i class="iconfont" >&#xe69b;</i>添加描述</p>' +
  301. '<p class="itemTime">'+dat[i].upl_time+'</p></div></li>';
  302. }
  303. $('#dataList').append(html)
  304. }
  305. /*联网加载列表数据*/
  306. function getListDataFromNet(pageNum,pageSize,successCallback,errorCallback) {
  307. mui.ajax('http://192.168.1.11:8000/app_cbd_img', {
  308. data: {
  309. 'page': pageNum,
  310. 'equip_id': equipId
  311. },
  312. dataType: 'json', //服务器返回json格式数据
  313. type: 'post', //HTTP请求类型
  314. timeout: 10000, //超时时间设置为10秒;
  315. beforeSend: function() {
  316. plus.nativeUI.showWaiting('请求中...');
  317. },
  318. complete: function() {
  319. plus.nativeUI.closeWaiting();
  320. },
  321. success: function(data) {
  322. $('#title').html(data.equip_id);
  323. disc = data.disc;
  324. successCallback(data.img,data.nums);
  325. },
  326. error: function(xhr, type, errorThrown) {
  327. }
  328. });
  329. }
  330. //图片轮播
  331. mui.previewImage();
  332. //删除
  333. mui('#dataList').on('tap', '.delBtn', function() {
  334. var _this = this;
  335. $(_this).addClass("activeBj"); // 追加样式
  336. setTimeout(function(){
  337. $(_this).removeClass("activeBj"); //移除p元素中值为"high"的class
  338. },30)
  339. var id = $(_this).parents('.item').data('id');
  340. mui.ajax('http://192.168.1.11:8000/cbd_delete_img', {
  341. data: {
  342. 'addr': id,
  343. 'equip_id': equipId
  344. },
  345. dataType: 'json', //服务器返回json格式数据
  346. type: 'post', //HTTP请求类型
  347. timeout: 10000, //超时时间设置为10秒;
  348. beforeSend: function() {
  349. plus.nativeUI.showWaiting('请求中...');
  350. },
  351. complete: function() {
  352. plus.nativeUI.closeWaiting();
  353. },
  354. success: function(data) {
  355. if(data == 1){
  356. window.location.reload();
  357. }
  358. },
  359. error: function(xhr, type, errorThrown) {
  360. mui.toast('删除失败')
  361. }
  362. })
  363. })
  364. //识别
  365. mui('#dataList').on('tap', '.discern', function() {
  366. var _this = this;
  367. $(_this).addClass("activeBj"); // 追加样式
  368. setTimeout(function(){
  369. $(_this).removeClass("activeBj"); //移除p元素中值为"high"的class
  370. },30)
  371. var path = $(_this).parents('.item').data('path');
  372. mui.openWindow({
  373. url: 'cbd_image_discern_resule.html',
  374. id: 'cbd_image_discern_resule',
  375. extras: {
  376. equipId: equipId,
  377. addr: path
  378. }
  379. })
  380. })
  381. //查看详情
  382. mui('#dataList').on('tap', '.lookDetial', function() {
  383. var _this = this;
  384. $(_this).addClass("activeBj"); // 追加样式
  385. setTimeout(function(){
  386. $(_this).removeClass("activeBj"); //移除p元素中值为"high"的class
  387. },30)
  388. var path = $(_this).parents('.item').data('path');
  389. mui.openWindow({
  390. url: 'lookWormDetial.html',
  391. id: 'lookWormDetial',
  392. extras: {
  393. equipId: equipId,
  394. addr: path
  395. }
  396. })
  397. })
  398. //添加详情
  399. mui('#dataList').on('tap', '.addDetial', function() {
  400. var _this = this;
  401. $(_this).addClass("activeBj"); // 追加样式
  402. setTimeout(function(){
  403. $(_this).removeClass("activeBj"); //移除p元素中值为"high"的class
  404. },30)
  405. var path = $(_this).parents('.item').data('path');
  406. mui.openWindow({
  407. url: 'wormDescribe.html',
  408. id: 'wormDescribe',
  409. extras: {
  410. equipId: equipId,
  411. addr: path
  412. }
  413. })
  414. })
  415. </script>
  416. </html>