Skip to content

Commit 5132724

Browse files
committed
fix:装扮分类兜底virtual_stock_item_details
1 parent 0281889 commit 5132724

4 files changed

Lines changed: 79 additions & 15 deletions

File tree

src/utils/mallDecoration.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const SUPPORTED_SKIN_CATEGORIES = ["calendar", "sidebar", "atcard", "homebg", "comment"];
2+
3+
const SKIN_CATEGORY_KEYWORDS = [
4+
{
5+
category: "calendar",
6+
keywords: ["首页日历", "日历"],
7+
},
8+
{
9+
category: "sidebar",
10+
keywords: ["侧边栏主题", "侧栏风格", "侧边栏"],
11+
},
12+
{
13+
category: "atcard",
14+
keywords: ["个人名片", "被圈卡片", "圈人卡"],
15+
},
16+
{
17+
category: "homebg",
18+
keywords: ["主页风格", "个人主页"],
19+
},
20+
{
21+
category: "comment",
22+
keywords: ["评论皮肤"],
23+
},
24+
];
25+
26+
function normalizeSkinCategory(category) {
27+
const value = String(category || "").trim();
28+
return SUPPORTED_SKIN_CATEGORIES.includes(value) ? value : "";
29+
}
30+
31+
function resolveMallSkinCategory(good = {}) {
32+
const detail = good.virtual_stock_item_details || {};
33+
const category = normalizeSkinCategory(detail.category);
34+
35+
if (category) {
36+
return category;
37+
}
38+
39+
const text = [good.title, good.subtitle, detail.title, detail.subtitle, detail.goods_describe]
40+
.filter(Boolean)
41+
.join(" ");
42+
const matched = SKIN_CATEGORY_KEYWORDS.find((item) => item.keywords.some((keyword) => text.includes(keyword)));
43+
44+
return matched?.category || "";
45+
}
46+
47+
export { resolveMallSkinCategory };

src/views/vip/mallNew/components/GoodDetail.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import Skeleton from "@/views/vip/mallNew/components/skeleton/index.vue";
8484
import { throttle } from "lodash";
8585
import { __cdn } from "@/utils/config";
8686
import { playAddCartFly } from "@/utils/mallCartFly";
87+
import { resolveMallSkinCategory } from "@/utils/mallDecoration";
8788
export default {
8889
name: "GoodMallDetail",
8990
components: {
@@ -109,7 +110,7 @@ export default {
109110
avatar: "头像框",
110111
emoticon: "表情包",
111112
comment: "评论皮肤",
112-
sidebr: "侧边栏主题",
113+
sidebar: "侧边栏主题",
113114
atcard: "个人名片",
114115
calendar: "首页日历",
115116
homebg: "主页风格",
@@ -122,12 +123,16 @@ export default {
122123
},
123124
goodInfo() {
124125
if (this.good && this.good.category === "virtual") {
125-
if (this.good.sub_category === "skin" && this.good.virtual_stock_item_details) {
126+
if (this.good.sub_category === "skin") {
127+
const category = resolveMallSkinCategory(this.good);
128+
if (!category) {
129+
return {
130+
category: this.good.sub_category,
131+
};
132+
}
126133
return {
127-
category: this.good.virtual_stock_item_details.category,
128-
img:
129-
__cdn +
130-
`design/decoration/images/${this.good.remark}/${this.good.virtual_stock_item_details.category}.png`,
134+
category,
135+
img: __cdn + `design/decoration/images/${this.good.remark}/${category}.png`,
131136
};
132137
}
133138
if (this.good.sub_category === "palu") {

src/views/vip/mallWeb/Detail.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { throttle } from "lodash";
7676
import { __cdn } from "@/utils/config";
7777
import BuyConfirm from "./components/BuyConfirm.vue";
7878
import { playAddCartFly } from "@/utils/mallCartFly";
79+
import { resolveMallSkinCategory } from "@/utils/mallDecoration";
7980
export default {
8081
name: "mall_detail_web",
8182
components: {
@@ -93,7 +94,7 @@ export default {
9394
avatar: "头像框",
9495
emoticon: "表情包",
9596
comment: "评论皮肤",
96-
sidebr: "侧边栏主题",
97+
sidebar: "侧边栏主题",
9798
atcard: "个人名片",
9899
calendar: "首页日历",
99100
homebg: "主页风格",
@@ -107,9 +108,15 @@ export default {
107108
goodInfo() {
108109
if (this.good && this.good.category === "virtual") {
109110
if (this.good.sub_category === "skin") {
111+
const category = resolveMallSkinCategory(this.good);
112+
if (!category) {
113+
return {
114+
category: this.good.sub_category,
115+
};
116+
}
110117
return {
111-
category: this.good.virtual_stock_item_details.category,
112-
img: `https://cdn.jx3box.com/design/decoration/images/${this.good.remark}/${this.good.virtual_stock_item_details.category}.png`,
118+
category,
119+
img: `${__cdn}design/decoration/images/${this.good.remark}/${category}.png`,
113120
};
114121
}
115122
if (this.good.sub_category === "palu") {

src/views/vip/mallWeb/components/GoodDetail.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { throttle } from "lodash";
7676
import { __cdn, __root } from "@/utils/config";
7777
import { playAddCartFly } from "@/utils/mallCartFly";
7878
import { handleMallExchangeError } from "@/utils/mallExchangeError";
79+
import { resolveMallSkinCategory } from "@/utils/mallDecoration";
7980
export default {
8081
name: "GoodWebDetail",
8182
components: {
@@ -96,7 +97,7 @@ export default {
9697
avatar: "头像框",
9798
emoticon: "表情包",
9899
comment: "评论皮肤",
99-
sidebr: "侧边栏主题",
100+
sidebar: "侧边栏主题",
100101
atcard: "个人名片",
101102
calendar: "首页日历",
102103
homebg: "主页风格",
@@ -111,12 +112,16 @@ export default {
111112
112113
goodInfo() {
113114
if (this.good && this.good.category === "virtual") {
114-
if (this.good.sub_category === "skin" && this.good.virtual_stock_item_details) {
115+
if (this.good.sub_category === "skin") {
116+
const category = resolveMallSkinCategory(this.good);
117+
if (!category) {
118+
return {
119+
category: this.good.sub_category,
120+
};
121+
}
115122
return {
116-
category: this.good.virtual_stock_item_details.category,
117-
img:
118-
__cdn +
119-
`design/decoration/images/${this.good.remark}/${this.good.virtual_stock_item_details.category}.png`,
123+
category,
124+
img: __cdn + `design/decoration/images/${this.good.remark}/${category}.png`,
120125
};
121126
}
122127
if (this.good.sub_category === "palu") {

0 commit comments

Comments
 (0)