sanmu
authored
|
1
2
3
4
5
6
7
|
<template>
<!-- <div class="bg-grey-lighten-3 tw-w-full tw-h-[60px]"></div> -->
<!-- color="grey-lighten-3" -->
<v-card class="mx-auto !tw-z-10" max-width="" height="60">
<v-layout>
<v-app-bar scroll-behavior="elevate" color="white" density="default">
<v-app-bar-title v-if="!showSearch">
|
|
8
9
10
11
12
13
14
|
<a href="/"
><v-img
src="/mobile/index-logo.png"
alt="canrud"
width="100"
height="40"
/></a>
|
sanmu
authored
|
15
16
17
18
19
20
|
</v-app-bar-title>
<template v-slot:append>
<v-btn icon v-if="!showSearch">
<v-icon @click="showSearch = !showSearch">mdi-magnify</v-icon>
</v-btn>
|
|
21
22
23
24
25
26
27
28
29
|
<v-app-bar-nav-icon
@click="drawer = !drawer"
v-if="!drawer"
></v-app-bar-nav-icon>
<v-app-bar-nav-icon
@click="drawer = !drawer"
v-if="drawer"
icon="mdi-window-close"
></v-app-bar-nav-icon>
|
sanmu
authored
|
30
31
32
|
</template>
<div class="tw-h-[36px] tw-w-[300px] ml-8" v-if="showSearch">
|
|
33
34
35
36
37
38
39
40
41
42
43
44
|
<v-text-field
dense
density="compact"
height="24"
label="Search keyword"
hide-details="auto"
variant="solo"
append-inner-icon="mdi-close"
@click:appendInner="handleClick"
@keydown="handleKeyDown"
v-model="input"
>
|
sanmu
authored
|
45
46
47
48
|
</v-text-field>
</div>
</v-app-bar>
|
|
49
50
51
52
53
54
55
|
<v-navigation-drawer
width="512"
v-model="drawer"
location="right"
temporary
floating
>
|
sanmu
authored
|
56
|
<v-list density="compact" nav>
|
|
57
58
59
60
61
62
63
|
<v-list-item
to="/"
title="Home"
value="home"
@click="handleTabClick"
color="blue-darken-1"
>
|
sanmu
authored
|
64
65
|
</v-list-item>
<v-divider></v-divider>
|
|
66
67
68
69
70
71
72
|
<v-list-item
to="/products"
title="Products"
value="Products"
@click="handleTabClick"
color="blue-darken-1"
></v-list-item>
|
sanmu
authored
|
73
|
<v-divider></v-divider>
|
|
74
75
76
77
78
79
80
|
<v-list-item
to="/about"
title="About"
value="about"
@click="handleTabClick"
color="blue-darken-1"
></v-list-item>
|
sanmu
authored
|
81
|
<v-divider></v-divider>
|
|
82
83
84
85
86
87
88
|
<v-list-item
to="/contact"
title="Contact"
value="contact"
@click="handleTabClick"
color="blue-darken-1"
></v-list-item>
|
sanmu
authored
|
89
90
91
92
|
<v-divider></v-divider>
<v-list-item title="Blog" value="blog" color="blue-darken-1">
<a href="http://blog.canrud.com/" target="" title="Blog">Blog</a>
</v-list-item>
|
sanmu
authored
|
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
|
</v-list>
</v-navigation-drawer>
</v-layout>
</v-card>
<!-- <v-container>
<v-row class="tw-m-auto tw-flex tw-items-center">
<v-col cols="2" class="pa-0 tw-h-[64px]">
<router-link to="/"><v-img src="/logo.jpg" alt="canrud" /></router-link>
</v-col>
<v-col cols="6" md="8" class="px-0">
<v-text-field
label="Search keyword"
hide-details="auto"
variant="solo"
append-inner-icon="mdi-magnify"
@click:appendInner="handleClick"
@keydown="handleKeyDown"
v-model="input"
>
</v-text-field>
</v-col>
<v-col cols="4" md="2" class="px-0">
<v-btn variant="text" @click="dialogStore.updateDialog(true)" color="blue-darken-2 mt-4"
>Concat Us
</v-btn>
</v-col>
</v-row>
</v-container> -->
<ContactDialog />
</template>
<script setup lang="ts">
|
|
126
127
128
129
130
131
|
import { ref, watchEffect } from "vue";
import { useProductListStore } from "@/stores/product_list";
import { useRouter } from "vue-router";
import { useDialogStore } from "@/stores/dialog";
import { useCategoryStore } from "@/stores/category";
import { useDisplay } from "vuetify";
|
sanmu
authored
|
132
|
|
|
133
134
|
const drawer = ref(false);
const showSearch = ref(false);
|
sanmu
authored
|
135
|
|
|
136
137
|
const productStore = useProductListStore();
const categoryStore = useCategoryStore();
|
sanmu
authored
|
138
|
|
|
139
|
const input = ref();
|
sanmu
authored
|
140
|
|
|
141
|
const router = useRouter();
|
sanmu
authored
|
142
143
144
|
const handleKeyDown = (e: any) => {
if (e.keyCode == 13) {
|
|
145
146
147
148
|
categoryStore.updateDisplay(!input.value);
productStore.updateKeyword(input.value);
productStore.updatePageNo(1);
router.push("/products");
|
sanmu
authored
|
149
|
}
|
|
150
|
};
|
sanmu
authored
|
151
152
|
const handleClick = () => {
|
|
153
154
|
showSearch.value = false;
};
|
sanmu
authored
|
155
156
|
const handleTabClick = () => {
|
|
157
158
159
|
categoryStore.updateDisplay(true);
productStore.updateKeyword("");
};
|
sanmu
authored
|
160
161
|
watchEffect(() => {
|
|
162
163
|
input.value = productStore.keyword;
});
|
sanmu
authored
|
164
165
166
|
onMounted(() => {
// 获取url的参数
|
|
167
168
|
const url = window.location.href;
const index = url.indexOf("?");
|
sanmu
authored
|
169
|
if (index !== -1) {
|
|
170
171
|
const params = url.slice(index + 1).split("&");
const obj: any = {};
|
sanmu
authored
|
172
|
params.forEach((item) => {
|
|
173
174
175
|
const arr = item.split("=");
obj[arr[0]] = arr[1];
});
|
sanmu
authored
|
176
177
|
// 获取dialog的状态
if (obj.flag) {
|
|
178
|
dialog.updateDialog(true);
|
sanmu
authored
|
179
180
181
|
}
if (obj.keyword) {
|
|
182
|
productStore.updateKeyword(obj.keyword);
|
sanmu
authored
|
183
184
|
}
}
|
|
185
|
});
|
sanmu
authored
|
186
187
188
189
190
191
192
193
194
195
196
197
198
|
</script>
<style lang="scss" scoped>
.tabs {
background-color: #1f88e5;
}
.active :deep {
.v-tab__slider {
bottom: 3px;
}
}
</style>
|