hy-app 0.4.13 → 0.5.0
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/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
export default interface HyCountToProps {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @description 开始的数值,默认从0增长到某一个数(默认 0 )
|
|
4
|
+
* */
|
|
5
|
+
startVal?: number
|
|
6
|
+
/**
|
|
7
|
+
* @description 要滚动的目标数值,必须 (默认 0 )
|
|
8
|
+
* */
|
|
9
|
+
endVal: number
|
|
10
|
+
/**
|
|
11
|
+
* @description 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认
|
|
12
|
+
* */
|
|
13
|
+
duration?: number
|
|
14
|
+
/**
|
|
15
|
+
* @description 设置数值后是否自动开始滚动 (默认 true )
|
|
16
|
+
* */
|
|
17
|
+
autoplay?: boolean
|
|
18
|
+
/**
|
|
19
|
+
* @description 要显示的小数位数,见官网说明(默认 0 )
|
|
20
|
+
* */
|
|
21
|
+
decimals?: number
|
|
22
|
+
/**
|
|
23
|
+
* @description 滚动结束时,是否缓动结尾,见官网说明(默认 true )
|
|
24
|
+
* */
|
|
25
|
+
useEasing?: boolean
|
|
26
|
+
/**
|
|
27
|
+
* @description 十进制分割 ( 默认 "." )
|
|
28
|
+
* */
|
|
29
|
+
decimal?: string
|
|
30
|
+
/**
|
|
31
|
+
* @description 字体颜色( 默认 '#606266' )
|
|
32
|
+
* */
|
|
33
|
+
color?: string
|
|
34
|
+
/**
|
|
35
|
+
* @description 字体大小,单位px( 默认 22 )
|
|
36
|
+
* */
|
|
37
|
+
fontSize?: number | string
|
|
38
|
+
/**
|
|
39
|
+
* @description 字体是否加粗(默认 false )
|
|
40
|
+
* */
|
|
41
|
+
bold?: boolean
|
|
42
|
+
/**
|
|
43
|
+
* @description 千位分隔符,见官网说明
|
|
44
|
+
* */
|
|
45
|
+
separator?: string
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface ICountToEmits {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
/** 结束执行函数 */
|
|
50
|
+
(e: 'end'): void
|
|
51
51
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# HyCoupon 优惠券组件
|
|
2
|
+
|
|
3
|
+
市场上常用的优惠券组件,支持多种状态展示和丰富的功能配置。
|
|
4
|
+
|
|
5
|
+
## 引入方式
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// 全局引入
|
|
9
|
+
import { createApp } from 'vue'
|
|
10
|
+
import HyDesignUni from '@/package'
|
|
11
|
+
import App from './App.vue'
|
|
12
|
+
|
|
13
|
+
const app = createApp(App)
|
|
14
|
+
app.use(HyDesignUni)
|
|
15
|
+
app.mount('#app')
|
|
16
|
+
|
|
17
|
+
// 局部引入
|
|
18
|
+
import { HyCoupon } from '@/package'
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
components: {
|
|
22
|
+
HyCoupon
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 基本用法
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<hy-coupon
|
|
31
|
+
amount="50"
|
|
32
|
+
title="新人专享优惠券"
|
|
33
|
+
subtitle="全场通用,无门槛使用"
|
|
34
|
+
validity="2023.10.01-2023.12.31"
|
|
35
|
+
@click="onCouponClick"
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 状态展示
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<!-- 已使用状态 -->
|
|
43
|
+
<hy-coupon
|
|
44
|
+
amount="30"
|
|
45
|
+
title="已使用优惠券"
|
|
46
|
+
status="used"
|
|
47
|
+
used-date="2023-10-15 14:30"
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
<!-- 已过期状态 -->
|
|
51
|
+
<hy-coupon
|
|
52
|
+
amount="15"
|
|
53
|
+
title="已过期优惠券"
|
|
54
|
+
status="expired"
|
|
55
|
+
expire-date="2023-10-01"
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<!-- 已禁用状态 -->
|
|
59
|
+
<hy-coupon
|
|
60
|
+
amount="25"
|
|
61
|
+
title="已禁用优惠券"
|
|
62
|
+
status="disabled"
|
|
63
|
+
disabled-reason="账户等级不足"
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 增强功能
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<!-- 专属优惠券 -->
|
|
71
|
+
<hy-coupon
|
|
72
|
+
amount="40"
|
|
73
|
+
title="专属优惠券"
|
|
74
|
+
is-exclusive
|
|
75
|
+
limit-per-user="1"
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<!-- 显示操作按钮 -->
|
|
79
|
+
<hy-coupon
|
|
80
|
+
amount="60"
|
|
81
|
+
title="限时优惠券"
|
|
82
|
+
show-action-button
|
|
83
|
+
@receive="onCouponReceive"
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<!-- 自定义按钮文本 -->
|
|
87
|
+
<hy-coupon
|
|
88
|
+
amount="100"
|
|
89
|
+
title="大额优惠券"
|
|
90
|
+
show-action-button
|
|
91
|
+
custom-button-text="立即兑换"
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Props
|
|
96
|
+
|
|
97
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
98
|
+
|-------|------|-------|------|
|
|
99
|
+
| amount | string/number | - | 优惠券金额 |
|
|
100
|
+
| title | string | - | 优惠券标题 |
|
|
101
|
+
| subtitle | string | '' | 优惠券副标题 |
|
|
102
|
+
| status | string | 'normal' | 优惠券状态:normal/disabled/used/expired |
|
|
103
|
+
| minSpend | string/number | 0 | 最低消费金额 |
|
|
104
|
+
| validity | string | '' | 有效期文本 |
|
|
105
|
+
| customStyle | Object | {} | 自定义样式 |
|
|
106
|
+
| showRightBorder | boolean | true | 是否显示右侧边框装饰 |
|
|
107
|
+
| tooltip | string | '' | 提示文本 |
|
|
108
|
+
| showActionButton | boolean | false | 是否显示操作按钮 |
|
|
109
|
+
| customButtonText | string | '' | 自定义按钮文本 |
|
|
110
|
+
| isExclusive | boolean | false | 是否为专属优惠券 |
|
|
111
|
+
| limitPerUser | number | 0 | 每用户限领数量 |
|
|
112
|
+
| usedDate | string | '' | 使用日期(已使用状态时显示) |
|
|
113
|
+
| expireDate | string | '' | 过期日期(已过期状态时显示) |
|
|
114
|
+
| disabledReason | string | '' | 禁用原因(已禁用状态时显示) |
|
|
115
|
+
| triggerReceiveOnClick | boolean | true | 点击时是否触发receive事件 |
|
|
116
|
+
|
|
117
|
+
## Events
|
|
118
|
+
|
|
119
|
+
| 事件名 | 说明 | 回调参数 |
|
|
120
|
+
|-------|------|--------|
|
|
121
|
+
| click | 点击优惠券时触发(仅正常状态) | event: { status: CouponStatus } |
|
|
122
|
+
| receive | 领取优惠券时触发 | - |
|
|
123
|
+
| hover | 鼠标悬停状态改变时触发 | value: boolean |
|
|
124
|
+
|
|
125
|
+
## 示例页面
|
|
126
|
+
|
|
127
|
+
请查看 `pages/coupon-demo/index.vue` 了解更多使用示例。
|
|
128
|
+
|
|
129
|
+
## 注意事项
|
|
130
|
+
|
|
131
|
+
1. 在移动端环境下,`hover` 相关效果可能表现不同,请根据实际情况调整。
|
|
132
|
+
2. 当优惠券金额较大时,建议使用 `customStyle` 调整字体大小以保证显示效果。
|
|
133
|
+
3. 在小屏幕设备上,长文本可能会被截断,建议优化文本内容或调整组件宽度。
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="['hy-coupon', `hy-coupon--${status}`, `hy-coupon--${type}`, customClass]"
|
|
4
|
+
:style="customStyle"
|
|
5
|
+
@click="handleClick"
|
|
6
|
+
@mouseenter="handleMouseEnter"
|
|
7
|
+
@mouseleave="handleMouseLeave"
|
|
8
|
+
>
|
|
9
|
+
<!-- 顶部和底部波浪形装饰 -->
|
|
10
|
+
<view class="top-wave"></view>
|
|
11
|
+
<view class="bottom-wave"></view>
|
|
12
|
+
|
|
13
|
+
<!-- 左侧金额区域 -->
|
|
14
|
+
<view class="hy-coupon__left">
|
|
15
|
+
<!-- 背景纹理 -->
|
|
16
|
+
<view class="texture"></view>
|
|
17
|
+
<text class="amount">
|
|
18
|
+
<text class="amount-symbol">¥</text>
|
|
19
|
+
{{ amount }}
|
|
20
|
+
</text>
|
|
21
|
+
<text class="min-spend" v-if="minSpend > 0"> 满{{ minSpend }}可用 </text>
|
|
22
|
+
</view>
|
|
23
|
+
|
|
24
|
+
<!-- 优惠券左侧边框装饰 -->
|
|
25
|
+
<view v-if="showLeftBorder" class="coupon-border-left"></view>
|
|
26
|
+
|
|
27
|
+
<!-- 右侧内容区域 -->
|
|
28
|
+
<view class="hy-coupon__right">
|
|
29
|
+
<view class="content">
|
|
30
|
+
<text class="title">{{ title }}</text>
|
|
31
|
+
<text v-if="subTitle" class="subtitle">{{ subTitle }}</text>
|
|
32
|
+
</view>
|
|
33
|
+
<text class="validity">{{ validityText }}</text>
|
|
34
|
+
|
|
35
|
+
<!-- 限制标签 -->
|
|
36
|
+
<view class="limit-tags" v-if="limitTags.length > 0">
|
|
37
|
+
<text v-for="(tag, index) in limitTags" :key="index" class="limit-tag">
|
|
38
|
+
{{ tag }}
|
|
39
|
+
</text>
|
|
40
|
+
</view>
|
|
41
|
+
|
|
42
|
+
<!-- 立即领取按钮 -->
|
|
43
|
+
<view class="action-button" v-if="showActionButton">
|
|
44
|
+
<text class="action-button-text">{{ buttonText }}</text>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
|
|
48
|
+
<!-- 优惠券右侧边框装饰 -->
|
|
49
|
+
<view v-if="showRightBorder" class="coupon-border-right"></view>
|
|
50
|
+
|
|
51
|
+
<!-- 悬浮提示 -->
|
|
52
|
+
<view v-if="tooltip" class="coupon-tooltip" :class="{ show: showTooltip }">
|
|
53
|
+
{{ tooltip }}
|
|
54
|
+
</view>
|
|
55
|
+
</view>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
import { defineComponent, ref, computed } from "vue";
|
|
60
|
+
import type { CouponStatus } from "./typing";
|
|
61
|
+
import { props } from "./props";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 优惠券组件
|
|
65
|
+
* @displayName hy-coupon
|
|
66
|
+
*/
|
|
67
|
+
export default defineComponent({
|
|
68
|
+
name: "HyCoupon",
|
|
69
|
+
props,
|
|
70
|
+
emits: ["click", "receive", "hover"],
|
|
71
|
+
setup(props: any, { emit }) {
|
|
72
|
+
|
|
73
|
+
// 响应式数据
|
|
74
|
+
const showTooltip = ref(false);
|
|
75
|
+
|
|
76
|
+
// 计算有效性文本
|
|
77
|
+
const validityText = computed(() => {
|
|
78
|
+
if (!props.validity) return "";
|
|
79
|
+
|
|
80
|
+
// 根据状态显示不同的有效期文本
|
|
81
|
+
switch (props.status) {
|
|
82
|
+
case "used":
|
|
83
|
+
return props.usedDate ? `使用时间: ${props.usedDate}` : "已使用";
|
|
84
|
+
case "expired":
|
|
85
|
+
return props.expireDate ? `有效期至: ${props.expireDate}` : "已过期";
|
|
86
|
+
case "disabled":
|
|
87
|
+
return props.disabledReason || "已禁用";
|
|
88
|
+
default:
|
|
89
|
+
return props.validity;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// 计算限制标签
|
|
94
|
+
const limitTags = computed(() => {
|
|
95
|
+
const tags: string[] = [];
|
|
96
|
+
|
|
97
|
+
// 根据属性添加不同的标签
|
|
98
|
+
if (props.isExclusive) {
|
|
99
|
+
tags.push("专属");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (props.limitPerUser > 0) {
|
|
103
|
+
tags.push(`限领${props.limitPerUser}张`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (props.minSpend > 0 && props.minSpend <= 1000) {
|
|
107
|
+
// 小额满减可以显示在标签中
|
|
108
|
+
tags.push(`满${props.minSpend}可用`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return tags;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// 按钮文本
|
|
115
|
+
const buttonText = computed(() => {
|
|
116
|
+
return (
|
|
117
|
+
props.customButtonText || (props.status === "normal" ? "立即领取" : "")
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// 是否显示操作按钮
|
|
122
|
+
const showActionButton = computed(() => {
|
|
123
|
+
return props.showActionButton && props.status === "normal";
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// 是否显示左侧边框装饰
|
|
127
|
+
const showLeftBorder = computed(() => {
|
|
128
|
+
return true; // 默认显示左侧边框装饰
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// 是否显示右侧边框装饰
|
|
132
|
+
const showRightBorder = computed(() => {
|
|
133
|
+
return true; // 默认显示右侧边框装饰
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// 处理点击事件
|
|
137
|
+
const handleClick = () => {
|
|
138
|
+
if (props.status === "normal") {
|
|
139
|
+
emit("click", { status: props.status });
|
|
140
|
+
|
|
141
|
+
// 如果需要,可以同时触发receive事件
|
|
142
|
+
if (props.triggerReceiveOnClick) {
|
|
143
|
+
emit("receive");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// 鼠标悬停处理
|
|
149
|
+
const handleMouseEnter = () => {
|
|
150
|
+
if (props.tooltip) {
|
|
151
|
+
showTooltip.value = true;
|
|
152
|
+
}
|
|
153
|
+
emit("hover", true);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// 鼠标离开处理
|
|
157
|
+
const handleMouseLeave = () => {
|
|
158
|
+
showTooltip.value = false;
|
|
159
|
+
emit("hover", false);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
showTooltip,
|
|
164
|
+
validityText,
|
|
165
|
+
limitTags,
|
|
166
|
+
buttonText,
|
|
167
|
+
showActionButton,
|
|
168
|
+
showLeftBorder,
|
|
169
|
+
showRightBorder,
|
|
170
|
+
handleClick,
|
|
171
|
+
handleMouseEnter,
|
|
172
|
+
handleMouseLeave,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<style lang="scss" scoped>
|
|
179
|
+
@import "./index.scss";
|
|
180
|
+
</style>
|