hy-app 0.5.11 → 0.5.12

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.
@@ -1,172 +1,183 @@
1
- <template>
2
- <view
3
- :class="cardClass"
4
- @click="handleClick"
5
- :style="[
6
- {
7
- background: bgColor,
8
- filter: boxShadow ? 'drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.2))' : ''
9
- },
10
- customStyle
11
- ]"
12
- >
13
- <!-- 优惠券主体 -->
14
- <view class="hy-coupon__content">
15
- <!-- 左侧金额/折扣信息 -->
16
- <view class="hy-coupon__content--left">
17
- <!-- @slot 自定义金额插槽 -->
18
- <slot v-if="$slots.left" name="left"></slot>
19
- <template v-else>
20
- <view class="hy-coupon__content--left__block">
21
- <view class="hy-coupon__content--left__value">
22
- <text>
23
- {{ amount || 0 }}
24
- </text>
25
- </view>
26
- <view class="hy-coupon__content--left__suffix">
27
- <text v-if="unit">{{ unit }}</text>
28
- <text v-else-if="type === 'discount'">折</text>
29
- <text v-else>元</text>
30
- </view>
31
- </view>
32
-
33
- <hy-tag
34
- :text="typeValue"
35
- size="mini"
36
- plain
37
- shape="circle"
38
- color="#FFFFFF"
39
- ></hy-tag>
40
- </template>
41
- </view>
42
-
43
- <hy-line
44
- :hairline="false"
45
- direction="column"
46
- dashed
47
- color="#FFFFFF"
48
- length="70%"
49
- ></hy-line>
50
-
51
- <!-- 右侧描述信息 -->
52
- <view class="hy-coupon__content--right">
53
- <!-- 自定义详情插槽 -->
54
- <slot v-if="$slots.right" name="right"></slot>
55
- <template v-else>
56
- <view class="hy-coupon__content--right__name">{{ title }}</view>
57
- <view class="hy-coupon__content--right__desc">{{ description }}</view>
58
- <view class="hy-coupon__content--right__validity">
59
- {{
60
- dateDesc
61
- ? dateDesc
62
- : `有效期: ${formatTime(startDate, format)} - ${formatTime(endDate, format)}`
63
- }}
64
- </view>
65
- </template>
66
- </view>
67
- </view>
68
-
69
- <!-- 右侧状态标签 -->
70
- <view class="hy-coupon__btn">
71
- <!-- 自定义按钮插槽 -->
72
- <slot v-if="$slots.button" name="button"></slot>
73
- <template v-else>
74
- <view v-if="btnMode === 'text'" class="hy-coupon__tag">
75
- <text class="hy-coupon__tag--btn" @tap.stop="onUsed">{{ btnText }}</text>
76
- </view>
77
- <hy-button
78
- v-if="btnMode === 'button'"
79
- :text="btnText"
80
- plain
81
- :disabled="isDisable"
82
- :size="buttonProp?.size || 'small'"
83
- :shape="buttonProp?.shape || 'circle'"
84
- :color="buttonProp?.color || '#FFFFFF'"
85
- :custom-style="{ marginRight: '10px' }"
86
- @click="onUsed"
87
- ></hy-button>
88
- </template>
89
- </view>
90
- </view>
91
- </template>
92
-
93
- <script lang="ts">
94
- export default {
95
- name: 'hy-coupon',
96
- options: {
97
- addGlobalClass: true,
98
- virtualHost: true,
99
- styleIsolation: 'shared'
100
- }
101
- }
102
- </script>
103
-
104
- <script setup lang="ts">
105
- import { computed } from 'vue'
106
- import type { ICouponEmits } from './typing'
107
- import { formatTime } from '../../libs'
108
- import couponProps from './props'
109
-
110
- // 组件
111
- import hyTag from '../hy-tag/hy-tag.vue'
112
- import hyLine from '../hy-line/hy-line.vue'
113
- import hyButton from '../hy-button/hy-button.vue'
114
-
115
- /**
116
- * 用于商品优惠券的业务组件
117
- * @displayName hy-coupon
118
- */
119
- defineOptions({})
120
-
121
- const props = defineProps(couponProps)
122
- const emit = defineEmits<ICouponEmits>()
123
-
124
- // 禁用功能
125
- const isDisable = computed(() => props.disabledStatus.includes(props.status))
126
-
127
- const typeValue = computed(() => {
128
- let text = ''
129
- if (props.typeText) {
130
- text = props.typeText
131
- } else {
132
- switch (props.type) {
133
- case 'moneyOff':
134
- text = '满减券'
135
- break
136
- case 'discount':
137
- text = '折扣券'
138
- break
139
- case 'fixedAmount':
140
- text = '无门槛券'
141
- break
142
- default:
143
- text = '未知券'
144
- break
145
- }
146
- }
147
- return text
148
- })
149
-
150
- const cardClass = computed(() => {
151
- const baseClass = 'hy-coupon hy-coupon__card'
152
- const typeClass = `hy-coupon--${props.type}`
153
- const statusClass = isDisable.value && 'hy-coupon--disabled'
154
- return `${baseClass} ${typeClass} ${statusClass} ${props.customClass}`
155
- })
156
-
157
- // 点击优惠券触发
158
- const handleClick = () => {
159
- emit('click')
160
- }
161
-
162
- // 点击使用优惠券触发
163
- const onUsed = () => {
164
- if (!isDisable.value) {
165
- emit('used')
166
- }
167
- }
168
- </script>
169
-
170
- <style scoped lang="scss">
171
- @import './index.scss';
172
- </style>
1
+ <template>
2
+ <view
3
+ :class="cardClass"
4
+ @click="handleClick"
5
+ :style="[
6
+ {
7
+ background: bgColor,
8
+ filter: boxShadow ? 'drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.2))' : ''
9
+ },
10
+ customStyle
11
+ ]"
12
+ >
13
+ <!-- 优惠券主体 -->
14
+ <view class="hy-coupon__content">
15
+ <!-- 左侧金额/折扣信息 -->
16
+ <view class="hy-coupon__content--left">
17
+ <!-- @slot 自定义金额插槽 -->
18
+ <slot v-if="$slots.left" name="left"></slot>
19
+ <template v-else>
20
+ <view class="hy-coupon__content--left__block">
21
+ <view class="hy-coupon__content--left__value">
22
+ <text>
23
+ {{ amount || 0 }}
24
+ </text>
25
+ </view>
26
+ <view class="hy-coupon__content--left__suffix">
27
+ <text v-if="unit">{{ unit }}</text>
28
+ <text v-else-if="type === 'discount'">折</text>
29
+ <text v-else>元</text>
30
+ </view>
31
+ </view>
32
+
33
+ <hy-tag
34
+ :text="typeValue"
35
+ size="mini"
36
+ plain
37
+ shape="circle"
38
+ color="#FFFFFF"
39
+ ></hy-tag>
40
+ </template>
41
+ </view>
42
+
43
+ <hy-line
44
+ :hairline="false"
45
+ direction="column"
46
+ dashed
47
+ color="#FFFFFF"
48
+ length="70%"
49
+ ></hy-line>
50
+
51
+ <!-- 右侧描述信息 -->
52
+ <view class="hy-coupon__content--right">
53
+ <!-- 自定义详情插槽 -->
54
+ <slot v-if="$slots.right" name="right"></slot>
55
+ <template v-else>
56
+ <view class="hy-coupon__content--right__name">{{ title }}</view>
57
+ <view
58
+ :class="[
59
+ 'hy-coupon__content--right__desc',
60
+ desEllipsis !== 'none' && 'is-ellipsis'
61
+ ]"
62
+ >{{ description }}</view
63
+ >
64
+ <view class="hy-coupon__content--right__validity">
65
+ {{
66
+ dateDesc
67
+ ? dateDesc
68
+ : `有效期: ${formatTime(startDate, format)} - ${formatTime(endDate, format)}`
69
+ }}
70
+ </view>
71
+ </template>
72
+ </view>
73
+ </view>
74
+
75
+ <!-- 右侧状态标签 -->
76
+ <view class="hy-coupon__btn">
77
+ <!-- 自定义按钮插槽 -->
78
+ <slot v-if="$slots.button" name="button"></slot>
79
+ <template v-else>
80
+ <view v-if="btnMode === 'text'" class="hy-coupon__tag">
81
+ <text class="hy-coupon__tag--btn" @tap.stop="onUsed">{{ btnText }}</text>
82
+ </view>
83
+ <hy-button
84
+ v-if="btnMode === 'button'"
85
+ :text="btnText"
86
+ plain
87
+ :disabled="isDisable"
88
+ :size="buttonProp?.size || 'small'"
89
+ :shape="buttonProp?.shape || 'circle'"
90
+ :color="buttonProp?.color || '#FFFFFF'"
91
+ :custom-style="{ marginRight: '10px' }"
92
+ @click="onUsed"
93
+ ></hy-button>
94
+ </template>
95
+ </view>
96
+ </view>
97
+ </template>
98
+
99
+ <script lang="ts">
100
+ export default {
101
+ name: 'hy-coupon',
102
+ options: {
103
+ addGlobalClass: true,
104
+ virtualHost: true,
105
+ styleIsolation: 'shared'
106
+ }
107
+ }
108
+ </script>
109
+
110
+ <script setup lang="ts">
111
+ import { computed } from 'vue'
112
+ import type { ICouponEmits } from './typing'
113
+ import { formatTime } from '../../libs'
114
+ import couponProps from './props'
115
+
116
+ // 组件
117
+ import hyTag from '../hy-tag/hy-tag.vue'
118
+ import hyLine from '../hy-line/hy-line.vue'
119
+ import hyButton from '../hy-button/hy-button.vue'
120
+
121
+ /**
122
+ * 用于商品优惠券的业务组件
123
+ * @displayName hy-coupon
124
+ */
125
+ defineOptions({})
126
+
127
+ const props = defineProps(couponProps)
128
+ const emit = defineEmits<ICouponEmits>()
129
+
130
+ // 禁用功能
131
+ const isDisable = computed(() => props.disabledStatus.includes(props.status))
132
+
133
+ const typeValue = computed(() => {
134
+ let text = ''
135
+ if (props.typeText) {
136
+ text = props.typeText
137
+ } else {
138
+ switch (props.type) {
139
+ case 'moneyOff':
140
+ text = '满减券'
141
+ break
142
+ case 'discount':
143
+ text = '折扣券'
144
+ break
145
+ case 'fixedAmount':
146
+ text = '无门槛券'
147
+ break
148
+ default:
149
+ text = '未知券'
150
+ break
151
+ }
152
+ }
153
+ return text
154
+ })
155
+
156
+ const cardClass = computed(() => {
157
+ const baseClass = 'hy-coupon hy-coupon__card'
158
+ const typeClass = `hy-coupon--${props.type}`
159
+ const statusClass = isDisable.value && 'hy-coupon--disabled'
160
+ return `${baseClass} ${typeClass} ${statusClass} ${props.customClass}`
161
+ })
162
+
163
+ // 点击优惠券触发
164
+ const handleClick = () => {
165
+ emit('click')
166
+ }
167
+
168
+ // 点击使用优惠券触发
169
+ const onUsed = () => {
170
+ if (!isDisable.value) {
171
+ emit('used')
172
+ }
173
+ }
174
+ </script>
175
+
176
+ <style scoped lang="scss">
177
+ @import './index.scss';
178
+ @import '../../libs/css/mixin.scss';
179
+
180
+ @include is(ellipsis) {
181
+ @include multiEllipsis(v-bind(desEllipsis));
182
+ }
183
+ </style>
@@ -5,7 +5,9 @@ $hy-box-width: 180rpx;
5
5
  @include b(coupon) {
6
6
  width: 100%;
7
7
  min-height: 190rpx;
8
- max-height: 220rpx;
8
+ max-height: 330rpx;
9
+ display: flex;
10
+ flex-direction: row;
9
11
 
10
12
  /* 已使用/过期状态的置灰效果 */
11
13
  @include m(disabled) {
@@ -30,10 +32,10 @@ $hy-box-width: 180rpx;
30
32
  /* 不同类型优惠券的背景色 */
31
33
  @include m(moneyOff) {
32
34
  background:
33
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, #ff7d00 0) top / 100% 60px
35
+ radial-gradient(circle at $hy-box-width top, transparent 15rpx, #ff7d00 0) top / 100% 85px
34
36
  no-repeat,
35
37
  radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, #ff7d00 0) bottom / 100%
36
- 51px no-repeat;
38
+ 85px no-repeat;
37
39
  //background:
38
40
  // radial-gradient(circle at left center, transparent 15rpx, #ff7d00 0) left center / 30rpx 100% no-repeat,
39
41
  // radial-gradient(circle at right center, transparent 15rpx, #ff7d00 0) right center / 30rpx 100% no-repeat;
@@ -42,14 +44,14 @@ $hy-box-width: 180rpx;
42
44
  }
43
45
  @include m(discount) {
44
46
  background:
45
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, #00c6ff 0) top / 100% 60px
47
+ radial-gradient(circle at $hy-box-width top, transparent 15rpx, #00c6ff 0) top / 100% 70px
46
48
  no-repeat,
47
49
  radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, #00c6ff 0) bottom / 100%
48
50
  51px no-repeat;
49
51
  }
50
52
  @include m(fixedAmount) {
51
53
  background:
52
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, $hy-error 0) top / 100% 60px
54
+ radial-gradient(circle at $hy-box-width top, transparent 15rpx, $hy-error 0) top / 100% 70px
53
55
  no-repeat,
54
56
  radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, $hy-error 0) bottom / 100%
55
57
  51px no-repeat;
@@ -73,6 +75,7 @@ $hy-box-width: 180rpx;
73
75
  width: $hy-box-width;
74
76
  padding: $hy-border-margin-padding-base;
75
77
  box-sizing: border-box;
78
+ flex-shrink: 0;
76
79
 
77
80
  @include e(block) {
78
81
  display: flex;
@@ -97,25 +100,23 @@ $hy-box-width: 180rpx;
97
100
 
98
101
  /* 右侧描述 */
99
102
  @include m(right) {
100
- flex: 1;
101
103
  display: flex;
102
104
  flex-direction: column;
103
- justify-content: flex-start;
104
- text-align: start;
105
+ box-sizing: border-box;
105
106
  padding: $hy-border-margin-padding-base;
106
107
 
107
108
  @include e(name) {
108
109
  font-size: 30rpx;
109
110
  font-weight: 600;
110
111
  margin-bottom: 8rpx;
111
- @include lineEllipsis;
112
112
  }
113
113
 
114
114
  @include e(desc) {
115
- @include multiEllipsis(2);
115
+ width: 100%;
116
116
  }
117
117
 
118
118
  @include e(validity) {
119
+ width: 100%;
119
120
  @include lineEllipsis;
120
121
  }
121
122
 
@@ -123,24 +124,19 @@ $hy-box-width: 180rpx;
123
124
  font-size: 22rpx;
124
125
  opacity: 0.9;
125
126
  line-height: 1.4;
126
- @include lineEllipsis;
127
127
  }
128
128
  }
129
129
  }
130
130
 
131
131
  /* 右侧状态标签 */
132
132
  @include e(btn) {
133
- position: absolute;
134
- bottom: 0;
135
- right: 0;
136
- height: 100%;
137
133
  display: flex;
138
134
  justify-content: flex-start;
139
135
  align-items: center;
140
136
  }
141
137
  @include e(tag) {
142
138
  height: 100%;
143
- margin-left: 60rpx;
139
+ margin-left: 20rpx;
144
140
  width: 120rpx;
145
141
  display: flex;
146
142
  align-items: center;
@@ -1,103 +1,108 @@
1
- import type { CSSProperties, PropType } from 'vue'
2
- import type { HyButtonProps } from '../hy-button/typing'
3
-
4
- const couponProps = {
5
- /** 优惠券标题 */
6
- title: {
7
- type: String,
8
- default: ''
9
- },
10
- /**
11
- * 优惠券类型:moneyOff:满减券,discount:折扣券,fixedAmount:无门槛券
12
- * @values moneyOff,discount,fixedAmount
13
- * */
14
- type: {
15
- type: String,
16
- default: ''
17
- },
18
- /** 金额底部优惠券类型文字描述 */
19
- typeText: {
20
- type: String,
21
- default: ''
22
- },
23
- /** 优惠券状态 */
24
- status: {
25
- type: String,
26
- default: ''
27
- },
28
- /** 优惠券禁用状态 */
29
- disabledStatus: {
30
- type: Array,
31
- default: () => ['']
32
- },
33
- /** 优惠券描述备注 */
34
- description: {
35
- type: String,
36
- default: ''
37
- },
38
- /** 优惠券金额 */
39
- amount: {
40
- type: [String, Number],
41
- default: ''
42
- },
43
- /** 优惠券单位,没有就用默认值 */
44
- unit: {
45
- type: String,
46
- default: ''
47
- },
48
- /** 优惠券开始时间 */
49
- startDate: {
50
- type: String,
51
- default: ''
52
- },
53
- /** 优惠券结束时间 */
54
- endDate: {
55
- type: String,
56
- default: ''
57
- },
58
- /** 时间格式 */
59
- format: {
60
- type: String,
61
- default: 'yyyy-MM-dd'
62
- },
63
- /** 日期描述,没有日期描述就用开始时间到结束时间 */
64
- dateDesc: {
65
- type: String,
66
- default: ''
67
- },
68
- /** 背景色 */
69
- bgColor: {
70
- type: String,
71
- default: ''
72
- },
73
- /** 是否显示阴影 */
74
- boxShadow: {
75
- type: Boolean,
76
- default: false
77
- },
78
- /**
79
- * 按钮类型
80
- * @values text,button,none
81
- * */
82
- btnMode: {
83
- type: String,
84
- default: 'button'
85
- },
86
- /** 按钮文字 */
87
- btnText: {
88
- type: String,
89
- default: '立即领取'
90
- },
91
- buttonProp: {
92
- type: Object as PropType<HyButtonProps>,
93
- default: () => ({})
94
- },
95
- /** 定义需要用到的外部样式 */
96
- customStyle: {
97
- type: Object as PropType<CSSProperties>
98
- },
99
- /** 自定义外部类名 */
100
- customClass: String
101
- }
102
-
103
- export default couponProps
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import type { HyButtonProps } from '../hy-button/typing'
3
+
4
+ const couponProps = {
5
+ /** 优惠券标题 */
6
+ title: {
7
+ type: String,
8
+ default: ''
9
+ },
10
+ /**
11
+ * 优惠券类型:moneyOff:满减券,discount:折扣券,fixedAmount:无门槛券
12
+ * @values moneyOff,discount,fixedAmount
13
+ * */
14
+ type: {
15
+ type: String,
16
+ default: ''
17
+ },
18
+ /** 金额底部优惠券类型文字描述 */
19
+ typeText: {
20
+ type: String,
21
+ default: ''
22
+ },
23
+ /** 优惠券状态 */
24
+ status: {
25
+ type: String,
26
+ default: ''
27
+ },
28
+ /** 优惠券禁用状态 */
29
+ disabledStatus: {
30
+ type: Array,
31
+ default: () => ['']
32
+ },
33
+ /** 优惠券描述备注 */
34
+ description: {
35
+ type: String,
36
+ default: ''
37
+ },
38
+ /** 优惠券金额 */
39
+ amount: {
40
+ type: [String, Number],
41
+ default: ''
42
+ },
43
+ /** 优惠券单位,没有就用默认值 */
44
+ unit: {
45
+ type: String,
46
+ default: ''
47
+ },
48
+ /** 描述省略行数,none不省略,1代表一行省略 */
49
+ desEllipsis: {
50
+ type: [String, Number],
51
+ default: 'none'
52
+ },
53
+ /** 优惠券开始时间 */
54
+ startDate: {
55
+ type: String,
56
+ default: ''
57
+ },
58
+ /** 优惠券结束时间 */
59
+ endDate: {
60
+ type: String,
61
+ default: ''
62
+ },
63
+ /** 时间格式 */
64
+ format: {
65
+ type: String,
66
+ default: 'yyyy-MM-dd'
67
+ },
68
+ /** 日期描述,没有日期描述就用开始时间到结束时间 */
69
+ dateDesc: {
70
+ type: String,
71
+ default: ''
72
+ },
73
+ /** 背景色 */
74
+ bgColor: {
75
+ type: String,
76
+ default: ''
77
+ },
78
+ /** 是否显示阴影 */
79
+ boxShadow: {
80
+ type: Boolean,
81
+ default: false
82
+ },
83
+ /**
84
+ * 按钮类型
85
+ * @values test,button,none
86
+ * */
87
+ btnMode: {
88
+ type: String,
89
+ default: 'button'
90
+ },
91
+ /** 按钮文字 */
92
+ btnText: {
93
+ type: String,
94
+ default: '立即领取'
95
+ },
96
+ buttonProp: {
97
+ type: Object as PropType<HyButtonProps>,
98
+ default: () => ({})
99
+ },
100
+ /** 定义需要用到的外部样式 */
101
+ customStyle: {
102
+ type: Object as PropType<CSSProperties>
103
+ },
104
+ /** 自定义外部类名 */
105
+ customClass: String
106
+ }
107
+
108
+ export default couponProps