FarmInfoCard.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="farm-info-card" :class="{ 'has-footer': showFooter }" @click="handleClick">
  3. <div class="item-content">
  4. <div class="item-left" :style="{ width: data.maxWidth ? 'calc(100% - 80px)' : 'auto' }">
  5. <img class="map-img" src="@/assets/img/home/farm.png" alt="地图" />
  6. <div class="item-info">
  7. <div class="item-header">
  8. <div class="farm-name van-ellipsis" :style="{ maxWidth: data.maxWidth || 'calc(100% - 90px)' }">{{ data.farmName }}</div>
  9. <div class="tags">
  10. <span class="tag tag-area">{{ data.area }}</span>
  11. <span class="tag tag-variety">{{ data.variety }}</span>
  12. </div>
  13. </div>
  14. <div class="farm-address van-ellipsis">{{ data.address }}</div>
  15. </div>
  16. </div>
  17. <!-- 右侧按钮插槽 -->
  18. <div v-if="hasRightSlot" class="item-right-btn" @click.stop>
  19. <slot name="right"></slot>
  20. </div>
  21. </div>
  22. <!-- 底部内容:服务次数或自定义内容 -->
  23. <div v-if="showFooter" :class="{'item-footer': data.serviceCount != 0}">
  24. <slot name="footer">
  25. <template v-if="data.serviceCount != 0">
  26. 农事服务过<span class="service-count">{{ data.serviceCount }}</span
  27. >次
  28. <span class="view-detail">查看详情</span>
  29. </template>
  30. </slot>
  31. </div>
  32. <!-- 底部提示框:需求信息和预计收益 -->
  33. <template v-if="data.broadcasts && data.broadcasts.length > 0">
  34. <slot name="bottomTip">
  35. <div class="item-footer remind-footer">
  36. <div class="remind-cont" v-html="data.broadcasts[0].content"></div>
  37. <span class="remind-text" @click.stop="handleRemind">提醒他</span>
  38. </div>
  39. <!-- <div class="item-footer item-bottom-tip" v-if="data.estimatedIncome">
  40. <div>
  41. 当前农场有 <span>{{ data.farmInfo }}</span> 的农情需求
  42. </div>
  43. <div class="income-text">
  44. 预计收益 <span>{{ data.estimatedIncome }}元</span>
  45. </div>
  46. </div> -->
  47. </slot>
  48. </template>
  49. <upload-execute ref="uploadExecuteRef" :onlyShare="true" />
  50. </div>
  51. </template>
  52. <script setup>
  53. import { computed, useSlots, ref } from "vue";
  54. import uploadExecute from "@/views/old_mini/task_condition/components/uploadExecute.vue";
  55. const props = defineProps({
  56. data: {
  57. type: Object,
  58. required: true,
  59. validator: (value) => {
  60. return (
  61. value.farmName !== undefined &&
  62. value.area !== undefined &&
  63. value.variety !== undefined &&
  64. value.address !== undefined
  65. );
  66. },
  67. },
  68. });
  69. const emit = defineEmits(["click"]);
  70. const slots = useSlots();
  71. const showFooter = computed(() => {
  72. return props.data.serviceCount !== undefined || !!slots.footer;
  73. });
  74. const hasRightSlot = computed(() => {
  75. return !!slots.right;
  76. });
  77. const handleClick = () => {
  78. emit("click", props.data);
  79. };
  80. const uploadExecuteRef = ref(null);
  81. const handleRemind = () => {
  82. // const data = {
  83. // ...props.data,
  84. // farmMiniUserId: props.data.receiveUserId,
  85. // farmId: props.data.id,
  86. // type: "remindUser"
  87. // }
  88. // uploadExecuteRef.value.showPopup(data);
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .farm-info-card {
  93. background: #fff;
  94. border-radius: 8px;
  95. position: relative;
  96. &.has-footer {
  97. padding: 12px 10px;
  98. border-radius: 5px;
  99. }
  100. &:not(.has-footer) {
  101. padding: 16px 12px;
  102. display: flex;
  103. flex-direction: column;
  104. align-items: stretch;
  105. }
  106. .item-content {
  107. width: 100%;
  108. display: flex;
  109. align-items: center;
  110. justify-content: space-between;
  111. .map-img {
  112. width: 40px;
  113. height: 40px;
  114. border-radius: 6px;
  115. object-fit: cover;
  116. }
  117. .item-left {
  118. display: flex;
  119. align-items: center;
  120. gap: 8px;
  121. width: calc(100% - 80px);
  122. }
  123. .item-info {
  124. width: 100%;
  125. .item-header {
  126. display: flex;
  127. gap: 10px;
  128. font-size: 14px;
  129. margin-bottom: 4px;
  130. .farm-name {
  131. font-weight: 600;
  132. color: #000;
  133. max-width: calc(100% - 90px);
  134. // max-width: 100px;
  135. }
  136. .tags {
  137. display: flex;
  138. gap: 6px;
  139. .tag {
  140. padding: 1px 8px;
  141. border-radius: 2px;
  142. font-size: 12px;
  143. &.tag-area {
  144. background: #f4f4f4;
  145. color: #1d2129;
  146. }
  147. &.tag-variety {
  148. background: rgba(232, 243, 255, 1);
  149. color: #2199f8;
  150. }
  151. }
  152. }
  153. }
  154. .farm-address {
  155. font-size: 12px;
  156. color: #86909c;
  157. max-width: 190px;
  158. }
  159. }
  160. }
  161. .item-footer {
  162. background: linear-gradient(90deg, rgba(33, 153, 248, 0.2) 0%, transparent 100%);
  163. padding: 6px 8px;
  164. display: flex;
  165. align-items: center;
  166. border-radius: 4px;
  167. margin-top: 10px;
  168. color: #2e2e2e;
  169. font-size: 12px;
  170. &.remind-footer {
  171. justify-content: space-between;
  172. }
  173. .remind-cont{
  174. width: calc(100% - 42px);
  175. ::v-deep{
  176. p{
  177. margin: 0;
  178. }
  179. }
  180. }
  181. .remind-text {
  182. color: #2199f8;
  183. font-weight: 500;
  184. width: 40px;
  185. }
  186. .service-count {
  187. margin: 0 2px;
  188. }
  189. .view-detail {
  190. margin-left: 10px;
  191. }
  192. .remind-text {
  193. font-weight: 400;
  194. }
  195. }
  196. .item-right-btn {
  197. text-align: center;
  198. color: #888b8d;
  199. font-size: 12px;
  200. padding: 5px 12px;
  201. border-radius: 20px;
  202. border: 1px solid #888b8d;
  203. }
  204. .item-bottom-tip {
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. background: linear-gradient(90deg, rgba(254, 164, 94, 0.2) 0%, transparent 100%);
  209. span {
  210. color: #eb7b20;
  211. font-weight: 500;
  212. }
  213. .income-text {
  214. color: #efb789;
  215. }
  216. }
  217. }
  218. .farm-info-card + .farm-info-card {
  219. margin-top: 12px;
  220. }
  221. </style>
  222. <style>
  223. .share-sheet{
  224. bottom: 50px;
  225. }
  226. </style>