index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. router.push(`/chat_frame?userId=${userId}&farmId=${currentFarmId}`);
  109. };
  110. async function getNearStore() {
  111. const params = {
  112. farmId: currentFarmId,
  113. };
  114. const {data} = await VE_API.z_agricultural_store.getStoreItem(params);
  115. return data.miniUserId;
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .diseases-dictionary-detail {
  120. position: relative;
  121. width: 100%;
  122. height: 100vh;
  123. overflow: hidden;
  124. background: #fff;
  125. .page-title {
  126. height: 44px;
  127. line-height: 44px;
  128. text-align: center;
  129. font-size: 17px;
  130. font-weight: bold;
  131. // border-bottom: 1px solid #ededed;
  132. .title-icon {
  133. cursor: pointer;
  134. position: absolute;
  135. left: 16px;
  136. top: 13px;
  137. }
  138. }
  139. .detail-content {
  140. height: calc(100% - 44px);
  141. overflow: auto;
  142. .detail-img {
  143. height: calc(100% - 34px);
  144. position: relative;
  145. padding: 4px 16px 30px 16px;
  146. .card-swipe-wrapper {
  147. width: 100%;
  148. height: 100%;
  149. border-radius: 24px 0 36px 4px;
  150. overflow: hidden;
  151. :deep(.van-swipe-item) {
  152. width: 100%;
  153. height: 100%;
  154. display: flex;
  155. flex-direction: column;
  156. }
  157. :deep(.van-swipe__indicators) {
  158. bottom: 10px;
  159. }
  160. :deep(.van-swipe__indicator) {
  161. width: 6px;
  162. height: 6px;
  163. background-color: #cccccc;
  164. border-radius: 50%;
  165. margin: 0 4px;
  166. transition: all 0.3s;
  167. }
  168. :deep(.van-swipe__indicator--active) {
  169. width: 20px;
  170. height: 6px;
  171. background-color: #2199f8;
  172. border-radius: 3px;
  173. }
  174. }
  175. .card-item {
  176. width: 100%;
  177. height: 100%;
  178. position: relative;
  179. .ing-wrap {
  180. color: #fff;
  181. position: absolute;
  182. left: 0;
  183. right: 0;
  184. top: 50%;
  185. transform: translateY(-50%);
  186. margin: 0 auto;
  187. background: rgba(0, 0, 0, 0.6);
  188. border-radius: 12px;
  189. width: 164px;
  190. height: 95px;
  191. display: flex;
  192. flex-direction: column;
  193. align-items: center;
  194. justify-content: center;
  195. z-index: 10;
  196. }
  197. .card-bg {
  198. border-radius: 24px 0 36px 4px;
  199. width: 100%;
  200. height: 100%;
  201. object-fit: cover;
  202. }
  203. .no-data {
  204. color: #fff;
  205. text-align: center;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. img {
  210. width: 17px;
  211. margin-right: 4px;
  212. }
  213. }
  214. .card-content {
  215. position: absolute;
  216. bottom: 0;
  217. left: 0;
  218. padding: 12px 12px 26px 12px;
  219. border-radius: 24px 0 36px 4px;
  220. color: #ffffff;
  221. background: rgba(0, 0, 0, 0.6);
  222. backdrop-filter: blur(4px);
  223. max-height: calc(100% - 38px);
  224. overflow: auto;
  225. width: 100%;
  226. box-sizing: border-box;
  227. &.no-data {
  228. padding: 16px 0 20px 0;
  229. }
  230. .ques-text {
  231. color: #ffd786;
  232. font-size: 18px;
  233. position: relative;
  234. padding-left: 12px;
  235. }
  236. .ques-text:after {
  237. content: "";
  238. position: absolute;
  239. width: 4px;
  240. height: 15px;
  241. top: 5px;
  242. left: 0;
  243. border-radius: 2px;
  244. background: #ffd186;
  245. }
  246. .dialog-famous {
  247. padding: 8px 0 4px 0;
  248. color: #ffd786;
  249. font-size: 16px;
  250. }
  251. .dialog-answer {
  252. line-height: 24px;
  253. }
  254. .advice-wrap {
  255. padding-top: 12px;
  256. }
  257. .item-tag {
  258. width: fit-content;
  259. padding: 4px 10px;
  260. border-radius: 20px;
  261. color: #ffd786;
  262. background: rgba(255, 215, 134, 0.2);
  263. margin-bottom: 6px;
  264. }
  265. .info {
  266. padding: 10px 10px 6px 0;
  267. font-size: 15px;
  268. }
  269. .desc {
  270. font-size: 14px;
  271. line-height: 24px;
  272. }
  273. .famous-info {
  274. display: flex;
  275. align-items: center;
  276. color: #ffd786;
  277. font-size: 16px;
  278. padding: 8px 0 0px 0;
  279. img {
  280. width: 16px;
  281. height: 16px;
  282. margin-right: 4px;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .btn-wrap {
  289. width: 100%;
  290. height: 56px;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. margin: 0 auto;
  295. padding: 0 16px;
  296. box-sizing: border-box;
  297. .btn {
  298. height: 40px;
  299. line-height: 40px;
  300. font-size: 16px;
  301. text-align: center;
  302. color: #000;
  303. border-radius: 4px;
  304. &.primary {
  305. flex: 1;
  306. color: #fff;
  307. background: #2199f8;
  308. }
  309. &.share {
  310. flex: 1;
  311. background: #fff;
  312. // width: 20%;
  313. min-width: 80px;
  314. text-align: center;
  315. border: 1px solid #8E8E8E;
  316. color: #000;
  317. border-radius: 20px;
  318. }
  319. }
  320. .btn + .btn {
  321. margin-left: 15px;
  322. }
  323. }
  324. .box-title {
  325. font-size: 16px;
  326. font-weight: bold;
  327. color: #000;
  328. padding: 16px 2px 16px 0;
  329. }
  330. .padding-t {
  331. padding-top: 26px;
  332. }
  333. .expert-box {
  334. .expert-item {
  335. display: flex;
  336. justify-content: space-between;
  337. }
  338. .expert-l {
  339. display: inline-flex;
  340. align-items: center;
  341. .expert-name {
  342. padding-left: 10px;
  343. }
  344. .expert-tag {
  345. background: #f7ecc7;
  346. padding: 2px 6px;
  347. color: #ae7d22;
  348. width: fit-content;
  349. border-radius: 4px;
  350. font-size: 12px;
  351. display: flex;
  352. align-items: center;
  353. margin-left: 10px;
  354. }
  355. img {
  356. width: 40px;
  357. height: 40px;
  358. border-radius: 50%;
  359. }
  360. }
  361. .line {
  362. margin: 16px;
  363. width: calc(100% - 32px);
  364. height: 1px;
  365. background: #f1f1f1;
  366. }
  367. }
  368. }
  369. }
  370. </style>