hy-app 0.6.4 → 0.6.6

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.
Files changed (106) hide show
  1. package/attributes.json +1 -1
  2. package/components/hy-address-picker/hy-address-picker.vue +249 -249
  3. package/components/hy-address-picker/props.ts +103 -103
  4. package/components/hy-button/hy-button.vue +320 -289
  5. package/components/hy-button/props.ts +143 -143
  6. package/components/hy-button/typing.d.ts +43 -35
  7. package/components/hy-calendar/header.vue +58 -58
  8. package/components/hy-calendar/hy-calendar.vue +8 -6
  9. package/components/hy-calendar/month.vue +402 -402
  10. package/components/hy-calendar/props.ts +169 -169
  11. package/components/hy-calendar/typing.d.ts +47 -45
  12. package/components/hy-cell-item/hy-cell-item.vue +161 -161
  13. package/components/hy-cell-item/props.ts +59 -59
  14. package/components/hy-check-button/hy-check-button.vue +135 -135
  15. package/components/hy-code-input/hy-code-input.vue +231 -231
  16. package/components/hy-code-input/props.ts +90 -90
  17. package/components/hy-config-provider/hy-config-provider.vue +53 -53
  18. package/components/hy-config-provider/props.ts +30 -30
  19. package/components/hy-coupon/hy-coupon.vue +183 -183
  20. package/components/hy-coupon/props.ts +108 -108
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
  22. package/components/hy-datetime-picker/props.ts +144 -144
  23. package/components/hy-datetime-picker/typing.d.ts +2 -0
  24. package/components/hy-divider/props.ts +83 -83
  25. package/components/hy-empty/icon.ts +72 -72
  26. package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
  27. package/components/hy-form/hy-form.vue +220 -220
  28. package/components/hy-icon/hy-icon.vue +112 -112
  29. package/components/hy-index-bar/hy-index-bar.vue +185 -185
  30. package/components/hy-index-bar/index.scss +64 -64
  31. package/components/hy-index-bar/props.ts +94 -94
  32. package/components/hy-index-bar/typing.d.ts +36 -36
  33. package/components/hy-input/hy-input.vue +333 -333
  34. package/components/hy-input/props.ts +186 -186
  35. package/components/hy-modal/hy-modal.vue +211 -211
  36. package/components/hy-modal/props.ts +94 -94
  37. package/components/hy-modal/typing.d.ts +16 -16
  38. package/components/hy-notice-bar/hy-row-notice.vue +121 -121
  39. package/components/hy-notify/hy-notify.vue +174 -174
  40. package/components/hy-number-step/hy-number-step.vue +367 -367
  41. package/components/hy-overlay/hy-overlay.vue +61 -61
  42. package/components/hy-overlay/props.ts +38 -38
  43. package/components/hy-pagination/hy-pagination.vue +136 -136
  44. package/components/hy-pagination/props.ts +58 -58
  45. package/components/hy-parse/hy-parse.vue +550 -550
  46. package/components/hy-parse/node/node.vue +781 -781
  47. package/components/hy-parse/parser.js +1455 -1455
  48. package/components/hy-parse/props.ts +19 -19
  49. package/components/hy-parse/typing.d.ts +68 -68
  50. package/components/hy-picker/hy-picker.vue +435 -435
  51. package/components/hy-picker/props.ts +122 -122
  52. package/components/hy-picker/typing.d.ts +38 -38
  53. package/components/hy-qrcode/props.ts +72 -72
  54. package/components/hy-qrcode/qrcode.js.bak +1433 -1433
  55. package/components/hy-radio/props.ts +97 -97
  56. package/components/hy-read-more/props.ts +48 -48
  57. package/components/hy-search/props.ts +133 -133
  58. package/components/hy-signature/canvasHelper.ts +51 -51
  59. package/components/hy-signature/props.ts +121 -121
  60. package/components/hy-skeleton/hy-skeleton.vue +142 -142
  61. package/components/hy-skeleton/props.ts +46 -46
  62. package/components/hy-skeleton/typing.d.ts +31 -31
  63. package/components/hy-steps/hy-steps.vue +275 -275
  64. package/components/hy-steps/typing.d.ts +25 -25
  65. package/components/hy-swiper/hy-swiper.vue +3 -3
  66. package/components/hy-swiper/index.scss +5 -5
  67. package/components/hy-swiper/props.ts +0 -1
  68. package/components/hy-table/hy-table.vue +630 -630
  69. package/components/hy-table/props.ts +62 -62
  70. package/components/hy-table/typing.d.ts +29 -29
  71. package/components/hy-tabs/hy-tabs.vue +336 -335
  72. package/components/hy-tabs/props.ts +84 -77
  73. package/components/hy-tag/hy-tag.vue +173 -173
  74. package/components/hy-tag/props.ts +89 -89
  75. package/components/hy-text/hy-text.vue +237 -237
  76. package/components/hy-text/props.ts +115 -115
  77. package/components/hy-textarea/hy-textarea.vue +198 -198
  78. package/components/hy-toast/hy-toast.vue +200 -200
  79. package/components/hy-toast/props.ts +3 -3
  80. package/components/hy-transition/hy-transition.vue +157 -157
  81. package/components/hy-transition/props.ts +32 -32
  82. package/components/hy-upload/hy-upload.vue +384 -384
  83. package/components/hy-watermark/hy-watermark.vue +1058 -1058
  84. package/components/hy-watermark/props.ts +109 -109
  85. package/global.d.ts +94 -94
  86. package/libs/api/http.ts +119 -119
  87. package/libs/composables/index.ts +8 -8
  88. package/libs/composables/useMessage.ts +149 -149
  89. package/libs/composables/useToast.ts +45 -45
  90. package/libs/composables/useTranslate.ts +10 -10
  91. package/libs/css/_config.scss +5 -5
  92. package/libs/index.ts +8 -8
  93. package/libs/locale/index.ts +32 -32
  94. package/libs/locale/lang/en-US.ts +84 -84
  95. package/libs/locale/lang/zh-CN.ts +87 -87
  96. package/libs/typing/index.ts +2 -2
  97. package/libs/typing/modules/common.d.ts +139 -139
  98. package/libs/typing/modules/form.ts +176 -176
  99. package/libs/typing/modules/http.d.ts +19 -19
  100. package/libs/typing/modules/index.d.ts +12 -12
  101. package/libs/utils/inside.ts +340 -340
  102. package/libs/utils/inspect.ts +140 -140
  103. package/libs/utils/utils.ts +525 -525
  104. package/package.json +81 -81
  105. package/tags.json +1 -1
  106. package/web-types.json +1 -1
