results.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. }
  38. },
  39. methods: {
  40. //forecast.forecast_system.equip_photo_discern识别 see again\
  41. async discern(ret) { //识别图片
  42. var publiukey = `-----BEGIN PUBLIC KEY-----
  43. MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6m92fXUrccS4SoLg4W4jPRNua
  44. 4BcRk4ldLcqPuQpD2Mds2+hw+Gi+0MUnshF/r/DTcCJgkt7rtoY9EB6/XJ6MFw14
  45. whhESFie/lZUWRsk8M89Rkr8m5rwmBl+uLAd5LopyshFqKTBXeT2ytHP1JCQLPBO
  46. 34Fy4/yEz4qEzkzBuwIDAQAB
  47. -----END PUBLIC KEY-----`;
  48. var time = +new Date();
  49. var str2 = 'YuNfEi' + time + 'YuNfEi'
  50. var pubblicData = jsencrypt.setEncrypt(publiukey, str2);
  51. const res = await this.$myRequest({
  52. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo_discern',
  53. data: {
  54. img_id: this.id,
  55. ret: ret,
  56. device_type: "cbd",
  57. identify_model: this.identify_model,
  58. sign: pubblicData
  59. },
  60. })
  61. console.log(res)
  62. if (res) {
  63. if (ret == "see") {
  64. this.resuils = res
  65. } else if (ret == "again") {
  66. // this.resuils.result
  67. // console.log(insect_dict)
  68. this.resuils.result = []
  69. var arr = res.result.split("#")
  70. for (var i = 0; i < arr.length; i++) {
  71. arr[i] = arr[i].split(",")
  72. var obj = {
  73. number: arr[i][0],
  74. nums: arr[i][1],
  75. result_list: insect_dict[arr[i][0]]
  76. }
  77. this.resuils.result.push(obj)
  78. }
  79. console.log(arr)
  80. // var obj
  81. }
  82. this.imgbg = false
  83. uni.showToast({
  84. title: '识别成功!',
  85. duration: 2000
  86. });
  87. } else {
  88. this.resuils.image = this.addr
  89. console.log(this.resuils)
  90. this.imgbg = false
  91. uni.showToast({
  92. title: '识别无结果!',
  93. duration: 2000,
  94. icon: "none"
  95. });
  96. }
  97. },
  98. anew() {
  99. this.discern("again")
  100. this.imgbg = true
  101. },
  102. examine(url) {
  103. console.log(url)
  104. var imgarr = []
  105. imgarr.push(url.image)
  106. console.log(imgarr)
  107. uni.previewImage({
  108. urls: imgarr
  109. });
  110. },
  111. },
  112. onLoad(option) {
  113. this.id = option.id
  114. this.addr = option.addr
  115. this.identify_model = option.identify_model
  116. this.discern("see")
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .images_box {
  122. width: 90%;
  123. margin: 0 auto;
  124. padding-top: 20rpx;
  125. .title {
  126. border-left: 10rpx solid #71cd9a;
  127. padding-left: 20rpx;
  128. font-size: 30rpx;
  129. }
  130. .images {
  131. margin: 20rpx 0;
  132. width: 100%;
  133. height: 480rpx;
  134. position: relative;
  135. image {
  136. width: 100%;
  137. position: absolute;
  138. top: 0;
  139. left: 0;
  140. }
  141. .jiazai {
  142. width: 480rpx;
  143. height: 400rpx;
  144. position: absolute;
  145. top: 50%;
  146. left: 50%;
  147. margin-top: -240rpx;
  148. margin-left: -240rpx;
  149. }
  150. .imgbg {
  151. width: 100%;
  152. height: 480rpx;
  153. position: absolute;
  154. top: 0;
  155. left: 0;
  156. background-color: rgba(0, 0, 0, 0.5);
  157. .img {
  158. width: 430rpx;
  159. height: 400rpx;
  160. position: absolute;
  161. top: 50%;
  162. left: 50%;
  163. margin-top: -200rpx;
  164. margin-left: -220rpx;
  165. }
  166. }
  167. }
  168. .btn {
  169. width: 100%;
  170. display: flex;
  171. justify-content: flex-end;
  172. .btn_box {
  173. width: 200rpx;
  174. height: 60rpx;
  175. background-color: #fbb40a;
  176. color: #FFFFFF;
  177. text-align: center;
  178. line-height: 60rpx;
  179. margin-left: -10rpx;
  180. }
  181. }
  182. }
  183. .information {
  184. width: 97%;
  185. margin: 0 auto;
  186. padding-top: 20rpx;
  187. .title {
  188. border-left: 10rpx solid #71cd9a;
  189. padding-left: 20rpx;
  190. font-size: 30rpx;
  191. }
  192. .information_data {
  193. margin: 30rpx;
  194. display: flex;
  195. box-shadow: 0 0 10rpx #e8e5f7;
  196. padding: 20rpx 10rpx;
  197. p {
  198. margin-right: 20rpx;
  199. font-size: 28rpx;
  200. span {
  201. color: #FF0000;
  202. }
  203. }
  204. }
  205. }
  206. </style>