| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <link href="../css/mui.min.css" rel="stylesheet" />
- <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
- <link rel="stylesheet" href="../css/swiper-4.4.6.min.css">
- <link href="../css/common.css" rel="stylesheet" />
- <style type="text/css">
- .innerBox{
- width: 90%;
- margin: 0 auto;
- border-radius: 10px;
- background: #fff;
- position: relative;
- padding-bottom: 30px;
- }
- .discernImg >img{
- border-radius: 10px 10px 0 0;
- }
- .detailsBox{
- padding: 0 10%;
- }
- .detailsBox h1{
- font-size: 20px;
- line-height: 50px;
- border-bottom: 1px solid #d3d3d3;
- }
- .detailsBox >div{
- color: #626262;
- text-indent: 30px;
- }
-
- .swiper-container {
- width: 98%;
- height: 98%;
- margin-bottom: 30px;
- }
- /*上传按钮*/
- .upfileBox{
- position: absolute;
- right: 18px;
- text-align: center;
- }
- #upFile{
- width: 107px;
- height: 50px;
- border-radius: 27px;
- background: url(../images/upfilebj.png) no-repeat;
- background-size: 100%;
- border: none;
- }
- /*swiper 前后按钮*/
- .swiper-button-prev, .swiper-container-rtl .swiper-button-next{
- background-image:url(../images/leftBtn.png)
- }
- .swiper-button-next, .swiper-container-rtl .swiper-button-prev{
- background-image:url(../images/rightBtn.png)
- }
- /*结果总数*/
- .result-top{
- margin-top: 16px;
- position: relative;
- width: 100%;
- height: 63px;
- padding: 10px 30px;
- font-size: 16px;
- }
- .result-top .fl{
- float: left;
- }
- #tipLeft{
- width: 42px;
- border-right: 2px solid #454545;
- margin-right: 10px;
- }
- #nullBox{
- line-height: 30px;
- text-align: center;
- color: #a5a5a5;
- font-size: 18px;
- }
- .discernImg img{
- /*height: 200px;*/
- }
- </style>
- </head>
- <body>
- <header class="mui-bar mui-bar-nav">
- <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
- <h1 class="mui-title">识别结果</h1>
- </header>
- <div class="mui-content">
- <div class="result-top">
- <div class="fl" id="tipLeft"></div>
- <div class="fl" id="tipRight">
- 此次识别种类<p id="wormNum"></p>
- </div>
- <div id="">
- <div class="upfileBox">
- <button id="upFile"></button>
- </div>
- </div>
- </div>
-
- <div class="resultDetial">
- <div class="swiper-container">
- <div class="swiper-wrapper">
- <!--<div class="swiper-slide">
- <div class="innerBox">
- <div class="introduceBox">
- <div class="discernImg">
- <img src="../images/ant.jpg" width="100%"/>
- </div>
- <div class="detailsBox">
- <h1>蚂蚁</h1>
- <div class="">
- 蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫蚂蚁是一种昆虫,别名蚁、玄驹、昆蜉、蚍蜉蚂,属节肢动物门,昆虫纲,膜翅目,蚁科。蚂蚁的种类繁多,世界上已知有11700多种,有21亚科283属,中国境内已确定的蚂蚁种类有600多种。
- </div>
- <div class="">
- 最近还发现了无性繁殖的蚂蚁新物种。蚂蚁的寿命很长,工蚁可生存几星期至3-10年,蚁后则可存活几年甚至十年。一个蚁巢在1个地方可生长几年甚至十几年。需要注意的是,白蚁不属于蚂蚁。
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="swiper-slide">
- <div class="innerBox">
- <div class="introduceBox">
- <div class="discernImg">
- <img src="../images/banner1.jpg" width="100%"/>
- </div>
- <div class="detailsBox">
- <h1>蚂蚁</h1>
- <div class="">
- 蚂蚁是一种昆虫,别名蚁、玄驹、昆蜉、蚍蜉蚂,属节肢动物门,昆虫纲,膜翅目,蚁科。蚂蚁的种类繁多,世界上已知有11700多种,有21亚科283属,中国境内已确定的蚂蚁种类有600多种。
- </div>
- <div class="">
- 最近还发现了无性繁殖的蚂蚁新物种。蚂蚁的寿命很长,工蚁可生存几星期至3-10年,蚁后则可存活几年甚至十年。一个蚁巢在1个地方可生长几年甚至十几年。需要注意的是,白蚁不属于蚂蚁。
- </div>
- </div>
- </div>
- </div>
- </div>-->
- <!--<div class="swiper-slide">Slide 3</div>-->
- </div>
- <!-- 如果需要导航按钮 -->
- <div class="swiper-button-prev"></div>
- <div class="swiper-button-next"></div>
- </div>
- </div>
-
- <div id="nullBox"></div>
- </div>
- <script src="../js/jquery-2.1.0.js"></script>
- <script src="../js/swiper-4.4.6.min.js"></script>
- <script src="../js/mui.min.js"></script>
- <script type="text/javascript">
- mui.plusReady(function() {
- var self = plus.webview.currentWebview();
- console.log(self.responseText);
- disposeFun(self.responseText)
- })
-
- function disposeFun(msg){
- console.log(msg);
- var msg = $.parseJSON(msg);
- $('.swiper-wrapper').html('');
- $('#nullBox').html('');
- var datamsg = msg.data;
- if(msg.code == 200){
- $('#tipLeft').html('识别成功');
- if(datamsg.length){
- var html = '';
- for(var i = 0;i<datamsg.length;i++){
- html += '<div class="swiper-slide"><div class="innerBox"><div class="introduceBox">'+
- '<div class="discernImg"><img src="'+datamsg[i].img_urls+'" width="100%"/></div><div class="detailsBox">'+
- '<h1>'+datamsg[i].name+'</h1><div class="">'+datamsg[i].prevention+'</div></div></div></div></div>';
- }
- $('.swiper-wrapper').append(html);
- var mySwiper = new Swiper ('.swiper-container', {
- direction: 'horizontal', // 垂直切换选项
- loop: false, // 循环模式选项
- // 如果需要前进后退按钮
- navigation: {
- nextEl: '.swiper-button-next',
- prevEl: '.swiper-button-prev',
- },
- })
- $('#wormNum').html(datamsg.length + '种');
- }else{
- $('#nullBox').html('暂无此类信息');
- $('#wormNum').html('暂无此类信息');
- }
- }else{
- $('#tipLeft').html('识别失败');
- var codeNum;
- if(msg.code == 401){
- $('#nullBox').html('未知错误');
- $('#wormNum').html('未知错误');
- }else{
- $('#nullBox').html('图片不存在');
- $('#wormNum').html('图片不存在');
- }
- }
- }
-
- // var html = '<div class="swiper-slide">Slide 4</div>';
- // $('.swiper-wrapper').append(html)
-
- //上传
- document.getElementById('upFile').addEventListener('tap', function() {
- if(mui.os.plus) {
- var a = [{
- title: '拍照'
- }, {
- title: '从手机相册选择'
- }];
- plus.nativeUI.actionSheet({
- title: '识别图片',
- cancel: '取消',
- buttons: a
- }, function(b) {
- console.log(b.index)
- switch(b.index) {
- case 0:
- break;
- case 1:
- //拍照
- getImages();
- break;
- case 2:
- //打开相册
- galleryImages();
- break;
- default:
- break;
- }
- }, false);
- }
- });
- //拍照
- function getImages() {
- var mobileCamera = plus.camera.getCamera();
- mobileCamera.captureImage(function(e) {
- plus.io.resolveLocalFileSystemURL(e, function(entry) {
- var path = entry.toLocalURL() + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(err) {
- console.log("读取拍照文件错误");
- });
- }, function(e) {
- console.log("er", err);
- }, function() {
- filename: '_doc/head.png';
- });
- }
- //从本地相册选择
- function galleryImages() {
- console.log("你选择了从相册选择");
- plus.gallery.pick(function(a) {
- plus.io.resolveLocalFileSystemURL(a, function(entry) {
- plus.io.resolveLocalFileSystemURL('_doc/', function(root) {
- root.getFile('head.png', {}, function(file) {
- //文件已经存在
- file.remove(function() {
- console.log("文件移除成功");
- entry.copyTo(root, 'head.png', function(e) {
- var path = e.fullPath + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(err) {
- console.log("copy image fail: ", err);
- });
- }, function(err) {
- console.log("删除图片失败:(" + JSON.stringify(err) + ")");
- });
- }, function(err) {
- //打开文件失败
- entry.copyTo(root, 'head.png', function(e) {
- var path = e.fullPath + '?version=' + new Date().getTime();
- uploadHeadImg(path);
- }, function(err) {
- console.log("上传图片失败:(" + JSON.stringify(err) + ")");
- });
- });
- }, function(e) {
- console.log("读取文件夹失败:(" + JSON.stringify(err) + ")");
- });
- });
- }, function(err) {
- console.log("读取拍照文件失败: ", err);
- }, {
- filter: 'image'
- });
- };
- //上传图片
- function uploadHeadImg(imgPath) {
- //服务端接口路径
- var server = "http://192.168.1.11:8000/app_insect_discern";
- //获取图片元素
- var wt = plus.nativeUI.showWaiting('上传中...');
- var task = plus.uploader.createUpload(server, {
- method: "POST",
- // timeout:10
- },
- function(t, status) { //上传完成
- if(status == 200) {
- // alert("上传成功:" + t.responseText);
- wt.close(); //关闭等待提示按钮
- disposeFun(t.responseText)
- } else {
- alert("上传失败:");
- wt.close(); //关闭等待提示按钮
- }
- }
- );
- //添加其他参数
- // task.addData("name", "test");
- task.addData("req", "change_photo");
- task.addFile(imgPath, {
- key: "imagefile"
- });
- task.start();
- }
-
- </script>
- </body>
- </html>
|