Browse Source

feat: 红包

huangqizheng/feature-20251213090502-现金退款多语言
zhangrenyuan 1 month ago
parent
commit
4f9a7fea3f
  1. 0
      d/gold_vue/gold-vue/src/views/language/languageTranslate.vue
  2. 3
      src/components/locales/lang/zh-CN.js
  3. 51
      src/views/consume/gold/addCoinConsume.vue

0
d/gold_vue/gold-vue/src/views/language/languageTranslate.vue

3
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: '红包最大抵扣金额',
},
// 审核组

51
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 () {
</el-select>
</el-form-item>
<el-form-item prop="price" :label="t('common_add.price')">
<el-input v-model="addConsume.price" style="width: 120px" disabled />
</el-form-item>
<el-form-item prop="sumGold" :label="t('common_add.consumeTotalGold')">
<el-input v-model="addConsume.sumGold" style="width: 120px" @input="validateInput()"
@change="calculateCoins(addConsume.sumGold)" />
<el-input v-model="addConsume.sumGold" style="width: 120px"
@blur="validateRedLimit()" />
</el-form-item>
@ -659,6 +699,11 @@ onMounted(async function () {
<p>{{ user.market }}</p>
</el-form-item>
</el-col>
<el-col :span="14">
<el-form-item :label="$t('common_add_user.maxReductionAmount')">
<p style="color: #2fa1ff">{{ user.red }} </p>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>

Loading…
Cancel
Save