FarmInfoCard.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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" :class="data.className || 'tag-variety'" v-show="data.variety || data.roleName">{{ data.variety || data.roleName }}</span>
  11. <span class="tag" :class="data.className || 'tag-gray'" v-show="data.area">{{ data.area }}</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. </slot>
  40. </template>
  41. <upload-execute ref="uploadExecuteRef" :onlyShare="true" />
  42. </div>
  43. </template>
  44. <script setup>
  45. import { computed, useSlots, ref } from "vue";
  46. import uploadExecute from "@/views/old_mini/task_condition/components/uploadExecute.vue";
  47. const props = defineProps({
  48. data: {
  49. type: Object,
  50. required: true,
  51. validator: (value) => {
  52. return (
  53. value.farmName !== undefined &&
  54. value.address !== undefined &&
  55. (value.variety !== undefined || value.roleName !== undefined)
  56. );
  57. },
  58. },
  59. });
  60. const emit = defineEmits(["click"]);
  61. const slots = useSlots();
  62. const showFooter = computed(() => {
  63. return props.data.serviceCount !== undefined || !!slots.footer;
  64. });
  65. const hasRightSlot = computed(() => {
  66. return !!slots.right;
  67. });
  68. const handleClick = () => {
  69. emit("click", props.data);
  70. };
  71. const uploadExecuteRef = ref(null);
  72. const handleRemind = () => {
  73. // const data = {
  74. // ...props.data,
  75. // farmMiniUserId: props.data.receiveUserId,
  76. // farmId: props.data.id,
  77. // type: "remindUser"
  78. // }
  79. // uploadExecuteRef.value.showPopup(data);
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. .farm-info-card {
  84. background: #fff;
  85. border-radius: 8px;
  86. position: relative;
  87. &.has-footer {
  88. padding: 12px 10px;
  89. border-radius: 5px;
  90. }
  91. &:not(.has-footer) {
  92. padding: 16px 12px;
  93. display: flex;
  94. flex-direction: column;
  95. align-items: stretch;
  96. }
  97. .item-content {
  98. width: 100%;
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-between;
  102. .map-img {
  103. width: 40px;
  104. height: 40px;
  105. border-radius: 6px;
  106. object-fit: cover;
  107. }
  108. .item-left {
  109. display: flex;
  110. align-items: center;
  111. gap: 8px;
  112. width: calc(100% - 80px);
  113. }
  114. .item-info {
  115. width: 100%;
  116. .item-header {
  117. display: flex;
  118. gap: 10px;
  119. font-size: 14px;
  120. margin-bottom: 4px;
  121. .farm-name {
  122. font-weight: 600;
  123. color: #000;
  124. max-width: calc(100% - 90px);
  125. // max-width: 100px;
  126. }
  127. .tags {
  128. display: flex;
  129. gap: 6px;
  130. align-items: center;
  131. .tag {
  132. padding: 1px 8px;
  133. border-radius: 2px;
  134. font-size: 12px;
  135. &.tag-gray {
  136. background: rgba(243, 243, 243, 0.5);
  137. color: #7D7D7D;
  138. }
  139. &.tag-role {
  140. background: rgba(255, 149, 61, 0.2);
  141. color: #FF953D;
  142. }
  143. &.tag-variety {
  144. background: rgba(232, 243, 255, 1);
  145. color: #2199f8;
  146. }
  147. }
  148. }
  149. }
  150. .farm-address {
  151. font-size: 12px;
  152. color: #86909c;
  153. max-width: 190px;
  154. }
  155. }
  156. }
  157. .item-footer {
  158. background: linear-gradient(90deg, rgba(33, 153, 248, 0.2) 0%, transparent 100%);
  159. padding: 6px 8px;
  160. display: flex;
  161. align-items: center;
  162. border-radius: 4px;
  163. margin-top: 10px;
  164. color: #2e2e2e;
  165. font-size: 12px;
  166. &.remind-footer {
  167. justify-content: space-between;
  168. }
  169. .remind-cont{
  170. width: calc(100% - 42px);
  171. ::v-deep{
  172. p{
  173. margin: 0;
  174. }
  175. }
  176. }
  177. .remind-text {
  178. color: #2199f8;
  179. font-weight: 500;
  180. width: 40px;
  181. }
  182. .service-count {
  183. margin: 0 2px;
  184. }
  185. .view-detail {
  186. margin-left: 10px;
  187. }
  188. .remind-text {
  189. font-weight: 400;
  190. }
  191. }
  192. .item-right-btn {
  193. text-align: center;
  194. color: #888b8d;
  195. font-size: 12px;
  196. padding: 5px 12px;
  197. border-radius: 20px;
  198. border: 1px solid #888b8d;
  199. }
  200. .item-bottom-tip {
  201. display: flex;
  202. align-items: center;
  203. justify-content: space-between;
  204. background: linear-gradient(90deg, rgba(254, 164, 94, 0.2) 0%, transparent 100%);
  205. span {
  206. color: #eb7b20;
  207. font-weight: 500;
  208. }
  209. .income-text {
  210. color: #efb789;
  211. }
  212. }
  213. }
  214. .farm-info-card + .farm-info-card {
  215. margin-top: 12px;
  216. }
  217. </style>
  218. <style>
  219. .share-sheet{
  220. bottom: 50px;
  221. }
  222. </style>