Commit 5ec91995 by Jaxon

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

1 parent 2bf3209a
import { mineRoutes } from "./mine";
import { performance } from "./performance";
import { getFirstNavigablePath } from "./shared";
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 = [
...teamWorkRoutes,
...viewRoutes,
...performance,
...mineRoutes,
];
......@@ -20,7 +15,8 @@ const defaultRedirect = getFirstNavigablePath(moduleRoutes) || "/";
export default [
{
path: "/",
redirect: defaultRedirect, // 默认重定向到首个移动端页面
// 默认重定向到首个移动端页面
redirect: defaultRedirect,
},
...moduleRoutes,
];
import { routeOutlet } from "./shared";
export const viewRoutes = [
export const performance = [
{
path: "/performance",
redirect: "/performance/index",
......
......@@ -12,7 +12,10 @@
class="tab-item"
:class="{ 'is-active': activeKey === item.key }"
@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"
:alt="item.label"
:src="item.icon" />
......@@ -23,9 +26,22 @@
</template>
<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 {
name: "TypeTabs",
props: {
/** @type {import("vue").PropType<BrandTabItem[]>} */
list: {
type: Array,
default() {
......@@ -200,6 +216,22 @@ export default {
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() {
if (!this.normalizedList.length) {
this.sliderX = 0;
......@@ -282,26 +314,26 @@ export default {
align-items: center;
min-width: 100%;
width: max-content;
padding: var(--fontSize6, 6px);
padding: 3px;
box-sizing: border-box;
border-radius: var(--fontSize48, 48px);
border-radius: 24px;
overflow: hidden;
}
.tabs-bg {
position: absolute;
inset: 0;
border-radius: var(--fontSize48, 48px);
border-radius: 24px;
pointer-events: none;
}
.slider {
position: absolute;
top: var(--fontSize6, 6px);
bottom: var(--fontSize6, 6px);
top: 3px;
bottom: 3px;
left: 0;
z-index: 1;
border-radius: var(--fontSize48, 48px);
border-radius: 24px;
background-color: var(--primary-color, #1677ff);
transition:
transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1),
......@@ -316,39 +348,46 @@ export default {
display: inline-flex;
align-items: center;
justify-content: center;
padding: var(--fontSize12, 12px) var(--fontSize28, 28px);
border-radius: var(--fontSize48, 48px);
padding: 6px 14px;
border-radius: 24px;
white-space: nowrap;
color: #222222;
background: rgba(243, 243, 244, 1);
cursor: pointer;
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 {
color: #ffffff;
background: transparent;
}
.tab-item + .tab-item {
margin-left: var(--fontSize12, 12px);
margin-left: 6px;
}
.icon {
position: relative;
z-index: 2;
width: var(--fontSize32, 32px);
height: var(--fontSize32, 32px);
margin-right: var(--fontSize12, 12px);
width: 16px;
height: 16px;
margin-right: 6px;
flex-shrink: 0;
object-fit: contain;
}
.svg-icon-image {
fill: currentColor;
}
.label {
position: relative;
z-index: 2;
line-height: var(--fontSize40, 40px);
font-size: var(--fontSize26, 26px);
line-height: 20px;
font-size: 13px;
transition: color 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
</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 @@
<van-tab title="门店业绩" />
</van-tabs>
<div class="filter-wrapper">
<BrandTabs :list="options.brandTypeList" />
</div>
</div>
</template>
<script>
import BrandTabs from "../components/brandTabs/index.vue";
import { brandTypeList } from "./data";
export default {
name: "PerformanceOverview",
components: {
BrandTabs,
},
data() {
return {
pageBgUrl: "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/page-bg.png",
options: {
brandTypeList,
},
};
},
};
......@@ -27,6 +37,22 @@ export default {
background-size: 100% 240px;
background-repeat: no-repeat;
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 {
.van-tab {
flex: none;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!