|
@@ -14,6 +14,7 @@
|
|
|
<view>{{ otherValueText || translate('otherValueText') }}</view>
|
|
<view>{{ otherValueText || translate('otherValueText') }}</view>
|
|
|
<view class="nut-ecard__list__input--con">
|
|
<view class="nut-ecard__list__input--con">
|
|
|
<input
|
|
<input
|
|
|
|
|
+ class="nut-ecard__list__input--input"
|
|
|
type="text"
|
|
type="text"
|
|
|
v-model="inputValue"
|
|
v-model="inputValue"
|
|
|
@input="change"
|
|
@input="change"
|
|
@@ -96,39 +97,47 @@ export default create({
|
|
|
|
|
|
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
const currentIndex: Ref<number | null | string> = ref(null);
|
|
const currentIndex: Ref<number | null | string> = ref(null);
|
|
|
|
|
+ const currentValue: Ref<number | null | string> = ref(null);
|
|
|
const inputValue: Ref<string | undefined | number> = ref();
|
|
const inputValue: Ref<string | undefined | number> = ref();
|
|
|
const stepValue: Ref<number> = ref(props.cardAmountMin);
|
|
const stepValue: Ref<number> = ref(props.cardAmountMin);
|
|
|
const money: Ref<number | string | undefined> = ref(props.modelValue);
|
|
const money: Ref<number | string | undefined> = ref(props.modelValue);
|
|
|
const handleClick = (item: { price: number | string }, index: number) => {
|
|
const handleClick = (item: { price: number | string }, index: number) => {
|
|
|
currentIndex.value = index;
|
|
currentIndex.value = index;
|
|
|
inputValue.value = '';
|
|
inputValue.value = '';
|
|
|
|
|
+ stepValue.value = props.cardAmountMin;
|
|
|
|
|
+ currentValue.value = item.price;
|
|
|
emit('change', item);
|
|
emit('change', item);
|
|
|
|
|
+ emit('update:modelValue', item.price);
|
|
|
};
|
|
};
|
|
|
const change = (event: Event) => {
|
|
const change = (event: Event) => {
|
|
|
let input = event.target as HTMLInputElement;
|
|
let input = event.target as HTMLInputElement;
|
|
|
let val = input.value.replace(/[^\d]/g, '');
|
|
let val = input.value.replace(/[^\d]/g, '');
|
|
|
inputValue.value = val;
|
|
inputValue.value = val;
|
|
|
|
|
+ currentValue.value = val;
|
|
|
if (Number(val) > props.cardAmountMax) {
|
|
if (Number(val) > props.cardAmountMax) {
|
|
|
inputValue.value = props.cardAmountMax;
|
|
inputValue.value = props.cardAmountMax;
|
|
|
|
|
+ currentValue.value = props.cardAmountMax;
|
|
|
}
|
|
}
|
|
|
if (Number(val) < props.cardAmountMin) {
|
|
if (Number(val) < props.cardAmountMin) {
|
|
|
inputValue.value = props.cardAmountMin;
|
|
inputValue.value = props.cardAmountMin;
|
|
|
|
|
+ currentValue.value = props.cardAmountMin;
|
|
|
}
|
|
}
|
|
|
emit('inputChange', Number(inputValue.value));
|
|
emit('inputChange', Number(inputValue.value));
|
|
|
|
|
+ emit('update:modelValue', Number(inputValue.value));
|
|
|
};
|
|
};
|
|
|
const inputClick = () => {
|
|
const inputClick = () => {
|
|
|
currentIndex.value = 'input';
|
|
currentIndex.value = 'input';
|
|
|
|
|
+ stepValue.value = props.cardAmountMin;
|
|
|
emit('update:modelValue', 0);
|
|
emit('update:modelValue', 0);
|
|
|
emit('inputClick');
|
|
emit('inputClick');
|
|
|
};
|
|
};
|
|
|
const changeStep = (value: number) => {
|
|
const changeStep = (value: number) => {
|
|
|
stepValue.value = value;
|
|
stepValue.value = value;
|
|
|
- emit('changeStep', stepValue.value); // 返回数量
|
|
|
|
|
|
|
+ emit('changeStep', stepValue.value, currentValue.value); // 返回数量, 返回当前选中值
|
|
|
};
|
|
};
|
|
|
watch(
|
|
watch(
|
|
|
() => props.modelValue,
|
|
() => props.modelValue,
|
|
|
(value) => {
|
|
(value) => {
|
|
|
- console.log('value', value);
|
|
|
|
|
money.value = value;
|
|
money.value = value;
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|