Skip to content

Commit

Permalink
fix: 修复 form-picker 等组件在微信平台下获取数值失败的问题 (#1093)
Browse files Browse the repository at this point in the history
Co-authored-by: DiamondYuan <[email protected]>
  • Loading branch information
DiamondYuan and DiamondYuan authored Feb 5, 2024
1 parent 3ada919 commit 0d66ceb
Show file tree
Hide file tree
Showing 38 changed files with 122 additions and 94 deletions.
6 changes: 3 additions & 3 deletions compiled/alipay/src/Form/FormCascaderPicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<cascader-picker
<ant-cascader-picker
options="{{ options }}"
cancelText="{{ cancelText }}"
okText="{{ okText }}"
Expand Down Expand Up @@ -44,12 +44,12 @@
name="title"
slot="title" />

<icon
<ant-icon
a:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-cascader-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</cascader-picker>
</ant-cascader-picker>
</view>

<view
Expand Down
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormCascaderPicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"cascader-picker": "../../Picker/CascaderPicker/index",
"icon": "../../Icon/index"
"ant-cascader-picker": "../../Picker/CascaderPicker/index",
"ant-icon": "../../Icon/index"
}
}
6 changes: 3 additions & 3 deletions compiled/alipay/src/Form/FormDatePicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<date-picker
<ant-date-picker
min="{{ min }}"
max="{{ max }}"
format="{{ format }}"
Expand Down Expand Up @@ -47,12 +47,12 @@
<slot
name="title"
slot="title" />
<icon
<ant-icon
a:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-date-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</date-picker>
</ant-date-picker>
</view>
<view
a:if="{{ !tooltip }}"
Expand Down
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormDatePicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"date-picker": "../../DatePicker/index",
"icon": "../../Icon/index"
"ant-date-picker": "../../DatePicker/index",
"ant-icon": "../../Icon/index"
}
}
3 changes: 2 additions & 1 deletion compiled/alipay/src/Form/FormDatePicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import {
} from '../../_util/hooks/useHandleCustomEvent';
import { useFormItem } from '../use-form-item';
import { FormDatePickerDefaultProps, FormDatePickerProps } from './props';
import { platform } from '../../_util/platform';

const FormDatePicker = (props: FormDatePickerProps) => {
const { formData, emit } = useFormItem(props);
const { triggerEventValues, triggerEventOnly, triggerEvent } =
useComponentEvent(props);

useMultipleValueHandleCustomEvent('onOk', (date, dateStr, e) => {
emit('onChange', date);
emit('onChange', platform() === 'wechat' ? date.getTime() : date);
triggerEventValues('ok', [date, dateStr], e);
});

Expand Down
6 changes: 3 additions & 3 deletions compiled/alipay/src/Form/FormPicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<picker
<ant-picker
cancelText="{{ cancelText }}"
okText="{{ okText }}"
placeholder="{{ placeholder }}"
Expand Down Expand Up @@ -43,12 +43,12 @@
<slot
name="content"
slot="content" />
<icon
<ant-icon
a:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</picker>
</ant-picker>
</view>
<view
a:if="{{ !tooltip }}"
Expand Down
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormPicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"picker": "../../Picker/index",
"icon": "../../Icon/index"
"ant-picker": "../../Picker/index",
"ant-icon": "../../Icon/index"
}
}
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormRadioGroup/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<radio-group
<ant-radio-group
options="{{ options }}"
value="{{ formData.value }}"
onChange="onChange"
Expand All @@ -24,7 +24,7 @@
slot-scope="props"
value="{{props.value}}"
index="{{props.index}}" />
</radio-group>
</ant-radio-group>
</view>

