提交 10d434ca authored 作者: lihuihui's avatar lihuihui

update

上级 9e36a678
...@@ -24,59 +24,37 @@ watchEffect(() => { ...@@ -24,59 +24,37 @@ watchEffect(() => {
} }
}) })
// h5的tab // h5的tab
let menuValue = $ref('') // tab选中值
let tabValue = $ref('')
onMounted(() => { onMounted(() => {
clearActive()
const defaultMenu = route.query?.type || '' const defaultMenu = route.query?.type || ''
shopStore.filters = shopStore.filters.reduce((a: any, b: any) => { tabValue = defaultMenu as string
if (b.value === defaultMenu) {
b.isActive = true
} else {
if (b.children) {
b.children.map((i: any) => i.value === defaultMenu && (i.isActive = true))
b.children.find((i: any) => i.isActive) && (b.isActive = true)
}
}
a.push(b)
return a
}, [])
menuValue = defaultMenu as string
}) })
// menu下拉框显示
let childMenuShow = $ref(false) let childMenuShow = $ref(false)
const menuTab = function (item: any) {
if (item.value === 'PRP') { const changeMenuTab = function (item: any) {
window.open('https://prp.ezijing.com') switch (item.value) {
window.location.reload() case 'PAA':
} childMenuShow = !childMenuShow
if (!item.children) { break
clearActive() case 'PRP':
item.isActive = true window.open('https://prp.ezijing.com')
childMenuShow = false break
menuValue = item.value default:
} else { tabValue = item.value
childMenuShow = !childMenuShow childMenuShow = false
} }
} }
const childMenuTab = function (item: any, cItem: any) { // 点击下拉框
clearActive() const changeMenuChildTab = function (item: any) {
item.isActive = true tabValue = item.value
cItem.isActive = true
menuValue = cItem.value
setTimeout(() => { setTimeout(() => {
childMenuShow = false childMenuShow = false
}, 100) }, 100)
} }
const clearActive = function () {
for (let i = 0; i < shopStore.filters.length; i++) {
shopStore.filters[i].isActive = false
if (shopStore.filters[i].children) {
shopStore.filters[i].children.map((c: any) => (c.isActive = false))
}
}
}
</script> </script>
<template> <template>
...@@ -116,15 +94,17 @@ const clearActive = function () { ...@@ -116,15 +94,17 @@ const clearActive = function () {
<img src="https://webapp-pub.ezijing.com/project_online/fi/shop_banner.jpg" class="shop_banner" /> <img src="https://webapp-pub.ezijing.com/project_online/fi/shop_banner.jpg" class="shop_banner" />
<div class="mobile-tab-box"> <div class="mobile-tab-box">
<div <div
:class="`item ${shopStore.filters[index].isActive && 'active'}`" :class="`item ${item.children
? item.children.find((i: any) => i.value === tabValue) && 'active'
: item.value === tabValue && 'active'}`"
v-for="(item, index) in shopStore.filters" v-for="(item, index) in shopStore.filters"
:key="index" :key="index"
> >
<span @click="menuTab(item)">{{ item.label }}</span> <span @click="changeMenuTab(item)">{{ item.label }}</span>
<div class="child" v-if="shopStore.filters[index]?.children && childMenuShow"> <div class="child" v-if="shopStore.filters[index]?.children && childMenuShow">
<div <div
@click="childMenuTab(item, cItem)" @click="changeMenuChildTab(cItem)"
:class="`child-item ${cItem.isActive && 'active'}`" :class="`child-item ${tabValue === cItem.value && 'active'}`"
v-for="(cItem, cIndex) in shopStore.filters[index]?.children" v-for="(cItem, cIndex) in shopStore.filters[index]?.children"
:key="cIndex" :key="cIndex"
> >
...@@ -134,11 +114,11 @@ const clearActive = function () { ...@@ -134,11 +114,11 @@ const clearActive = function () {
</div> </div>
</div> </div>
<div v-for="(item, index) in shopStore.filters" :key="index"> <div v-for="(item, index) in shopStore.filters" :key="index">
<CourseList v-if="menuValue === item.value" :type="item.value" :courseList="shopStore.shopList" :key="index" /> <CourseList v-if="tabValue === item.value" :type="item.value" :courseList="shopStore.shopList" :key="index" />
<template v-if="shopStore.filters[index]?.children"> <template v-if="shopStore.filters[index]?.children">
<div v-for="(cItem, cIndex) in shopStore.filters[index]?.children" :key="cIndex"> <div v-for="(cItem, cIndex) in shopStore.filters[index]?.children" :key="cIndex">
<CourseList <CourseList
v-if="menuValue === cItem.value" v-if="tabValue === cItem.value"
:type="cItem.value" :type="cItem.value"
:courseList="shopStore.shopList" :courseList="shopStore.shopList"
:key="index" :key="index"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论