results.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view>
  3. <view class="images_box">
  4. <p class="title">图片标记</p>
  5. <view class="images">
  6. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/jiazai.ui.gif'" mode="" class="jiazai"></image>
  7. <image :src="resuils.image" mode="" @click="examine(resuils)"></image>
  8. <view class="imgbg" v-if="imgbg">
  9. <image src="../../../../static/images/cb/6286299.gif" mode="" class="img"></image>
  10. </view>
  11. </view>
  12. <view class="btn">
  13. <p class="btn_box" @click="anew">重新识别</p>
  14. </view>
  15. </view>
  16. <view class="information">
  17. <p class="title">识别结果</p>
  18. <view class="information_data" v-for="item,index in resuils.result">
  19. <p>害虫名称:<span>{{item.result_list+"("+item.number+")"}}</span></p>
  20. <p>害虫数量:<span>{{item.nums}}只</span></p>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. resuils:{
  30. image:""
  31. },
  32. id:"",
  33. imgbg:false,
  34. addr:""
  35. }
  36. },
  37. methods: {
  38. //forecast.forecast_system.equip_photo_discern识别 see again
  39. async discern(ret) { //识别图片
  40. const res = await this.$myRequest({
  41. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_discern',
  42. data: {
  43. img_id: this.id,
  44. ret: ret,
  45. device_type: "cbd",
  46. identify_model: "A"
  47. }
  48. })
  49. console.log(res)
  50. if(res){
  51. uni.showToast({
  52. title: '识别成功!',
  53. duration: 2000
  54. });
  55. this.resuils = res
  56. this.imgbg =false
  57. }else{
  58. this.resuils.image = this.addr
  59. console.log(this.resuils)
  60. this.imgbg = false
  61. uni.showToast({
  62. title: '识别无结果!',
  63. duration: 2000,
  64. icon:"none"
  65. });
  66. }
  67. },
  68. anew(){
  69. this.discern("again")
  70. this.imgbg =true
  71. },
  72. examine(url) {
  73. console.log(url)
  74. var imgarr = []
  75. imgarr.push(url.image)
  76. console.log(imgarr)
  77. uni.previewImage({
  78. urls: imgarr
  79. });
  80. },
  81. },
  82. onLoad(option) {
  83. this.id = option.id
  84. this.addr = option.addr
  85. this.discern("see")
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. .images_box{
  91. width: 90%;
  92. margin: 0 auto;
  93. padding-top: 20rpx;
  94. .title{
  95. border-left: 10rpx solid #71cd9a;
  96. padding-left: 20rpx;
  97. font-size: 30rpx;
  98. }
  99. .images{
  100. margin: 20rpx 0;
  101. width: 100%;
  102. height: 480rpx;
  103. position: relative;
  104. image{
  105. width: 100%;
  106. position: absolute;
  107. top: 0;
  108. left: 0;
  109. }
  110. .jiazai{
  111. width: 480rpx;
  112. height: 400rpx;
  113. position: absolute;
  114. top: 50%;
  115. left: 50%;
  116. margin-top: -240rpx;
  117. margin-left: -240rpx;
  118. }
  119. .imgbg{
  120. width: 100%;
  121. height: 480rpx;
  122. position: absolute;
  123. top: 0;
  124. left: 0;
  125. background-color: rgba(0,0,0,0.5);
  126. .img{
  127. width: 430rpx;
  128. height: 400rpx;
  129. position: absolute;
  130. top: 50%;
  131. left: 50%;
  132. margin-top: -200rpx;
  133. margin-left: -220rpx;
  134. }
  135. }
  136. }
  137. .btn{
  138. width: 100%;
  139. display: flex;
  140. justify-content: flex-end;
  141. .btn_box{
  142. width: 200rpx;
  143. height: 60rpx;
  144. background-color: #fbb40a;
  145. color: #FFFFFF;
  146. text-align: center;
  147. line-height: 60rpx;
  148. margin-left: -10rpx;
  149. }
  150. }
  151. }
  152. .information{
  153. width: 97%;
  154. margin: 0 auto;
  155. padding-top: 20rpx;
  156. .title{
  157. border-left: 10rpx solid #71cd9a;
  158. padding-left: 20rpx;
  159. font-size: 30rpx;
  160. }
  161. .information_data{
  162. margin: 30rpx;
  163. display: flex;
  164. box-shadow: 0 0 10rpx #e8e5f7;
  165. padding: 20rpx 10rpx;
  166. p{
  167. margin-right: 20rpx;
  168. font-size: 28rpx;
  169. span{
  170. color: #FF0000;
  171. }
  172. }
  173. }
  174. }
  175. </style>