homeFloatingPanel.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <floating-panel class="floating-panel" :class="{ 'background-panel': isBackground }" v-model:height="height" :anchors="anchors" :content-draggable="false" @height-change="handleHeightChange">
  3. <template #header>
  4. <div class="floating-panel-header">
  5. <div class="tabs">
  6. <div
  7. :class="['tab-item', activeTab === index ? 'active' : '']"
  8. v-for="(tab, index) in tabs"
  9. :key="tab"
  10. @click="handleTabClick(index)"
  11. >
  12. {{ tab }}
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <div class="floating-panel-content">
  18. <div class="select-group">
  19. <div class="select-item">
  20. <div class="select-item-title">123</div>
  21. </div>
  22. </div>
  23. <div class="tabs-content-group">
  24. <div :class="['tabs-content-item',activeTabsContent === index ? 'active' : '']" v-for="(tab,index) in tabsContent" :key="tab" @click="handleTabsContentClick(index)">
  25. {{ tab }}
  26. </div>
  27. </div>
  28. <div class="card-content-group">
  29. <div class="card-content-item">
  30. <div class="card-content-item-title">果园总览</div>
  31. <div class="card-content-item-content">
  32. <div>果园面积共XX亩,共有XX棵生产树。</div>
  33. <div>本次飞巡拍摄了XX张照片,包括了XX棵树,目前为施用根部有机肥阶段,根据树体冠幅大小,果园预计施用有机肥XXkg。</div>
  34. <div>目前XX%的树体暂未萌动新梢,需要进行剪枝农事,提高树体光合效率与通风效率。</div>
  35. </div>
  36. </div>
  37. <div class="card-content-item">
  38. <div class="card-content-item-title">整体园相</div>
  39. <div class="card-content-item-content">
  40. <div class="card-name">透光率</div>
  41. <div class="card-value">透光率体现树体自身郁闭程度,当前XX%的树体透光性较差,可能造成整体减产XX%,需立即执行剪枝农事;XX%的树体透光正常,建议继续保持现有管理措施并及时巡园。</div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </floating-panel>
  47. </template>
  48. <script setup>
  49. import { FloatingPanel } from "vant";
  50. import { useStore } from "vuex";
  51. import { computed, ref } from "vue";
  52. const store = useStore();
  53. // const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  54. const tabBarHeight = ref(localStorage.getItem("tabBarHeight") * 1 || 50);
  55. const defalutHeight = ref(tabBarHeight.value + 32);
  56. const anchors = ref([defalutHeight.value, 310 + tabBarHeight.value, Math.round(1 * window.innerHeight)]);
  57. const height = ref(anchors.value[2]);
  58. const activeTab = ref(0);
  59. const tabs = ref(["农事任务", "农场档案"]);
  60. const handleTabClick = (index) => {
  61. activeTab.value = index;
  62. };
  63. const tabsContent = ref(["果园总览", "整体园相", "营养管理", "病虫管理"]);
  64. const activeTabsContent = ref(0);
  65. const handleTabsContentClick = (index) => {
  66. activeTabsContent.value = index;
  67. };
  68. const emit = defineEmits(['heightChange'])
  69. const isBackground = ref(false)
  70. const handleHeightChange = (data) => {
  71. isBackground.value = false
  72. if(data.height > anchors.value[1]){
  73. isBackground.value = true
  74. }
  75. emit('heightChange',data.height)
  76. };
  77. </script>
  78. <style lang="scss" scoped>
  79. .van-floating-panel{
  80. border-radius: 0;
  81. }
  82. .floating-panel {
  83. width: 100%;
  84. background: linear-gradient(180deg, transparent 0%, #F5F7FB 14%);
  85. ::v-deep {
  86. .van-floating-panel__content {
  87. background: transparent;
  88. }
  89. }
  90. .floating-panel-header {
  91. width: calc(100% - 24px);
  92. border-radius: 14px 14px 0 0;
  93. margin: 0 auto;
  94. background: #fff;
  95. .tabs {
  96. display: flex;
  97. .tab-item {
  98. flex: 1;
  99. text-align: center;
  100. font-size: 16px;
  101. color: rgba(0, 0, 0, 0.5);
  102. font-weight: 500;
  103. padding: 10px 0;
  104. &.active {
  105. color: #2199f8;
  106. border-radius: 14px 14px 0 0;
  107. background: linear-gradient(180deg, #cee5fb 0%, #fff 80%);
  108. }
  109. }
  110. }
  111. }
  112. .floating-panel-content {
  113. width: calc(100% - 24px);
  114. height: 100%;
  115. margin: 0 auto;
  116. .select-group {
  117. padding-top: 5px;
  118. background: #fff;
  119. .select-item {
  120. .select-item-title {
  121. font-size: 16px;
  122. }
  123. }
  124. }
  125. .tabs-content-group{
  126. display: flex;
  127. justify-content: space-evenly;
  128. padding: 5px 0;
  129. border-radius: 0 0 14px 14px;
  130. background: #fff;
  131. .tabs-content-item{
  132. font-size: 14px;
  133. color: rgba(0, 0, 0, 0.5);
  134. font-weight: 500;
  135. padding: 4px 12px;
  136. border-radius: 14px;
  137. text-align: center;
  138. &.active{
  139. color: #2199f8;
  140. background: rgba(33, 153, 248, 0.2);
  141. }
  142. }
  143. }
  144. .card-content-group{
  145. padding: 12px 0;
  146. .card-content-item{
  147. margin-top: 10px;
  148. border-radius: 14px;
  149. padding: 12px;
  150. background: #fff;
  151. color: #171717;
  152. .card-content-item-title{
  153. font-size: 16px;
  154. font-weight: 500;
  155. text-align: center;
  156. position: relative;
  157. &::before{
  158. content: '';
  159. position: absolute;
  160. left: 50%;
  161. transform: translateX(-50%);
  162. bottom: -1px;
  163. width: 66px;
  164. height: 8px;
  165. background: rgba(33, 153, 248, 0.3);
  166. border-radius: 4px;
  167. }
  168. }
  169. .card-content-item-content{
  170. margin-top: 12px;
  171. border-radius: 8px;
  172. background: rgba(238, 238, 238, 0.3);
  173. padding: 10px;
  174. line-height: 23px;
  175. div + div{
  176. margin-top: 5px;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. &.background-panel{
  183. background: #F5F7FB;
  184. .floating-panel-header {
  185. margin-top: 12px;
  186. }
  187. }
  188. }
  189. </style>