recognize.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <div class="diseases-dictionary-detail">
  3. <div class="page-title" @click="goBack">
  4. <el-icon class="title-icon" color="rgba(0, 0, 0, 0.8)" size="16"><ArrowLeftBold /></el-icon>
  5. 识别结果
  6. </div>
  7. <div class="detail-content">
  8. <div class="detail-img">
  9. <div class="card-item">
  10. <div class="ing-wrap" v-if="isRecognize">
  11. <div>
  12. <el-icon size="20" class="is-loading">
  13. <Loading />
  14. </el-icon>
  15. </div>
  16. 正在识别,请稍后...
  17. </div>
  18. <!-- <img class="card-bg" src="@/assets/img/diseases/1.jpg" /> -->
  19. <img class="card-bg" :src="base_img_url2 + imgKey + resize" />
  20. <div class="card-content" v-if="!isRecognize && !noData">
  21. <div class="title-ques">
  22. <div class="ques-text">病虫名称:{{recoginizeResult?.name}}</div>
  23. </div>
  24. <div class="dialog-famous">管理方法:</div>
  25. <div class="dialog-answer" v-html="recoginizeResult?.cure">
  26. </div>
  27. <div class="info">基本信息:</div>
  28. <div class="desc">
  29. {{recoginizeResult?.info}}
  30. </div>
  31. <div class="famous-info">
  32. <img src="@/assets/img/home/link-icon.png" />
  33. <span class="type-name">{{recoginizeResult?.name}}</span>
  34. <span>合作专家:韦帮稳</span>
  35. </div>
  36. </div>
  37. <div class="card-content no-data" v-if="!isRecognize && noData">
  38. <img src="@/assets/img/home/good-fill.png" />
  39. 长势良好,并未发现病虫害
  40. </div>
  41. </div>
  42. </div>
  43. <div class="btn-wrap" v-if="!isRecognize">
  44. <div class="btn share" @click="toPage">咨询专家</div>
  45. <div class="btn primary" @click="triggerRecord">触发农事</div>
  46. </div>
  47. <!-- <div class="recognizing-box" v-if="isRecognize">正在识别,请稍等~</div> -->
  48. </div>
  49. </div>
  50. <Popup v-model:show="tipsShow" class="tips-popup">
  51. <div class="right-icon">
  52. <img class="right-img" src="@/assets/img/home/right.png" alt="">
  53. </div>
  54. <div class="no-popup-title">
  55. <span>农事已触发成功</span>
  56. <div class="no-popup-title-sub">您可以在 农场监测-农事任务 看到农事状态</div>
  57. </div>
  58. <div class="no-popup-btn" @click="tipsShow = false">我知道了</div>
  59. </Popup>
  60. </template>
  61. <script setup>
  62. import { onMounted, ref } from "vue";
  63. import { useRouter, useRoute } from "vue-router";
  64. import { base_img_url2 } from "@/api/config.js";
  65. import { Popup } from "vant";
  66. import wx from "weixin-js-sdk";
  67. import MqttClient from "@/plugins/MqttClient";
  68. let resize = '?x-oss-process=image/resize,w_1300'
  69. const route = useRoute();
  70. // const json = JSON.parse(route.query.json);
  71. const json = {
  72. "imgKey":"16926861-1e20-4cbd-8bf2-90208db5a2d0/806080da-1a30-4b5b-b64b-b22e722c6cb6/DJI_202509010800_001_806080da-1a30-4b5b-b64b-b22e722c6cb6/DJI_20250901080536_0045_V_code-ws0fsmge97gh.jpeg",
  73. "imgId":431600}
  74. const imgKey = json.imgKey;
  75. const imgId = json.imgId;
  76. const isRecognize = ref(false);
  77. const recoginizeResult = ref({
  78. name: "蒂蛀虫",
  79. cure: " (1) 化学农药喷洒,如:乙醇草酸酯乳油‌。 <br/>(2) 最佳喷药时间:荔枝成熟期要防治蒂蛀虫,一般建议在荔枝成熟前5-8天进行喷药。 <br/>(3) 使用剂量‌:喷药时应按照说明书上的使用剂量进行使用,不要过量使用。",
  80. info: "又称蛀蒂虫,属于鳞翅目细蛾科,主要危害荔枝和龙眼的果实、嫩茎、嫩叶和花穗。",
  81. });
  82. const noData = ref(false);
  83. onMounted(() => {
  84. console.log("img", imgId, imgKey);
  85. // 使用示例
  86. const topics = ["phone/image/update/" + imgId]; // 订阅的主题数组
  87. const mqttClient = new MqttClient(topics, (topic, message) => {
  88. let res = message.toString();
  89. console.log("接收推送信息:", res);
  90. let status = JSON.parse(res).status;
  91. console.log("status", status);
  92. if (status === "recog_ing") {
  93. console.log("recog_ing");
  94. }
  95. if (status === "recog_finished") {
  96. let resData = JSON.parse(message)
  97. console.log("recog_finished",resData.data);
  98. isRecognize.value = false;
  99. if (resData.data && resData.data.length) {
  100. noData.value = false
  101. const formData = new FormData();
  102. formData.append('code', resData.data[0]);
  103. VE_API.disease.fetchDiseaseDetail(formData).then(({data}) => {
  104. recoginizeResult.value = data;
  105. })
  106. } else {
  107. noData.value = true
  108. }
  109. }
  110. });
  111. mqttClient.connect();
  112. });
  113. const router = useRouter();
  114. const goBack = () => {
  115. // router.go(-1);
  116. router.push('/diseases_dictionary')
  117. };
  118. const toDetail = () => {
  119. router.push("/diseases_dictionary_detail");
  120. };
  121. const toRecognize = () => {
  122. // router.push("/diseases_recognize")
  123. const gardenData = {
  124. organId: 25862,
  125. };
  126. wx.miniProgram.navigateTo({
  127. url: `/pages/subPages/recognize_carmera/index?gardenData=${JSON.stringify(gardenData)}`,
  128. });
  129. };
  130. const tipsShow = ref(false)
  131. function triggerRecord() {
  132. tipsShow.value = true
  133. }
  134. function toPage() {
  135. router.push("/expert_list")
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .diseases-dictionary-detail {
  140. position: relative;
  141. width: 100%;
  142. height: 100vh;
  143. overflow: hidden;
  144. background: #fff;
  145. .page-title {
  146. height: 44px;
  147. line-height: 44px;
  148. text-align: center;
  149. font-size: 17px;
  150. font-weight: bold;
  151. // border-bottom: 1px solid #ededed;
  152. .title-icon {
  153. cursor: pointer;
  154. position: absolute;
  155. left: 16px;
  156. top: 13px;
  157. }
  158. }
  159. .detail-content {
  160. height: calc(100% - 44px - 20px);
  161. overflow: auto;
  162. .detail-img {
  163. height: calc(100% - 100px);
  164. position: relative;
  165. padding: 4px 16px 30px 16px;
  166. .card-item {
  167. width: 100%;
  168. height: 100%;
  169. position: relative;
  170. .ing-wrap {
  171. color: #fff;
  172. position: absolute;
  173. left: 0;
  174. right: 0;
  175. top: 50%;
  176. transform: translateY(-50%);
  177. margin: 0 auto;
  178. background: rgba(0, 0, 0, 0.6);
  179. border-radius: 12px;
  180. width: 164px;
  181. height: 95px;
  182. display: flex;
  183. flex-direction: column;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. img {
  188. border-radius: 24px 0 36px 4px;
  189. width: 100%;
  190. height: 100%;
  191. object-fit: cover;
  192. }
  193. .no-data {
  194. color: #fff;
  195. text-align: center;
  196. padding-top: 26px;
  197. img {
  198. width: 26px;
  199. }
  200. }
  201. .card-content {
  202. position: absolute;
  203. bottom: 0;
  204. left: 0;
  205. padding: 12px 12px 26px 12px;
  206. border-radius: 24px 0 36px 4px;
  207. color: #ffffff;
  208. background: rgba(0, 0, 0, 0.6);
  209. backdrop-filter: blur(4px);
  210. max-height: calc(100% - 38px);
  211. overflow: auto;
  212. width: 100%;
  213. box-sizing: border-box;
  214. .ques-text {
  215. color: #ffd786;
  216. font-size: 18px;
  217. position: relative;
  218. padding-left: 12px;
  219. }
  220. .ques-text:after {
  221. content: "";
  222. position: absolute;
  223. width: 4px;
  224. height: 15px;
  225. top: 5px;
  226. left: 0;
  227. border-radius: 2px;
  228. background: #ffd186;
  229. }
  230. .dialog-famous {
  231. padding: 8px 0 4px 0;
  232. color: #ffd786;
  233. font-size: 16px;
  234. }
  235. .dialog-answer {
  236. line-height: 24px;
  237. }
  238. .info {
  239. padding: 10px 10px 6px 0;
  240. font-size: 15px;
  241. }
  242. .desc {
  243. font-size: 14px;
  244. line-height: 24px;
  245. }
  246. .famous-info {
  247. display: flex;
  248. align-items: center;
  249. color: #ffd786;
  250. font-size: 16px;
  251. padding: 8px 0 0px 0;
  252. .type-name {
  253. padding: 0 4px 0 8px;
  254. }
  255. img {
  256. width: 16px;
  257. }
  258. }
  259. }
  260. }
  261. .recognize-img {
  262. width: 100%;
  263. }
  264. }
  265. .btn-wrap {
  266. width: 100%;
  267. height: 56px;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. margin: 0 auto;
  272. padding: 0 16px;
  273. box-sizing: border-box;
  274. .btn {
  275. height: 40px;
  276. line-height: 40px;
  277. font-size: 16px;
  278. text-align: center;
  279. color: #000;
  280. border-radius: 24px;
  281. &.primary {
  282. flex: 1;
  283. color: #fff;
  284. background: #2199f8;
  285. }
  286. &.share {
  287. background: #fff;
  288. min-width: 80px;
  289. flex: 1;
  290. text-align: center;
  291. border: 1px solid #8E8E8E;
  292. }
  293. }
  294. .btn + .btn {
  295. margin-left: 15px;
  296. }
  297. }
  298. .recognizing-box {
  299. padding-top: 30px;
  300. text-align: center;
  301. font-size: 16px;
  302. }
  303. .box-title {
  304. font-size: 16px;
  305. font-weight: bold;
  306. color: #000;
  307. padding: 16px 2px 16px 0;
  308. }
  309. .padding-t {
  310. padding-top: 26px;
  311. }
  312. .expert-box {
  313. .expert-item {
  314. display: flex;
  315. justify-content: space-between;
  316. }
  317. .expert-l {
  318. display: inline-flex;
  319. align-items: center;
  320. .expert-name {
  321. padding-left: 10px;
  322. }
  323. .expert-tag {
  324. background: #f7ecc7;
  325. padding: 2px 6px;
  326. color: #ae7d22;
  327. width: fit-content;
  328. border-radius: 4px;
  329. font-size: 12px;
  330. display: flex;
  331. align-items: center;
  332. margin-left: 10px;
  333. }
  334. img {
  335. width: 40px;
  336. height: 40px;
  337. border-radius: 50%;
  338. }
  339. }
  340. .line {
  341. margin: 16px;
  342. width: calc(100% - 32px);
  343. height: 1px;
  344. background: #f1f1f1;
  345. }
  346. }
  347. }
  348. }
  349. .tips-popup {
  350. width: 300px;
  351. border-radius: 14px;
  352. padding: 28px 15px 20px;
  353. box-sizing: border-box;
  354. .right-icon {
  355. text-align: center;
  356. padding-bottom: 12px;
  357. .right-img {
  358. width: 68px;
  359. }
  360. }
  361. .no-popup-title {
  362. font-size: 24px;
  363. font-weight: 500;
  364. text-align: center;
  365. .no-popup-title-sub{
  366. font-size: 14px;
  367. margin-top: 8px;
  368. }
  369. }
  370. .no-popup-btn {
  371. background-color: #2199F8;
  372. padding: 8px;
  373. border-radius: 20px;
  374. color: #fff;
  375. font-size: 16px;
  376. margin-top: 32px;
  377. text-align: center;
  378. }
  379. }
  380. </style>