index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. <Swipe class="card-swipe-wrapper" :show-indicators="imgKey && imgKey.length > 1" :loop="false">
  10. <SwipeItem v-for="(img, index) in imgKey" :key="index">
  11. <div class="card-item">
  12. <div class="ing-wrap" v-if="isRecognize">
  13. <div>
  14. <el-icon size="20" class="is-loading">
  15. <Loading />
  16. </el-icon>
  17. </div>
  18. 正在识别,请稍后...
  19. </div>
  20. <img class="card-bg" :src="displayUrls[index]" />
  21. <div class="card-content" v-if="!isRecognize">
  22. <div class="title-ques">
  23. <div class="ques-text">病虫名称:{{ recognizeResult[index]?.diseaseName }}</div>
  24. </div>
  25. <div class="dialog-famous">管理方法:</div>
  26. <div class="dialog-answer">
  27. {{ recognizeResult[index]?.managementMethod }}
  28. </div>
  29. <div v-if="recognizeResult[index]?.basicInfo" class="advice-wrap">
  30. <div class="item-tag">基本信息</div>
  31. <div v-html="recognizeResult[index]?.basicInfo"></div>
  32. </div>
  33. <!-- <div class="famous-info" @click="toDetail(index)">
  34. <img src="@/assets/img/home/link-icon.png" />
  35. <span>点击查看农事详情</span>
  36. </div> -->
  37. </div>
  38. <!-- <div class="card-content no-data" v-if="!isRecognize && recognizeResult[index]?.status === 'nodata'">
  39. <img src="@/assets/img/home/good-fill.png" />
  40. 长势良好,并未发现病虫害
  41. </div> -->
  42. </div>
  43. </SwipeItem>
  44. </Swipe>
  45. </div>
  46. <div class="btn-wrap" v-if="!isRecognize">
  47. <div class="btn share" @click="toConsult">咨询专家</div>
  48. </div>
  49. </div>
  50. </div>
  51. <!-- 农事信息弹窗 -->
  52. <detail-dialog ref="detailDialogRef" :show-success-only="true"></detail-dialog>
  53. <!-- 上传弹窗组件 -->
  54. <active-upload-popup></active-upload-popup>
  55. </template>
  56. <script setup>
  57. import { onMounted, ref } from "vue";
  58. import { Swipe, SwipeItem } from "vant";
  59. import { useRouter, useRoute } from "vue-router";
  60. import { base_img_url2 } from "@/api/config.js";
  61. import { ElMessage } from "element-plus";
  62. import detailDialog from "@/components/detailDialog.vue";
  63. import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
  64. import { toRaw } from 'vue'
  65. let resize = "?x-oss-process=image/resize,w_300";
  66. const route = useRoute();
  67. const miniJson = toRaw(route.query.miniJson);
  68. const json = JSON.parse(miniJson || "{}");
  69. // const json = JSON.parse(
  70. // `{"imgKey":["birdseye-look-mini/766/1761968109259.png","birdseye-look-mini/766/1761968110225.png"],"farmId":766,"id":"65","imageIds":["772470289337421824","772470289337421825"],"token":"bcc0e12d-bff6-4f1f-8edc-2ab80b19af41"}`)
  71. const imgKey = json.imgKey?.split(",") || [];
  72. const isRecognize = ref(true);
  73. // 存储每张图片的 farmWorkLibId,用于后续接口请求
  74. const farmWorkLibIdsByIndex = ref({});
  75. // 预置显示地址:默认使用传入的 cloudFilename
  76. const displayUrls = imgKey.map((p) => base_img_url2 + p + resize);
  77. const detailDialogRef = ref(null);
  78. const recognizeResult = ref([]);
  79. onMounted(() => {
  80. VE_API.ali.AIRecognize({
  81. imageUrls: displayUrls,
  82. }).then(({data}) => {
  83. recognizeResult.value = data;
  84. isRecognize.value = false;
  85. });
  86. });
  87. const router = useRouter();
  88. const goBack = () => {
  89. // router.go(-1);
  90. router.push(`/home`);
  91. };
  92. const toDetail = (index) => {
  93. // 根据当前图片的索引获取对应的 farmWorkLibId
  94. const farmWorkLibIdList = farmWorkLibIdsByIndex.value[index];
  95. const farmWorkLibId = Array.isArray(farmWorkLibIdList) && farmWorkLibIdList.length > 0
  96. ? farmWorkLibIdList[0]
  97. : null;
  98. // 调用子组件方法,传递 farmWorkLibId 参数
  99. if (farmWorkLibId) {
  100. detailDialogRef.value.showDialog(farmWorkLibId);
  101. } else {
  102. ElMessage.warning('暂无农事详情');
  103. }
  104. };
  105. const currentFarmId = localStorage.getItem('selectedFarmId')
  106. const toConsult = async () => {
  107. const userId = await getNearStore();
  108. console.log("userId", userId);``
  109. router.push(`/chat_frame?userId=${userId}&farmId=${currentFarmId}`);
  110. };
  111. async function getNearStore() {
  112. const params = {
  113. farmId: currentFarmId,
  114. };
  115. const {data} = await VE_API.z_agricultural_store.getStoreItem(params);
  116. return data.miniUserId;
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .diseases-dictionary-detail {
  121. position: relative;
  122. width: 100%;
  123. height: 100vh;
  124. overflow: hidden;
  125. background: #fff;
  126. .page-title {
  127. height: 44px;
  128. line-height: 44px;
  129. text-align: center;
  130. font-size: 17px;
  131. font-weight: bold;
  132. // border-bottom: 1px solid #ededed;
  133. .title-icon {
  134. cursor: pointer;
  135. position: absolute;
  136. left: 16px;
  137. top: 13px;
  138. }
  139. }
  140. .detail-content {
  141. height: calc(100% - 44px - 20px);
  142. overflow: auto;
  143. .detail-img {
  144. height: calc(100% - 100px);
  145. position: relative;
  146. padding: 4px 16px 30px 16px;
  147. .card-swipe-wrapper {
  148. width: 100%;
  149. height: 100%;
  150. border-radius: 24px 0 36px 4px;
  151. overflow: hidden;
  152. :deep(.van-swipe-item) {
  153. width: 100%;
  154. height: 100%;
  155. display: flex;
  156. flex-direction: column;
  157. }
  158. :deep(.van-swipe__indicators) {
  159. bottom: 10px;
  160. }
  161. :deep(.van-swipe__indicator) {
  162. width: 6px;
  163. height: 6px;
  164. background-color: #cccccc;
  165. border-radius: 50%;
  166. margin: 0 4px;
  167. transition: all 0.3s;
  168. }
  169. :deep(.van-swipe__indicator--active) {
  170. width: 20px;
  171. height: 6px;
  172. background-color: #2199f8;
  173. border-radius: 3px;
  174. }
  175. }
  176. .card-item {
  177. width: 100%;
  178. height: 100%;
  179. position: relative;
  180. .ing-wrap {
  181. color: #fff;
  182. position: absolute;
  183. left: 0;
  184. right: 0;
  185. top: 50%;
  186. transform: translateY(-50%);
  187. margin: 0 auto;
  188. background: rgba(0, 0, 0, 0.6);
  189. border-radius: 12px;
  190. width: 164px;
  191. height: 95px;
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. justify-content: center;
  196. z-index: 10;
  197. }
  198. .card-bg {
  199. border-radius: 24px 0 36px 4px;
  200. width: 100%;
  201. height: 100%;
  202. object-fit: cover;
  203. }
  204. .no-data {
  205. color: #fff;
  206. text-align: center;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. img {
  211. width: 17px;
  212. margin-right: 4px;
  213. }
  214. }
  215. .card-content {
  216. position: absolute;
  217. bottom: 0;
  218. left: 0;
  219. padding: 12px 12px 26px 12px;
  220. border-radius: 24px 0 36px 4px;
  221. color: #ffffff;
  222. background: rgba(0, 0, 0, 0.6);
  223. backdrop-filter: blur(4px);
  224. max-height: calc(100% - 38px);
  225. overflow: auto;
  226. width: 100%;
  227. box-sizing: border-box;
  228. &.no-data {
  229. padding: 16px 0 20px 0;
  230. }
  231. .ques-text {
  232. color: #ffd786;
  233. font-size: 18px;
  234. position: relative;
  235. padding-left: 12px;
  236. }
  237. .ques-text:after {
  238. content: "";
  239. position: absolute;
  240. width: 4px;
  241. height: 15px;
  242. top: 5px;
  243. left: 0;
  244. border-radius: 2px;
  245. background: #ffd186;
  246. }
  247. .dialog-famous {
  248. padding: 8px 0 4px 0;
  249. color: #ffd786;
  250. font-size: 16px;
  251. }
  252. .dialog-answer {
  253. line-height: 24px;
  254. }
  255. .advice-wrap {
  256. padding-top: 12px;
  257. }
  258. .item-tag {
  259. width: fit-content;
  260. padding: 4px 10px;
  261. border-radius: 20px;
  262. color: #ffd786;
  263. background: rgba(255, 215, 134, 0.2);
  264. margin-bottom: 6px;
  265. }
  266. .info {
  267. padding: 10px 10px 6px 0;
  268. font-size: 15px;
  269. }
  270. .desc {
  271. font-size: 14px;
  272. line-height: 24px;
  273. }
  274. .famous-info {
  275. display: flex;
  276. align-items: center;
  277. color: #ffd786;
  278. font-size: 16px;
  279. padding: 8px 0 0px 0;
  280. img {
  281. width: 16px;
  282. height: 16px;
  283. margin-right: 4px;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. .btn-wrap {
  290. width: 100%;
  291. height: 56px;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. margin: 0 auto;
  296. padding: 0 16px;
  297. box-sizing: border-box;
  298. .btn {
  299. height: 40px;
  300. line-height: 40px;
  301. font-size: 16px;
  302. text-align: center;
  303. color: #000;
  304. border-radius: 4px;
  305. &.primary {
  306. flex: 1;
  307. color: #fff;
  308. background: #2199f8;
  309. }
  310. &.share {
  311. flex: 1;
  312. background: #fff;
  313. // width: 20%;
  314. min-width: 80px;
  315. text-align: center;
  316. border: 1px solid #8E8E8E;
  317. color: #000;
  318. border-radius: 20px;
  319. }
  320. }
  321. .btn + .btn {
  322. margin-left: 15px;
  323. }
  324. }
  325. .box-title {
  326. font-size: 16px;
  327. font-weight: bold;
  328. color: #000;
  329. padding: 16px 2px 16px 0;
  330. }
  331. .padding-t {
  332. padding-top: 26px;
  333. }
  334. .expert-box {
  335. .expert-item {
  336. display: flex;
  337. justify-content: space-between;
  338. }
  339. .expert-l {
  340. display: inline-flex;
  341. align-items: center;
  342. .expert-name {
  343. padding-left: 10px;
  344. }
  345. .expert-tag {
  346. background: #f7ecc7;
  347. padding: 2px 6px;
  348. color: #ae7d22;
  349. width: fit-content;
  350. border-radius: 4px;
  351. font-size: 12px;
  352. display: flex;
  353. align-items: center;
  354. margin-left: 10px;
  355. }
  356. img {
  357. width: 40px;
  358. height: 40px;
  359. border-radius: 50%;
  360. }
  361. }
  362. .line {
  363. margin: 16px;
  364. width: calc(100% - 32px);
  365. height: 1px;
  366. background: #f1f1f1;
  367. }
  368. }
  369. }
  370. }
  371. </style>