results.vue 4.6 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. }
  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. res.image = this.addr
  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. this.imgbg = false
  84. uni.showToast({
  85. title: '识别成功!',
  86. duration: 2000
  87. });
  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. this.id = option.id
  115. this.addr = option.addr
  116. this.identify_model = option.identify_model
  117. this.discern("see")
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .images_box {
  123. width: 90%;
  124. margin: 0 auto;
  125. padding-top: 20rpx;
  126. .title {
  127. border-left: 10rpx solid #71cd9a;
  128. padding-left: 20rpx;
  129. font-size: 30rpx;
  130. }
  131. .images {
  132. margin: 20rpx 0;
  133. width: 100%;
  134. height: 480rpx;
  135. position: relative;
  136. image {
  137. width: 100%;
  138. position: absolute;
  139. top: 0;
  140. left: 0;
  141. }
  142. .jiazai {
  143. width: 480rpx;
  144. height: 400rpx;
  145. position: absolute;
  146. top: 50%;
  147. left: 50%;
  148. margin-top: -240rpx;
  149. margin-left: -240rpx;
  150. }
  151. .imgbg {
  152. width: 100%;
  153. height: 480rpx;
  154. position: absolute;
  155. top: 0;
  156. left: 0;
  157. background-color: rgba(0, 0, 0, 0.5);
  158. .img {
  159. width: 430rpx;
  160. height: 400rpx;
  161. position: absolute;
  162. top: 50%;
  163. left: 50%;
  164. margin-top: -200rpx;
  165. margin-left: -220rpx;
  166. }
  167. }
  168. }
  169. .btn {
  170. width: 100%;
  171. display: flex;
  172. justify-content: flex-end;
  173. .btn_box {
  174. width: 200rpx;
  175. height: 60rpx;
  176. background-color: #fbb40a;
  177. color: #FFFFFF;
  178. text-align: center;
  179. line-height: 60rpx;
  180. margin-left: -10rpx;
  181. }
  182. }
  183. }
  184. .information {
  185. width: 97%;
  186. margin: 0 auto;
  187. padding-top: 20rpx;
  188. .title {
  189. border-left: 10rpx solid #71cd9a;
  190. padding-left: 20rpx;
  191. font-size: 30rpx;
  192. }
  193. .information_data {
  194. margin: 30rpx;
  195. display: flex;
  196. box-shadow: 0 0 10rpx #e8e5f7;
  197. padding: 20rpx 10rpx;
  198. p {
  199. margin-right: 20rpx;
  200. font-size: 28rpx;
  201. span {
  202. color: #FF0000;
  203. }
  204. }
  205. }
  206. }
  207. </style>