farmDetails.vue 24 KB

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