results.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. if (ret == "see") {
  65. this.resuils = res
  66. } else if (ret == "again") {
  67. // this.resuils.result
  68. // console.log(insect_dict)
  69. this.resuils.result = []
  70. var arr = res.result.split("#")
  71. for (var i = 0; i < arr.length; i++) {
  72. arr[i] = arr[i].split(",")
  73. var obj = {
  74. number: arr[i][0],
  75. nums: arr[i][1],
  76. result_list: insect_dict[arr[i][0]]
  77. }
  78. this.resuils.result.push(obj)
  79. }
  80. console.log(arr)
  81. // var obj
  82. }
  83. uni.showToast({
  84. title: '识别成功!',
  85. duration: 2000
  86. });
  87. this.imgbg = false
  88. } else {
  89. this.resuils.image = this.addr
  90. console.log(this.resuils)
  91. this.imgbg = false
  92. uni.showToast({
  93. title: '识别无结果!',
  94. duration: 2000,
  95. icon: "none"
  96. });
  97. }
  98. },
  99. anew() {
  100. this.discern("again")
  101. this.imgbg = true
  102. },
  103. examine(url) {
  104. console.log(url)
  105. var imgarr = []
  106. imgarr.push(url.image)
  107. console.log(imgarr)
  108. uni.previewImage({
  109. urls: imgarr
  110. });
  111. },
  112. },
  113. onLoad(option) {
  114. // console.log('结果页面:',option)
  115. this.id = option.id
  116. this.addr = option.addr
  117. this.identify_model = option.identify_model
  118. this.discern("see")
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .images_box {
  124. width: 90%;
  125. margin: 0 auto;
  126. padding-top: 20rpx;
  127. .title {
  128. border-left: 10rpx solid #71cd9a;
  129. padding-left: 20rpx;
  130. font-size: 30rpx;
  131. }
  132. .images {
  133. margin: 20rpx 0;
  134. width: 100%;
  135. height: 480rpx;
  136. position: relative;
  137. image {
  138. width: 100%;
  139. position: absolute;
  140. top: 0;
  141. left: 0;
  142. }
  143. .jiazai {
  144. width: 480rpx;
  145. height: 400rpx;
  146. position: absolute;
  147. top: 50%;
  148. left: 50%;
  149. margin-top: -240rpx;
  150. margin-left: -240rpx;
  151. }
  152. .imgbg {
  153. width: 100%;
  154. height: 480rpx;
  155. position: absolute;
  156. top: 0;
  157. left: 0;
  158. background-color: rgba(0, 0, 0, 0.5);
  159. .img {
  160. width: 430rpx;
  161. height: 400rpx;
  162. position: absolute;
  163. top: 50%;
  164. left: 50%;
  165. margin-top: -200rpx;
  166. margin-left: -220rpx;
  167. }
  168. }
  169. }
  170. .btn {
  171. width: 100%;
  172. display: flex;
  173. justify-content: flex-end;
  174. .btn_box {
  175. width: 200rpx;
  176. height: 60rpx;
  177. background-color: #fbb40a;
  178. color: #FFFFFF;
  179. text-align: center;
  180. line-height: 60rpx;
  181. margin-left: -10rpx;
  182. }
  183. }
  184. }
  185. .information {
  186. width: 97%;
  187. margin: 0 auto;
  188. padding-top: 20rpx;
  189. .title {
  190. border-left: 10rpx solid #71cd9a;
  191. padding-left: 20rpx;
  192. font-size: 30rpx;
  193. }
  194. .information_data {
  195. margin: 30rpx;
  196. display: flex;
  197. box-shadow: 0 0 10rpx #e8e5f7;
  198. padding: 20rpx 10rpx;
  199. p {
  200. margin-right: 20rpx;
  201. font-size: 28rpx;
  202. span {
  203. color: #FF0000;
  204. }
  205. }
  206. }
  207. }
  208. </style>