<view
Expand Down
2 changes: 1 addition & 1 deletion compiled/alipay/src/Form/FormRadioGroup/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"radio-group": "../../Radio/RadioGroup/index"
"ant-radio-group": "../../Radio/RadioGroup/index"
}
}
6 changes: 3 additions & 3 deletions compiled/alipay/src/Form/FormRangePicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<range-picker
<ant-range-picker
endPlaceholder="{{ endPlaceholder }}"
startPlaceholder="{{ startPlaceholder }}"
splitCharacter="{{ splitCharacter }}"
Expand Down Expand Up @@ -50,12 +50,12 @@
<slot
name="title"
slot="title" />
<icon
<ant-icon
a:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-range-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</range-picker>
</ant-range-picker>
</view>
<view
a:if="{{ !tooltip }}"
Expand Down
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormRangePicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"range-picker": "../../DatePicker/RangePicker/index",
"icon": "../../Icon/index"
"ant-range-picker": "../../DatePicker/RangePicker/index",
"ant-icon": "../../Icon/index"
}
}
11 changes: 10 additions & 1 deletion compiled/alipay/src/Form/FormRangePicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useHandleCustomEventOnly,
useMultipleValueHandleCustomEvent,
} from '../../_util/hooks/useHandleCustomEvent';
import { platform } from '../../_util/platform';
import { useFormItem } from '../use-form-item';
import { FormRangePickerDefaultProps, FormRangePickerProps } from './props';

Expand All @@ -15,7 +16,15 @@ const FormDatePicker = (props: FormRangePickerProps) => {
useComponentEvent(props);

useMultipleValueHandleCustomEvent('onOk', (date, dateStr, e) => {
emit('onChange', date);
emit(
'onChange',
date.map((o: Date) => {
if (platform() === 'wechat') {
return o.getTime();
}
return o;
})
);
triggerEventValues('ok', [date, dateStr], e);
});

Expand Down
4 changes: 2 additions & 2 deletions compiled/wechat/demo/pages/DatePicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
placeholder="请选择"
bind:pickerchange="handlePickerChange"
bind:visiblechange="handleTriggerPicker"
onCancel="handleDismiss"
bind:cancel="handleDismiss"
bind:ok="handleOk" />
</ant-list-item>
<ant-list-item>
Expand Down Expand Up @@ -77,7 +77,7 @@
placeholder="请选择"
bind:pickerchange="handlePickerChange"
bind:visiblechange="handleTriggerPicker"
onCancel="handleDismiss"
bind:cancel="handleDismiss"
bind:ok="handleOk"
onFormatLabel="{{ handleFormatLabel ? handleFormatLabel : 'handleFormatLabel' }}" />
</ant-list-item>
Expand Down
4 changes: 2 additions & 2 deletions compiled/wechat/src/Form/FormCascaderPicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"cascader-picker": "../../Picker/CascaderPicker/index",
"icon": "../../Icon/index"
"ant-cascader-picker": "../../Picker/CascaderPicker/index",
"ant-icon": "../../Icon/index"
}
}
10 changes: 5 additions & 5 deletions compiled/wechat/src/Form/FormCascaderPicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<cascader-picker
<ant-cascader-picker
options="{{ options }}"
cancelText="{{ cancelText }}"
okText="{{ okText }}"
Expand All @@ -32,9 +32,9 @@
indicatorStyle="{{ indicatorStyle }}"
indicatorClassName="{{ indicatorClassName }}"
value="{{ formData.value }}"
onOk="onOk"
bind:ok="onOk"
bind:change="onChange"
onCancel="onDismissPicker"
bind:cancel="onDismissPicker"
bind:visiblechange="onVisibleChange"
onFormat="{{ handleFormat ? handleFormat : 'handleFormat' }}">
<slot
Expand All @@ -44,12 +44,12 @@
name="title"
slot="title" />

<icon
<ant-icon
wx:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-cascader-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</cascader-picker>
</ant-cascader-picker>
</view>