@@ -1,289 +1,320 @@
1
- <template>
2
- <!-- #ifndef APP-NVUE -->
3
- <button
4
- :hover-start-time="Number(hoverStartTime)"
5
- :hover-stay-time="Number(hoverStayTime)"
6
- :form-type="formType"
7
- :open-type="openType"
8
- :lang="lang"
9
- :scope="scope"
10
- :data-name="dataName"
11
- :app-parameter="appParameter"
12
- :hover-stop-propagation="hoverStopPropagation"
13
- :send-message-title="sendMessageTitle"
14
- :send-message-path="sendMessagePath"
15
- :session-from="sessionFrom"
16
- :send-message-img="sendMessageImg"
17
- :show-message-card="showMessageCard"
18
- @getphonenumber="getphonenumber"
19
- @getuserinfo="getuserinfo"
20
- @getAuthorize="getAuthorize"
21
- @error="error"
22
- @opensetting="opensetting"
23
- @launchapp="launchapp"
24
- @agreeprivacyauthorization="agreeprivacyauthorization"
25
- :hover-class="!disabled && !loading ? 'hy-button--active' : ''"
26
- :style="[baseColor, customStyle]"
27
- @click="clickHandler"
28
- :class="['hy-button', !border && 'hy-button__no-border', bemClass, customClass]"
29
- >
30
- <template v-if="loading">
31
- <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
32
- <text class="hy-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">
33
- {{ loadingText || text }}
34
- </text>
35
- </template>
36
- <template v-else>
37
- <hy-icon
38
- v-if="icon?.name"
39
- :name="icon?.name"
40
- :color="iconColorCom"
41
- :size="icon?.size || textSize * 1.35"
42
- :bold="icon?.bold"
43
- :customPrefix="icon?.customPrefix"
44
- :imgMode="icon?.imgMode"
45
- :width="icon?.width"
46
- :height="icon?.height"
47
- :top="icon?.top"
48
- :stop="icon?.stop"
49
- :round="icon?.round"
50
- :customStyle="icon?.customStyle || { marginRight: '2px' }"
51
- ></hy-icon>
52
- <!-- @slot 插入默认的值 -->
53
- <slot v-if="$slots.default"></slot>
54
- <text v-else class="hy-button__text" :style="[{ fontSize: textSize + 'px' }]">{{
55
- text
56
- }}</text>
57
- </template>
58
- </button>
59
- <!-- #endif -->
60
-
61
- <!-- #ifdef APP-NVUE -->
62
- <view
63
- :hover-start-time="Number(hoverStartTime)"
64
- :hover-stay-time="Number(hoverStayTime)"
65
- class="hy-button"
66
- :hover-class="
67
- !disabled && !loading && !color && (plain || type === 'info')
68
- ? 'hy-button--active--plain'
69
- : !disabled && !loading && !plain
70
- ? 'hy-button--active'
71
- : ''
72
- "
73
- @click="clickHandler"
74
- :class="bemClass"
75
- :style="[baseColor, customStyle]"
76
- >
77
- <template v-if="loading">
78
- <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
79
- <text
80
- class="hy-button__loading-text"
81
- :style="[nvueTextStyle]"
82
- :class="[plain && `hy-button__text--plain--${type}`]"
83
- >
84
- {{ loadingText || text }}
85
- </text>
86
- </template>
87
- <template v-else>
88
- <hy-icon
89
- v-if="icon?.name"
90
- :name="icon?.name"
91
- :color="iconColorCom"
92
- :size="icon?.size || textSize * 1.35"
93
- :bold="icon?.bold"
94
- :customPrefix="icon?.customPrefix"
95
- :imgMode="icon?.imgMode"
96
- :width="icon?.width"
97
- :height="icon?.height"
98
- :top="icon?.top"
99
- :stop="icon?.stop"
100
- :round="icon?.round"
101
- :customStyle="icon?.customStyle || { marginRight: '2px' }"
102
- ></hy-icon>
103
- <text
104
- class="hy-button__text"
105
- :style="[
106
- {
107
- marginLeft: icon ? '2px' : 0
108
- },
109
- nvueTextStyle
110
- ]"
111
- :class="[plain && `hy-button__text--plain--${type}`]"
112
- >
113
- {{ text }}
114
- </text>
115
- </template>
116
- </view>
117
- <!-- #endif -->
118
- </template>
119
-
120
- <script lang="ts">
121
- export default {
122
- name: 'hy-button',
123
- options: {
124
- addGlobalClass: true,
125
- virtualHost: true,
126
- styleIsolation: 'shared'
127
- }
128
- }
129
- </script>
130
-
131
- <script setup lang="ts">
132
- import { computed } from 'vue'
133
- import type { CSSProperties } from 'vue'
134
- import { ColorConfig, bem, throttle } from '../../libs'
135
- import type { IButtonEmits } from './typing'
136
- import buttonProps from '../hy-button/props'
137
- // 组件
138
- import HyIcon from '../hy-icon/hy-icon.vue'
139
- import HyLoading from '../hy-loading/hy-loading.vue'
140
-
141
- /**
142
- * 该组件内部实现以uni-app的基础button组件为基础,进行二次封装
143
- * @displayName hy-button
144
- */
145
- defineOptions({})
146
-
147
- const props = defineProps(buttonProps)
148
- const emit = defineEmits<IButtonEmits>()
149
-
150
- const textColor = (ColorConfig as any)[props.type]
151
-
152
- /**
153
- * @description 生成bem风格的类名
154
- */
155
- const bemClass = computed(() => {
156
- // this.bem为一个computed变量,在mixin中
157
- if (!props.color) {
158
- return bem('button', props, ['type', 'shape', 'size'], ['disabled', 'plain', 'hairline'])
159
- } else {
160
- // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
161
- return bem('button', props, ['shape', 'size'], ['disabled', 'plain', 'hairline'])
162
- }
163
- })
164
-
165
- const loadingColor = computed(() => {
166
- if (props.plain) {
167
- // 如果有设置color值,则用color值,否则使用type主题颜色
168
- return props.color ? props.color : ''
169
- }
170
- if (props.type === 'info') {
171
- return '#c9c9c9'
172
- }
173
- return '#fff'
174
- })
175
-
176
- const iconColorCom = computed((): string => {
177
- // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
178
- if (props.icon?.color) return props.icon?.color
179
- if (props.plain) {
180
- return props.color ? props.color : ''
181
- } else {
182
- return '#ffffff'
183
- }
184
- })
185
- const baseColor = computed((): CSSProperties => {
186
- let style: CSSProperties = {}
187
- if (props.color) {
188
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
189
- style.color = props.plain ? props.color : 'white'
190
- if (!props.plain) {
191
- // 非镂空,背景色使用自定义的颜色
192
- style['background'] = props.color
193
- }
194
- if (props.color.indexOf('gradient') !== -1) {
195
- // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
196
- // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
197
- // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
198
- style.borderTopWidth = 0
199
- style.borderRightWidth = 0
200
- style.borderBottomWidth = 0
201
- style.borderLeftWidth = 0
202
- if (!props.plain) {
203
- style.backgroundImage = props.color
204
- }
205
- } else {
206
- // 非渐变色,则设置边框相关的属性
207
- style.borderColor = props.color
208
- style.borderWidth = '1px'
209
- style.borderStyle = 'solid'
210
- }
211
- } else {
212
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
213
- // style.color = props.plain ? textColor : "";
214
- }
215
- return style
216
- })
217
-
218
- // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
219
- const nvueTextStyle = computed((): CSSProperties => {
220
- let style: CSSProperties = {}
221
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
222
- if (props.type === 'info') {
223
- style.color = '#323233'
224
- }
225
- if (props.color) {
226
- style.color = props.plain ? props.color : 'white'
227
- }
228
- style.fontSize = textSize.value + 'px'
229
- return style
230
- })
231
- /**
232
- * 字体大小
233
- * */
234
- const textSize = computed((): number => {
235
- let fontSize = 14
236
- if (props.size === 'large') fontSize = 16
237
- if (props.size === 'medium') fontSize = 14
238
- if (props.size === 'small') fontSize = 12
239
- if (props.size === 'mini') fontSize = 10
240
- return fontSize
241
- })
242
-
243
- const clickHandler = (e: any) => {
244
- // 非禁止并且非加载中,才能点击
245
- if (!props.disabled && !props.loading) {
246
- // 进行节流控制,每this.throttle毫秒内,只在开始处执行
247
- throttle(() => {
248
- emit('click', e)
249
- }, props.throttleTime)
250
- }
251
- // 是否阻止事件传播
252
- props.stop && e.stopPropagation()
253
- }
254
-
255
- /**
256
- * 支付宝小程序授权
257
- * @param e
258
- */
259
- function getAuthorize(e: any) {
260
- if (props.scope === 'phoneNumber') {
261
- getphonenumber(e)
262
- } else if (props.scope === 'userInfo') {
263
- getuserinfo(e)
264
- }
265
- }
266
-
267
- const getphonenumber = (e: any) => {
268
- emit('getphonenumber', e)
269
- }
270
- const getuserinfo = (e: any) => {
271
- emit('getuserinfo', e)
272
- }
273
- const error = (e: any) => {
274
- emit('error', e)
275
- }
276
- const opensetting = (e: any) => {
277
- emit('opensetting', e)
278
- }
279
- const launchapp = (e: any) => {
280
- emit('launchapp', e)
281
- }
282
- const agreeprivacyauthorization = (e: any) => {
283
- emit('agreeprivacyauthorization', e)
284
- }
285
- </script>
286
-
287
- <style lang="scss" scoped>
288
- @import './index.scss';
289
- </style>
1
+ <template>
2
+ <!-- #ifndef APP-NVUE -->
3
+ <button
4
+ :hover-start-time="Number(hoverStartTime)"
5
+ :hover-stay-time="Number(hoverStayTime)"
6
+ :form-type="formType"
7
+ :open-type="openType"
8
+ :lang="lang"
9
+ :scope="scope"
10
+ :data-name="dataName"
11
+ :app-parameter="appParameter"
12
+ :hover-stop-propagation="hoverStopPropagation"
13
+ :send-message-title="sendMessageTitle"
14
+ :send-message-path="sendMessagePath"
15
+ :session-from="sessionFrom"
16
+ :send-message-img="sendMessageImg"
17
+ :show-message-card="showMessageCard"
18
+ @getphonenumber="getphonenumber"
19
+ @getuserinfo="getuserinfo"
20
+ @getAuthorize="getAuthorize"
21
+ @chooseavatar="chooseavatar"
22
+ @error="error"
23
+ @contact="contact"
24
+ @opensetting="opensetting"
25
+ @launchapp="launchapp"
26
+ @agreeprivacyauthorization="agreeprivacyauthorization"
27
+ :hover-class="!disabled && !loading ? 'hy-button--active' : ''"
28
+ :style="[baseColor, customStyle]"
29
+ @click="clickHandler"
30
+ :class="['hy-button', !border && 'hy-button__no-border', bemClass, customClass]"
31
+ >
32
+ <template v-if="loading">
33
+ <hy-loading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></hy-loading>
34
+ <text class="hy-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">
35
+ {{ loadingText || text }}
36
+ </text>
37
+ </template>
38
+ <template v-else>
39
+ <hy-icon
40
+ v-if="icon?.name"
41
+ :name="icon?.name"
42
+ :color="iconColorCom"
43
+ :size="icon?.size || textSize * 1.35"
44
+ :bold="icon?.bold"
45
+ :customPrefix="icon?.customPrefix"
46
+ :imgMode="icon?.imgMode"
47
+ :width="icon?.width"
48
+ :height="icon?.height"
49
+ :top="icon?.top"
50
+ :stop="icon?.stop"
51
+ :round="icon?.round"
52
+ :customStyle="icon?.customStyle || { marginRight: '2px' }"
53
+ ></hy-icon>
54
+ <!-- @slot 插入默认的值 -->
55
+ <slot v-if="$slots.default"></slot>
56
+ <text v-else class="hy-button__text" :style="[{ fontSize: textSize + 'px' }]">{{
57
+ text
58
+ }}</text>
59
+ </template>
60
+ </button>
61
+ <!-- #endif -->
62
+
63
+ <!-- #ifdef APP-NVUE -->
64
+ <view
65
+ :hover-start-time="Number(hoverStartTime)"
66
+ :hover-stay-time="Number(hoverStayTime)"
67
+ class="hy-button"
68
+ :hover-class="
69
+ !disabled && !loading && !color && (plain || type === 'info')
70
+ ? 'hy-button--active--plain'
71
+ : !disabled && !loading && !plain
72
+ ? 'hy-button--active'
73
+ : ''
74
+ "
75
+ @click="clickHandler"
76
+ :class="bemClass"
77
+ :style="[baseColor, customStyle]"
78
+ >
79
+ <template v-if="loading">
80
+ <hy-loading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></hy-loading>
81
+ <text
82
+ class="hy-button__loading-text"
83
+ :style="[nvueTextStyle]"
84
+ :class="[plain && `hy-button__text--plain--${type}`]"
85
+ >
86
+ {{ loadingText || text }}
87
+ </text>
88
+ </template>
89
+ <template v-else>
90
+ <hy-icon
91
+ v-if="icon?.name"
92
+ :name="icon?.name"
93
+ :color="iconColorCom"
94
+ :size="icon?.size || textSize * 1.35"
95
+ :bold="icon?.bold"
96
+ :customPrefix="icon?.customPrefix"
97
+ :imgMode="icon?.imgMode"
98
+ :width="icon?.width"
99
+ :height="icon?.height"
100
+ :top="icon?.top"
101
+ :stop="icon?.stop"
102
+ :round="icon?.round"
103
+ :customStyle="icon?.customStyle || { marginRight: '2px' }"
104
+ ></hy-icon>
105
+ <text
106
+ class="hy-button__text"
107
+ :style="[
108
+ {
109
+ marginLeft: icon ? '2px' : 0
110
+ },
111
+ nvueTextStyle
112
+ ]"
113
+ :class="[plain && `hy-button__text--plain--${type}`]"
114
+ >
115
+ {{ text }}
116
+ </text>
117
+ </template>
118
+ </view>
119
+ <!-- #endif -->
120
+ </template>
121
+
122
+ <script lang="ts">
123
+ export default {
124
+ name: 'hy-button',
125
+ options: {
126
+ addGlobalClass: true,
127
+ virtualHost: true,
128
+ styleIsolation: 'shared'
129
+ }
130
+ }
131
+ </script>
132
+
133
+ <script setup lang="ts">
134
+ import { computed } from 'vue'
135
+ import type { CSSProperties } from 'vue'
136
+ import { ColorConfig, bem, throttle } from '../../libs'
137
+ import type { IButtonEmits } from './typing'
138
+ import buttonProps from '../hy-button/props'
139
+ // 组件
140
+ import HyIcon from '../hy-icon/hy-icon.vue'
141
+ import HyLoading from '../hy-loading/hy-loading.vue'
142
+
143
+ /**
144
+ * 该组件内部实现以uni-app的基础button组件为基础,进行二次封装
145
+ * @displayName hy-button
146
+ */
147
+ defineOptions({})
148
+
149
+ const props = defineProps(buttonProps)
150
+ const emit = defineEmits<IButtonEmits>()
151
+
152
+ const textColor = (ColorConfig as any)[props.type]
153
+
154
+ /**
155
+ * @description 生成bem风格的类名
156
+ */
157
+ const bemClass = computed(() => {
158
+ // this.bem为一个computed变量,在mixin中
159
+ if (!props.color) {
160
+ return bem('button', props, ['type', 'shape', 'size'], ['disabled', 'plain', 'hairline'])
161
+ } else {
162
+ // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
163
+ return bem('button', props, ['shape', 'size'], ['disabled', 'plain', 'hairline'])
164
+ }
165
+ })
166
+
167
+ const loadingColor = computed(() => {
168
+ if (props.plain) {
169
+ // 如果有设置color值,则用color值,否则使用type主题颜色
170
+ return props.color ? props.color : ''
171
+ }
172
+ if (props.type === 'info') {
173
+ return '#c9c9c9'
174
+ }
175
+ return '#fff'
176
+ })
177
+
178
+ const iconColorCom = computed((): string => {
179
+ // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
180
+ if (props.icon?.color) return props.icon?.color
181
+ if (props.plain) {
182
+ return props.color ? props.color : ''
183
+ } else {
184
+ return '#ffffff'
185
+ }
186
+ })
187
+ const baseColor = computed((): CSSProperties => {
188
+ let style: CSSProperties = {}
189
+ if (props.color) {
190
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
191
+ style.color = props.plain ? props.color : 'white'
192
+ if (!props.plain) {
193
+ // 非镂空,背景色使用自定义的颜色
194
+ style['background'] = props.color
195
+ }
196
+ if (props.color.indexOf('gradient') !== -1) {
197
+ // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
198
+ // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
199
+ // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
200
+ style.borderTopWidth = 0
201
+ style.borderRightWidth = 0
202
+ style.borderBottomWidth = 0
203
+ style.borderLeftWidth = 0
204
+ if (!props.plain) {
205
+ style.backgroundImage = props.color
206
+ }
207
+ } else {
208
+ // 非渐变色,则设置边框相关的属性
209
+ style.borderColor = props.color
210
+ style.borderWidth = '1px'
211
+ style.borderStyle = 'solid'
212
+ }
213
+ } else {
214
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
215
+ // style.color = props.plain ? textColor : "";
216
+ }
217
+ return style
218
+ })
219
+
220
+ // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
221
+ const nvueTextStyle = computed((): CSSProperties => {
222
+ let style: CSSProperties = {}
223
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
224
+ if (props.type === 'info') {
225
+ style.color = '#323233'
226
+ }
227
+ if (props.color) {
228
+ style.color = props.plain ? props.color : 'white'
229
+ }
230
+ style.fontSize = textSize.value + 'px'
231
+ return style
232
+ })
233
+ /**
234
+ * 字体大小
235
+ * */
236
+ const textSize = computed((): number => {
237
+ let fontSize = 14
238
+ if (props.size === 'large') fontSize = 16
239
+ if (props.size === 'medium') fontSize = 14
240
+ if (props.size === 'small') fontSize = 12
241
+ if (props.size === 'mini') fontSize = 10
242
+ return fontSize
243
+ })
244
+
245
+ const clickHandler = (e: any) => {
246
+ // 非禁止并且非加载中,才能点击
247
+ if (!props.disabled && !props.loading) {
248
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
249
+ throttle(() => {
250
+ emit('click', e)
251
+ }, props.throttleTime)
252
+ }
253
+ // 是否阻止事件传播
254
+ props.stop && e.stopPropagation()
255
+ }
256
+
257
+ /**
258
+ * 支付宝小程序授权
259
+ * @param e
260
+ */
261
+ function getAuthorize(e: any) {
262
+ if (props.scope === 'phoneNumber') {
263
+ getphonenumber(e)
264
+ } else if (props.scope === 'userInfo') {
265
+ getuserinfo(e)
266
+ }
267
+ }
268
+ /**
269
+ * 获取用户手机号回调
270
+ * */
271
+ const getphonenumber = (e: any) => {
272
+ emit('getphonenumber', e)
273
+ }
274
+ /**
275
+ * 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
276
+ * */
277
+ const getuserinfo = (e: any) => {
278
+ emit('getuserinfo', e)
279
+ }
280
+ /**
281
+ * 当使用开放能力时,发生错误的回调
282
+ * */
283
+ const error = (e: any) => {
284
+ emit('error', e)
285
+ }
286
+ /**
287
+ * 在打开授权设置页并关闭后回调
288
+ * */
289
+ const opensetting = (e: any) => {
290
+ emit('opensetting', e)
291
+ }
292
+ /**
293
+ * 从小程序打开 App 成功的回调
294
+ * */
295
+ const launchapp = (e: any) => {
296
+ emit('launchapp', e)
297
+ }
298
+ /**
299
+ * 用户同意隐私协议事件回调,open-type="agreePrivacyAuthorization"时有效
300
+ * */
301
+ const agreeprivacyauthorization = (e: any) => {
302
+ emit('agreeprivacyauthorization', e)
303
+ }
304
+ /**
305
+ * 获取用户头像回调
306
+ * */
307
+ const chooseavatar = (e: any) => {
308
+ emit('chooseavatar', e)
309
+ }
310
+ /**
311
+ * 客服消息回调
312
+ * */
313
+ const contact = (e: any) => {
314
+ emit('contact', e)
315
+ }
316
+ </script>
317
+
318
+ <style lang="scss" scoped>
319
+ @import './index.scss';
320
+ </style>