farmDetails.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <div class="farm-details-page">
  3. <custom-header name="农场详情"></custom-header>
  4. <div class="farm-details-content">
  5. <farm-info-card
  6. v-if="farmDetail.name"
  7. :data="{
  8. farmName: farmDetail.name || '',
  9. userType: farmDetail.userType || '托管客户',
  10. variety: farmDetail.typeName || '',
  11. address: farmDetail.address || '',
  12. }"
  13. @click="handleFarmInfo"
  14. >
  15. <!-- <template #right>
  16. <div @click="handleFarmInfo">基本信息</div>
  17. </template> -->
  18. <template #footerData>
  19. <div class="footer-data">
  20. <div class="footer-l">
  21. <div class="farm-info-footer-item">
  22. <div class="farm-info-footer-item-label">农事服务</div>
  23. <div class="farm-info-footer-item-value">10<span class="unit">次</span></div>
  24. </div>
  25. <div class="farm-info-footer-item">
  26. <div class="farm-info-footer-item-label">总收益</div>
  27. <div class="farm-info-footer-item-value">1450<span class="unit">元</span></div>
  28. </div>
  29. </div>
  30. <div class="footer-action" @click="handleDetail('plan?farmId=101532&miniJson={\'farmId\':101532}')">农事规划</div>
  31. </div>
  32. </template>
  33. </farm-info-card>
  34. <tabs v-model:active="activeTab" class="custom-tabs" scrollspy sticky offset-top="40" background="#F2F3F5">
  35. <tab title="作物档案" class="tab-item">
  36. <common-box title="作物档案">
  37. <template #right>
  38. <span @click="handleDetail('farm_list')">查看详情</span>
  39. </template>
  40. <template v-if="farmWorkData.length">
  41. <div class="farm-work-timeline">
  42. <div
  43. class="farm-work-item"
  44. v-for="(item, index) in farmWorkData"
  45. :key="item.time"
  46. :class="{ 'is-estimated': index === farmWorkData.length - 1 }"
  47. >
  48. <div class="timeline-left">
  49. <div class="timeline-dot"></div>
  50. <div class="timeline-line"></div>
  51. </div>
  52. <div class="timeline-right">
  53. <div class="farm-work-card">
  54. <div class="farm-work-date">{{ item.time }}</div>
  55. <div class="farm-work-desc">
  56. <span class="farm-work-action">{{ item.action }}</span>
  57. <span class="farm-work-content">{{ item.content }}</span>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <empty
  65. v-else
  66. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  67. image-size="80"
  68. description="暂无数据"
  69. class="empty-state"
  70. />
  71. </common-box>
  72. </tab>
  73. <tab title="农事服务" class="tab-item">
  74. <common-box title="农事服务">
  75. <template #right>
  76. <span @click="handleDetail('service_list')">查看详情</span>
  77. </template>
  78. <tab-list
  79. type="light"
  80. v-model="farmServiceActiveTab"
  81. :tabs="farmServiceTabs"
  82. @change="handleFarmServiceTabChange"
  83. />
  84. <stats-box :stats-data="serviceStatsData" />
  85. <div v-for="(section, index) in detailList" :key="index" class="content-section">
  86. <record-item
  87. :record-item-data="section"
  88. onlyRecipeName
  89. :content-mode="farmServiceActiveTab === 0 ? 'serviceDetail' : ''"
  90. title-mode="default"
  91. :title-right-text="farmServiceActiveTab === 0 ? '分享成果' : ''"
  92. :title-right-type="farmServiceActiveTab === 1 ? 'dot' : null"
  93. :title-right-dot-text="farmServiceActiveTab === 1 ? '2区' : ''"
  94. class="recipe-item"
  95. />
  96. </div>
  97. <empty
  98. v-if="detailList.length === 0"
  99. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  100. image-size="80"
  101. description="暂无数据"
  102. class="empty-state"
  103. />
  104. </common-box>
  105. </tab>
  106. <tab title="作物相册" class="tab-item">
  107. <common-box title="作物相册">
  108. <template #right>
  109. <span @click="handleShareReport()">查看更多</span>
  110. </template>
  111. <div class="photo-img-wrap">
  112. <photo-provider :photo-closable="true">
  113. <photo-consumer
  114. v-for="(src, index) in cropAlbum"
  115. intro="执行照片"
  116. :key="index"
  117. :src="base_img_url2 + src.filename"
  118. >
  119. <div class="photo-img">
  120. <img :src="base_img_url2 + src.filename + resize_300" />
  121. </div>
  122. </photo-consumer>
  123. </photo-provider>
  124. </div>
  125. </common-box>
  126. </tab>
  127. </tabs>
  128. </div>
  129. <div class="custom-bottom-fixed-btns">
  130. <div class="bottom-btn secondary-btn" @click="handleShareFarm">分享农场</div>
  131. <div class="bottom-btn primary-btn" @click="handleChatFarm">在线沟通</div>
  132. </div>
  133. </div>
  134. <fn-share-sheet v-model:show="showShare" @select="onSelect" :options="[{ name: '微信', icon: 'wechat' }]" />
  135. <!-- 农场信息 -->
  136. <farm-info-popup
  137. ref="farmInfoRef"
  138. :farmId="farmIdVal"
  139. :showEditBtn="!farmDetail.farmersMiniUserId"
  140. :showBtn="true"
  141. ></farm-info-popup>
  142. </template>
  143. <script setup>
  144. import { ref, onMounted } from "vue";
  145. import { useRoute, useRouter } from "vue-router";
  146. import { Tab, Tabs, Empty } from "vant";
  147. import { base_img_url2, resize_300 } from "@/api/config";
  148. import wx from "weixin-js-sdk";
  149. import customHeader from "@/components/customHeader.vue";
  150. import FarmInfoCard from "@/components/pageComponents/FarmInfoCard.vue";
  151. import tabList from "@/components/pageComponents/TabList.vue";
  152. import commonBox from "@/components/pageComponents/CommonBox.vue";
  153. import StatsBox from "@/components/pageComponents/StatsBox.vue";
  154. import recordItem from "@/components/recordItem.vue";
  155. import farmInfoPopup from "../home/components/farmInfoPopup.vue";
  156. import FnShareSheet from "@/components/pageComponents/FnShareSheet.vue";
  157. import config from "@/api/config";
  158. import { ElMessage } from "element-plus";
  159. const router = useRouter();
  160. const route = useRoute();
  161. const activeTab = ref(0);
  162. const farmServiceTabs = ["过往服务", "未来服务"];
  163. const farmServiceActiveTab = ref(0);
  164. const farmInfoRef = ref(null);
  165. const handleFarmInfo = () => {
  166. farmInfoRef.value.handleShow();
  167. };
  168. const handleFarmServiceTabChange = (index) => {
  169. if (index === 0) {
  170. getFarmPastServiceCost();
  171. getDetailList();
  172. } else {
  173. getFutureFarmWorkList();
  174. serviceStatsData.value = [
  175. { value: "1258", unit: "元", desc: "预计收益" },
  176. { value: "1258", unit: "元", desc: "预计成本" },
  177. ];
  178. }
  179. };
  180. const serviceStatsData = ref([]);
  181. onMounted(() => {
  182. farmIdVal.value = route.query.farmId;
  183. paramsPage.value = {
  184. farmId: farmIdVal.value,
  185. limit: 1,
  186. page: 1,
  187. };
  188. getFarmDetail();
  189. getFarmWorkList();
  190. getDetailList();
  191. getFarmPastServiceCost();
  192. });
  193. const farmIdVal = ref(null);
  194. const farmDetail = ref({});
  195. const paramsPage = ref({});
  196. const getFarmDetail = () => {
  197. VE_API.user.getFarmDetail({ farmId: farmIdVal.value }).then(({ data }) => {
  198. farmDetail.value = data || {};
  199. console.log(farmDetail.value);
  200. });
  201. };
  202. const farmWorkData = ref([]);
  203. const getFarmWorkList = () => {
  204. // VE_API.user.getFarmWorkList(paramsPage.value).then(({ data }) => {
  205. // if (data && data.length > 0) {
  206. // farmWorkData.value = data[0] || {};
  207. // }
  208. // });
  209. farmWorkData.value = [
  210. {
  211. time: "8/8",
  212. action: "进入",
  213. content: "花芽分化期",
  214. },
  215. {
  216. time: "8/1",
  217. action: "做了",
  218. content: "杀虫 农事",
  219. },
  220. {
  221. time: "7/25",
  222. action: "预计进入",
  223. content: "果实膨大期",
  224. },
  225. ];
  226. };
  227. const cropAlbum = ref([
  228. {
  229. district: "",
  230. filename: "birdseye-look-mini/91429/1765361542408.png",
  231. fosterCode: "",
  232. gardenId: null,
  233. gardenName: "",
  234. growText: "",
  235. id: "786656608116543488",
  236. localPath: "",
  237. localResPath: "",
  238. location: "POINT(113.407189 23.032344)",
  239. treeCode: "",
  240. treeGeoHash: "ws0eh8utt204",
  241. },
  242. {
  243. address: "",
  244. angle: "",
  245. baseMap: "",
  246. blueZoneId: null,
  247. district: "",
  248. filename: "birdseye-look-mini/91429/1763371316207.jpg",
  249. fosterCode: "",
  250. gardenId: null,
  251. gardenName: "",
  252. growText: "",
  253. id: "778308963891417088",
  254. localPath: "",
  255. localResPath: "",
  256. location: "POINT(113.407189 23.032344)",
  257. miniUserId: null,
  258. miniUserName: "",
  259. modelId: null,
  260. phenologyId: "39",
  261. treeCode: "",
  262. treeGeoHash: "ws0eh8utt204",
  263. treeId: 223920,
  264. uploadDate: "2025-11-17",
  265. },
  266. {
  267. filename: "birdseye-look-mini/91754/1763367875786.jpg",
  268. fosterCode: "",
  269. gardenId: null,
  270. gardenName: "",
  271. growText: "",
  272. id: "778294553688936448",
  273. localPath: "",
  274. localResPath: "",
  275. location: "POINT(113.407189 23.032344)",
  276. treeCode: "",
  277. treeGeoHash: "ws0eh8utt204",
  278. treeId: 223920,
  279. uploadDate: "2025-11-17",
  280. },
  281. ]);
  282. const detailList = ref([]);
  283. const getDetailList = () => {
  284. const params = {
  285. ...paramsPage.value,
  286. flowStatus: "4,5",
  287. };
  288. VE_API.user.getDetailList(params).then(({ data }) => {
  289. detailList.value = data || [];
  290. });
  291. };
  292. const getFutureFarmWorkList = () => {
  293. VE_API.user.getFutureFarmWorkList(paramsPage.value).then(({ data }) => {
  294. detailList.value = data || [];
  295. });
  296. };
  297. const getFarmPastServiceCost = () => {
  298. VE_API.user.getFarmPastServiceCost({ farmId: farmIdVal.value }).then(({ data }) => {
  299. serviceStatsData.value = [
  300. { value: data?.totalCost, unit: "元", desc: "总收益" },
  301. { value: data?.totalCost, unit: "元", desc: "投入成本" },
  302. { value: data?.serviceCount, unit: "次", desc: "服务次数" },
  303. ];
  304. });
  305. };
  306. const handleDetail = (path) => {
  307. router.push(`/${path}?farmId=${farmIdVal.value}`);
  308. };
  309. const handleShareReport = () => {
  310. router.push({
  311. path: "/farm_report",
  312. query: {
  313. miniJson: JSON.stringify({ farmId: farmIdVal.value }),
  314. },
  315. });
  316. };
  317. const showShare = ref(false);
  318. const handleShareFarm = () => {
  319. showShare.value = true;
  320. };
  321. const handleChatFarm = () => {
  322. if (route.query.receiveUserId != "null") {
  323. router.push(`/chat_frame?userId=${route.query.receiveUserId}&farmId=${farmIdVal.value}`);
  324. } else {
  325. ElMessage.warning("尚未绑定用户,暂时无法沟通");
  326. }
  327. };
  328. const onSelect = () => {
  329. const query = {
  330. agriculturalStoreId: route.query.agriculturalStoreId,
  331. farmId: route.query.farmId,
  332. speciesName: farmDetail.value.speciesName,
  333. containerId: farmDetail.value.containerId,
  334. receiveUserId: route.query.receiveUserId,
  335. };
  336. wx.miniProgram.navigateTo({
  337. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=shareFarm`,
  338. });
  339. };
  340. </script>
  341. <style scoped lang="scss">
  342. .farm-details-page {
  343. width: 100%;
  344. height: 100vh;
  345. background: #F2F3F5;
  346. .farm-details-content {
  347. box-sizing: border-box;
  348. padding: 10px 12px 70px 12px;
  349. overflow: auto;
  350. height: calc(100% - 40px);
  351. box-sizing: border-box;
  352. .custom-tabs {
  353. ::v-deep {
  354. .van-tabs__wrap {
  355. height: auto;
  356. }
  357. .van-tabs__nav {
  358. .van-tab {
  359. color: #8b8b8b;
  360. background: #F7F8FA;
  361. height: 34px;
  362. font-weight: 400;
  363. border-radius: 25px;
  364. width: fit-content;
  365. flex: none;
  366. padding: 0 12px;
  367. margin-right: 8px;
  368. }
  369. .van-tab--active {
  370. color: #fff;
  371. background: #2199f8;
  372. font-weight: 400;
  373. }
  374. }
  375. .van-tabs__line {
  376. display: none;
  377. }
  378. .van-tabs__nav--line {
  379. padding: 12px 0;
  380. }
  381. }
  382. .tab-item + .tab-item {
  383. margin-top: 12px;
  384. }
  385. .photo-img-wrap {
  386. display: flex;
  387. flex-wrap: wrap;
  388. gap: 10px;
  389. ::v-deep {
  390. .PhotoConsumer {
  391. width: 31%;
  392. height: 92px;
  393. }
  394. }
  395. .photo-img {
  396. width: 100%;
  397. height: 100%;
  398. position: relative;
  399. box-sizing: border-box;
  400. border: 2px solid transparent;
  401. border-radius: 8px;
  402. overflow: hidden;
  403. img {
  404. width: 100%;
  405. height: 100%;
  406. border-radius: 8px;
  407. object-fit: cover;
  408. }
  409. }
  410. }
  411. }
  412. .question-header {
  413. display: flex;
  414. align-items: center;
  415. margin-bottom: 6px;
  416. gap: 8px;
  417. font-weight: 500;
  418. .question-icon {
  419. width: 22px;
  420. height: 20px;
  421. }
  422. }
  423. .answer-content {
  424. color: #333333;
  425. margin: 6px 0 10px 0;
  426. }
  427. .answer-img {
  428. display: flex;
  429. gap: 5px;
  430. img {
  431. flex: 1;
  432. max-width: 105px;
  433. height: 105px;
  434. border-radius: 5px;
  435. object-fit: cover;
  436. }
  437. }
  438. .content-section {
  439. .recipe-item {
  440. border: 1px solid rgba(0, 0, 0, 0.1);
  441. margin: 12px 0 0 0;
  442. }
  443. }
  444. .plan-tab-item {
  445. .recipe-item {
  446. padding: 0;
  447. }
  448. }
  449. .plan-list-wrapper {
  450. height: 500px;
  451. margin-top: 12px;
  452. }
  453. .report-content {
  454. font-size: 13px;
  455. }
  456. .answer-btn {
  457. display: flex;
  458. align-items: center;
  459. justify-content: space-between;
  460. margin-top: 10px;
  461. > div {
  462. display: flex;
  463. gap: 10px;
  464. }
  465. }
  466. .answer-btn-item {
  467. padding: 7px 12px;
  468. border-radius: 25px;
  469. font-size: 12px;
  470. text-align: center;
  471. background: rgba(33, 153, 248, 0.1);
  472. color: #2199f8;
  473. min-width: 52px;
  474. box-sizing: border-box;
  475. &.primary {
  476. background: #2199f8;
  477. color: #ffffff;
  478. }
  479. }
  480. .empty-state {
  481. ::v-deep .van-empty {
  482. padding: 40px 0;
  483. }
  484. }
  485. .footer-data {
  486. display: flex;
  487. align-items: center;
  488. justify-content: space-between;
  489. gap: 12px;
  490. margin-top: 12px;
  491. .footer-l {
  492. display: flex;
  493. gap: 8px;
  494. flex: 1;
  495. .farm-info-footer-item {
  496. display: flex;
  497. border: 0.4px solid rgba(215, 215, 215, 0.5);
  498. padding: 8px 5px 5px;
  499. box-sizing: border-box;
  500. .farm-info-footer-item-label {
  501. font-size: 12px;
  502. color: rgba(32, 32, 32, 0.4);
  503. margin-bottom: 4px;
  504. }
  505. .farm-info-footer-item-value {
  506. font-size: 16px;
  507. color: #202020;
  508. padding-left: 2px;
  509. .unit {
  510. font-size: 12px;
  511. padding-left: 2px;
  512. color: rgba(32, 32, 32, 0.4);
  513. }
  514. }
  515. }
  516. }
  517. .footer-action {
  518. border: 0.5px solid #888B8D;
  519. border-radius: 20px;
  520. padding: 5px 12px;
  521. font-size: 12px;
  522. color: #888B8D;
  523. white-space: nowrap;
  524. cursor: pointer;
  525. flex-shrink: 0;
  526. }
  527. }
  528. .farm-work-timeline {
  529. padding: 10px 0;
  530. .farm-work-item {
  531. display: flex;
  532. align-items: flex-start;
  533. position: relative;
  534. &:not(:last-child) {
  535. margin-bottom: 20px;
  536. }
  537. .timeline-left {
  538. display: flex;
  539. flex-direction: column;
  540. align-items: center;
  541. margin-right: 12px;
  542. position: relative;
  543. .timeline-dot {
  544. width: 6px;
  545. height: 6px;
  546. border-radius: 50%;
  547. border: 1px solid #2199f8;
  548. flex-shrink: 0;
  549. z-index: 1;
  550. }
  551. .timeline-line {
  552. width: 1px;
  553. height: 48px;
  554. background: #e5e6eb;
  555. position: absolute;
  556. top: 8px;
  557. }
  558. }
  559. .timeline-right {
  560. flex: 1;
  561. .farm-work-card {
  562. border: 1px solid #8bccff;
  563. border-radius: 4px;
  564. background: #f8fcff;
  565. padding: 12px;
  566. display: flex;
  567. align-items: center;
  568. color: #1d2129;
  569. font-size: 14px;
  570. line-height: 22px;
  571. display: flex;
  572. align-items: center;
  573. .farm-work-date {
  574. padding-right: 4px;
  575. }
  576. .farm-work-desc {
  577. .farm-work-action {
  578. padding-right: 4px;
  579. }
  580. }
  581. }
  582. }
  583. &.is-estimated {
  584. .timeline-right {
  585. .farm-work-card {
  586. background: rgba(246, 250, 255, 0.5);
  587. border: 1px solid rgba(190, 218, 255, 0.5);
  588. .farm-work-date,
  589. .farm-work-desc {
  590. color: rgba(29, 33, 41, 0.5);
  591. }
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. }
  599. </style>