feat: 会员等级配置

This commit is contained in:
lzhizhao 2025-08-09 22:34:23 +08:00
parent 1a9c11f4ca
commit 919ec0710b
1 changed files with 236 additions and 21 deletions

View File

@ -263,11 +263,7 @@
align="center"
>
</el-table-column>
<el-table-column
prop="taskDescription"
label="任务描述"
align="center"
>
<el-table-column prop="taskDesc" label="任务描述" align="center">
</el-table-column>
<el-table-column label="是否启用" width="100" align="center">
<template slot-scope="scope">
@ -1294,11 +1290,58 @@ export default {
};
},
//
isTaskConfigEmpty(taskSettings) {
if (!taskSettings || !taskSettings.taskConfigDetail) {
return true;
}
const config = taskSettings.taskConfigDetail;
// 0
//
if (config.hasOwnProperty("oneDay")) {
return (
!config.oneDay &&
!config.twoDay &&
!config.threeDay &&
!config.fourDay &&
!config.fiveDay &&
!config.sixDay &&
!config.sevenDay
);
}
//
if (config.hasOwnProperty("oneGoodsViewPoints")) {
return !config.oneGoodsViewPoints;
}
//
if (config.hasOwnProperty("pointsRatioAmount")) {
return !config.pointsRatioAmount;
}
//
if (config.hasOwnProperty("oneSharePoints")) {
return !config.oneSharePoints;
}
//
if (config.hasOwnProperty("textCommentPoints")) {
return !config.textCommentPoints && !config.imageTextCommentPoints;
}
// 0
const values = Object.values(config);
return values.every(value => !value || value === 0);
},
//
handleEditSignIn() {
this.showSignInDialog = true;
// ID
if (!this.recordId) {
//
if (this.isTaskConfigEmpty(this.dailySignSettings)) {
this.dailySignSettings.taskConfigDetail = {
oneDay: 1,
twoDay: 2,
@ -1313,8 +1356,8 @@ export default {
handleEditBrowse() {
this.showBrowseDialog = true;
// ID
if (!this.recordId) {
//
if (this.isTaskConfigEmpty(this.viewGoodsSettings)) {
this.viewGoodsSettings.taskConfigDetail = {
oneGoodsViewPoints: 1,
enableDailyPointsLimit: true,
@ -1325,8 +1368,8 @@ export default {
handleEditPurchase() {
this.showPurchaseDialog = true;
// ID
if (!this.recordId) {
//
if (this.isTaskConfigEmpty(this.buyGoodsSettings)) {
this.buyGoodsSettings.taskConfigDetail = {
pointsRatioAmount: 1,
enableDailyPointsLimit: true,
@ -1337,8 +1380,8 @@ export default {
handleEditShare() {
this.showShareDialog = true;
// ID
if (!this.recordId) {
//
if (this.isTaskConfigEmpty(this.shareGoodsSettings)) {
this.shareGoodsSettings.taskConfigDetail = {
oneSharePoints: 5,
enableDailyPointsLimit: true,
@ -1349,8 +1392,8 @@ export default {
handleEditReview() {
this.showReviewDialog = true;
// ID
if (!this.recordId) {
//
if (this.isTaskConfigEmpty(this.commentGoodsSettings)) {
this.commentGoodsSettings.taskConfigDetail = {
textCommentPoints: 3,
imageTextCommentPoints: 5,
@ -1399,26 +1442,96 @@ export default {
},
saveSignInForm() {
//
const taskDesc = this.generateDailySignDescription();
this.dailySignSettings.taskDesc = taskDesc;
// editPointsTaskData
if (this.editPointsTaskData && this.editPointsTaskData.length > 0) {
const task = this.editPointsTaskData.find(
t => t.taskName === "每日签到"
);
if (task) {
task.taskDesc = taskDesc;
}
}
this.showSignInDialog = false;
// this.$message.success("");
},
saveBrowseForm() {
//
const taskDesc = this.generateViewGoodsDescription();
this.viewGoodsSettings.taskDesc = taskDesc;
// editPointsTaskData
if (this.editPointsTaskData && this.editPointsTaskData.length > 0) {
const task = this.editPointsTaskData.find(
t => t.taskName === "浏览商品"
);
if (task) {
task.taskDesc = taskDesc;
}
}
this.showBrowseDialog = false;
// this.$message.success("");
},
savePurchaseForm() {
//
const taskDesc = this.generateBuyGoodsDescription();
this.buyGoodsSettings.taskDesc = taskDesc;
// editPointsTaskData
if (this.editPointsTaskData && this.editPointsTaskData.length > 0) {
const task = this.editPointsTaskData.find(
t => t.taskName === "购买商品"
);
if (task) {
task.taskDesc = taskDesc;
}
}
this.showPurchaseDialog = false;
// this.$message.success("");
},
saveShareForm() {
//
const taskDesc = this.generateShareGoodsDescription();
this.shareGoodsSettings.taskDesc = taskDesc;
// editPointsTaskData
if (this.editPointsTaskData && this.editPointsTaskData.length > 0) {
const task = this.editPointsTaskData.find(
t => t.taskName === "分享商品"
);
if (task) {
task.taskDesc = taskDesc;
}
}
this.showShareDialog = false;
// this.$message.success("");
},
saveReviewForm() {
//
const taskDesc = this.generateCommentGoodsDescription();
this.commentGoodsSettings.taskDesc = taskDesc;
// editPointsTaskData
if (this.editPointsTaskData && this.editPointsTaskData.length > 0) {
const task = this.editPointsTaskData.find(
t => t.taskName === "评价商品"
);
if (task) {
task.taskDesc = taskDesc;
}
}
this.showReviewDialog = false;
// this.$message.success("");
},
@ -1453,6 +1566,108 @@ export default {
LV4: "#f5222d"
};
return colorMap[levelName] || "#666";
},
//
generateDailySignDescription() {
const config = this.dailySignSettings.taskConfigDetail;
if (
!config ||
(!config.oneDay &&
!config.twoDay &&
!config.threeDay &&
!config.fourDay &&
!config.fiveDay &&
!config.sixDay &&
!config.sevenDay)
) {
return "-";
}
const descriptions = [];
if (config.oneDay) descriptions.push(`第一天签到${config.oneDay}`);
if (config.twoDay) descriptions.push(`第二天${config.twoDay}`);
if (config.threeDay) descriptions.push(`第三天${config.threeDay}`);
if (config.fourDay) descriptions.push(`第四天${config.fourDay}`);
if (config.fiveDay) descriptions.push(`第五天${config.fiveDay}`);
if (config.sixDay) descriptions.push(`第六天${config.sixDay}`);
if (config.sevenDay) descriptions.push(`连续7天${config.sevenDay}`);
return descriptions.length > 0 ? descriptions.join("") : "-";
},
//
generateViewGoodsDescription() {
const config = this.viewGoodsSettings.taskConfigDetail;
if (!config || !config.oneGoodsViewPoints) {
return "-";
}
let description = `浏览一个商品获得${config.oneGoodsViewPoints}`;
if (config.enableDailyPointsLimit && config.dailyPointsLimit) {
description += `,每天最多获得${config.dailyPointsLimit}`;
}
return description;
},
//
generateBuyGoodsDescription() {
const config = this.buyGoodsSettings.taskConfigDetail;
if (!config || !config.pointsRatioAmount) {
return "-";
}
let description = `购买${config.pointsRatioAmount}元=1分`;
if (config.enableDailyPointsLimit && config.dailyPointsLimit) {
description += `,每天最多获得${config.dailyPointsLimit}`;
}
return description;
},
//
generateShareGoodsDescription() {
const config = this.shareGoodsSettings.taskConfigDetail;
if (!config || !config.oneSharePoints) {
return "-";
}
let description = `分享一个商品获得${config.oneSharePoints}`;
if (config.enableDailyPointsLimit && config.dailyPointsLimit) {
const maxTimes = Math.floor(
config.dailyPointsLimit / config.oneSharePoints
);
description += `,每天最多获得${maxTimes}`;
}
return description;
},
//
generateCommentGoodsDescription() {
const config = this.commentGoodsSettings.taskConfigDetail;
if (
!config ||
(!config.textCommentPoints && !config.imageTextCommentPoints)
) {
return "-";
}
const descriptions = [];
if (config.textCommentPoints) {
descriptions.push(`文字评价获得${config.textCommentPoints}`);
}
if (config.imageTextCommentPoints) {
descriptions.push(`图文评价获得${config.imageTextCommentPoints}`);
}
let description = descriptions.join("");
if (config.enableDailyPointsLimit && config.dailyPointsLimit) {
description += `,每天最多获得${config.dailyPointsLimit}`;
}
return description;
}
},
computed: {
@ -1463,32 +1678,32 @@ export default {
"marketId"
]),
//
// 使
pointsTaskData() {
return [
{
taskName: "每日签到",
taskDescription: "第一天签到1分第二天2分第三天3分连续7天10分",
taskDesc: this.generateDailySignDescription(),
isEnabled: this.dailySignSettings.taskEnable
},
{
taskName: "浏览商品",
taskDescription: "浏览一个商品获得1分每天最多获得2分",
taskDesc: this.generateViewGoodsDescription(),
isEnabled: this.viewGoodsSettings.taskEnable
},
{
taskName: "购买商品",
taskDescription: "购买1元=1分每天最多获得500分",
taskDesc: this.generateBuyGoodsDescription(),
isEnabled: this.buyGoodsSettings.taskEnable
},
{
taskName: "分享商品",
taskDescription: "分享一个商品获得5分每天最多获得3次",
taskDesc: this.generateShareGoodsDescription(),
isEnabled: this.shareGoodsSettings.taskEnable
},
{
taskName: "评价商品",
taskDescription: "评价一个商品获得3分每天最多获得5次",
taskDesc: this.generateCommentGoodsDescription(),
isEnabled: this.commentGoodsSettings.taskEnable
}
];