refactor: 替换项目中硬编码文本为多语言配置
将多处页面和组件内的硬编码文字替换为国际化语言包调用,包括空状态提示、按钮文案、表单占位符、弹窗标题等内容,统一项目多语言管理
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<view :class="['box', 'align-left']" :style="item._boxAlignStyle">
|
||||
<input
|
||||
type="text"
|
||||
:placeholder="item.value.placeholder || '请输入提示语'"
|
||||
:placeholder="item.value.placeholder || $lang('form.inputPlaceholder')"
|
||||
placeholder-class="placeholder color-tip"
|
||||
v-model="item.val"
|
||||
/>
|
||||
@@ -28,7 +28,7 @@
|
||||
</view>
|
||||
<view :class="['box', 'align-left']" :style="item._boxAlignStyle">
|
||||
<textarea
|
||||
:placeholder="item.value.placeholder || '请输入提示语'"
|
||||
:placeholder="item.value.placeholder || $lang('form.inputPlaceholder')"
|
||||
placeholder-class="placeholder color-tip"
|
||||
v-model="item.val"
|
||||
></textarea>
|
||||
@@ -50,7 +50,7 @@
|
||||
</view>
|
||||
<view :class="['box', 'box-flex', 'align-right']">
|
||||
<text v-if="item.val != ''">{{ item.val }}</text>
|
||||
<text v-else class="color-tip">{{ item.value.placeholder || '请选择' }}</text>
|
||||
<text v-else class="color-tip">{{ item.value.placeholder || $lang('form.selectPlaceholder') }}</text>
|
||||
<text class="iconfont icon-right"></text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -146,7 +146,7 @@
|
||||
@change="bindDateChange($event, index)"
|
||||
>
|
||||
<view :class="['uni-input', !item.val ? 'color-tip' : '']">
|
||||
{{ item.val ? item.val : (item.value.placeholder || '请选择日期') }}
|
||||
{{ item.val ? item.val : (item.value.placeholder || $lang('form.selectDate')) }}
|
||||
</view>
|
||||
</picker>
|
||||
<text class="iconfont icon-right"></text>
|
||||
@@ -170,7 +170,7 @@
|
||||
>
|
||||
<view class="picker-box">
|
||||
<view :class="['uni-input', !item.start_date ? 'color-tip' : '']">
|
||||
{{ item.start_date ? item.start_date : (item.value.placeholder_start || '开始日期') }}
|
||||
{{ item.start_date ? item.start_date : (item.value.placeholder_start || $lang('form.startDate')) }}
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
@@ -184,7 +184,7 @@
|
||||
>
|
||||
<view class="picker-box">
|
||||
<view :class="['uni-input', !item.end_date ? 'color-tip' : '']">
|
||||
{{ item.end_date ? item.end_date : (item.value.placeholder_end || '结束日期') }}
|
||||
{{ item.end_date ? item.end_date : (item.value.placeholder_end || $lang('form.endDate')) }}
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
@@ -207,7 +207,7 @@
|
||||
@change="bindTimeChange($event, index)"
|
||||
>
|
||||
<view :class="['uni-input', !item.val ? 'color-tip' : '']">
|
||||
{{ item.val ? item.val : (item.value.placeholder || '请选择时间') }}
|
||||
{{ item.val ? item.val : (item.value.placeholder || $lang('form.selectTime')) }}
|
||||
</view>
|
||||
</picker>
|
||||
<text class="iconfont icon-right"></text>
|
||||
@@ -231,7 +231,7 @@
|
||||
>
|
||||
<view class="picker-box">
|
||||
<view :class="['uni-input', !item.start_time ? 'color-tip' : '']">
|
||||
{{ item.start_time ? item.start_time : (item.value.placeholder_start || '开始时间') }}
|
||||
{{ item.start_time ? item.start_time : (item.value.placeholder_start || $lang('form.startTime')) }}
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
@@ -245,7 +245,7 @@
|
||||
>
|
||||
<view class="picker-box">
|
||||
<view :class="['uni-input', !item.end_time ? 'color-tip' : '']">
|
||||
{{ item.end_time ? item.end_time : (item.value.placeholder_end || '结束时间') }}
|
||||
{{ item.end_time ? item.end_time : (item.value.placeholder_end || $lang('form.endTime')) }}
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
@@ -268,7 +268,7 @@
|
||||
@getRegions="handleGetRegions($event, index)"
|
||||
>
|
||||
<view :class="['select-address', !item.val ? 'empty' : '', !item.val ? 'color-tip' : '']">
|
||||
{{ item.val ? item.val : (item.value.placeholder || (item.value.default_type == 1 ? '请选择省市' : '请选择省市区')) }}
|
||||
{{ item.val ? item.val : (item.value.placeholder || (item.value.default_type == 1 ? $lang('form.selectProvinceCity') : $lang('form.selectProvinceCityDistrict'))) }}
|
||||
</view>
|
||||
</pick-regions>
|
||||
<text class="iconfont icon-right"></text>
|
||||
@@ -788,89 +788,89 @@ export default {
|
||||
|
||||
if (item.controller == 'Text') {
|
||||
if (item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请输入' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.inputRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.name == 'ID_CARD' && !/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(item.val)) {
|
||||
if (!item.value.required) {
|
||||
this.$util.showToast({ title: '身份证输入不合法' });
|
||||
this.$util.showToast({ title: this.$lang('form.idCardInvalid') });
|
||||
return false;
|
||||
}
|
||||
if (item.val != '') {
|
||||
this.$util.showToast({ title: '身份证输入不合法' });
|
||||
this.$util.showToast({ title: this.$lang('form.idCardInvalid') });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.name == 'MOBILE' && !this.$util.verifyMobile(item.val)) {
|
||||
if (!item.value.required) {
|
||||
this.$util.showToast({ title: '手机号输入不合法' });
|
||||
this.$util.showToast({ title: this.$lang('form.phoneInvalid') });
|
||||
return false;
|
||||
}
|
||||
if (item.val != '') {
|
||||
this.$util.showToast({ title: '手机号输入不合法' });
|
||||
this.$util.showToast({ title: this.$lang('form.phoneInvalid') });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.controller == 'Textarea' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请输入' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.inputRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Select' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Checkbox' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请至少选择一个' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectAtLeastOne') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Img' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请至少上传一张' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.uploadAtLeastOne') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Date' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Datelimit') {
|
||||
if (item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.$util.timeTurnTimeStamp(item.start_date) > this.$util.timeTurnTimeStamp(item.end_date)) {
|
||||
this.$util.showToast({ title: '结束日期不能小于开始日期' });
|
||||
this.$util.showToast({ title: this.$lang('form.endDateBeforeStart') });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.controller == 'Time' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.controller == 'Timelimit') {
|
||||
if (item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.start_time >= item.end_time) {
|
||||
this.$util.showToast({ title: '结束时间必须大于开始时间' });
|
||||
this.$util.showToast({ title: this.$lang('form.endTimeBeforeStart') });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.controller == 'City' && item.value.required && !item.val) {
|
||||
this.$util.showToast({ title: '请选择' + item.value.title });
|
||||
this.$util.showToast({ title: this.$lang('form.selectRequired') + item.value.title });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -902,7 +902,7 @@ export default {
|
||||
if (res.length > 0) {
|
||||
res.forEach(function(img) {
|
||||
if (self.formData[index].img_lists.length >= Number(self.formData[index].value.max_count)) {
|
||||
self.$util.showToast({ title: '最多上传' + self.formData[index].value.max_count + '张图片' });
|
||||
self.$util.showToast({ title: this.$lang('form.maxUploadImages') + self.formData[index].value.max_count + this.$lang('form.images') });
|
||||
return false;
|
||||
}
|
||||
self.formData[index].img_lists.push(img);
|
||||
@@ -916,7 +916,7 @@ export default {
|
||||
addImg(index) {
|
||||
let self = this;
|
||||
if (this.formData[index].img_lists.length >= Number(this.formData[index].value.max_count)) {
|
||||
this.$util.showToast({ title: '最多上传' + this.formData[index].value.max_count + '张图片' });
|
||||
this.$util.showToast({ title: this.$lang('form.maxUploadImages') + this.formData[index].value.max_count + this.$lang('form.images') });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user