@yorkjs/hive-biz 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hive-biz.esm.js +1 -1
- package/dist/hive-biz.esm.js.map +1 -1
- package/dist/hive-biz.esm.min.js +1 -1
- package/dist/hive-biz.esm.min.js.map +1 -1
- package/dist/hive-biz.js +1 -1
- package/dist/hive-biz.js.map +1 -1
- package/dist/hive-biz.min.js +1 -1
- package/dist/hive-biz.min.js.map +1 -1
- package/package.json +1 -1
- package/types/coupon/constant.d.ts +6 -0
- package/types/coupon/couponSelector.d.ts +22 -0
- package/types/coupon/couponUtil.d.ts +13 -0
- package/types/coupon/type.d.ts +55 -0
- package/types/index.d.ts +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const COUPON_BENEFIT_TYPE_AMOUNT = 1;
|
|
2
|
+
export declare const COUPON_BENEFIT_TYPE_DISCOUNT = 2;
|
|
3
|
+
export declare const COUPON_EXPAND_TYPE_EXTRA = "extra";
|
|
4
|
+
export declare const COUPON_EXPAND_TYPE_REASON = "reason";
|
|
5
|
+
export declare const COUPON_EXPAND_TYPE_NONE = "none";
|
|
6
|
+
export declare const COUPON_CONFIRM_EMPTY_MSG = "\u8BF7\u9009\u62E9\u4F18\u60E0\u5238";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ICouponConfirmResult, ICouponSelectorOptions, ICouponSelectorView } from './type';
|
|
2
|
+
export declare class CouponSelector {
|
|
3
|
+
private list;
|
|
4
|
+
private selectedId?;
|
|
5
|
+
private expandedIds;
|
|
6
|
+
private formatItem?;
|
|
7
|
+
private expandOne;
|
|
8
|
+
private onChange;
|
|
9
|
+
constructor(options: ICouponSelectorOptions);
|
|
10
|
+
setList(list: any[]): void;
|
|
11
|
+
appendList(list: any[]): void;
|
|
12
|
+
getView(): ICouponSelectorView;
|
|
13
|
+
select(id: string | number): void;
|
|
14
|
+
toggleExpand(id: string | number): void;
|
|
15
|
+
confirm(): ICouponConfirmResult;
|
|
16
|
+
private _toViewItem;
|
|
17
|
+
private _findCoupon;
|
|
18
|
+
private _pickValidSelectedId;
|
|
19
|
+
private _isExpanded;
|
|
20
|
+
private _setExpanded;
|
|
21
|
+
private _notifyChange;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CouponExpandType, CouponFormatItem, ICoupon, ICouponKvLine } from './type';
|
|
2
|
+
export declare function isSameCouponId(a?: string | number, b?: string | number): boolean;
|
|
3
|
+
export declare function formatCouponList(rawList?: any[], formatItem?: CouponFormatItem): ICoupon[];
|
|
4
|
+
export declare function formatCouponAmountValue(coupon: ICoupon): string;
|
|
5
|
+
export declare function formatCouponAmountPrefix(coupon: ICoupon): string;
|
|
6
|
+
export declare function formatCouponAmountSuffix(coupon: ICoupon): string;
|
|
7
|
+
export declare function formatCouponThreshold(coupon: ICoupon): string;
|
|
8
|
+
export declare function formatCouponKvText(line: ICouponKvLine): string;
|
|
9
|
+
export declare function getCouponContentLines(coupon: ICoupon): ICouponKvLine[];
|
|
10
|
+
export declare function parseCouponKvLine(text: string): ICouponKvLine;
|
|
11
|
+
export declare function getCouponExpandKvLines(coupon: ICoupon): ICouponKvLine[];
|
|
12
|
+
export declare function getCouponExpandType(coupon: ICoupon): CouponExpandType;
|
|
13
|
+
export declare function getCouponExpandLines(coupon: ICoupon): string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { COUPON_EXPAND_TYPE_EXTRA, COUPON_EXPAND_TYPE_NONE, COUPON_EXPAND_TYPE_REASON } from './constant';
|
|
2
|
+
export type CouponFormatItem = (item: any) => ICoupon | null | undefined;
|
|
3
|
+
export type CouponExpandType = typeof COUPON_EXPAND_TYPE_EXTRA | typeof COUPON_EXPAND_TYPE_REASON | typeof COUPON_EXPAND_TYPE_NONE;
|
|
4
|
+
export interface ICoupon {
|
|
5
|
+
id: string | number;
|
|
6
|
+
title: string;
|
|
7
|
+
available: boolean;
|
|
8
|
+
benefitType: number;
|
|
9
|
+
amount?: number;
|
|
10
|
+
discount?: number;
|
|
11
|
+
thresholdAmount?: number;
|
|
12
|
+
thresholdText?: string;
|
|
13
|
+
typeText?: string;
|
|
14
|
+
expireText?: string;
|
|
15
|
+
extraLines?: string[];
|
|
16
|
+
unavailableReason?: string;
|
|
17
|
+
original?: any;
|
|
18
|
+
}
|
|
19
|
+
export interface ICouponKvLine {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ICouponViewItem {
|
|
24
|
+
coupon: ICoupon;
|
|
25
|
+
selected: boolean;
|
|
26
|
+
expanded: boolean;
|
|
27
|
+
available: boolean;
|
|
28
|
+
amountPrefix: string;
|
|
29
|
+
amountValue: string;
|
|
30
|
+
amountSuffix: string;
|
|
31
|
+
title: string;
|
|
32
|
+
contentLines: string[];
|
|
33
|
+
thresholdText: string;
|
|
34
|
+
typeText: string;
|
|
35
|
+
expireText: string;
|
|
36
|
+
expandType: CouponExpandType;
|
|
37
|
+
expandLines: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface ICouponSelectorView {
|
|
40
|
+
items: ICouponViewItem[];
|
|
41
|
+
selectedId?: string | number;
|
|
42
|
+
selectedCoupon?: ICoupon;
|
|
43
|
+
}
|
|
44
|
+
export interface ICouponSelectorOptions {
|
|
45
|
+
list?: any[];
|
|
46
|
+
value?: string | number;
|
|
47
|
+
formatItem?: CouponFormatItem;
|
|
48
|
+
expandOne?: boolean;
|
|
49
|
+
onChange: () => void;
|
|
50
|
+
}
|
|
51
|
+
export interface ICouponConfirmResult {
|
|
52
|
+
isValid: boolean;
|
|
53
|
+
errMsg?: string;
|
|
54
|
+
coupon?: ICoupon;
|
|
55
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -6,3 +6,7 @@ export * from './selector/type';
|
|
|
6
6
|
export * from './selector/productUtil';
|
|
7
7
|
export * from './selector/customizationUtil';
|
|
8
8
|
export * from './selector/comboUtil';
|
|
9
|
+
export * from './coupon/constant';
|
|
10
|
+
export * from './coupon/type';
|
|
11
|
+
export * from './coupon/couponUtil';
|
|
12
|
+
export * from './coupon/couponSelector';
|