[breaking change] Sku: no longer support i18n (#1734)
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
<van-button
|
||||
v-if="showAddCartBtn"
|
||||
bottom-action
|
||||
:text="$t('cart')"
|
||||
text="加入购物车"
|
||||
@click="skuEventBus.$emit('sku:addCart')"
|
||||
/>
|
||||
<van-button
|
||||
type="primary"
|
||||
bottom-action
|
||||
:text="buyText || $t('buy')"
|
||||
:text="buyText || '立即购买'"
|
||||
@click="skuEventBus.$emit('sku:buy')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
:disabled="!!paddingImg"
|
||||
:after-read="afterReadFile"
|
||||
:max-size="maxSize * 1024 * 1024"
|
||||
@oversize="$toast($t('maxSize', maxSize))"
|
||||
@oversize="onOversize"
|
||||
>
|
||||
<div :class="b('header')">
|
||||
<div v-if="paddingImg">{{ $t('uploading') }}</div>
|
||||
<div v-if="paddingImg">正在上传...</div>
|
||||
<template v-else>
|
||||
<icon name="photograph" />
|
||||
<span class="label">{{ $t(value ? 'rephoto' : 'photo') }}</span> {{ $t('or') }}
|
||||
<span class="label">{{ value ? '重拍' : '拍照' }}</span> 或
|
||||
<icon name="photo" />
|
||||
<span class="label">{{ $t(value ? 'reselect' : 'select') }}</span>
|
||||
<span class="label">{{ value ? '重新选择照片' : '选择照片' }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</van-uploader>
|
||||
@@ -84,6 +84,10 @@ export default create({
|
||||
}).catch(() => {
|
||||
this.paddingImg = '';
|
||||
});
|
||||
},
|
||||
|
||||
onOversize() {
|
||||
this.$toast(`最大可上传图片为${this.maxSize}MB,请尝试压缩图片尺寸`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<cell
|
||||
v-if="message.type === 'image'"
|
||||
:class="b('image-cell')"
|
||||
:label="$t('onePic')"
|
||||
label="仅限一张"
|
||||
:key="`${goodsId}-${index}`"
|
||||
:required="message.required == '1'"
|
||||
:title="message.name"
|
||||
@@ -36,6 +36,16 @@ import validateEmail from '../../utils/validate/email';
|
||||
import validateNumber from '../../utils/validate/number';
|
||||
import SkuImgUploader from './SkuImgUploader';
|
||||
|
||||
const PLACEHOLDER = {
|
||||
id_no: '输入身份证号码',
|
||||
text: '输入文本',
|
||||
tel: '输入数字',
|
||||
email: '输入邮箱',
|
||||
date: '点击选择日期',
|
||||
time: '点击选择时间',
|
||||
textarea: '点击填写段落文本'
|
||||
};
|
||||
|
||||
export default create({
|
||||
name: 'sku-messages',
|
||||
|
||||
@@ -114,7 +124,7 @@ export default create({
|
||||
|
||||
getPlaceholder(message) {
|
||||
const type = +message.multiple === 1 ? 'textarea' : message.type;
|
||||
return this.messagePlaceholderMap[type] || this.$t(`placeholder.${type}`);
|
||||
return this.messagePlaceholderMap[type] || PLACEHOLDER[type];
|
||||
},
|
||||
|
||||
validateMessages() {
|
||||
@@ -128,22 +138,22 @@ export default create({
|
||||
// 必填字段的校验
|
||||
if (message.required == '1') { // eslint-disable-line
|
||||
const textType = message.type === 'image'
|
||||
? 'upload'
|
||||
: 'fill';
|
||||
return this.$t(textType) + message.name;
|
||||
? '请上传'
|
||||
: '请填写';
|
||||
return textType + message.name;
|
||||
}
|
||||
} else {
|
||||
if (message.type === 'tel' && !validateNumber(value)) {
|
||||
return this.$t('number');
|
||||
return '请填写正确的数字格式留言';
|
||||
}
|
||||
if (message.type === 'mobile' && !/^\d{6,20}$/.test(value)) {
|
||||
return this.$t('mobile');
|
||||
return '手机号长度为6-20位数字';
|
||||
}
|
||||
if (message.type === 'email' && !validateEmail(value)) {
|
||||
return this.$t('email');
|
||||
return '请填写正确的邮箱';
|
||||
}
|
||||
if (message.type === 'id_no' && (value.length < 15 || value.length > 18)) {
|
||||
return this.$t('id_no');
|
||||
return '请填写正确的身份证号码';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="van-sku-stepper-stock">
|
||||
<div class="van-sku-stepper-container">
|
||||
<div class="van-sku__stepper-title">{{ stepperTitle || $t('title') }}:</div>
|
||||
<div class="van-sku__stepper-title">{{ stepperTitle || '购买数量' }}:</div>
|
||||
<stepper
|
||||
class="van-sku__stepper"
|
||||
v-model="currentNum"
|
||||
@@ -77,7 +77,7 @@ export default create({
|
||||
const { stockFormatter } = this.customStepperConfig;
|
||||
if (stockFormatter) return stockFormatter(this.stock);
|
||||
|
||||
return this.$t('remain', this.stock);
|
||||
return `剩余${this.stock}件`;
|
||||
},
|
||||
|
||||
quotaText() {
|
||||
@@ -87,7 +87,7 @@ export default create({
|
||||
if (quotaText) {
|
||||
text = quotaText;
|
||||
} else if (this.quota > 0) {
|
||||
text = this.$t('quota', this.quota);
|
||||
text = `每人限购${this.quota}件`;
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
Reference in New Issue
Block a user