Commit 5ec91995 by Jaxon

feat(业绩概览): 品牌tabs组件

1 parent 2bf3209a
import { mineRoutes } from "./mine"; import { mineRoutes } from "./mine";
import { performance } from "./performance";
import { getFirstNavigablePath } from "./shared"; import { getFirstNavigablePath } from "./shared";
import { teamWorkRoutes } from "./teamWork"; import { teamWorkRoutes } from "./teamWork";
import { viewRoutes } from "./view";
export { mineRoutes } from "./mine";
export { routeOutlet } from "./shared";
export { teamWorkRoutes } from "./teamWork";
export { viewRoutes } from "./view";
// 第一个元素会作为 / 路径的 重定向路由 作为 默认页面 // 第一个元素会作为 / 路径的 重定向路由 作为 默认页面
const moduleRoutes = [ const moduleRoutes = [
...teamWorkRoutes, ...teamWorkRoutes,
...viewRoutes, ...performance,
...mineRoutes, ...mineRoutes,
]; ];
...@@ -20,7 +15,8 @@ const defaultRedirect = getFirstNavigablePath(moduleRoutes) || "/"; ...@@ -20,7 +15,8 @@ const defaultRedirect = getFirstNavigablePath(moduleRoutes) || "/";
export default [ export default [
{ {
path: "/", path: "/",
redirect: defaultRedirect, // 默认重定向到首个移动端页面 // 默认重定向到首个移动端页面
redirect: defaultRedirect,
}, },
...moduleRoutes, ...moduleRoutes,
]; ];
import { routeOutlet } from "./shared"; import { routeOutlet } from "./shared";
export const viewRoutes = [ export const performance = [
{ {
path: "/performance", path: "/performance",
redirect: "/performance/index", redirect: "/performance/index",
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
class="tab-item" class="tab-item"
:class="{ 'is-active': activeKey === item.key }" :class="{ 'is-active': activeKey === item.key }"
@click="onTap(item, index)"> @click="onTap(item, index)">
<img v-if="item.icon && (!item.showIconOnActiveOnly || activeKey === item.key)" <SvgIcon v-if="shouldRenderSvgIcon(item)"
class="icon svg-icon-image"
:name="getSvgIconName(item.icon)" />
<img v-else-if="shouldRenderImageIcon(item)"
class="icon" class="icon"
:alt="item.label" :alt="item.label"
:src="item.icon" /> :src="item.icon" />
...@@ -23,9 +26,22 @@ ...@@ -23,9 +26,22 @@
</template> </template>
<script> <script>
/**
* @typedef {Object} BrandTabItem
* @property {string|number} [key]
* @property {string|number} [value]
* @property {string|number} [id]
* @property {string|number} [label]
* @property {string|number} [text]
* @property {string|number} [name]
* @property {string} [icon]
* @property {boolean} [showIconOnActiveOnly]
*/
export default { export default {
name: "TypeTabs", name: "TypeTabs",
props: { props: {
/** @type {import("vue").PropType<BrandTabItem[]>} */
list: { list: {
type: Array, type: Array,
default() { default() {
...@@ -200,6 +216,22 @@ export default { ...@@ -200,6 +216,22 @@ export default {
item, item,
}); });
}, },
shouldRenderSvgIcon(item) {
return this.shouldShowIcon(item) && this.isSvgIcon(item && item.icon);
},
shouldRenderImageIcon(item) {
return this.shouldShowIcon(item) && !this.isSvgIcon(item && item.icon);
},
shouldShowIcon(item) {
return Boolean(item && item.icon)
&& (!item.showIconOnActiveOnly || this.activeKey === item.key);
},
isSvgIcon(icon) {
return typeof icon === "string" && icon.endsWith("|svg");
},
getSvgIconName(icon) {
return this.isSvgIcon(icon) ? icon.slice(0, -4) : "";
},
updateSlider() { updateSlider() {
if (!this.normalizedList.length) { if (!this.normalizedList.length) {
this.sliderX = 0; this.sliderX = 0;
...@@ -282,26 +314,26 @@ export default { ...@@ -282,26 +314,26 @@ export default {
align-items: center; align-items: center;
min-width: 100%; min-width: 100%;
width: max-content; width: max-content;
padding: var(--fontSize6, 6px); padding: 3px;
box-sizing: border-box; box-sizing: border-box;
border-radius: var(--fontSize48, 48px); border-radius: 24px;
overflow: hidden; overflow: hidden;
} }
.tabs-bg { .tabs-bg {
position: absolute; position: absolute;
inset: 0; inset: 0;
border-radius: var(--fontSize48, 48px); border-radius: 24px;
pointer-events: none; pointer-events: none;
} }
.slider { .slider {
position: absolute; position: absolute;
top: var(--fontSize6, 6px); top: 3px;
bottom: var(--fontSize6, 6px); bottom: 3px;
left: 0; left: 0;
z-index: 1; z-index: 1;
border-radius: var(--fontSize48, 48px); border-radius: 24px;
background-color: var(--primary-color, #1677ff); background-color: var(--primary-color, #1677ff);
transition: transition:
transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1),
...@@ -316,39 +348,46 @@ export default { ...@@ -316,39 +348,46 @@ export default {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: var(--fontSize12, 12px) var(--fontSize28, 28px); padding: 6px 14px;
border-radius: var(--fontSize48, 48px); border-radius: 24px;
white-space: nowrap; white-space: nowrap;
color: #222222; color: #222222;
background: rgba(243, 243, 244, 1); background: rgba(243, 243, 244, 1);
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
transition: color 250ms cubic-bezier(0.2, 0.8, 0.2, 1); transition:
color 250ms cubic-bezier(0.2, 0.8, 0.2, 1),
background-color 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
} }
.tab-item.is-active { .tab-item.is-active {
color: #ffffff; color: #ffffff;
background: transparent;
} }
.tab-item + .tab-item { .tab-item + .tab-item {
margin-left: var(--fontSize12, 12px); margin-left: 6px;
} }
.icon { .icon {
position: relative; position: relative;
z-index: 2; z-index: 2;
width: var(--fontSize32, 32px); width: 16px;
height: var(--fontSize32, 32px); height: 16px;
margin-right: var(--fontSize12, 12px); margin-right: 6px;
flex-shrink: 0; flex-shrink: 0;
object-fit: contain; object-fit: contain;
} }
.svg-icon-image {
fill: currentColor;
}
.label { .label {
position: relative; position: relative;
z-index: 2; z-index: 2;
line-height: var(--fontSize40, 40px); line-height: 20px;
font-size: var(--fontSize26, 26px); font-size: 13px;
transition: color 250ms cubic-bezier(0.2, 0.8, 0.2, 1); transition: color 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
} }
</style> </style>
export const brandTypeList = [
{
showIconOnActiveOnly: true,
icon: "brand-icon|svg",
key: "0",
label: "问界鸿蒙-延保权益",
},
{
showIconOnActiveOnly: true,
icon: "brand-icon|svg",
key: "1",
label: "通用品牌-延保权益",
},
];
...@@ -5,17 +5,27 @@ ...@@ -5,17 +5,27 @@
<van-tab title="门店业绩" /> <van-tab title="门店业绩" />
</van-tabs> </van-tabs>
<div class="filter-wrapper"> <div class="filter-wrapper">
<BrandTabs :list="options.brandTypeList" />
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import BrandTabs from "../components/brandTabs/index.vue";
import { brandTypeList } from "./data";
export default { export default {
name: "PerformanceOverview", name: "PerformanceOverview",
components: {
BrandTabs,
},
data() { data() {
return { return {
pageBgUrl: "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/page-bg.png", pageBgUrl: "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/page-bg.png",
options: {
brandTypeList,
},
}; };
}, },
}; };
...@@ -27,6 +37,22 @@ export default { ...@@ -27,6 +37,22 @@ export default {
background-size: 100% 240px; background-size: 100% 240px;
background-repeat: no-repeat; background-repeat: no-repeat;
height: 100%; height: 100%;
padding-top: 12px;
.page-header {
display: flex;
align-items: center;
padding: 0 12px 12px;
}
.page-title {
color: #3975c6;
font-size: 16px;
font-weight: 600;
line-height: 20px;
margin-left: 8px;
}
::v-deep .van-tabs { ::v-deep .van-tabs {
.van-tab { .van-tab {
flex: none; flex: none;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!