hy-app 0.5.11 → 0.5.13

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>
@@ -1,11 +1,14 @@
1
1
  @use '../../libs/css/mixin' as *;
2
2
  @use '../../libs/css/theme.scss' as *;
3
3
 
4
- $hy-box-width: 180rpx;
4
+ $hy-coupon--box-width: 180rpx;
5
+ $hy-coupon--bg-height: 166rpx;
5
6
  @include b(coupon) {
6
7
  width: 100%;
7
8
  min-height: 190rpx;
8
- max-height: 220rpx;
9
+ max-height: 330rpx;
10
+ display: flex;
11
+ flex-direction: row;
9
12
 
10
13
  /* 已使用/过期状态的置灰效果 */
11
14
  @include m(disabled) {
@@ -30,10 +33,10 @@ $hy-box-width: 180rpx;
30
33
  /* 不同类型优惠券的背景色 */
31
34
  @include m(moneyOff) {
32
35
  background:
33
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, #ff7d00 0) top / 100% 60px
36
+ radial-gradient(circle at $hy-coupon--box-width top, transparent 15rpx, #ff7d00 0) top / 100% $hy-coupon--bg-height
34
37
  no-repeat,
35
- radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, #ff7d00 0) bottom / 100%
36
- 51px no-repeat;
38
+ radial-gradient(circle at $hy-coupon--box-width bottom, transparent 15rpx, #ff7d00 0) bottom / 100%
39
+ $hy-coupon--bg-height no-repeat;
37
40
  //background:
38
41
  // radial-gradient(circle at left center, transparent 15rpx, #ff7d00 0) left center / 30rpx 100% no-repeat,
39
42
  // radial-gradient(circle at right center, transparent 15rpx, #ff7d00 0) right center / 30rpx 100% no-repeat;
@@ -42,17 +45,17 @@ $hy-box-width: 180rpx;
42
45
  }
43
46
  @include m(discount) {
44
47
  background:
45
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, #00c6ff 0) top / 100% 60px
48
+ radial-gradient(circle at $hy-coupon--box-width top, transparent 15rpx, #00c6ff 0) top / 100% $hy-coupon--bg-height
46
49
  no-repeat,
47
- radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, #00c6ff 0) bottom / 100%
48
- 51px no-repeat;
50
+ radial-gradient(circle at $hy-coupon--box-width bottom, transparent 15rpx, #00c6ff 0) bottom / 100%
51
+ $hy-coupon--bg-height no-repeat;
49
52
  }
50
53
  @include m(fixedAmount) {
51
54
  background:
52
- radial-gradient(circle at $hy-box-width top, transparent 15rpx, $hy-error 0) top / 100% 60px
55
+ radial-gradient(circle at $hy-coupon--box-width top, transparent 15rpx, $hy-error 0) top / 100% $hy-coupon--bg-height
53
56
  no-repeat,
54
- radial-gradient(circle at $hy-box-width bottom, transparent 15rpx, $hy-error 0) bottom / 100%
55
- 51px no-repeat;
57
+ radial-gradient(circle at $hy-coupon--box-width bottom, transparent 15rpx, $hy-error 0) bottom / 100%
58
+ $hy-coupon--bg-height no-repeat;
56
59
  }
57
60
 
58
61
  /* 优惠券内容区域 */
@@ -70,9 +73,10 @@ $hy-box-width: 180rpx;
70
73
  justify-content: center;
71
74
  align-items: center;
72
75
  height: 100%;
73
- width: $hy-box-width;
76
+ width: $hy-coupon--box-width;
74
77
  padding: $hy-border-margin-padding-base;
75
78
  box-sizing: border-box;
79
+ flex-shrink: 0;
76
80
 
77
81
  @include e(block) {
78
82
  display: flex;
@@ -97,25 +101,23 @@ $hy-box-width: 180rpx;
97
101
 
98
102
  /* 右侧描述 */
99
103
  @include m(right) {
100
- flex: 1;
101
104
  display: flex;
102
105
  flex-direction: column;
103
- justify-content: flex-start;
104
- text-align: start;
106
+ box-sizing: border-box;
105
107
  padding: $hy-border-margin-padding-base;
106
108
 
107
109
  @include e(name) {
108
110
  font-size: 30rpx;
109
111
  font-weight: 600;
110
112
  margin-bottom: 8rpx;
111
- @include lineEllipsis;
112
113
  }
113
114
 
114
115
  @include e(desc) {
115
- @include multiEllipsis(2);
116
+ width: 100%;
116
117
  }
117
118
 
118
119
  @include e(validity) {
120
+ width: 100%;
119
121
  @include lineEllipsis;
120
122
  }
121
123
 
@@ -123,24 +125,19 @@ $hy-box-width: 180rpx;
123
125
  font-size: 22rpx;
124
126
  opacity: 0.9;
125
127
  line-height: 1.4;
126
- @include lineEllipsis;
127
128
  }
128
129
  }
129
130
  }
130
131
 
131
132
  /* 右侧状态标签 */
132
133
  @include e(btn) {
133
- position: absolute;
134
- bottom: 0;
135
- right: 0;
136
- height: 100%;
137
134
  display: flex;
138
135
  justify-content: flex-start;
139
136
  align-items: center;
140
137
  }
141
138
  @include e(tag) {
142
139
  height: 100%;
143
- margin-left: 60rpx;
140
+ margin-left: 20rpx;
144
141
  width: 120rpx;
145
142
  display: flex;
146
143
  align-items: center;