优化标签logo无法更换的问题
This commit is contained in:
@@ -233,7 +233,7 @@ import shopExtendApi from "@/api/account/shopExtend";
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tableActive: "",
|
tableActive: "ticket_logo",
|
||||||
tableData: [],
|
tableData: [],
|
||||||
selectItem: {},
|
selectItem: {},
|
||||||
imageUrl: "",
|
imageUrl: "",
|
||||||
@@ -248,7 +248,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 刷新列表数据
|
// 刷新列表数据
|
||||||
async doSubmit() {
|
async doSubmit() {
|
||||||
this.selectItem.value = JSON.stringify(this.imgList)
|
// console.log('this.selectItem.value', this.selectItem.value);
|
||||||
|
// return
|
||||||
|
|
||||||
|
// this.selectItem.value = JSON.stringify(this.imgList)
|
||||||
await shopExtendApi.edit({
|
await shopExtendApi.edit({
|
||||||
...this.selectItem,
|
...this.selectItem,
|
||||||
autokey: this.selectItem.autoKey,
|
autokey: this.selectItem.autoKey,
|
||||||
|
|||||||
@@ -47,9 +47,9 @@
|
|||||||
{{ multiplyAndFormat(scope.row.amount || 0) }}
|
{{ multiplyAndFormat(scope.row.amount || 0) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="积分" prop="accountPoints">
|
<el-table-column label="积分" prop="pointBalance">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ scope.row.accountPoints || 0 }}
|
{{ scope.row.pointBalance || 0 }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="90" fixed="right">
|
<el-table-column label="操作" width="90" fixed="right">
|
||||||
|
|||||||
@@ -439,11 +439,17 @@ async function pointsInit() {
|
|||||||
|
|
||||||
// 保险取值
|
// 保险取值
|
||||||
const eq = pointsConfig?.equivalentPoints || 0;
|
const eq = pointsConfig?.equivalentPoints || 0;
|
||||||
const maxRatio = pointsConfig?.maxDeductionRatio || 0;
|
const rawMaxRatio = pointsConfig?.maxDeductionRatio || 0;
|
||||||
|
// 兼容后端返回的百分比或小数两种形式:如果大于1,则视为百分比(如100表示100%),需除以100
|
||||||
|
const maxRatio = rawMaxRatio > 1 ? rawMaxRatio / 100 : rawMaxRatio;
|
||||||
const minPay = pointsConfig?.minPaymentAmount || 0;
|
const minPay = pointsConfig?.minPaymentAmount || 0;
|
||||||
|
|
||||||
// 计算当前订单可抵扣金额上限(元)
|
// 计算当前订单可抵扣金额上限(元)
|
||||||
|
// 使用“抵扣前实付金额”作为门槛判断(即把当前已应用的积分抵扣金额加回),
|
||||||
|
// 避免在已经抵扣导致 finalPay 变小后错误地判定为不可用。
|
||||||
let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0;
|
let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0;
|
||||||
|
const currentPointDeduction = Number(carts.orderCostSummary.pointDeductionAmount) || 0;
|
||||||
|
const basePay = finalPay + currentPointDeduction;
|
||||||
|
|
||||||
const res = {
|
const res = {
|
||||||
usable: true,
|
usable: true,
|
||||||
@@ -455,8 +461,9 @@ async function pointsInit() {
|
|||||||
unusableReason: "",
|
unusableReason: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 如果订单实付低于最小使用门槛,则不可用
|
// 如果订单实付低于最小使用门槛,则不可用(门槛仅作为启用条件)
|
||||||
if (finalPay <= 0 || (minPay > 0 && finalPay < minPay)) {
|
// 这里使用 basePay(抵扣前实付)进行判断,确保已填写积分后不会回退为不可用
|
||||||
|
if (basePay <= 0 || (minPay > 0 && basePay < minPay)) {
|
||||||
res.usable = false;
|
res.usable = false;
|
||||||
res.unusableReason = `订单实付金额低于 ${minPay} 元,无法使用积分抵扣`;
|
res.unusableReason = `订单实付金额低于 ${minPay} 元,无法使用积分抵扣`;
|
||||||
} else if (eq <= 0) {
|
} else if (eq <= 0) {
|
||||||
@@ -464,23 +471,22 @@ async function pointsInit() {
|
|||||||
res.unusableReason = `积分换算比例配置错误,无法使用积分抵扣`;
|
res.unusableReason = `积分换算比例配置错误,无法使用积分抵扣`;
|
||||||
} else {
|
} else {
|
||||||
// 计算基于比例限制的最大抵扣金额(元)
|
// 计算基于比例限制的最大抵扣金额(元)
|
||||||
let maxByRatio = finalPay * maxRatio;
|
// 注意:此处不再减少 minPaymentAmount,minPaymentAmount 仅用作是否可用的门槛;
|
||||||
// 保证抵扣后剩余金额 >= minPaymentAmount
|
// 真正的最大抵扣由 maxRatio(抵扣比例)与用户积分数量共同决定。
|
||||||
if (minPay > 0) {
|
// 计算基于比例限制的最大抵扣金额(元),基于抵扣前实付金额
|
||||||
const allowed = finalPay - minPay;
|
let maxByRatio = basePay * maxRatio;
|
||||||
if (allowed <= 0) {
|
|
||||||
res.usable = false;
|
|
||||||
res.unusableReason = `抵扣后实付金额必须大于等于 ${minPay} 元,当前不可使用积分`;
|
|
||||||
} else {
|
|
||||||
maxByRatio = Math.min(maxByRatio, allowed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.usable) {
|
if (res.usable) {
|
||||||
// 可用积分上限(向下取整为 eq 的倍数)
|
// 可用积分上限(按等价积分步长对齐到 eq 的倍数)
|
||||||
const maxByMoney = Math.floor(maxByRatio * eq);
|
const maxByMoney = Math.floor(maxByRatio * eq);
|
||||||
const userPoints = carts.vipUser.pointBalance || 0;
|
const userPoints = carts.vipUser.pointBalance || 0;
|
||||||
res.maxUsablePoints = Math.min(userPoints, maxByMoney);
|
let computedMax = Math.min(userPoints, maxByMoney);
|
||||||
|
// 对齐到等价积分步长,保证输入步长生效
|
||||||
|
if (eq > 0) {
|
||||||
|
computedMax = Math.floor(computedMax / eq) * eq;
|
||||||
|
}
|
||||||
|
res.maxUsablePoints = computedMax;
|
||||||
|
console.debug("pointsInit debug:", { finalPay: finalPay, basePay: basePay, eq, rawMaxRatio, maxRatio, maxByMoney, userPoints, computedMax });
|
||||||
// 最小抵扣积分为配置值或等于换算比
|
// 最小抵扣积分为配置值或等于换算比
|
||||||
res.minDeductionPoints = pointsConfig?.minDeductionPoints || eq;
|
res.minDeductionPoints = pointsConfig?.minDeductionPoints || eq;
|
||||||
if (res.maxUsablePoints < res.minDeductionPoints) {
|
if (res.maxUsablePoints < res.minDeductionPoints) {
|
||||||
@@ -498,8 +504,20 @@ async function pointsInit() {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果可用则默认填充可用最大值,否则清零
|
// 如果可用则默认填充可用最大值(对齐步长),否则清零
|
||||||
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
|
if (res.usable) {
|
||||||
|
// 计算默认填充值:基于抵扣前实付的比例上限与等价比计算需要的积分数
|
||||||
|
const defaultMaxByMoney = Math.floor(basePay * res.maxDeductionRatio * res.equivalentPoints);
|
||||||
|
let defaultPts = Math.min(res.maxUsablePoints || 0, defaultMaxByMoney || 0);
|
||||||
|
if (res.equivalentPoints > 0) {
|
||||||
|
defaultPts = Math.floor(defaultPts / res.equivalentPoints) * res.equivalentPoints;
|
||||||
|
}
|
||||||
|
// 最终确保不超过用户积分
|
||||||
|
const userPts = carts.vipUser.pointBalance || 0;
|
||||||
|
usePointsNumber.value = Math.min(defaultPts, userPts);
|
||||||
|
} else {
|
||||||
|
usePointsNumber.value = 0;
|
||||||
|
}
|
||||||
if (!res.usable) score.sel = -1;
|
if (!res.usable) score.sel = -1;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -532,17 +550,15 @@ function pointsToMoney(val) {
|
|||||||
// 再次校验不超过允许的最大抵扣金额(基于比例或门槛)
|
// 再次校验不超过允许的最大抵扣金额(基于比例或门槛)
|
||||||
let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0;
|
let finalPay = Number(carts.orderCostSummary.finalPayAmount) || 0;
|
||||||
let maxByRatio = finalPay * cfg.maxDeductionRatio;
|
let maxByRatio = finalPay * cfg.maxDeductionRatio;
|
||||||
if (cfg.minPaymentAmount > 0) {
|
// 对于单笔抵扣:若订单实付低于配置的最小门槛,则不可使用(作为启用条件)
|
||||||
const allowed = finalPay - cfg.minPaymentAmount;
|
if (cfg.minPaymentAmount > 0 && finalPay < cfg.minPaymentAmount) {
|
||||||
if (allowed <= 0) {
|
|
||||||
usePointsNumber.value = 0;
|
usePointsNumber.value = 0;
|
||||||
carts.orderCostSummary.pointUsed = 0;
|
carts.orderCostSummary.pointUsed = 0;
|
||||||
carts.orderCostSummary.pointDeductionAmount = 0;
|
carts.orderCostSummary.pointDeductionAmount = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maxByRatio = Math.min(maxByRatio, allowed);
|
|
||||||
}
|
|
||||||
const maxAllowedMoney = new BigNumber(maxByRatio).decimalPlaces(2, BigNumber.ROUND_DOWN).toNumber();
|
const maxAllowedMoney = new BigNumber(maxByRatio).decimalPlaces(2, BigNumber.ROUND_DOWN).toNumber();
|
||||||
|
console.debug("pointsToMoney debug:", { finalPay, cfg, pts, money, maxByRatio, maxAllowedMoney });
|
||||||
if (money > maxAllowedMoney) {
|
if (money > maxAllowedMoney) {
|
||||||
// 调整积分到允许的最大金额对应的积分
|
// 调整积分到允许的最大金额对应的积分
|
||||||
const allowedPts = Math.floor(maxAllowedMoney * cfg.equivalentPoints);
|
const allowedPts = Math.floor(maxAllowedMoney * cfg.equivalentPoints);
|
||||||
@@ -858,9 +874,13 @@ defineExpose({
|
|||||||
.order-info {
|
.order-info {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
.title {}
|
.title {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.value {}
|
.value {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.price {
|
.price {
|
||||||
color: #fa5555;
|
color: #fa5555;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ const contentConfig: IContentConfig<any> = {
|
|||||||
{
|
{
|
||||||
label: "消费次数累计",
|
label: "消费次数累计",
|
||||||
align: "center",
|
align: "center",
|
||||||
prop: "consumeAmount",
|
prop: "consumeCount",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "注册时间",
|
label: "注册时间",
|
||||||
|
|||||||
Reference in New Issue
Block a user