FarmInfoCard.vue 7.0 KB

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