mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: prettier js codes
This commit is contained in:
parent
2adcfd8b8b
commit
1e864a445f
@ -112,12 +112,12 @@ export default createComponent({
|
||||
|
||||
if (this.placeholderMap[type] && result.length) {
|
||||
// set columns placeholder
|
||||
const codeFill =
|
||||
type === 'province'
|
||||
? ''
|
||||
: type === 'city'
|
||||
? PLACEHOLDER_CODE.slice(2, 4)
|
||||
: PLACEHOLDER_CODE.slice(4, 6);
|
||||
let codeFill = '';
|
||||
if (type === 'city') {
|
||||
codeFill = PLACEHOLDER_CODE.slice(2, 4);
|
||||
} else if (type === 'county') {
|
||||
codeFill = PLACEHOLDER_CODE.slice(4, 6);
|
||||
}
|
||||
|
||||
result.unshift({
|
||||
code: `${code}${codeFill}`,
|
||||
|
@ -4,16 +4,21 @@ import { CheckboxMixin } from '../mixins/checkbox';
|
||||
const [createComponent, bem] = createNamespace('checkbox');
|
||||
|
||||
export default createComponent({
|
||||
mixins: [CheckboxMixin({
|
||||
bem,
|
||||
role: 'checkbox',
|
||||
parent: 'vanCheckbox',
|
||||
})],
|
||||
mixins: [
|
||||
CheckboxMixin({
|
||||
bem,
|
||||
role: 'checkbox',
|
||||
parent: 'vanCheckbox',
|
||||
}),
|
||||
],
|
||||
|
||||
computed: {
|
||||
checked: {
|
||||
get() {
|
||||
return this.parent ? this.parent.value.indexOf(this.name) !== -1 : this.value;
|
||||
if (this.parent) {
|
||||
return this.parent.value.indexOf(this.name) !== -1;
|
||||
}
|
||||
return this.value;
|
||||
},
|
||||
|
||||
set(val) {
|
||||
|
@ -106,9 +106,10 @@ export default createComponent({
|
||||
}
|
||||
|
||||
const { parent, currentName } = this;
|
||||
const name = parent.accordion && currentName === parent.value ? '' : currentName;
|
||||
const close = parent.accordion && currentName === parent.value;
|
||||
const name = close ? '' : currentName;
|
||||
|
||||
this.parent.switch(name, !this.expanded);
|
||||
parent.switch(name, !this.expanded);
|
||||
},
|
||||
|
||||
onTransitionEnd() {
|
||||
|
@ -182,7 +182,10 @@ export default createComponent({
|
||||
|
||||
const CouponTab = (
|
||||
<Tab title={title}>
|
||||
<div class={bem('list', { 'with-bottom': this.showCloseButton })} style={this.listStyle}>
|
||||
<div
|
||||
class={bem('list', { 'with-bottom': this.showCloseButton })}
|
||||
style={this.listStyle}
|
||||
>
|
||||
{coupons.map((coupon, index) => (
|
||||
<Coupon
|
||||
ref="card"
|
||||
@ -200,7 +203,10 @@ export default createComponent({
|
||||
|
||||
const DisabledCouponTab = (
|
||||
<Tab title={disabledTitle}>
|
||||
<div class={bem('list', { 'with-bottom': this.showCloseButton })} style={this.listStyle}>
|
||||
<div
|
||||
class={bem('list', { 'with-bottom': this.showCloseButton })}
|
||||
style={this.listStyle}
|
||||
>
|
||||
{disabledCoupons.map(coupon => (
|
||||
<Coupon
|
||||
disabled
|
||||
|
@ -17,7 +17,9 @@ function formatDiscount(discount) {
|
||||
}
|
||||
|
||||
function formatAmount(amount) {
|
||||
return (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
|
||||
return (amount / 100).toFixed(
|
||||
amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2
|
||||
);
|
||||
}
|
||||
|
||||
export default createComponent({
|
||||
@ -45,7 +47,8 @@ export default createComponent({
|
||||
}
|
||||
|
||||
if (coupon.denominations) {
|
||||
return `<span>${this.currency}</span> ${formatAmount(this.coupon.denominations)}`;
|
||||
const denominations = formatAmount(this.coupon.denominations);
|
||||
return `<span>${this.currency}</span> ${denominations}`;
|
||||
}
|
||||
|
||||
if (coupon.discount) {
|
||||
@ -70,13 +73,20 @@ export default createComponent({
|
||||
<div class={bem('content')}>
|
||||
<div class={bem('head')}>
|
||||
<h2 class={bem('amount')} domPropsInnerHTML={this.faceAmount} />
|
||||
<p class={bem('condition')}>{this.coupon.condition || this.conditionMessage}</p>
|
||||
<p class={bem('condition')}>
|
||||
{this.coupon.condition || this.conditionMessage}
|
||||
</p>
|
||||
</div>
|
||||
<div class={bem('body')}>
|
||||
<p class={bem('name')}>{coupon.name}</p>
|
||||
<p class={bem('valid')}>{this.validPeriod}</p>
|
||||
{!this.disabled && (
|
||||
<Checkbox value={this.chosen} class={bem('corner')} size={18} checked-color={RED} />
|
||||
<Checkbox
|
||||
value={this.chosen}
|
||||
class={bem('corner')}
|
||||
size={18}
|
||||
checked-color={RED}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -44,15 +44,21 @@ export default createComponent({
|
||||
|
||||
computed: {
|
||||
ranges() {
|
||||
const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = this.getBoundary(
|
||||
'max',
|
||||
this.innerValue
|
||||
);
|
||||
const {
|
||||
maxYear,
|
||||
maxDate,
|
||||
maxMonth,
|
||||
maxHour,
|
||||
maxMinute,
|
||||
} = this.getBoundary('max', this.innerValue);
|
||||
|
||||
const { minYear, minDate, minMonth, minHour, minMinute } = this.getBoundary(
|
||||
'min',
|
||||
this.innerValue
|
||||
);
|
||||
const {
|
||||
minYear,
|
||||
minDate,
|
||||
minMonth,
|
||||
minHour,
|
||||
minMinute,
|
||||
} = this.getBoundary('min', this.innerValue);
|
||||
|
||||
const result = [
|
||||
{
|
||||
@ -134,7 +140,11 @@ export default createComponent({
|
||||
|
||||
updateInnerValue() {
|
||||
const indexes = this.getPicker().getIndexes();
|
||||
const getValue = index => getTrueValue(this.originColumns[index].values[indexes[index]]);
|
||||
|
||||
const getValue = index => {
|
||||
const { values } = this.originColumns[index];
|
||||
return getTrueValue(values[indexes[index]]);
|
||||
};
|
||||
|
||||
const year = getValue(0);
|
||||
const month = getValue(1);
|
||||
|
@ -75,11 +75,12 @@ export default createComponent({
|
||||
|
||||
updateInnerValue() {
|
||||
const [hourIndex, minuteIndex] = this.getPicker().getIndexes();
|
||||
const hour = this.originColumns[0].values[hourIndex] || this.originColumns[0].values[0];
|
||||
const minute = this.originColumns[1].values[minuteIndex] || this.originColumns[1].values[0];
|
||||
const value = `${hour}:${minute}`;
|
||||
const [hourColumn, minuteColumn] = this.originColumns;
|
||||
|
||||
this.innerValue = this.formatValue(value);
|
||||
const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
|
||||
const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
|
||||
|
||||
this.innerValue = this.formatValue(`${hour}:${minute}`);
|
||||
},
|
||||
|
||||
onChange(picker) {
|
||||
|
@ -103,7 +103,9 @@ export default createComponent({
|
||||
const title = this.slots('title') || this.title;
|
||||
|
||||
const Title = title && (
|
||||
<div class={bem('header', { isolated: !message && !messageSlot })}>{title}</div>
|
||||
<div class={bem('header', { isolated: !message && !messageSlot })}>
|
||||
{title}
|
||||
</div>
|
||||
);
|
||||
|
||||
const Content = (messageSlot || message) && (
|
||||
@ -111,7 +113,10 @@ export default createComponent({
|
||||
{messageSlot || (
|
||||
<div
|
||||
domPropsInnerHTML={message}
|
||||
class={bem('message', { 'has-title': title, [messageAlign]: messageAlign })}
|
||||
class={bem('message', {
|
||||
'has-title': title,
|
||||
[messageAlign]: messageAlign,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
@ -73,10 +73,11 @@ Dialog.defaultOptions = {
|
||||
|
||||
Dialog.alert = Dialog;
|
||||
|
||||
Dialog.confirm = options => Dialog({
|
||||
showCancelButton: true,
|
||||
...options,
|
||||
});
|
||||
Dialog.confirm = options =>
|
||||
Dialog({
|
||||
showCancelButton: true,
|
||||
...options,
|
||||
});
|
||||
|
||||
Dialog.close = () => {
|
||||
if (instance) {
|
||||
|
@ -102,7 +102,9 @@ export default createComponent({
|
||||
]}
|
||||
style={{ color: item.showPopup ? this.activeColor : '' }}
|
||||
>
|
||||
<div class="van-ellipsis">{item.slots('title') || item.displayTitle}</div>
|
||||
<div class="van-ellipsis">
|
||||
{item.slots('title') || item.displayTitle}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
));
|
||||
|
@ -87,6 +87,18 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
getText() {
|
||||
const textSlot = this.slots('text');
|
||||
|
||||
if (textSlot) {
|
||||
return textSlot;
|
||||
}
|
||||
|
||||
if (this.text) {
|
||||
return <span class={bem('text')}>{this.text}</span>;
|
||||
}
|
||||
},
|
||||
|
||||
genContent() {
|
||||
const slot = this.slots();
|
||||
|
||||
@ -94,10 +106,7 @@ export default createComponent({
|
||||
return slot;
|
||||
}
|
||||
|
||||
return [
|
||||
this.genIcon(),
|
||||
this.slots('text') || (this.text && <span class={bem('text')}>{this.text}</span>),
|
||||
];
|
||||
return [this.genIcon(), this.getText()];
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -109,9 +109,21 @@ export default createComponent({
|
||||
return slot;
|
||||
}
|
||||
|
||||
const iconName = mode === 'closeable' ? 'cross' : mode === 'link' ? 'arrow' : '';
|
||||
let iconName;
|
||||
if (mode === 'closeable') {
|
||||
iconName = 'cross';
|
||||
} else if (mode === 'link') {
|
||||
iconName = 'arrow';
|
||||
}
|
||||
|
||||
if (iconName) {
|
||||
return <Icon class={bem('right-icon')} name={iconName} onClick={onClickIcon} />;
|
||||
return (
|
||||
<Icon
|
||||
class={bem('right-icon')}
|
||||
name={iconName}
|
||||
onClick={onClickIcon}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,10 +145,17 @@ export default createComponent({
|
||||
|
||||
const Title = showTitle && (
|
||||
<div class={[bem('title'), BORDER_TOP]}>
|
||||
{titleLeftSlot && <span class={bem('title-left')}>{titleLeftSlot}</span>}
|
||||
{titleLeftSlot && (
|
||||
<span class={bem('title-left')}>{titleLeftSlot}</span>
|
||||
)}
|
||||
{title && <span>{title}</span>}
|
||||
{showTitleClose && (
|
||||
<span role="button" tabindex="0" class={bem('close')} onClick={this.onClose}>
|
||||
<span
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class={bem('close')}
|
||||
onClick={this.onClose}
|
||||
>
|
||||
{closeButtonText}
|
||||
</span>
|
||||
)}
|
||||
@ -192,7 +199,10 @@ export default createComponent({
|
||||
<div
|
||||
vShow={this.show}
|
||||
style={{ zIndex: this.zIndex }}
|
||||
class={bem([theme, { 'safe-area-inset-bottom': this.safeAreaInsetBottom }])}
|
||||
class={bem([
|
||||
theme,
|
||||
{ 'safe-area-inset-bottom': this.safeAreaInsetBottom },
|
||||
])}
|
||||
onTouchstart={stopPropagation}
|
||||
onAnimationend={this.onAnimationEnd}
|
||||
onWebkitAnimationEnd={this.onAnimationEnd}
|
||||
|
@ -40,7 +40,8 @@ export default createComponent({
|
||||
|
||||
computed: {
|
||||
count() {
|
||||
const count = this.pageCount || Math.ceil(this.totalItems / this.itemsPerPage);
|
||||
const count =
|
||||
this.pageCount || Math.ceil(this.totalItems / this.itemsPerPage);
|
||||
return Math.max(1, count);
|
||||
},
|
||||
|
||||
@ -55,7 +56,8 @@ export default createComponent({
|
||||
// Default page limits
|
||||
let startPage = 1;
|
||||
let endPage = pageCount;
|
||||
const isMaxSized = this.showPageSize !== undefined && this.showPageSize < pageCount;
|
||||
const isMaxSized =
|
||||
this.showPageSize !== undefined && this.showPageSize < pageCount;
|
||||
|
||||
// recompute if showPageSize
|
||||
if (isMaxSized) {
|
||||
@ -140,10 +142,16 @@ export default createComponent({
|
||||
</li>
|
||||
))}
|
||||
{simple && (
|
||||
<li class={bem('page-desc')}>{this.slots('pageDesc') || `${value}/${this.count}`}</li>
|
||||
<li class={bem('page-desc')}>
|
||||
{this.slots('pageDesc') || `${value}/${this.count}`}
|
||||
</li>
|
||||
)}
|
||||
<li
|
||||
class={[bem('item', { disabled: value === this.count }), bem('next'), BORDER]}
|
||||
class={[
|
||||
bem('item', { disabled: value === this.count }),
|
||||
bem('next'),
|
||||
BORDER,
|
||||
]}
|
||||
onClick={onSelect(value + 1)}
|
||||
>
|
||||
{this.nextText || t('next')}
|
||||
|
@ -180,11 +180,7 @@ export default createComponent({
|
||||
return (
|
||||
<div class={[BORDER_TOP_BOTTOM, bem('toolbar')]}>
|
||||
{this.slots() || [
|
||||
<button
|
||||
type="button"
|
||||
class={bem('cancel')}
|
||||
onClick={this.cancel}
|
||||
>
|
||||
<button type="button" class={bem('cancel')} onClick={this.cancel}>
|
||||
{this.cancelButtonText || t('cancel')}
|
||||
</button>,
|
||||
this.genTitle(),
|
||||
|
@ -4,11 +4,13 @@ import { CheckboxMixin } from '../mixins/checkbox';
|
||||
const [createComponent, bem] = createNamespace('radio');
|
||||
|
||||
export default createComponent({
|
||||
mixins: [CheckboxMixin({
|
||||
bem,
|
||||
role: 'radio',
|
||||
parent: 'vanRadio',
|
||||
})],
|
||||
mixins: [
|
||||
CheckboxMixin({
|
||||
bem,
|
||||
role: 'radio',
|
||||
parent: 'vanRadio',
|
||||
}),
|
||||
],
|
||||
|
||||
computed: {
|
||||
currentValue: {
|
||||
|
@ -27,7 +27,9 @@ export default createComponent({
|
||||
const { align, justify } = this;
|
||||
const flex = this.type === 'flex';
|
||||
const margin = `-${Number(this.gutter) / 2}px`;
|
||||
const style = this.gutter ? { marginLeft: margin, marginRight: margin } : {};
|
||||
const style = this.gutter
|
||||
? { marginLeft: margin, marginRight: margin }
|
||||
: {};
|
||||
|
||||
return (
|
||||
<this.tag
|
||||
|
@ -162,7 +162,9 @@ export default createComponent({
|
||||
return false;
|
||||
}
|
||||
// 属性未全选
|
||||
if (this.propList.some(it => (this.selectedProp[it.k_id] || []).length < 1)) {
|
||||
if (
|
||||
this.propList.some(it => (this.selectedProp[it.k_id] || []).length < 1)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -193,8 +195,14 @@ export default createComponent({
|
||||
};
|
||||
}
|
||||
if (skuComb) {
|
||||
skuComb.properties = getSelectedProperties(this.propList, this.selectedProp);
|
||||
skuComb.property_price = this.selectedPropValues.reduce((acc, cur) => acc + (cur.price || 0), 0);
|
||||
skuComb.properties = getSelectedProperties(
|
||||
this.propList,
|
||||
this.selectedProp
|
||||
);
|
||||
skuComb.property_price = this.selectedPropValues.reduce(
|
||||
(acc, cur) => acc + (cur.price || 0),
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
return skuComb;
|
||||
@ -210,7 +218,10 @@ export default createComponent({
|
||||
|
||||
price() {
|
||||
if (this.selectedSkuComb) {
|
||||
return ((this.selectedSkuComb.price + this.selectedSkuComb.property_price) / 100).toFixed(2);
|
||||
return (
|
||||
(this.selectedSkuComb.price + this.selectedSkuComb.property_price) /
|
||||
100
|
||||
).toFixed(2);
|
||||
}
|
||||
// sku.price是一个格式化好的价格区间
|
||||
return this.sku.price;
|
||||
@ -218,7 +229,11 @@ export default createComponent({
|
||||
|
||||
originPrice() {
|
||||
if (this.selectedSkuComb && this.selectedSkuComb.origin_price) {
|
||||
return ((this.selectedSkuComb.origin_price + this.selectedSkuComb.property_price) / 100).toFixed(2);
|
||||
return (
|
||||
(this.selectedSkuComb.origin_price +
|
||||
this.selectedSkuComb.property_price) /
|
||||
100
|
||||
).toFixed(2);
|
||||
}
|
||||
return this.sku.origin_price;
|
||||
},
|
||||
@ -269,7 +284,11 @@ export default createComponent({
|
||||
|
||||
return [
|
||||
`${t('stock')} `,
|
||||
<span class={bem('stock-num', { highlight: this.stock < this.stockThreshold })}>
|
||||
<span
|
||||
class={bem('stock-num', {
|
||||
highlight: this.stock < this.stockThreshold,
|
||||
})}
|
||||
>
|
||||
{this.stock}
|
||||
</span>,
|
||||
` ${t('stockUnit')}`,
|
||||
@ -289,7 +308,9 @@ export default createComponent({
|
||||
.filter(item => (this.selectedProp[item.k_id] || []).length < 1)
|
||||
.map(item => item.k);
|
||||
|
||||
return `${t('select')} ${unselectedSku.concat(unselectedProp).join(';')}`;
|
||||
return `${t('select')} ${unselectedSku
|
||||
.concat(unselectedProp)
|
||||
.join(';')}`;
|
||||
},
|
||||
},
|
||||
|
||||
@ -335,7 +356,8 @@ export default createComponent({
|
||||
|
||||
// 重置 selectedSku
|
||||
this.skuTree.forEach(item => {
|
||||
this.selectedSku[item.k_s] = this.initialSku[item.k_s] || UNSELECTED_SKU_VALUE_ID;
|
||||
this.selectedSku[item.k_s] =
|
||||
this.initialSku[item.k_s] || UNSELECTED_SKU_VALUE_ID;
|
||||
});
|
||||
|
||||
// 只有一个 sku 规格值时默认选中
|
||||
@ -389,11 +411,15 @@ export default createComponent({
|
||||
},
|
||||
|
||||
getSkuCartMessages() {
|
||||
return this.$refs.skuMessages ? this.$refs.skuMessages.getCartMessages() : {};
|
||||
return this.$refs.skuMessages
|
||||
? this.$refs.skuMessages.getCartMessages()
|
||||
: {};
|
||||
},
|
||||
|
||||
validateSkuMessages() {
|
||||
return this.$refs.skuMessages ? this.$refs.skuMessages.validateMessages() : '';
|
||||
return this.$refs.skuMessages
|
||||
? this.$refs.skuMessages.validateMessages()
|
||||
: '';
|
||||
},
|
||||
|
||||
validateSku() {
|
||||
@ -418,7 +444,10 @@ export default createComponent({
|
||||
// 点击已选中的sku时则取消选中
|
||||
this.selectedSku =
|
||||
this.selectedSku[skuValue.skuKeyStr] === skuValue.id
|
||||
? { ...this.selectedSku, [skuValue.skuKeyStr]: UNSELECTED_SKU_VALUE_ID }
|
||||
? {
|
||||
...this.selectedSku,
|
||||
[skuValue.skuKeyStr]: UNSELECTED_SKU_VALUE_ID,
|
||||
}
|
||||
: { ...this.selectedSku, [skuValue.skuKeyStr]: skuValue.id };
|
||||
|
||||
this.$emit('sku-selected', {
|
||||
@ -575,19 +604,27 @@ export default createComponent({
|
||||
const slots = name => this.slots(name, slotsProps);
|
||||
|
||||
const Header = slots('sku-header') || (
|
||||
<SkuHeader sku={sku} goods={goods} skuEventBus={skuEventBus} selectedSku={selectedSku}>
|
||||
<SkuHeader
|
||||
sku={sku}
|
||||
goods={goods}
|
||||
skuEventBus={skuEventBus}
|
||||
selectedSku={selectedSku}
|
||||
>
|
||||
{slots('sku-header-price') || (
|
||||
<div class="van-sku__goods-price">
|
||||
<span class="van-sku__price-symbol">¥</span>
|
||||
<span class="van-sku__price-num">{price}</span>
|
||||
{this.priceTag && <span class="van-sku__price-tag">{this.priceTag}</span>}
|
||||
{this.priceTag && (
|
||||
<span class="van-sku__price-tag">{this.priceTag}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{slots('sku-header-origin-price') || (
|
||||
originPrice && (
|
||||
<SkuHeaderItem>{t('originPrice')} ¥{originPrice}</SkuHeaderItem>
|
||||
)
|
||||
)}
|
||||
{slots('sku-header-origin-price') ||
|
||||
(originPrice && (
|
||||
<SkuHeaderItem>
|
||||
{t('originPrice')} ¥{originPrice}
|
||||
</SkuHeaderItem>
|
||||
))}
|
||||
{!this.hideStock && (
|
||||
<SkuHeaderItem>
|
||||
<span class="van-sku__stock">{this.stockText}</span>
|
||||
|
@ -53,9 +53,7 @@ export default createComponent({
|
||||
maxSize={this.maxSize * 1024 * 1024}
|
||||
onOversize={this.onOversize}
|
||||
>
|
||||
<div class={bem('img')}>
|
||||
{content}
|
||||
</div>
|
||||
<div class={bem('img')}>{content}</div>
|
||||
</Uploader>
|
||||
);
|
||||
},
|
||||
@ -63,15 +61,14 @@ export default createComponent({
|
||||
genMask() {
|
||||
return (
|
||||
<div class={bem('mask')}>
|
||||
{this.uploadFail
|
||||
? (
|
||||
[
|
||||
<Icon name="warning-o" size="20px" />,
|
||||
<div class={bem('warn-text')} domPropsInnerHTML={t('fail')} />,
|
||||
]
|
||||
) : (
|
||||
<Loading type="spinner" size="20px" color="white" />
|
||||
)}
|
||||
{this.uploadFail ? (
|
||||
[
|
||||
<Icon name="warning-o" size="20px" />,
|
||||
<div class={bem('warn-text')} domPropsInnerHTML={t('fail')} />,
|
||||
]
|
||||
) : (
|
||||
<Loading type="spinner" size="20px" color="white" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@ -80,33 +77,34 @@ export default createComponent({
|
||||
render() {
|
||||
return (
|
||||
<div class={bem()}>
|
||||
{this.value && this.genUploader(
|
||||
[
|
||||
<img src={this.value} />,
|
||||
<Icon
|
||||
name="clear"
|
||||
class={bem('delete')}
|
||||
onClick={() => {
|
||||
this.$emit('input', '');
|
||||
}}
|
||||
/>,
|
||||
],
|
||||
true
|
||||
)}
|
||||
{this.value &&
|
||||
this.genUploader(
|
||||
[
|
||||
<img src={this.value} />,
|
||||
<Icon
|
||||
name="clear"
|
||||
class={bem('delete')}
|
||||
onClick={() => {
|
||||
this.$emit('input', '');
|
||||
}}
|
||||
/>,
|
||||
],
|
||||
true
|
||||
)}
|
||||
|
||||
{this.paddingImg && this.genUploader(
|
||||
[
|
||||
<img src={this.paddingImg} />,
|
||||
this.genMask(),
|
||||
],
|
||||
!this.uploadFail
|
||||
)}
|
||||
{this.paddingImg &&
|
||||
this.genUploader(
|
||||
[<img src={this.paddingImg} />, this.genMask()],
|
||||
!this.uploadFail
|
||||
)}
|
||||
|
||||
{!this.value && !this.paddingImg && this.genUploader(
|
||||
<div class={bem('trigger')}>
|
||||
<Icon name="photograph" size="22px" />
|
||||
</div>
|
||||
)}
|
||||
{!this.value &&
|
||||
!this.paddingImg &&
|
||||
this.genUploader(
|
||||
<div class={bem('trigger')}>
|
||||
<Icon name="photograph" size="22px" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
@ -103,43 +103,54 @@ export default createComponent({
|
||||
if (message.type === 'email' && !isEmail(value)) {
|
||||
return t('invalid.email');
|
||||
}
|
||||
if (message.type === 'id_no' && (value.length < 15 || value.length > 18)) {
|
||||
if (
|
||||
message.type === 'id_no' &&
|
||||
(value.length < 15 || value.length > 18)
|
||||
) {
|
||||
return t('invalid.id_no');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
genMessage(message, index) {
|
||||
if (message.type === 'image') {
|
||||
return (
|
||||
<Cell
|
||||
key={`${this.goodsId}-${index}`}
|
||||
title={message.name}
|
||||
label={t('imageLabel')}
|
||||
class={bem('image-cell')}
|
||||
required={String(message.required) === '1'}
|
||||
valueClass={bem('image-cell-value')}
|
||||
>
|
||||
<SkuImgUploader
|
||||
vModel={this.messageValues[index].value}
|
||||
maxSize={this.messageConfig.uploadMaxSize}
|
||||
uploadImg={this.messageConfig.uploadImg}
|
||||
/>
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Field
|
||||
vModel={this.messageValues[index].value}
|
||||
maxlength="200"
|
||||
label={message.name}
|
||||
key={`${this.goodsId}-${index}`}
|
||||
required={String(message.required) === '1'}
|
||||
placeholder={this.getPlaceholder(message)}
|
||||
type={this.getType(message)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<CellGroup class={bem()} border={this.messages.length > 0}>
|
||||
{this.messages.map((message, index) => (message.type === 'image' ? (
|
||||
<Cell
|
||||
class={bem('image-cell')}
|
||||
value-class={bem('image-cell-value')}
|
||||
label={t('imageLabel')}
|
||||
title={message.name}
|
||||
key={`${this.goodsId}-${index}`}
|
||||
required={String(message.required) === '1'}
|
||||
>
|
||||
<SkuImgUploader
|
||||
vModel={this.messageValues[index].value}
|
||||
uploadImg={this.messageConfig.uploadImg}
|
||||
maxSize={this.messageConfig.uploadMaxSize}
|
||||
/>
|
||||
</Cell>
|
||||
) : (
|
||||
<Field
|
||||
vModel={this.messageValues[index].value}
|
||||
maxlength="200"
|
||||
label={message.name}
|
||||
key={`${this.goodsId}-${index}`}
|
||||
required={String(message.required) === '1'}
|
||||
placeholder={this.getPlaceholder(message)}
|
||||
type={this.getType(message)}
|
||||
/>
|
||||
)))}
|
||||
{this.messages.map(this.genMessage)}
|
||||
</CellGroup>
|
||||
);
|
||||
},
|
||||
|
@ -11,6 +11,18 @@ export default createComponent({
|
||||
multiple: Boolean,
|
||||
},
|
||||
|
||||
computed: {
|
||||
choosed() {
|
||||
const { selectedProp, skuKeyStr, skuValue } = this;
|
||||
|
||||
if (selectedProp && selectedProp[skuKeyStr]) {
|
||||
return selectedProp[skuKeyStr].indexOf(skuValue.id) > -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSelect() {
|
||||
this.skuEventBus.$emit('sku:propSelect', {
|
||||
@ -22,14 +34,11 @@ export default createComponent({
|
||||
},
|
||||
|
||||
render() {
|
||||
const choosed = this.selectedProp && (this.selectedProp[this.skuKeyStr] || []).indexOf(this.skuValue.id) > -1;
|
||||
return (
|
||||
<span
|
||||
class={[
|
||||
'van-sku-row__item',
|
||||
{
|
||||
'van-sku-row__item--active': choosed,
|
||||
},
|
||||
{ 'van-sku-row__item--active': this.choosed },
|
||||
]}
|
||||
onClick={this.onSelect}
|
||||
>
|
||||
|
@ -157,7 +157,9 @@ export default createComponent({
|
||||
return (
|
||||
<div class="van-sku-stepper-stock">
|
||||
<div class="van-sku-stepper-container">
|
||||
<div class="van-sku__stepper-title">{this.stepperTitle || t('num')}</div>
|
||||
<div class="van-sku__stepper-title">
|
||||
{this.stepperTitle || t('num')}
|
||||
</div>
|
||||
<Stepper
|
||||
vModel={this.currentNum}
|
||||
class="van-sku__stepper"
|
||||
@ -168,7 +170,9 @@ export default createComponent({
|
||||
onOverlimit={this.onOverLimit}
|
||||
onChange={this.onChange}
|
||||
/>
|
||||
{!this.hideQuotaText && this.quotaText && <span class="van-sku__stepper-quota">({this.quotaText})</span>}
|
||||
{!this.hideQuotaText && this.quotaText && (
|
||||
<span class="van-sku__stepper-quota">({this.quotaText})</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -65,11 +65,11 @@ export const isAllSelected = (skuTree, selectedSku) => {
|
||||
|
||||
// 根据已选择的 sku 获取 skuComb
|
||||
export const getSkuComb = (skuList, selectedSku) => {
|
||||
const skuComb = skuList.filter(item => (
|
||||
const skuComb = skuList.filter(item =>
|
||||
Object.keys(selectedSku).every(
|
||||
skuKeyStr => String(item[skuKeyStr]) === String(selectedSku[skuKeyStr])
|
||||
)
|
||||
));
|
||||
);
|
||||
return skuComb[0];
|
||||
};
|
||||
|
||||
@ -103,11 +103,11 @@ export const isSkuChoosable = (skuList, selectedSku, skuToChoose) => {
|
||||
skuKey => matchedSku[skuKey] !== UNSELECTED_SKU_VALUE_ID
|
||||
);
|
||||
|
||||
const filteredSku = skuList.filter(sku => (
|
||||
const filteredSku = skuList.filter(sku =>
|
||||
skusToCheck.every(
|
||||
skuKey => String(matchedSku[skuKey]) === String(sku[skuKey])
|
||||
)
|
||||
));
|
||||
);
|
||||
|
||||
const stock = filteredSku.reduce((total, sku) => {
|
||||
total += sku.stock_num;
|
||||
|
@ -107,7 +107,9 @@ export default createComponent({
|
||||
if (this.disabled) return;
|
||||
|
||||
const rect = this.$el.getBoundingClientRect();
|
||||
const delta = this.vertical ? event.clientY - rect.top : event.clientX - rect.left;
|
||||
const delta = this.vertical
|
||||
? event.clientY - rect.top
|
||||
: event.clientX - rect.left;
|
||||
const total = this.vertical ? rect.height : rect.width;
|
||||
const value = (delta / total) * this.range + this.min;
|
||||
|
||||
@ -129,7 +131,8 @@ export default createComponent({
|
||||
|
||||
format(value) {
|
||||
return (
|
||||
Math.round(Math.max(this.min, Math.min(value, this.max)) / this.step) * this.step
|
||||
Math.round(Math.max(this.min, Math.min(value, this.max)) / this.step) *
|
||||
this.step
|
||||
);
|
||||
},
|
||||
},
|
||||
|
@ -34,7 +34,9 @@ export default createComponent({
|
||||
const inactiveIconSlot = this.slots('inactive-icon');
|
||||
|
||||
if (inactiveIcon || inactiveIconSlot) {
|
||||
return inactiveIconSlot || <Icon class={bem('icon')} name={inactiveIcon} />;
|
||||
return (
|
||||
inactiveIconSlot || <Icon class={bem('icon')} name={inactiveIcon} />
|
||||
);
|
||||
}
|
||||
|
||||
return <i class={bem('circle')} />;
|
||||
|
@ -78,7 +78,9 @@ export default createComponent({
|
||||
|
||||
computed: {
|
||||
minusDisabled() {
|
||||
return this.disabled || this.disableMinus || this.currentValue <= this.min;
|
||||
return (
|
||||
this.disabled || this.disableMinus || this.currentValue <= this.min
|
||||
);
|
||||
},
|
||||
|
||||
plusDisabled() {
|
||||
|
@ -85,10 +85,16 @@ export default createComponent({
|
||||
|
||||
genIcon() {
|
||||
const { icon, type, iconPrefix, loadingType } = this;
|
||||
const hasIcon = icon || (type === 'success' || type === 'fail');
|
||||
const hasIcon = icon || type === 'success' || type === 'fail';
|
||||
|
||||
if (hasIcon) {
|
||||
return <Icon class={bem('icon')} classPrefix={iconPrefix} name={icon || type} />;
|
||||
return (
|
||||
<Icon
|
||||
class={bem('icon')}
|
||||
classPrefix={iconPrefix}
|
||||
name={icon || type}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (type === 'loading') {
|
||||
@ -120,7 +126,10 @@ export default createComponent({
|
||||
>
|
||||
<div
|
||||
vShow={this.value}
|
||||
class={[bem([this.position, { [this.type]: !this.icon }]), this.className]}
|
||||
class={[
|
||||
bem([this.position, { [this.type]: !this.icon }]),
|
||||
this.className,
|
||||
]}
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{this.genIcon()}
|
||||
|
@ -117,19 +117,21 @@ export default createComponent({
|
||||
files = files.slice(0, maxCount);
|
||||
}
|
||||
|
||||
Promise.all(files.map(file => readFile(file, this.resultType))).then(contents => {
|
||||
const fileList = files.map((file, index) => {
|
||||
const result = { file };
|
||||
Promise.all(files.map(file => readFile(file, this.resultType))).then(
|
||||
contents => {
|
||||
const fileList = files.map((file, index) => {
|
||||
const result = { file };
|
||||
|
||||
if (contents[index]) {
|
||||
result.content = contents[index];
|
||||
}
|
||||
if (contents[index]) {
|
||||
result.content = contents[index];
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
this.onAfterRead(fileList, oversize);
|
||||
});
|
||||
this.onAfterRead(fileList, oversize);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
readFile(files, this.resultType).then(content => {
|
||||
const result = { file: files };
|
||||
@ -317,7 +319,9 @@ export default createComponent({
|
||||
return (
|
||||
<div class={bem('upload')} style={style}>
|
||||
<Icon name="plus" class={bem('upload-icon')} />
|
||||
{this.uploadText && <span class={bem('upload-text')}>{this.uploadText}</span>}
|
||||
{this.uploadText && (
|
||||
<span class={bem('upload-text')}>{this.uploadText}</span>
|
||||
)}
|
||||
{Input}
|
||||
</div>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user