feat: 会员等级配置
This commit is contained in:
parent
1a9c11f4ca
commit
919ec0710b
|
@ -263,11 +263,7 @@
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column prop="taskDesc" label="任务描述" align="center">
|
||||||
prop="taskDescription"
|
|
||||||
label="任务描述"
|
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="是否启用" width="100" align="center">
|
<el-table-column label="是否启用" width="100" align="center">
|
||||||
<template slot-scope="scope">
|
<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() {
|
handleEditSignIn() {
|
||||||
this.showSignInDialog = true;
|
this.showSignInDialog = true;
|
||||||
// 如果没有记录ID,设置默认值
|
// 如果配置为空或未配置,设置默认值
|
||||||
if (!this.recordId) {
|
if (this.isTaskConfigEmpty(this.dailySignSettings)) {
|
||||||
this.dailySignSettings.taskConfigDetail = {
|
this.dailySignSettings.taskConfigDetail = {
|
||||||
oneDay: 1,
|
oneDay: 1,
|
||||||
twoDay: 2,
|
twoDay: 2,
|
||||||
|
@ -1313,8 +1356,8 @@ export default {
|
||||||
|
|
||||||
handleEditBrowse() {
|
handleEditBrowse() {
|
||||||
this.showBrowseDialog = true;
|
this.showBrowseDialog = true;
|
||||||
// 如果没有记录ID,设置默认值
|
// 如果配置为空或未配置,设置默认值
|
||||||
if (!this.recordId) {
|
if (this.isTaskConfigEmpty(this.viewGoodsSettings)) {
|
||||||
this.viewGoodsSettings.taskConfigDetail = {
|
this.viewGoodsSettings.taskConfigDetail = {
|
||||||
oneGoodsViewPoints: 1,
|
oneGoodsViewPoints: 1,
|
||||||
enableDailyPointsLimit: true,
|
enableDailyPointsLimit: true,
|
||||||
|
@ -1325,8 +1368,8 @@ export default {
|
||||||
|
|
||||||
handleEditPurchase() {
|
handleEditPurchase() {
|
||||||
this.showPurchaseDialog = true;
|
this.showPurchaseDialog = true;
|
||||||
// 如果没有记录ID,设置默认值
|
// 如果配置为空或未配置,设置默认值
|
||||||
if (!this.recordId) {
|
if (this.isTaskConfigEmpty(this.buyGoodsSettings)) {
|
||||||
this.buyGoodsSettings.taskConfigDetail = {
|
this.buyGoodsSettings.taskConfigDetail = {
|
||||||
pointsRatioAmount: 1,
|
pointsRatioAmount: 1,
|
||||||
enableDailyPointsLimit: true,
|
enableDailyPointsLimit: true,
|
||||||
|
@ -1337,8 +1380,8 @@ export default {
|
||||||
|
|
||||||
handleEditShare() {
|
handleEditShare() {
|
||||||
this.showShareDialog = true;
|
this.showShareDialog = true;
|
||||||
// 如果没有记录ID,设置默认值
|
// 如果配置为空或未配置,设置默认值
|
||||||
if (!this.recordId) {
|
if (this.isTaskConfigEmpty(this.shareGoodsSettings)) {
|
||||||
this.shareGoodsSettings.taskConfigDetail = {
|
this.shareGoodsSettings.taskConfigDetail = {
|
||||||
oneSharePoints: 5,
|
oneSharePoints: 5,
|
||||||
enableDailyPointsLimit: true,
|
enableDailyPointsLimit: true,
|
||||||
|
@ -1349,8 +1392,8 @@ export default {
|
||||||
|
|
||||||
handleEditReview() {
|
handleEditReview() {
|
||||||
this.showReviewDialog = true;
|
this.showReviewDialog = true;
|
||||||
// 如果没有记录ID,设置默认值
|
// 如果配置为空或未配置,设置默认值
|
||||||
if (!this.recordId) {
|
if (this.isTaskConfigEmpty(this.commentGoodsSettings)) {
|
||||||
this.commentGoodsSettings.taskConfigDetail = {
|
this.commentGoodsSettings.taskConfigDetail = {
|
||||||
textCommentPoints: 3,
|
textCommentPoints: 3,
|
||||||
imageTextCommentPoints: 5,
|
imageTextCommentPoints: 5,
|
||||||
|
@ -1399,26 +1442,96 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
saveSignInForm() {
|
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.showSignInDialog = false;
|
||||||
// this.$message.success("每日签到设置已更新");
|
// this.$message.success("每日签到设置已更新");
|
||||||
},
|
},
|
||||||
|
|
||||||
saveBrowseForm() {
|
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.showBrowseDialog = false;
|
||||||
// this.$message.success("浏览商品设置已更新");
|
// this.$message.success("浏览商品设置已更新");
|
||||||
},
|
},
|
||||||
|
|
||||||
savePurchaseForm() {
|
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.showPurchaseDialog = false;
|
||||||
// this.$message.success("购买商品设置已更新");
|
// this.$message.success("购买商品设置已更新");
|
||||||
},
|
},
|
||||||
|
|
||||||
saveShareForm() {
|
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.showShareDialog = false;
|
||||||
// this.$message.success("分享商品设置已更新");
|
// this.$message.success("分享商品设置已更新");
|
||||||
},
|
},
|
||||||
|
|
||||||
saveReviewForm() {
|
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.showReviewDialog = false;
|
||||||
// this.$message.success("评价商品设置已更新");
|
// this.$message.success("评价商品设置已更新");
|
||||||
},
|
},
|
||||||
|
@ -1453,6 +1566,108 @@ export default {
|
||||||
LV4: "#f5222d"
|
LV4: "#f5222d"
|
||||||
};
|
};
|
||||||
return colorMap[levelName] || "#666";
|
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: {
|
computed: {
|
||||||
|
@ -1463,32 +1678,32 @@ export default {
|
||||||
"marketId"
|
"marketId"
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// 积分任务数据,固定任务描述,开启状态从设置对象中获取
|
// 积分任务数据,优先使用编辑弹框中配置的数据进行生成展示
|
||||||
pointsTaskData() {
|
pointsTaskData() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
taskName: "每日签到",
|
taskName: "每日签到",
|
||||||
taskDescription: "第一天签到1分,第二天2分,第三天3分,连续7天10分",
|
taskDesc: this.generateDailySignDescription(),
|
||||||
isEnabled: this.dailySignSettings.taskEnable
|
isEnabled: this.dailySignSettings.taskEnable
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
taskName: "浏览商品",
|
taskName: "浏览商品",
|
||||||
taskDescription: "浏览一个商品获得1分,每天最多获得2分",
|
taskDesc: this.generateViewGoodsDescription(),
|
||||||
isEnabled: this.viewGoodsSettings.taskEnable
|
isEnabled: this.viewGoodsSettings.taskEnable
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
taskName: "购买商品",
|
taskName: "购买商品",
|
||||||
taskDescription: "购买1元=1分,每天最多获得500分",
|
taskDesc: this.generateBuyGoodsDescription(),
|
||||||
isEnabled: this.buyGoodsSettings.taskEnable
|
isEnabled: this.buyGoodsSettings.taskEnable
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
taskName: "分享商品",
|
taskName: "分享商品",
|
||||||
taskDescription: "分享一个商品获得5分,每天最多获得3次",
|
taskDesc: this.generateShareGoodsDescription(),
|
||||||
isEnabled: this.shareGoodsSettings.taskEnable
|
isEnabled: this.shareGoodsSettings.taskEnable
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
taskName: "评价商品",
|
taskName: "评价商品",
|
||||||
taskDescription: "评价一个商品获得3分,每天最多获得5次",
|
taskDesc: this.generateCommentGoodsDescription(),
|
||||||
isEnabled: this.commentGoodsSettings.taskEnable
|
isEnabled: this.commentGoodsSettings.taskEnable
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue