Mr.Shi
2023-08-11 6e19ef63c0a87588abd76c04ab228a73e3060ea4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
    <div class="box">
        <div class="box_h" style="height: 49px;" :style="store.state.type ? 'padding-bottom: 15px;' : ''"></div>
        <div class="box_tar" style="height: 49px;" :style="store.state.type ? 'padding-bottom: 15px;' : ''">
            <div class="box_tar_item" v-for="(item, i) in Menu" :key="i" @click.stop="jump(item.path)">
                <div class="box_tar_item_position" v-if="item.isCode">
                    <img class="box_tar_item_code" :src="item.isActive ? item.activeIcom : item.icon" alt="" />
                    <span :style="{ color: item.isActive ? '#222222' : '#666666' }">{{item.name}}</span>
                </div>
                <div class="box_tar_item_normal" v-else>
                    <van-badge :content="store.state.upcomingNum.d" max="99" v-if="item.path === '/index' && store.state.upcomingNum.d > 0">
                        <img :src="item.isActive ? item.activeIcom : item.icon" alt="" />
                    </van-badge>
                    <img :src="item.isActive ? item.activeIcom : item.icon" alt="" v-else />
                    <span :style="{ color: item.isActive ? '#222222' : '#666666' }">{{item.name}}</span>
                </div>
            </div>
        </div>
        <!--    扫码组件   -->
        <v-ScanCode
            :openCode="openCode"
            :infos="['第一次扫码', '第二次扫码']"
            @closePopup="closePopup"
            @onDecode="onDecode">
        </v-ScanCode>
    </div>
</template>
 
<script setup lang="ts">
    import { ref, reactive, watch, nextTick, onMounted } from 'vue'
    import { useRoute, useRouter } from "vue-router";
    import { useStore } from "vuex"
    import { MenuVerification } from '@/interface'
 
    const store = useStore()
 
    let datas = ref<string[]>([])
 
    const openCode = ref<boolean>(false)
 
    const route = useRoute()
 
    const router = useRouter()
 
    const Menu = reactive<Array<MenuVerification>>([
        {
            icon: require('@/assets/icon/nav_daiban@2x.png'),
            activeIcom: require('@/assets/icon/nav_daiban_sel@2x.png'),
            path: '/index',
            isActive: false,
            name: '待办'
        },
        {
            icon: require('@/assets/icon/nav_gongzuotai@2x.png'),
            activeIcom: require('@/assets/icon/nav_gongzuotai_sel@2x.png'),
            path: '/workbench',
            isActive: false,
            name: '工作台'
        },
        // {
        //     icon: require('@/assets/icon/nav_saoma@2x.png'),
        //     activeIcom: require('@/assets/icon/nav_saoma@2x.png'),
        //     path: '',
        //     isActive: false,
        //     isCode: true,
        //     name: '扫码'
        // },
        // {
        //     icon: require('@/assets/icon/nav_kanban@2x.png'),
        //     activeIcom: require('@/assets/icon/nav_kanban_sel@2x.png'),
        //     path: '/bulletinboard',
        //     isActive: false,
        //     name: '看板'
        // },
        {
            icon: require('@/assets/icon/nav_wode@2x.png'),
            activeIcom: require('@/assets/icon/nav_wode_sel@2x.png'),
            path: '/my',
            isActive: false,
            name: '我的'
        }
    ])
 
    const jump = (path: string): void => {
        if (path === '') {
            openCode.value = true
            return
        }
        router.push({ path })
    }
 
    // 关闭扫码组件
    const closePopup = (): void => {
        openCode.value = false
    }
 
    // 获取扫码值
    const onDecode = (data: string[]): void => {
        console.log(data)
        datas.value = data
        nextTick(() => {
            openCode.value = false
        })
    }
 
    // 监听函数
    watch(() => route.path,(news, old): void => {
        Menu.forEach(item => {
            item.isActive = item.path === news;
        })
    },{ immediate: true })
 
    onMounted(() =>{
        store.dispatch('getUpcomingNum')
    })
</script>
 
<style lang="scss" scoped>
.box {
    .box_tar {
        width: 100%;
        display: flex;
        background: white;
        position: fixed;
        bottom: 0;
        left: 0;
        box-shadow: 0px -2px 0px 0px rgba(238, 238, 238, 0.9);
        .box_tar_item {
            flex: 1;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            position: relative;
            .box_tar_item_normal {
                display: flex;
                align-items: center;
                justify-content: center;
                flex-direction: column;
                .box_tar_item_code {
                    width: 88px;
                    height: 88px;
                }
                img {
                    width: 44px;
                    height: 44px;
                }
                span {
                    font-size: 20px;
                    font-weight: 400;
                    color: #666666;
                    text-shadow: 0px -2px 0px rgba(238, 238, 238, 0.9);
                }
            }
            .box_tar_item_position {
                display: flex;
                flex-direction: column;
                align-items: center;
                position: absolute;
                top: -30px;
                z-index: 9;
                .box_tar_item_code {
                    width: 88px;
                    height: 88px;
                }
                img {
                    width: 26px;
                    height: 26px;
                }
                span {
                    font-size: 20px;
                    font-weight: 400;
                    color: #666666;
                    padding-bottom: 12px;
                    text-shadow: 0px -2px 0px rgba(238, 238, 238, 0.9);
                }
            }
        }
    }
}
</style>