autoDiscernResult.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <link href="../css/mui.min.css" rel="stylesheet" />
  8. <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
  9. <link rel="stylesheet" href="../css/swiper-4.4.6.min.css">
  10. <link href="../css/common.css" rel="stylesheet" />
  11. <style type="text/css">
  12. .innerBox{
  13. width: 90%;
  14. margin: 0 auto;
  15. border-radius: 10px;
  16. background: #fff;
  17. position: relative;
  18. padding-bottom: 30px;
  19. }
  20. .discernImg >img{
  21. border-radius: 10px 10px 0 0;
  22. }
  23. .detailsBox{
  24. padding: 0 10%;
  25. }
  26. .detailsBox h1{
  27. font-size: 20px;
  28. line-height: 50px;
  29. border-bottom: 1px solid #d3d3d3;
  30. }
  31. .detailsBox >div{
  32. color: #626262;
  33. text-indent: 30px;
  34. }
  35. .swiper-container {
  36. width: 98%;
  37. height: 98%;
  38. margin-bottom: 30px;
  39. }
  40. /*上传按钮*/
  41. .upfileBox{
  42. position: absolute;
  43. right: 18px;
  44. text-align: center;
  45. }
  46. #upFile{
  47. width: 107px;
  48. height: 50px;
  49. border-radius: 27px;
  50. background: url(../images/upfilebj.png) no-repeat;
  51. background-size: 100%;
  52. border: none;
  53. }
  54. /*swiper 前后按钮*/
  55. .swiper-button-prev, .swiper-container-rtl .swiper-button-next{
  56. background-image:url(../images/leftBtn.png)
  57. }
  58. .swiper-button-next, .swiper-container-rtl .swiper-button-prev{
  59. background-image:url(../images/rightBtn.png)
  60. }
  61. /*结果总数*/
  62. .result-top{
  63. margin-top: 16px;
  64. position: relative;
  65. width: 100%;
  66. height: 63px;
  67. padding: 10px 30px;
  68. font-size: 16px;
  69. }
  70. .result-top .fl{
  71. float: left;
  72. }
  73. #tipLeft{
  74. width: 42px;
  75. border-right: 2px solid #454545;
  76. margin-right: 10px;
  77. }
  78. #nullBox{
  79. line-height: 30px;
  80. text-align: center;
  81. color: #a5a5a5;
  82. font-size: 18px;
  83. }
  84. .discernImg img{
  85. /*height: 200px;*/
  86. }
  87. </style>
  88. </head>
  89. <body>
  90. <header class="mui-bar mui-bar-nav">
  91. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  92. <h1 class="mui-title">识别结果</h1>
  93. </header>
  94. <div class="mui-content">
  95. <div class="result-top">
  96. <div class="fl" id="tipLeft"></div>
  97. <div class="fl" id="tipRight">
  98. 此次识别种类<p id="wormNum"></p>
  99. </div>
  100. <div id="">
  101. <div class="upfileBox">
  102. <button id="upFile"></button>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="resultDetial">
  107. <div class="swiper-container">
  108. <div class="swiper-wrapper">
  109. <!--<div class="swiper-slide">
  110. <div class="innerBox">
  111. <div class="introduceBox">
  112. <div class="discernImg">
  113. <img src="../images/ant.jpg" width="100%"/>
  114. </div>
  115. <div class="detailsBox">
  116. <h1>蚂蚁</h1>
  117. <div class="">
  118. 蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫,别名蚁、玄驹、昆蜉、蚍蜉蚂,属节肢动物门,昆虫纲,膜翅目,蚁科。蚂蚁的种类繁多,世界上已知有11700多种,有21亚科283属,中国境内已确定的蚂蚁种类有600多种。
  119. </div>
  120. <div class="">
  121. 最近还发现了无性繁殖的蚂蚁新物种。蚂蚁的寿命很长,工蚁可生存几星期至3-10年,蚁后则可存活几年甚至十年。一个蚁巢在1个地方可生长几年甚至十几年。需要注意的是,白蚁不属于蚂蚁。
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="swiper-slide">
  128. <div class="innerBox">
  129. <div class="introduceBox">
  130. <div class="discernImg">
  131. <img src="../images/banner1.jpg" width="100%"/>
  132. </div>
  133. <div class="detailsBox">
  134. <h1>蚂蚁</h1>
  135. <div class="">
  136. 蚂蚁是一种昆虫,别名蚁、玄驹、昆蜉、蚍蜉蚂,属节肢动物门,昆虫纲,膜翅目,蚁科。蚂蚁的种类繁多,世界上已知有11700多种,有21亚科283属,中国境内已确定的蚂蚁种类有600多种。
  137. </div>
  138. <div class="">
  139. 最近还发现了无性繁殖的蚂蚁新物种。蚂蚁的寿命很长,工蚁可生存几星期至3-10年,蚁后则可存活几年甚至十年。一个蚁巢在1个地方可生长几年甚至十几年。需要注意的是,白蚁不属于蚂蚁。
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>-->
  145. <!--<div class="swiper-slide">Slide 3</div>-->
  146. </div>
  147. <!-- 如果需要导航按钮 -->
  148. <div class="swiper-button-prev"></div>
  149. <div class="swiper-button-next"></div>
  150. </div>
  151. </div>
  152. <div id="nullBox"></div>
  153. </div>
  154. <script src="../js/jquery-2.1.0.js"></script>
  155. <script src="../js/swiper-4.4.6.min.js"></script>
  156. <script src="../js/mui.min.js"></script>
  157. <script type="text/javascript">
  158. mui.plusReady(function() {
  159. var self = plus.webview.currentWebview();
  160. console.log(self.responseText);
  161. disposeFun(self.responseText)
  162. })
  163. function disposeFun(msg){
  164. console.log(msg);
  165. var msg = $.parseJSON(msg);
  166. $('.swiper-wrapper').html('');
  167. $('#nullBox').html('');
  168. var datamsg = msg.data;
  169. if(msg.code == 200){
  170. $('#tipLeft').html('识别成功');
  171. if(datamsg.length){
  172. var html = '';
  173. for(var i = 0;i<datamsg.length;i++){
  174. html += '<div class="swiper-slide"><div class="innerBox"><div class="introduceBox">'+
  175. '<div class="discernImg"><img src="'+datamsg[i].img_urls+'" width="100%"/></div><div class="detailsBox">'+
  176. '<h1>'+datamsg[i].name+'</h1><div class="">'+datamsg[i].prevention+'</div></div></div></div></div>';
  177. }
  178. $('.swiper-wrapper').append(html);
  179. var mySwiper = new Swiper ('.swiper-container', {
  180. direction: 'horizontal', // 垂直切换选项
  181. loop: false, // 循环模式选项
  182. // 如果需要前进后退按钮
  183. navigation: {
  184. nextEl: '.swiper-button-next',
  185. prevEl: '.swiper-button-prev',
  186. },
  187. })
  188. $('#wormNum').html(datamsg.length + '种');
  189. }else{
  190. $('#nullBox').html('暂无此类信息');
  191. $('#wormNum').html('暂无此类信息');
  192. }
  193. }else{
  194. $('#tipLeft').html('识别失败');
  195. var codeNum;
  196. if(msg.code == 401){
  197. $('#nullBox').html('此类暂未录入');
  198. $('#wormNum').html('此类暂未录入');
  199. }else{
  200. $('#nullBox').html('图片不存在');
  201. $('#wormNum').html('图片不存在');
  202. }
  203. }
  204. }
  205. // var html = '<div class="swiper-slide">Slide 4</div>';
  206. // $('.swiper-wrapper').append(html)
  207. //上传
  208. document.getElementById('upFile').addEventListener('tap', function() {
  209. if(mui.os.plus) {
  210. var a = [{
  211. title: '拍照'
  212. }, {
  213. title: '从手机相册选择'
  214. }];
  215. plus.nativeUI.actionSheet({
  216. title: '识别图片',
  217. cancel: '取消',
  218. buttons: a
  219. }, function(b) {
  220. console.log(b.index)
  221. switch(b.index) {
  222. case 0:
  223. break;
  224. case 1:
  225. //拍照
  226. getImages();
  227. break;
  228. case 2:
  229. //打开相册
  230. galleryImages();
  231. break;
  232. default:
  233. break;
  234. }
  235. }, false);
  236. }
  237. });
  238. //拍照
  239. function getImages() {
  240. var mobileCamera = plus.camera.getCamera();
  241. mobileCamera.captureImage(function(e) {
  242. plus.io.resolveLocalFileSystemURL(e, function(entry) {
  243. var path = entry.toLocalURL() + '?version=' + new Date().getTime();
  244. uploadHeadImg(path);
  245. }, function(err) {
  246. console.log("读取拍照文件错误");
  247. });
  248. }, function(e) {
  249. console.log("er", err);
  250. }, function() {
  251. filename: '_doc/head.png';
  252. });
  253. }
  254. //从本地相册选择
  255. function galleryImages() {
  256. console.log("你选择了从相册选择");
  257. plus.gallery.pick(function(a) {
  258. plus.io.resolveLocalFileSystemURL(a, function(entry) {
  259. plus.io.resolveLocalFileSystemURL('_doc/', function(root) {
  260. root.getFile('head.png', {}, function(file) {
  261. //文件已经存在
  262. file.remove(function() {
  263. console.log("文件移除成功");
  264. entry.copyTo(root, 'head.png', function(e) {
  265. var path = e.fullPath + '?version=' + new Date().getTime();
  266. uploadHeadImg(path);
  267. }, function(err) {
  268. console.log("copy image fail: ", err);
  269. });
  270. }, function(err) {
  271. console.log("删除图片失败:(" + JSON.stringify(err) + ")");
  272. });
  273. }, function(err) {
  274. //打开文件失败
  275. entry.copyTo(root, 'head.png', function(e) {
  276. var path = e.fullPath + '?version=' + new Date().getTime();
  277. uploadHeadImg(path);
  278. }, function(err) {
  279. console.log("上传图片失败:(" + JSON.stringify(err) + ")");
  280. });
  281. });
  282. }, function(e) {
  283. console.log("读取文件夹失败:(" + JSON.stringify(err) + ")");
  284. });
  285. });
  286. }, function(err) {
  287. console.log("读取拍照文件失败: ", err);
  288. }, {
  289. filter: 'image'
  290. });
  291. };
  292. //上传图片
  293. function uploadHeadImg(imgPath) {
  294. alert(1)
  295. //服务端接口路径
  296. var server = "http://47.99.110.100:8080/recognizationSys/api/recognization";
  297. //获取图片元素
  298. var wt = plus.nativeUI.showWaiting('上传中...');
  299. var task = plus.uploader.createUpload(server, {
  300. method: "POST",
  301. // timeout:10
  302. },
  303. function(t, status) { //上传完成
  304. if(status == 200) {
  305. // alert("上传成功:" + t.responseText);
  306. wt.close(); //关闭等待提示按钮
  307. disposeFun(t.responseText)
  308. } else {
  309. alert("上传失败:");
  310. wt.close(); //关闭等待提示按钮
  311. }
  312. }
  313. );
  314. //添加其他参数
  315. // task.addData("name", "test");
  316. task.addData("username", "yunfei");
  317. task.addData("uniqueKey", "84e6eb40f3a616dd14b1fefc75425006");
  318. task.addData("gis", "118.279643#31.221456");
  319. task.addData("imageType", "1");
  320. task.addFile(imgPath, {
  321. key: "imageFile"
  322. });
  323. task.start();
  324. }
  325. function uploadHeadImg1(imgPath) {
  326. //服务端接口路径
  327. var server = "http://120.27.222.26/app_insect_discern";
  328. //获取图片元素
  329. var wt = plus.nativeUI.showWaiting('上传中...');
  330. var task = plus.uploader.createUpload(server, {
  331. method: "POST",
  332. // timeout:10
  333. },
  334. function(t, status) { //上传完成
  335. if(status == 200) {
  336. // alert("上传成功:" + t.responseText);
  337. wt.close(); //关闭等待提示按钮
  338. disposeFun(t.responseText)
  339. } else {
  340. alert("上传失败:");
  341. wt.close(); //关闭等待提示按钮
  342. }
  343. }
  344. );
  345. //添加其他参数
  346. // task.addData("name", "test");
  347. task.addData("req", "change_photo");
  348. task.addFile(imgPath, {
  349. key: "imagefile"
  350. });
  351. task.start();
  352. }
  353. </script>
  354. </body>
  355. </html>