Parcourir la source

feat:添加浮动面板头部切换

wangsisi il y a 2 semaines
Parent
commit
cef006d85e

+ 0 - 7
src/router/globalRoutes.js

@@ -18,13 +18,6 @@ export default [
         meta: { showTabbar: true, keepAlive: true },
         component: () => import("@/views/old_mini/home/index.vue"),
     },
-    // 飞鸟灵境
-    {
-        path: "/wonderland",
-        name: "Wonderland",
-        meta: { keepAlive: true },
-        component: () => import("@/views/old_mini/home/wonderland/index.vue"),
-    },
     {
         path: "/farm",
         name: "Farm",

+ 0 - 104
src/views/old_mini/home/components/adoptPopup.vue

@@ -1,104 +0,0 @@
-<template>
-    <popup class="adopt-popup" v-model:show="show">
-        <div class="title">
-            <div>恭喜你</div>
-            <div>送您一张 <span>认养卡</span></div>
-            <img class="tree" src="@/assets/img/home/adopt-popup-icon.png" alt="">
-        </div>
-        <div class="card">
-            <img src="@/assets/img/home/popup-bg.png" alt="">
-            <div class="garden-info">
-                <div class="garden-txt">
-                    <span>糯米糍</span>
-                    <div>品种</div>
-                </div>
-                <div class="garden-txt">
-                    <span>荔博园</span>
-                    <div>农场</div>
-                </div>
-                <div class="garden-txt">
-                    <span>39年</span>
-                    <div>树龄</div>
-                </div>
-                <div class="garden-txt">
-                    <span>92分</span>
-                    <div>生态指标</div>
-                </div>
-                <div class="garden-txt">
-                    <span>20斤</span>
-                    <div>认养斤数</div>
-                </div>
-            </div>
-            <div class="button">确认</div>
-        </div>
-    </popup>
-</template>
-
-<script setup>
-import { Popup } from 'vant';
-import { ref } from 'vue';
-
-const show = ref(false);
-</script>
-
-<style lang="scss" scoped>
-.adopt-popup{
-    width: 88%;
-    padding: 8px;
-    box-sizing: border-box;
-    background: url('@/assets/img/home/adopt-popup-bg.png') no-repeat center center /100% 100%;
-    overflow-y: none;
-    .title{
-        position: relative;
-        font-size: 24px;
-        font-weight: bold;
-        padding: 10px 0 14px 13px;
-        span{
-            color: #01BEDB;
-        }
-        .tree{
-            width: 195px;
-            height: 220px;
-            position: absolute;
-            right: -36px;
-            top: -52px;
-            z-index: 1;
-        }
-    }
-    .card{
-        background: #fff;
-        border-radius: 20px;
-        padding: 16px;
-        position: relative;
-        z-index: 2;
-        img{
-            width: 100%;
-            height: 136px;
-            object-fit: cover;
-            border-radius: 8px;
-            margin-bottom: 12px;
-        }
-        .garden-info{
-            display: flex;
-            margin-bottom: 28px;
-            .garden-txt{
-                flex: 1;
-                text-align: center;
-                div{
-                    font-size: 12px;
-                    color: #999999;
-                }
-            }
-        }
-    }
-    .button{
-        text-align: center;
-        color: #fff;
-        padding: 11px;
-        font-size: 18px;
-        background: linear-gradient(180deg,#18E0FF,#00C5E3);
-        border-radius: 30px;
-        margin-bottom: 4px;
-    }
-}
-</style>

+ 123 - 5
src/views/old_mini/home/components/homeFloatingPanel.vue

@@ -1,6 +1,32 @@
 <template>
-    <floating-panel class="floating-panel" v-model:height="height" :anchors="anchors">
-      123
+    <floating-panel class="floating-panel" :class="{ 'background-panel': isBackground }" v-model:height="height" :anchors="anchors" :content-draggable="false" @height-change="handleHeightChange">
+        <template #header>
+            <div class="floating-panel-header">
+                <div class="tabs">
+                    <div
+                        :class="['tab-item', activeTab === index ? 'active' : '']"
+                        v-for="(tab, index) in tabs"
+                        :key="tab"
+                        @click="handleTabClick(index)"
+                    >
+                        {{ tab }}
+                    </div>
+                </div>
+            </div>
+        </template>
+        <div class="floating-panel-content">
+            <div class="select-group">
+                <div class="select-item">
+                    <div class="select-item-title">123</div>
+                </div>
+            </div>
+            <div class="tabs-content-group">
+                <div :class="['tabs-content-item',activeTabsContent === index ? 'active' : '']" v-for="(tab,index) in tabsContent" :key="tab" @click="handleTabsContentClick(index)">
+                    {{ tab }}
+                </div>
+            </div>
+            <div></div>
+        </div>
     </floating-panel>
 </template>
 
@@ -11,15 +37,107 @@ import { computed, ref } from "vue";
 
 const store = useStore();
 // const tabBarHeight = computed(() => store.state.home.tabBarHeight);
-const tabBarHeight = ref(localStorage.getItem('tabBarHeight')*1 || 50);
+const tabBarHeight = ref(localStorage.getItem("tabBarHeight") * 1 || 50);
 
-const defalutHeight = ref(tabBarHeight.value + 34);
+const defalutHeight = ref(tabBarHeight.value + 32);
 const anchors = ref([defalutHeight.value, 310 + tabBarHeight.value, Math.round(1 * window.innerHeight)]);
 const height = ref(anchors.value[1]);
+
+const activeTab = ref(0);
+const tabs = ref(["农事任务", "农场档案"]);
+
+const handleTabClick = (index) => {
+    activeTab.value = index;
+};
+
+const tabsContent = ref(["果园总览", "整体园相", "营养管理", "病虫管理"]);
+
+const activeTabsContent = ref(0);
+const handleTabsContentClick = (index) => {
+    activeTabsContent.value = index;
+};
+
+const emit = defineEmits(['heightChange'])
+
+const isBackground = ref(false)
+const handleHeightChange = (data) => {
+    isBackground.value = false
+    if(data.height > anchors.value[1]){
+        isBackground.value = true
+    }
+    emit('heightChange',data.height)
+};
 </script>
 
 <style lang="scss" scoped>
 .floating-panel {
-    
+    width: 100%;
+    background: linear-gradient(180deg, transparent 0%, #F5F7FB 14%);
+    ::v-deep {
+        .van-floating-panel__content {
+            background: transparent;
+        }
+    }
+    .floating-panel-header {
+        width: calc(100% - 24px);
+        border-radius: 14px 14px 0 0;
+        margin: 0 auto;
+        background: #fff;
+        .tabs {
+            display: flex;
+            .tab-item {
+                flex: 1;
+                text-align: center;
+                font-size: 16px;
+                color: rgba(0, 0, 0, 0.5);
+                font-weight: 500;
+                padding: 10px 0;
+                &.active {
+                    color: #2199f8;
+                    border-radius: 14px 14px 0 0;
+                    background: linear-gradient(180deg, #cee5fb 0%, #fff 80%);
+                }
+            }
+        }
+    }
+    .floating-panel-content {
+        width: calc(100% - 24px);
+        height: 100%;
+        margin: 0 auto;
+        .select-group {
+            padding-top: 5px;
+            background: #fff;
+            .select-item {
+                .select-item-title {
+                    font-size: 16px;
+                }
+            }
+        }
+        .tabs-content-group{
+            display: flex;
+            justify-content: space-evenly;
+            padding: 5px 0;
+            border-radius: 0 0 14px 14px;
+            background: #fff;
+            .tabs-content-item{
+                font-size: 14px;
+                color: rgba(0, 0, 0, 0.5);
+                font-weight: 500;
+                padding: 4px 12px;
+                border-radius: 14px;
+                text-align: center;
+                &.active{
+                    color: #2199f8;
+                    background: rgba(33, 153, 248, 0.2);
+                }
+            }
+        }
+    }
+    &.background-panel{
+        background: #F5F7FB;
+        .floating-panel-header {
+            margin-top: 12px;
+        }
+    }
 }
 </style>

+ 0 - 28
src/views/old_mini/home/components/iconGroup.vue

@@ -1,28 +0,0 @@
-<template>
-    <div class="icon-group">
-        <img src="@/assets/img/home/garden-icon-1.png" alt="">
-        <img src="@/assets/img/home/garden-icon-2.png" alt="">
-        <img src="@/assets/img/home/garden-icon-3.png" alt="">
-    </div>
-</template>
-
-<script setup>
-
-</script>
-
-<style lang="scss" scoped>
-.icon-group{
-    position: absolute;
-    left: 12px;
-    top: 110px;
-    display: flex;
-    flex-direction: column;
-    img{
-        width: 40px;
-        height: 40px;
-    }
-    img + img{
-        margin-top: 8px;
-    }
-}
-</style>

+ 15 - 4
src/views/old_mini/home/index.vue

@@ -7,7 +7,7 @@
         <!-- 天气 -->
         <weather-info class="weather-info" @weatherExpanded="weatherExpanded"></weather-info>
         <!-- 浮动面板 -->
-        <home-floating-panel class="home-floating-panel"></home-floating-panel>
+        <home-floating-panel class="home-floating-panel" :style="{ zIndex: zIndex}" @heightChange="heightChange"></home-floating-panel>
     </div>
 </template>
 
@@ -34,6 +34,14 @@ const isExpanded = ref(false);
 const weatherExpanded = (isExpandedValue) => {
     isExpanded.value = isExpandedValue;
 }
+
+const zIndex = ref(1)
+const heightChange = (height) => {
+    zIndex.value = 1
+    if(height > 310 + tabBarHeight.value){
+        zIndex.value = 3
+    }
+}
 </script>
 
 <style lang="scss" scoped>
@@ -53,18 +61,21 @@ const weatherExpanded = (isExpandedValue) => {
         width: 100%;
         height: 100%;
         background-color: rgba(0, 0, 0, 0.52);
+        z-index: 2;
     }
     .weather-info {
         position: absolute;
         top: 12px;
         left: 12px;
         width: calc(100% - 24px);
+        z-index: 2;
     }
     .home-floating-panel{
-        position: absolute;
+        position: fixed;
         bottom: 0;
-        left: 12px;
-        width: calc(100% - 24px);
+        left: 0;
+        width: 100%;
+        z-index: 1;
     }
 }
 

+ 0 - 232
src/views/old_mini/home/wonderland/index.vue

@@ -1,232 +0,0 @@
-<template>
-    <div class="container">
-        <custom-header name="飞鸟灵境"></custom-header>
-        <div class="content">
-            <select-group class="select-wrap" @gardenList="gardenList" @toggle="toggle"></select-group>
-            <div class="video">
-                <video ref="myVideo" class="mp4" autoplay loop muted @canplay="onVideoReady">
-                    <source src="@/assets/img/home/video.mp4" type="video/mp4">
-                </video>
-            </div>
-            <div class="button button-bg" @click="handleGarden">逛逛果园</div>
-            <icon-group v-show="showIcon" @click="handleDetail"></icon-group>
-        </div>
-    </div>
-    <!-- 果园详情弹窗 -->
-    <popup class="garden-popup" v-model:show="showDetail" round closeable>
-        <img src="@/assets/img/mine/gy-img.png" alt="">
-        <!-- <div class="garden-title">{{ garden.title }}</div>
-        <div class="garden-wrap">
-            <div class="garden-cont">
-                <div class="title">{{ garden.aboutTitle }}</div>
-                <div class="desc">
-                    <div class="text">{{ garden.about }}</div>
-                    <div class="text">{{ garden.text }}</div>
-                </div>
-            </div>
-            <div class="garden-cont">
-                <div class="title">{{ garden.hisTitle }}</div>
-                <div class="desc">
-                    <div class="text">{{ garden.his }}</div>
-                </div>
-            </div>
-            <div class="garden-cont">
-                <div class="title">{{ garden.professionTitle }}</div>
-            </div>
-            <div class="garden-cont">
-                <div class="title">{{ garden.featureTitle }}</div>
-                <div class="feature">
-                    <div class="text">{{ garden.content }}</div>
-                </div>
-            </div>
-        </div> -->
-    </popup>
-</template>
-
-<script setup>
-import selectGroup from "@/components/selectGroup.vue";
-import { onActivated, onMounted, ref } from "vue";
-import { Popup } from "vant";
-import { useRouter } from "vue-router";
-import customHeader from "@/components/customHeader.vue";
-import iconGroup from "../components/iconGroup.vue";
-const router = useRouter();
-
-const handleGarden = () => {
-    router.push("/garden");
-};
-
-const showIcon = ref(true)
-function toggle(value){
-    showIcon.value = !value
-}
-
-const gardenData = [
-    {
-        id: 19,
-        title: "广州从化荔博园",
-        aboutTitle: "关于我们",
-        about: `广州市从化区荔枝文化博览园位于于广州市从化江埔街九里步,园区内共有116个荔枝品种,其中18个是国家荔枝良种重大科研联合攻关生产试验品种(含对照品种),这里是创建荔枝产业优质种质的基因库。`,
-        text: `博览园主要功能是 “一库两园三平台”“一库”是指荔枝产业优质种质资源库。“两园”是指荔枝科技创新园、5G智慧荔枝园。“三平台”是指荔枝科技技术示范推广平台荔农致富创业指导培训平台、广东特质农产品交易平台。`,
-        hisTitle: "文化历史",
-        his: `广州从化荔博园与华南农业大学、广东省省农科院联合共建荔枝产业研究院,是国家荔枝龙眼产业技术体系示范基地、国家荔枝良种重大科研联合攻关生产试验基地、国家天地昆虫科技创新联盟技术研发应用示范基地。`,
-        professionTitle: "专业技术",
-        profession: [
-            {
-                title: "智能化无人机飞巡平台",
-                url: "",
-            },
-            {
-                title: "现代化智能作业设备",
-                url: "",
-            },
-        ],
-        featureTitle: "特色产品",
-        feature: {
-            content:
-                '<div style="text-indent: 2em;">一颗北园绿分九口吃完。第一口先吃龙头(北园绿果身饱满,左右两肩耸起,一高一低,高者称之为龙头,低者称之为凤尾,有龙凤呈祥之意)一口咬下,便会感觉到[嗦]的一声脆响,然后再吃凤尾,再沿着龙头和凤尾向下吃,共分九口吃完,最后满心欢喜地吐出果核。</div>',
-            tip: "记住:品尝珍品时切忌囫囵吞枣,牛嚼牡丹,要注意仪态,细嚼慢咽,否则品尝不到北园绿的精华。",
-            url: "https://birdseye-img-ali-cdn.sysuimars.com/foster/byl-detail/feature-bg.png",
-        },
-    },
-];
-const garden = gardenData[0];
-const showDetail = ref(true);
-const handleDetail = () => {
-    showDetail.value = true;
-};
-
-const myVideo = ref(null)
-const onVideoReady = () =>{
-    myVideo.value.play()
-}
-
-onActivated(()=>{
-    // showDetail.value = false
-    myVideo.value.play()
-})
-
-function gardenList(arr) {
-    // console.log('arr',arr);
-}
-
-onMounted(() => {});
-</script>
-
-<style lang="scss" scoped>
-.container {
-    width: 100%;
-    height: calc(100vh - 40px);
-    .content {
-        width: 100%;
-        height: 100%;
-        position: relative;
-        .select-wrap {
-            position: absolute;
-            top: 15px;
-            left: 15px;
-            width: calc(100% - 30px);
-            height: 40px;
-            z-index: 2;
-        }
-        .video {
-            width: 100%;
-            height: 100%;
-            .mp4{
-                width: 100%;
-                height: 100%;
-                object-fit: cover;
-            }
-        }
-        .button {
-            position: absolute;
-            left: 48px;
-            bottom: 50px;
-            width: calc(100% - 48px * 2);
-        }
-    }
-}
-
-.button-bg {
-    background: linear-gradient(0deg, #18e0ff, #00c5e3);
-    border-radius: 30px;
-    border: 1px solid #fff;
-    font-size: 18px;
-    padding: 11px;
-    box-sizing: border-box;
-    text-align: center;
-    color: #fff;
-    font-weight: 500;
-}
-
-.garden-popup {
-    width: 85%;
-    height: 70%;
-    overflow: auto;
-    background-image: url("https://birdseye-img-ali-cdn.sysuimars.com/foster/detail/bg.png");
-    background-size: cover;
-    img{
-        width: 100%;
-    }
-    .garden-title {
-        width: 76%;
-        height: 40px;
-        line-height: 40px;
-        font-size: 19px;
-        margin: 50px auto 15px auto;
-        color: #fff;
-        text-align: center;
-        background: url("@/assets/img/home/garden-title.png") no-repeat center center / 100% 100%;
-    }
-    .garden-wrap {
-        width: 100%;
-        height: calc(100% - 110px);
-        padding: 0 8px;
-        overflow-y: auto;
-        box-sizing: border-box;
-    }
-    .garden-cont {
-        width: 100%;
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        padding: 34px;
-        box-sizing: border-box;
-        background: url("@/assets/img/home/garden-cont.png") no-repeat center center / 100% 100%;
-        .title {
-            font-size: 16px;
-            font-weight: 500;
-            color: #4e9fa1;
-            border: 1px solid #4e9fa1;
-            border-radius: 20px;
-            padding: 0 10px;
-            margin-bottom: 15px;
-        }
-        .desc {
-            .text {
-                text-indent: 2em;
-                line-height: 1.6;
-            }
-            .text + .text {
-                margin-top: 15px;
-            }
-        }
-        .feature {
-            width: 100%;
-            height: 200px;
-            background: url("@/assets/img/home/feature-bg.png") no-repeat center center / 100% 100%;
-        }
-    }
-    .garden-cont + .garden-cont {
-        position: relative;
-        &::before {
-            content: "";
-            position: absolute;
-            top: -24px;
-            height: 38px;
-            width: 70%;
-            background: url("@/assets/img/home/garden-line.png") no-repeat center center / 100% 100%;
-        }
-    }
-}
-</style>