Compare commits

..

No commits in common. "8eac20b9cbb8c855ea394ea11edc2ae48b54ed25" and "c0c0bdce17c21a2309cca54345ced97b6dd800fc" have entirely different histories.

5 changed files with 6 additions and 39 deletions

View File

@ -95,7 +95,6 @@ export default defineComponent({
emits: [
'save',
'focus',
'change',
'delete',
'clickArea',
'changeArea',
@ -137,10 +136,6 @@ export default defineComponent({
emit('focus', key);
};
const onChange = (key: string, value: string) => {
emit('change', { key, value });
};
const rules = computed<Record<string, FieldRule[]>>(() => {
const { validator, telValidator } = props;
@ -278,7 +273,6 @@ export default defineComponent({
rules={rules.value.name}
placeholder={t('name')}
onFocus={() => onFocus('name')}
onUpdate:modelValue={(val) => onChange('name', val)}
/>
<Field
v-model={data.tel}
@ -289,7 +283,6 @@ export default defineComponent({
maxlength={props.telMaxlength}
placeholder={t('tel')}
onFocus={() => onFocus('tel')}
onUpdate:modelValue={(val) => onChange('tel', val)}
/>
<Field
v-show={props.showArea}

View File

@ -101,7 +101,6 @@ export default {
| --- | --- | --- |
| save | Emitted when the save button is clicked | _info: AddressEditInfo_ |
| focus | Emitted when field is focused | _key: string_ |
| change | Emitted when only the name and tel field are changed | _{key: string, value: string}_ |
| delete | Emitted when confirming delete | _info: AddressEditInfo_ |
| select-search | Emitted when a search result is selected | _value: string_ |
| click-area | Emitted when the area field is clicked | - |

View File

@ -101,7 +101,6 @@ export default {
| --- | --- | --- |
| save | 点击保存按钮时触发 | _info: AddressEditInfo_ |
| focus | 输入框聚焦时触发 | _key: string_ |
| change | 仅 `name``tel` 输入框值改变触发 | _{key: string, value: string}_ |
| delete | 确认删除地址时触发 | _info: AddressEditInfo_ |
| select-search | 选中搜索结果时触发 | _value: string_ |
| click-area | 点击收件地区时触发 | - |

View File

@ -109,24 +109,6 @@ test('should emit changeDetail event after changing address detail', () => {
expect(wrapper.emitted('changeDetail')).toEqual([['123']]);
});
test('should emit change event after name or tel input', () => {
const wrapper = mount(AddressEdit);
const field = wrapper.findAll('.van-field__control')[0];
(field.element as HTMLInputElement).value = '123';
field.trigger('input');
expect(wrapper.emitted('change')?.[0]).toEqual([
{ key: 'name', value: '123' },
]);
const field1 = wrapper.findAll('.van-field__control')[1];
(field1.element as HTMLInputElement).value = '123';
field1.trigger('input');
expect(wrapper.emitted('change')?.[1]).toEqual([
{ key: 'tel', value: '123' },
]);
});
test('should show search result after focusing to address detail', async () => {
const wrapper = mount(AddressEdit, {
props: {

View File

@ -97,19 +97,13 @@ export default defineComponent({
const empty = document.createElement('canvas');
empty.width = canvas.width;
empty.height = canvas.height;
if (props.backgroundColor) {
const emptyCtx = empty.getContext('2d');
setCanvasBgColor(emptyCtx);
}
return canvas.toDataURL() === empty.toDataURL();
};
const setCanvasBgColor = (
ctx: CanvasRenderingContext2D | null | undefined,
) => {
if (ctx && props.backgroundColor) {
ctx.fillStyle = props.backgroundColor;
ctx.fillRect(0, 0, state.width, state.height);
const setCanvasBgColor = () => {
if (state.ctx && props.backgroundColor) {
state.ctx.fillStyle = props.backgroundColor;
state.ctx.fillRect(0, 0, state.width, state.height);
}
};
@ -140,7 +134,7 @@ export default defineComponent({
if (state.ctx) {
state.ctx.clearRect(0, 0, state.width, state.height);
state.ctx.closePath();
setCanvasBgColor(state.ctx);
setCanvasBgColor();
}
emit('clear');
};
@ -153,7 +147,7 @@ export default defineComponent({
// ensure canvas is rendered
nextTick(() => {
setCanvasBgColor(state.ctx);
setCanvasBgColor();
});
}
});