refactor(merch): 替换硬编码文本为国际化语言包

1.  将商品详情页的"立即咨询"替换为$lang('merch.consultNow')
2.  新增商品相关国际化文案并替换原有硬编码字符串
3.  统一使用多语言函数处理页面文本内容
This commit is contained in:
2026-06-22 18:13:11 +08:00
parent e9483e26e5
commit 1143175990
4 changed files with 26 additions and 19 deletions

View File

@@ -2410,6 +2410,7 @@ export const lang = {
goods: {
piece: "件",
buy: "购买",
yuan: "元",
givePoints: "送{points}积分",
giveDiscountCoupon: "送{num}张{discount}折优惠券",
andGiveDiscountCoupon: "、送{num}张{discount}折优惠券",
@@ -2419,9 +2420,13 @@ export const lang = {
semicolonSpend: ";",
spendLimitFreeShipping: "满{limit}{unit}包邮",
semicolonSpendLimitFreeShipping: ";满{limit}{unit}包邮",
spendLimitMinus: "满{limit}{unit}减{money}元",
semicolonSpendLimitMinus: ";满{limit}{unit}减{money}元",
searchResultCount: "搜索结果共{count}件商品",
insufficientStock: "商品库存不足",
maxBuyLimit: "该商品每人限购{max}{unit}",
couponAlreadyClaimed: "优惠券已领取",
couponClaimSuccess: "领取优惠券成功",
},
// 文章
@@ -2433,6 +2438,7 @@ export const lang = {
merch: {
grounding: "下架",
listing: "上架",
consultNow: "立即咨询",
sameDay: "当日达",
nextDay: "次日达",
dayAfter: "隔日达",
@@ -2445,10 +2451,13 @@ export const lang = {
validDays: "购买后几日有效",
expireDate: "指定过期日期",
addCarmi: "添加卡密",
addCarmiWithCount: "添加卡密【{count}】",
singleLimit: "单次限购",
longLimit: "长期限购",
editGoods: "编辑商品",
addGoods: "添加商品",
selectGoodsForm: "请选择商品表单",
selectSupplier: "请选择供应商",
},
// 配送

View File

@@ -362,7 +362,7 @@ export default {
//获取满减信息
getManjian(data) {
this.manjian = data;
let limit = data.type == 0 ? '元' : '件';
let limit = data.type == 0 ? this.$lang('goods.yuan') : this.$lang('goods.piece');
Object.keys(data.rule_json).forEach((key) => {
var item = data.rule_json[key];
if (item.coupon_data) {
@@ -374,40 +374,40 @@ export default {
// 满减
if (item.discount_money != undefined) {
if (this.manjian.manjian == undefined) {
this.manjian.manjian = '满' + item.limit + limit + '减' + item.discount_money + '元';
this.manjian.manjian = this.$lang('goods.spendLimitMinus', { limit: item.limit, unit: limit, money: item.discount_money });
} else {
this.manjian.manjian += ';满' + item.limit + limit + '减' + item.discount_money + '元';
this.manjian.manjian += this.$lang('goods.semicolonSpendLimitMinus', { limit: item.limit, unit: limit, money: item.discount_money });
}
}
// 满送
if (item.point != undefined || item.coupon != undefined) {
let text = '';
if (item.point != undefined) {
text = '送' + item.point + '积分';
text = this.$lang('goods.givePoints', { points: item.point });
}
if (item.coupon != undefined && item.coupon_data != undefined) {
item.coupon_data.forEach((couponItem, couponIndex) => {
if (couponItem.type == 'discount') {
if (text == '') text = '送' + item.coupon_num[couponIndex] + '张' + parseFloat(couponItem.discount) + '折优惠券';
else text += '、送' + item.coupon_num[couponIndex] + '张' + parseFloat(couponItem.discount) + '折优惠券';
if (text == '') text = this.$lang('goods.giveDiscountCoupon', { num: item.coupon_num[couponIndex], discount: parseFloat(couponItem.discount) });
else text += this.$lang('goods.andGiveDiscountCoupon', { num: item.coupon_num[couponIndex], discount: parseFloat(couponItem.discount) });
} else {
if (text == '') text = '送' + item.coupon_num[couponIndex] + '张' + parseFloat(couponItem.money) + '元优惠券';
else text += '、送' + item.coupon_num[couponIndex] + '张' + parseFloat(couponItem.money) + '元优惠券';
if (text == '') text = this.$lang('goods.giveMoneyCoupon', { num: item.coupon_num[couponIndex], money: parseFloat(couponItem.money) });
else text += this.$lang('goods.andGiveMoneyCoupon', { num: item.coupon_num[couponIndex], money: parseFloat(couponItem.money) });
}
})
}
if (this.manjian.mansong == undefined) {
this.manjian.mansong = '满' + item.limit + limit + text;
this.manjian.mansong = this.$lang('goods.spendLimit', { limit: item.limit, unit: limit }) + text;
} else {
this.manjian.mansong += ';' + '满' + item.limit + limit + text;
this.manjian.mansong += this.$lang('goods.semicolonSpend') + this.$lang('goods.spendLimit', { limit: item.limit, unit: limit }) + text;
}
}
// 包邮
if (item.free_shipping != undefined) {
if (this.manjian.free_shipping == undefined) {
this.manjian.free_shipping = '满' + item.limit + limit + '包邮';
this.manjian.free_shipping = this.$lang('goods.spendLimitFreeShipping', { limit: item.limit, unit: limit });
} else {
this.manjian.free_shipping += ';满' + item.limit + limit + '包邮';
this.manjian.free_shipping += this.$lang('goods.semicolonSpendLimitFreeShipping', { limit: item.limit, unit: limit });
}
}
});

View File

@@ -99,8 +99,7 @@
parseFloat(showPrice(item)).toFixed(2).split('.')[1] }}</text>
</view>
<view class="discount-price" v-else>
<text class="price price-style large">{{ $lang('Make') ? $lang('Make') : '立即咨询'
}}</text>
<text class="price price-style large">{{ $lang('merch.consultNow') }}</text>
</view>
@@ -193,8 +192,7 @@
parseFloat(showPrice(item)).toFixed(2).split('.')[1] }}</text>
</view>
<view class="discount-price" v-else>
<text class="price price-style large">{{ $lang('Make') ? $lang('Make') : '立即咨询'
}}</text>
<text class="price price-style large">{{ $lang('merch.consultNow') }}</text>
</view>
<view class="member-price-tag"
v-if="item.member_price && item.member_price == showPrice(item)">

View File

@@ -530,7 +530,7 @@ export default {
this.goodsData.carmichael = uni.getStorageSync('editGoodsCarmichael') ? JSON.parse(uni.getStorageSync('editGoodsCarmichael')) : [];
if (this.goodsData.carmichael.length > 0) {
this.carmiLength = '添加卡密【' + this.goodsData.carmichael.length + '】'
this.carmiLength = this.$lang('merch.addCarmiWithCount', { count: this.goodsData.carmichael.length })
}
}
@@ -905,7 +905,7 @@ export default {
getGoodsForm() {
getOrderFormList().then(res=>{
if (res.data) {
let goodsForm = ['请选择商品表单'];
let goodsForm = [this.$lang('merch.selectGoodsForm')];
res.data.forEach((item, index) => {
goodsForm.push(item.form_name);
if (this.goodsData.form_id && this.goodsData.form_id == item.id) this.goodsData.goods_form_index = index + 1;
@@ -926,7 +926,7 @@ export default {
getSupplyList() {
getSupplyList().then(res=>{
if (res.data) {
let supplyForm = ['请选择供应商'];
let supplyForm = [this.$lang('merch.selectSupplier')];
res.data.forEach((item, index) => {
supplyForm.push(item.title);
if (this.goodsData.supplier_id && this.goodsData.supplier_id == item.supplier_id) this.goodsData.supply_index = index + 1;