From 4f9a7fea3f2fc4f717341f9a1e7d74a653f73211 Mon Sep 17 00:00:00 2001
From: zhangrenyuan <18990852002@163.com>
Date: Fri, 5 Dec 2025 19:30:15 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E7=BA=A2=E5=8C=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/language/languageTranslate.vue | 0
src/components/locales/lang/zh-CN.js | 3 ++
src/views/consume/gold/addCoinConsume.vue | 51 ++++++++++++++++++++--
3 files changed, 51 insertions(+), 3 deletions(-)
delete mode 100644 d/gold_vue/gold-vue/src/views/language/languageTranslate.vue
diff --git a/d/gold_vue/gold-vue/src/views/language/languageTranslate.vue b/d/gold_vue/gold-vue/src/views/language/languageTranslate.vue
deleted file mode 100644
index e69de29..0000000
diff --git a/src/components/locales/lang/zh-CN.js b/src/components/locales/lang/zh-CN.js
index e7b7d9a..734d19f 100644
--- a/src/components/locales/lang/zh-CN.js
+++ b/src/components/locales/lang/zh-CN.js
@@ -85,6 +85,7 @@ export default {
getTotalFailed: '获取合计数失败,请稍后重试',
payPlatformError: '平台信息格式错误,请联系管理员',
confirmRefund: '确认退款?',
+ limitRedAmount: '红包抵扣额不足',
// 校验精网号,充值等输入
checkInputContent: '请检查输入内容',
permanentAndFreeNoZero: '永久金币和免费金币不能同时为0',
@@ -210,6 +211,7 @@ export default {
rechargeAmount: '充值金额',
currencyName: '货币名称',
goodsName: '商品名称',
+ price: '原价',
goodsNamePlaceholder: '请选择商品',
payModel: '收款方式',
refundType: '退款类型',
@@ -249,6 +251,7 @@ export default {
consumptionTimes: '消费次数',
onlyStatisticsDataAfter20250101: '仅统计2025-01-01后的数据',
store: '所属门店',
+ maxReductionAmount: '红包最大抵扣金额',
},
// 审核组
diff --git a/src/views/consume/gold/addCoinConsume.vue b/src/views/consume/gold/addCoinConsume.vue
index efd152f..784142a 100644
--- a/src/views/consume/gold/addCoinConsume.vue
+++ b/src/views/consume/gold/addCoinConsume.vue
@@ -36,6 +36,7 @@ const user = ref({
jwcode: null,
name: "",
market: "",
+ red: null,
historySumGold: null,
historyPermanentGold: null,
historyFreeGold: null,
@@ -56,6 +57,7 @@ const addConsume = ref({
// jwcode 是数字
jwcode: null, //精网号
goodsName: "",// 商品名称
+ price: null, // 原价
sumGold: null, // 消费金币总数
freeGold: null, // 免费金币
permanentGold: null, // 永久金币
@@ -171,6 +173,24 @@ function validateInput() {
return true;
}
+// 仅在鼠标离开(blur)时校验:消耗金币数 + 红包抵扣金额 ≥ 原价
+function validateRedLimit() {
+ const sumGold = parseFloat(addConsume.value.sumGold);
+ const price = Number(addConsume.value.price || 0);
+ const redMax = Number(user.value.red || 0);
+ if (!isNaN(price) && price > 0) {
+ if (isNaN(sumGold) || sumGold <= 0) {
+ ElMessage.error(t('elmessage.noEmptySumGold'));
+ return false;
+ }
+ if (sumGold + redMax < price) {
+ ElMessage.error(t('elmessage.limitRedAmount'));
+ return false;
+ }
+ }
+ return true;
+}
+
// 消耗金币计算函数
function calculateCoins(sumGold) {
console.log("消耗金币计算函数:计算金币", sumGold);
@@ -240,6 +260,7 @@ const add = async function () {
data: {
jwcode: addConsume.value.jwcode,
adminId: adminData.value.id,
+ price: Number(addConsume.value.price || 0) * 100,
sumGold: addConsume.value.sumGold * 100,
freeGold: addConsume.value.freeGold * 100,
taskGold: addConsume.value.taskGold * 100,
@@ -392,6 +413,9 @@ const addBefore = () => {
});
return;
}
+ if (!validateInput() || !validateRedLimit()) {
+ return;
+ }
ReadCookies.value = `coinConsume:${addConsume.value.jwcode}:${addConsume.value.goodsName.value}`
// 获取cookie
const cookie = Cookies.get(ReadCookies.value)
@@ -491,7 +515,8 @@ const getGoods = async function () {
goods.value = result.data.map(item => ({
id: item.id,
label: item.name,
- value: item.name
+ value: item.name,
+ price: item.price
}));
} catch (error) {
console.log("请求失败", error);
@@ -521,6 +546,18 @@ watch(
}
);
+// 监听商品选择,自动展示原价
+watch(
+ () => addConsume.value.goodsName,
+ (newGoods) => {
+ if (newGoods && typeof newGoods === 'object') {
+ addConsume.value.price = Number(newGoods.price || 0) || null;
+ } else {
+ addConsume.value.price = null;
+ }
+ }
+);
+
/*
====================挂载=================================
*/
@@ -551,10 +588,13 @@ onMounted(async function () {
+
{{ user.market }}
+{{ user.red }}
+