farmInfoPopup.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <Popup v-model:show="show" class="farm-info-popup" closeable>
  3. <div class="popup-content-box">
  4. <div class="popup-title">基本信息</div>
  5. <div class="popup-content">
  6. <div class="map-box">
  7. <div class="map" ref="mapContainer"></div>
  8. <div class="map-text" @click="handleEditMap">点击编辑地块</div>
  9. </div>
  10. <cell-group inset class="cell-group">
  11. <field v-model="farmInfo.name" readonly label="农场名称" />
  12. <field v-model="farmInfo.area" readonly label="农场面积" />
  13. <field v-model="farmInfo.plant" readonly label="种植作物" />
  14. <field class="address-field" v-model="farmInfo.address" readonly label="农场位置" />
  15. </cell-group>
  16. </div>
  17. <div class="popup-footer">
  18. <div class="footer-btn no-btn" @click="handleCancel">取消</div>
  19. <div class="footer-btn yes-btn" @click="handleEdit">去编辑</div>
  20. </div>
  21. </div>
  22. </Popup>
  23. </template>
  24. <script setup>
  25. import { Popup, Field, CellGroup } from "vant";
  26. import { ref, nextTick } from "vue";
  27. import { useRouter } from "vue-router";
  28. import IndexMap from "../map/index.js";
  29. import { useStore } from "vuex";
  30. const store = useStore();
  31. const router = useRouter();
  32. const show = ref(false);
  33. const mapContainer = ref(null);
  34. const indexMap = new IndexMap();
  35. const farmInfo = ref({
  36. name: "从化荔博园",
  37. area: "1000亩",
  38. plant: "荔枝",
  39. address: "广东省广州市从化区",
  40. });
  41. const handleShow = () => {
  42. show.value = true;
  43. nextTick(() => {
  44. const point = store.state.home.miniUserLocationPoint
  45. indexMap.initMap(point, mapContainer.value);
  46. });
  47. };
  48. const handleEditMap = () => {
  49. router.push("/edit_map");
  50. // indexMap.clearLayer();
  51. };
  52. const handleEdit = () => {
  53. router.push("/create_farm");
  54. };
  55. const handleCancel = () => {
  56. show.value = false;
  57. };
  58. defineExpose({handleShow});
  59. </script>
  60. <style lang="scss" scoped>
  61. .farm-info-popup {
  62. width: 100%;
  63. border-radius: 8px;
  64. .popup-content-box {
  65. background: url("@/assets/img/home/popup-mask.png") no-repeat center left / 100% 100%;
  66. padding: 20px;
  67. }
  68. ::v-deep {
  69. .van-popup__close-icon {
  70. color: #000;
  71. }
  72. }
  73. .popup-title {
  74. text-align: center;
  75. font-size: 24px;
  76. font-family: "PangMenZhengDao";
  77. }
  78. .popup-content {
  79. margin: 12px 0;
  80. .map-box {
  81. width: 100%;
  82. height: 150px;
  83. position: relative;
  84. .map {
  85. width: 100%;
  86. height: 100%;
  87. clip-path: inset(0px round 5px);
  88. pointer-events: none;
  89. }
  90. .map-text {
  91. position: absolute;
  92. right: 6px;
  93. bottom: 8px;
  94. font-size: 12px;
  95. color: #ffffff;
  96. padding: 8px 12px;
  97. border-radius: 20px;
  98. background: rgba(0, 0, 0, 0.5);
  99. border: 1px solid rgba(255, 255, 255, 0.5);
  100. }
  101. }
  102. .cell-group {
  103. margin: 12px 0 0;
  104. .address-field {
  105. position: relative;
  106. &::before {
  107. position: absolute;
  108. box-sizing: border-box;
  109. content: " ";
  110. pointer-events: none;
  111. right: 16px;
  112. bottom: 0;
  113. left: 16px;
  114. border-bottom: 1px solid #ebedf0;
  115. transform: scaleY(0.5);
  116. }
  117. }
  118. }
  119. }
  120. .popup-footer {
  121. display: flex;
  122. gap: 13px;
  123. .footer-btn {
  124. text-align: center;
  125. flex: 1;
  126. padding: 8px 0;
  127. border-radius: 25px;
  128. }
  129. .no-btn {
  130. color: #666666;
  131. border: 1px solid #999999;
  132. }
  133. .yes-btn {
  134. background: #2199f8;
  135. color: #fff;
  136. }
  137. }
  138. }
  139. </style>