<view
Expand Down
3 changes: 2 additions & 1 deletion compiled/wechat/src/Form/FormDatePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
import { useHandleCustomEvent, useHandleCustomEventOnly, useMultipleValueHandleCustomEvent, } from '../../_util/hooks/useHandleCustomEvent';
import { useFormItem } from '../use-form-item';
import { FormDatePickerDefaultProps } from './props';
import { platform } from '../../_util/platform';
var FormDatePicker = function (props) {
var _a = useFormItem(props), formData = _a.formData, emit = _a.emit;
var _b = useComponentEvent(props), triggerEventValues = _b.triggerEventValues, triggerEventOnly = _b.triggerEventOnly, triggerEvent = _b.triggerEvent;
useMultipleValueHandleCustomEvent('onOk', function (date, dateStr, e) {
emit('onChange', date);
emit('onChange', platform() === 'wechat' ? date.getTime() : date);
triggerEventValues('ok', [date, dateStr], e);
});
useMultipleValueHandleCustomEvent('onPickerChange', function (date, dateStr, e) {
Expand Down
4 changes: 2 additions & 2 deletions compiled/wechat/src/Form/FormDatePicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"date-picker": "../../DatePicker/index",
"icon": "../../Icon/index"
"ant-date-picker": "../../DatePicker/index",
"ant-icon": "../../Icon/index"
}
}
12 changes: 6 additions & 6 deletions compiled/wechat/src/Form/FormDatePicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<date-picker
<ant-date-picker
min="{{ min }}"
max="{{ max }}"
format="{{ format }}"
Expand All @@ -35,9 +35,9 @@
indicatorStyle="{{ indicatorStyle }}"
indicatorClassName="{{ indicatorClassName }}"
value="{{ formData.value }}"
onOk="onOk"
onPickerChange="onPickerChange"
onCancel="onDismissPicker"
bind:ok="onOk"
bind:pickerchange="onPickerChange"
bind:cancel="onDismissPicker"
bind:visiblechange="onVisibleChange"
onFormatLabel="{{ handleFormatLabel ? handleFormatLabel : 'handleFormatLabel' }}"
onFormat="{{ handleFormat ? handleFormat : 'handleFormat' }}">
Expand All @@ -47,12 +47,12 @@
<slot
name="title"
slot="title" />
<icon
<ant-icon
wx:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-date-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</date-picker>
</ant-date-picker>
</view>
<view
wx:if="{{ !tooltip }}"
Expand Down
4 changes: 2 additions & 2 deletions compiled/wechat/src/Form/FormPicker/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"picker": "../../Picker/index",
"icon": "../../Icon/index"
"ant-picker": "../../Picker/index",
"ant-icon": "../../Icon/index"
}
}
10 changes: 5 additions & 5 deletions compiled/wechat/src/Form/FormPicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
validateStatus="{{ validateStatus }}"
help="{{ help }}">
<view>
<picker
<ant-picker
cancelText="{{ cancelText }}"
okText="{{ okText }}"
placeholder="{{ placeholder }}"
Expand All @@ -32,9 +32,9 @@
indicatorClassName="{{ indicatorClassName }}"
options="{{ options }}"
value="{{ formData.value }}"
onOk="onOk"
bind:ok="onOk"
bind:change="onChange"
onCancel="onDismissPicker"
bind:cancel="onDismissPicker"
bind:visiblechange="onVisibleChange"
onFormat="{{ handleFormat ? handleFormat : 'handleFormat' }}">
<slot
Expand All @@ -43,12 +43,12 @@
<slot
name="content"
slot="content" />
<icon
<ant-icon
wx:if="{{ arrowUtil.getArrow(arrow) }}"
className="ant-form-picker-arrow"
type="{{ arrowUtil.getArrow(arrow) }}"
slot="suffix" />
</picker>
</ant-picker>
</view>
<view
wx:if="{{ !tooltip }}"
Expand Down
2 changes: 1 addition & 1 deletion compiled/wechat/src/Form/FormRadioGroup/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"component": true,
"usingComponents": {
"form-item": "../FormItem/index",
"radio-group": "../../Radio/RadioGroup/index"
"ant-radio-group": "../../Radio/RadioGroup/index"
}
}
Loading

0 comments on commit 0d66ceb

Please sign in to comment.