results.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view>
  3. <view class="images_box">
  4. <p class="title">图片标记</p>
  5. <view class="images">
  6. <image :src="$imageURL+'/bigdata_app'+'/image/cb/jiazai.ui.gif'" mode=""
  7. class="jiazai"></image>
  8. <image :src="resuils.image" mode="" @click="examine(resuils)"></image>
  9. <view class="imgbg" v-if="imgbg">
  10. <image src="../../../../static/images/cb/6286299.gif" mode="" class="img"></image>
  11. </view>
  12. </view>
  13. <view class="btn">
  14. <p class="btn_box" @click="anew">重新识别</p>
  15. </view>
  16. </view>
  17. <view class="information">
  18. <p class="title">识别结果</p>
  19. <view class="information_data" v-for="item,index in resuils.result">
  20. <p>害虫名称:<span>{{item.result_list+"("+item.number+")"}}</span></p>
  21. <p>害虫数量:<span>{{item.nums}}只</span></p>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import jsencrypt from '@/components/jsencrypt/jsencrypt.vue';
  28. import insect_dict from "../../../../static/data/cbd_pest_library.js"
  29. export default {
  30. data() {
  31. return {
  32. resuils: {
  33. image: ""
  34. },
  35. id: "",
  36. imgbg: false,
  37. addr: ""
  38. }
  39. },
  40. methods: {
  41. //forecast.forecast_system.equip_photo_discern识别 see again
  42. async discern(ret) { //识别图片
  43. var publiukey = `-----BEGIN PUBLIC KEY-----
  44. MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6m92fXUrccS4SoLg4W4jPRNua
  45. 4BcRk4ldLcqPuQpD2Mds2+hw+Gi+0MUnshF/r/DTcCJgkt7rtoY9EB6/XJ6MFw14
  46. whhESFie/lZUWRsk8M89Rkr8m5rwmBl+uLAd5LopyshFqKTBXeT2ytHP1JCQLPBO
  47. 34Fy4/yEz4qEzkzBuwIDAQAB
  48. -----END PUBLIC KEY-----`;
  49. var time = +new Date();
  50. var str2 = 'YuNfEi' + time + 'YuNfEi'
  51. var pubblicData = jsencrypt.setEncrypt(publiukey, str2);
  52. const res = await this.$myRequest({
  53. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_discern',
  54. data: {
  55. img_id: this.id,
  56. ret: ret,
  57. device_type: "cbd",
  58. identify_model: this.identify_model,
  59. sign: pubblicData
  60. }
  61. })
  62. console.log(res)
  63. if (res) {
  64. res.image = this.addr//由于识别结果图片不存了,改为先原图展示,后续再处理
  65. if (ret == "see") {
  66. this.resuils = res
  67. } else if (ret == "again") {
  68. // this.resuils.result
  69. // console.log(insect_dict)
  70. this.resuils.result = []
  71. var arr = res.result.split("#")
  72. for (var i = 0; i < arr.length; i++) {
  73. arr[i] = arr[i].split(",")
  74. var obj = {
  75. number: arr[i][0],
  76. nums: arr[i][1],
  77. result_list: insect_dict[arr[i][0]]
  78. }
  79. this.resuils.result.push(obj)
  80. }
  81. console.log(arr)
  82. // var obj
  83. }
  84. uni.showToast({
  85. title: '识别成功!',
  86. duration: 2000
  87. });
  88. this.imgbg = false
  89. } else {
  90. this.resuils.image = this.addr
  91. console.log(this.resuils)
  92. this.imgbg = false
  93. uni.showToast({
  94. title: '识别无结果!',
  95. duration: 2000,
  96. icon: "none"
  97. });
  98. }
  99. },
  100. anew() {
  101. this.discern("again")
  102. this.imgbg = true
  103. },
  104. examine(url) {
  105. console.log(url)
  106. var imgarr = []
  107. imgarr.push(url.image)
  108. console.log(imgarr)
  109. uni.previewImage({
  110. urls: imgarr
  111. });
  112. },
  113. },
  114. onLoad(option) {
  115. // console.log('结果页面:',option)
  116. this.id = option.id
  117. this.addr = option.addr
  118. this.identify_model = option.identify_model
  119. this.discern("see")
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .images_box {
  125. width: 90%;
  126. margin: 0 auto;
  127. padding-top: 20rpx;
  128. .title {
  129. border-left: 10rpx solid #71cd9a;
  130. padding-left: 20rpx;
  131. font-size: 30rpx;
  132. }
  133. .images {
  134. margin: 20rpx 0;
  135. width: 100%;
  136. height: 480rpx;
  137. position: relative;
  138. image {
  139. width: 100%;
  140. position: absolute;
  141. top: 0;
  142. left: 0;
  143. }
  144. .jiazai {
  145. width: 480rpx;
  146. height: 400rpx;
  147. position: absolute;
  148. top: 50%;
  149. left: 50%;
  150. margin-top: -240rpx;
  151. margin-left: -240rpx;
  152. }
  153. .imgbg {
  154. width: 100%;
  155. height: 480rpx;
  156. position: absolute;
  157. top: 0;
  158. left: 0;
  159. background-color: rgba(0, 0, 0, 0.5);
  160. .img {
  161. width: 430rpx;
  162. height: 400rpx;
  163. position: absolute;
  164. top: 50%;
  165. left: 50%;
  166. margin-top: -200rpx;
  167. margin-left: -220rpx;
  168. }
  169. }
  170. }
  171. .btn {
  172. width: 100%;
  173. display: flex;
  174. justify-content: flex-end;
  175. .btn_box {
  176. width: 200rpx;
  177. height: 60rpx;
  178. background-color: #fbb40a;
  179. color: #FFFFFF;
  180. text-align: center;
  181. line-height: 60rpx;
  182. margin-left: -10rpx;
  183. }
  184. }
  185. }
  186. .information {
  187. width: 97%;
  188. margin: 0 auto;
  189. padding-top: 20rpx;
  190. .title {
  191. border-left: 10rpx solid #71cd9a;
  192. padding-left: 20rpx;
  193. font-size: 30rpx;
  194. }
  195. .information_data {
  196. margin: 30rpx;
  197. display: flex;
  198. box-shadow: 0 0 10rpx #e8e5f7;
  199. padding: 20rpx 10rpx;
  200. p {
  201. margin-right: 20rpx;
  202. font-size: 28rpx;
  203. span {
  204. color: #FF0000;
  205. }
  206. }
  207. }
  208. }
  209. </style>