uview-pro 0.2.4 → 0.3.1

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 (249) hide show
  1. package/changelog.md +584 -545
  2. package/components/common/props.ts +22 -22
  3. package/components/u-action-sheet/types.ts +37 -35
  4. package/components/u-action-sheet/u-action-sheet.vue +178 -167
  5. package/components/u-alert-tips/types.ts +41 -39
  6. package/components/u-alert-tips/u-alert-tips.vue +238 -223
  7. package/components/u-avatar/types.ts +36 -34
  8. package/components/u-avatar/u-avatar.vue +217 -207
  9. package/components/u-avatar-cropper/types.ts +23 -23
  10. package/components/u-avatar-cropper/u-avatar-cropper.vue +297 -286
  11. package/components/u-avatar-cropper/weCropper.d.ts +62 -62
  12. package/components/u-avatar-cropper/weCropper.js +1281 -1281
  13. package/components/u-avatar-cropper/weCropper.ts +1276 -1276
  14. package/components/u-back-top/types.ts +36 -39
  15. package/components/u-back-top/u-back-top.vue +140 -128
  16. package/components/u-badge/types.ts +38 -36
  17. package/components/u-badge/u-badge.vue +183 -165
  18. package/components/u-button/types.ts +66 -66
  19. package/components/u-button/u-button.vue +579 -566
  20. package/components/u-calendar/types.ts +75 -75
  21. package/components/u-calendar/u-calendar.vue +793 -793
  22. package/components/u-car-keyboard/types.ts +14 -12
  23. package/components/u-car-keyboard/u-car-keyboard.vue +262 -253
  24. package/components/u-card/types.ts +61 -59
  25. package/components/u-card/u-card.vue +209 -194
  26. package/components/u-cell-group/types.ts +19 -17
  27. package/components/u-cell-group/u-cell-group.vue +60 -50
  28. package/components/u-cell-item/types.ts +56 -54
  29. package/components/u-cell-item/u-cell-item.vue +226 -213
  30. package/components/u-checkbox/types.ts +33 -31
  31. package/components/u-checkbox/u-checkbox.vue +282 -283
  32. package/components/u-checkbox-group/types.ts +34 -32
  33. package/components/u-checkbox-group/u-checkbox-group.vue +130 -130
  34. package/components/u-circle-progress/types.ts +54 -52
  35. package/components/u-circle-progress/u-circle-progress.vue +206 -191
  36. package/components/u-city-select/types.ts +22 -20
  37. package/components/u-city-select/u-city-select.vue +276 -264
  38. package/components/u-col/types.ts +32 -30
  39. package/components/u-col/u-col.vue +142 -123
  40. package/components/u-collapse/types.ts +33 -33
  41. package/components/u-collapse/u-collapse.vue +190 -186
  42. package/components/u-collapse-item/types.ts +27 -27
  43. package/components/u-collapse-item/u-collapse-item.vue +290 -285
  44. package/components/u-column-notice/types.ts +50 -48
  45. package/components/u-column-notice/u-column-notice.vue +222 -210
  46. package/components/u-count-down/types.ts +44 -42
  47. package/components/u-count-down/u-count-down.vue +286 -274
  48. package/components/u-count-to/types.ts +34 -32
  49. package/components/u-count-to/u-count-to.vue +266 -248
  50. package/components/u-divider/types.ts +33 -31
  51. package/components/u-divider/u-divider.vue +145 -129
  52. package/components/u-dropdown/types.ts +34 -32
  53. package/components/u-dropdown/u-dropdown.vue +330 -302
  54. package/components/u-dropdown-item/types.ts +29 -27
  55. package/components/u-dropdown-item/u-dropdown-item.vue +120 -128
  56. package/components/u-empty/types.ts +38 -36
  57. package/components/u-empty/u-empty.vue +103 -88
  58. package/components/u-field/types.ts +71 -69
  59. package/components/u-field/u-field.vue +388 -373
  60. package/components/u-form/types.ts +29 -27
  61. package/components/u-form/u-form.vue +130 -136
  62. package/components/u-form-item/types.ts +72 -70
  63. package/components/u-form-item/u-form-item.vue +447 -447
  64. package/components/u-full-screen/types.ts +16 -14
  65. package/components/u-full-screen/u-full-screen.vue +103 -89
  66. package/components/u-gap/types.ts +20 -18
  67. package/components/u-gap/u-gap.vue +50 -40
  68. package/components/u-grid/types.ts +21 -19
  69. package/components/u-grid/u-grid.vue +91 -93
  70. package/components/u-grid-item/types.ts +16 -16
  71. package/components/u-grid-item/u-grid-item.vue +130 -134
  72. package/components/u-icon/types.ts +61 -62
  73. package/components/u-icon/u-icon.vue +296 -294
  74. package/components/u-image/types.ts +51 -51
  75. package/components/u-image/u-image.vue +239 -230
  76. package/components/u-index-anchor/types.ts +16 -16
  77. package/components/u-index-anchor/u-index-anchor.vue +94 -86
  78. package/components/u-index-list/types.ts +43 -43
  79. package/components/u-index-list/u-index-list.vue +352 -355
  80. package/components/u-input/types.ts +137 -140
  81. package/components/u-input/u-input.vue +288 -279
  82. package/components/u-keyboard/types.ts +40 -40
  83. package/components/u-keyboard/u-keyboard.vue +178 -169
  84. package/components/u-lazy-load/types.ts +37 -37
  85. package/components/u-lazy-load/u-lazy-load.vue +246 -235
  86. package/components/u-line/types.ts +44 -44
  87. package/components/u-line/u-line.vue +68 -59
  88. package/components/u-line-progress/types.ts +58 -58
  89. package/components/u-line-progress/u-line-progress.vue +126 -117
  90. package/components/u-link/types.ts +43 -43
  91. package/components/u-link/u-link.vue +84 -75
  92. package/components/u-loading/types.ts +35 -35
  93. package/components/u-loading/u-loading.vue +105 -96
  94. package/components/u-loading-popup/types.ts +26 -26
  95. package/components/u-loading-popup/u-loading-popup.vue +253 -239
  96. package/components/u-loadmore/types.ts +79 -79
  97. package/components/u-loadmore/u-loadmore.vue +156 -145
  98. package/components/u-mask/types.ts +40 -43
  99. package/components/u-mask/u-mask.vue +113 -106
  100. package/components/u-message-input/types.ts +74 -74
  101. package/components/u-message-input/u-message-input.vue +281 -270
  102. package/components/u-modal/types.ts +118 -118
  103. package/components/u-modal/u-modal.vue +220 -211
  104. package/components/u-navbar/types.ts +103 -103
  105. package/components/u-navbar/u-navbar.vue +251 -240
  106. package/components/u-no-network/image.ts +2 -2
  107. package/components/u-no-network/types.ts +28 -28
  108. package/components/u-no-network/u-no-network.vue +303 -292
  109. package/components/u-notice-bar/types.ts +111 -111
  110. package/components/u-notice-bar/u-notice-bar.vue +189 -179
  111. package/components/u-number-box/types.ts +42 -42
  112. package/components/u-number-box/u-number-box.vue +321 -312
  113. package/components/u-number-keyboard/types.ts +26 -26
  114. package/components/u-number-keyboard/u-number-keyboard.vue +188 -179
  115. package/components/u-picker/types.ts +123 -123
  116. package/components/u-picker/u-picker.vue +685 -676
  117. package/components/u-popup/types.ts +59 -59
  118. package/components/u-popup/u-popup.vue +385 -375
  119. package/components/u-radio/types.ts +27 -25
  120. package/components/u-radio/u-radio.vue +279 -272
  121. package/components/u-radio-group/types.ts +31 -29
  122. package/components/u-radio-group/u-radio-group.vue +96 -108
  123. package/components/u-rate/types.ts +42 -40
  124. package/components/u-rate/u-rate.vue +249 -234
  125. package/components/u-read-more/types.ts +37 -35
  126. package/components/u-read-more/u-read-more.vue +172 -156
  127. package/components/u-root-portal/u-root-portal.vue +56 -54
  128. package/components/u-row/types.ts +22 -20
  129. package/components/u-row/u-row.vue +105 -87
  130. package/components/u-row-notice/types.ts +41 -39
  131. package/components/u-row-notice/u-row-notice.vue +256 -244
  132. package/components/u-safe-bottom/u-safe-bottom.vue +57 -46
  133. package/components/u-search/types.ts +55 -53
  134. package/components/u-search/u-search.vue +279 -268
  135. package/components/u-section/types.ts +34 -32
  136. package/components/u-section/u-section.vue +150 -131
  137. package/components/u-select/types.ts +45 -43
  138. package/components/u-select/u-select.vue +388 -378
  139. package/components/u-skeleton/types.ts +22 -20
  140. package/components/u-skeleton/u-skeleton.vue +231 -220
  141. package/components/u-slider/types.ts +34 -32
  142. package/components/u-slider/u-slider.vue +255 -247
  143. package/components/u-status-bar/u-status-bar.vue +74 -65
  144. package/components/u-steps/types.ts +30 -28
  145. package/components/u-steps/u-steps.vue +181 -169
  146. package/components/u-sticky/types.ts +24 -22
  147. package/components/u-sticky/u-sticky.vue +178 -162
  148. package/components/u-subsection/types.ts +38 -36
  149. package/components/u-subsection/u-subsection.vue +339 -328
  150. package/components/u-swipe-action/types.ts +52 -50
  151. package/components/u-swipe-action/u-swipe-action.vue +276 -260
  152. package/components/u-swiper/types.ts +49 -47
  153. package/components/u-swiper/u-swiper.vue +308 -291
  154. package/components/u-switch/types.ts +30 -28
  155. package/components/u-switch/u-switch.vue +150 -141
  156. package/components/u-tabbar/types.ts +38 -36
  157. package/components/u-tabbar/u-tabbar.vue +315 -298
  158. package/components/u-table/types.ts +27 -25
  159. package/components/u-table/u-table.vue +67 -55
  160. package/components/u-tabs/types.ts +53 -51
  161. package/components/u-tabs/u-tabs.vue +302 -291
  162. package/components/u-tabs-swiper/types.ts +55 -53
  163. package/components/u-tabs-swiper/u-tabs-swiper.vue +409 -397
  164. package/components/u-tag/types.ts +39 -37
  165. package/components/u-tag/u-tag.vue +268 -252
  166. package/components/u-td/types.ts +14 -12
  167. package/components/u-td/u-td.vue +98 -87
  168. package/components/u-text/types.ts +72 -72
  169. package/components/u-text/u-text.vue +343 -341
  170. package/components/u-th/types.ts +14 -12
  171. package/components/u-th/u-th.vue +92 -81
  172. package/components/u-time-line/u-time-line.vue +53 -39
  173. package/components/u-time-line-item/types.ts +16 -14
  174. package/components/u-time-line-item/u-time-line-item.vue +90 -78
  175. package/components/u-toast/types.ts +38 -36
  176. package/components/u-toast/u-toast.vue +240 -233
  177. package/components/u-top-tips/types.ts +16 -14
  178. package/components/u-top-tips/u-top-tips.vue +130 -113
  179. package/components/u-tr/types.ts +11 -8
  180. package/components/u-tr/u-tr.vue +39 -24
  181. package/components/u-upload/types.ts +82 -80
  182. package/components/u-upload/u-upload.vue +568 -559
  183. package/components/u-verification-code/types.ts +24 -22
  184. package/components/u-verification-code/u-verification-code.vue +176 -164
  185. package/components/u-waterfall/types.ts +18 -16
  186. package/components/u-waterfall/u-waterfall.vue +187 -175
  187. package/iconfont.css +913 -913
  188. package/index.scss +25 -25
  189. package/index.ts +38 -38
  190. package/libs/config/config.ts +26 -26
  191. package/libs/config/zIndex.ts +37 -37
  192. package/libs/css/color.scss +155 -155
  193. package/libs/css/common.scss +178 -178
  194. package/libs/css/style.components.scss +16 -16
  195. package/libs/css/style.h5.scss +8 -8
  196. package/libs/css/style.mp.scss +72 -72
  197. package/libs/css/style.nvue.scss +15 -15
  198. package/libs/css/style.vue.scss +188 -188
  199. package/libs/function/$parent.ts +24 -24
  200. package/libs/function/addUnit.ts +13 -13
  201. package/libs/function/color.ts +37 -37
  202. package/libs/function/colorGradient.ts +139 -139
  203. package/libs/function/debounce.ts +28 -28
  204. package/libs/function/deepClone.ts +39 -39
  205. package/libs/function/deepMerge.ts +35 -35
  206. package/libs/function/getParent.ts +63 -63
  207. package/libs/function/getRect.ts +26 -26
  208. package/libs/function/guid.ts +42 -42
  209. package/libs/function/md5.ts +403 -403
  210. package/libs/function/parent.ts +21 -21
  211. package/libs/function/queryParams.ts +64 -64
  212. package/libs/function/random.ts +16 -16
  213. package/libs/function/randomArray.ts +11 -11
  214. package/libs/function/route.ts +118 -118
  215. package/libs/function/styleUtils.ts +83 -83
  216. package/libs/function/sys.ts +15 -15
  217. package/libs/function/test.ts +289 -289
  218. package/libs/function/throttle.ts +31 -31
  219. package/libs/function/timeFormat.ts +55 -55
  220. package/libs/function/timeFrom.ts +48 -48
  221. package/libs/function/toast.ts +14 -14
  222. package/libs/function/trim.ts +21 -21
  223. package/libs/function/type2icon.ts +39 -39
  224. package/libs/hooks/index.ts +4 -3
  225. package/libs/hooks/useCompRelation.ts +364 -0
  226. package/libs/hooks/useComponent.ts +759 -759
  227. package/libs/hooks/useEmitter.ts +79 -79
  228. package/libs/hooks/useParent.ts +33 -33
  229. package/libs/hooks/useRect.ts +33 -33
  230. package/libs/index.ts +337 -320
  231. package/libs/request/auto-http.ts +76 -76
  232. package/libs/request/index.ts +242 -242
  233. package/libs/store/index.ts +88 -88
  234. package/libs/util/async-validator.d.ts +75 -75
  235. package/libs/util/async-validator.js +1 -1
  236. package/libs/util/calendar.d.ts +57 -57
  237. package/libs/util/emitter.ts +112 -112
  238. package/libs/util/eventBus.ts +86 -86
  239. package/libs/util/logger.ts +364 -364
  240. package/libs/util/mitt.ts +118 -118
  241. package/libs/util/parent.ts +20 -20
  242. package/package.json +4 -4
  243. package/readme.md +241 -241
  244. package/theme.scss +38 -38
  245. package/types/components.d.ts +97 -97
  246. package/types/global.d.ts +331 -331
  247. package/types/ignore-errors.d.ts +30 -30
  248. package/types/index.d.ts +19 -19
  249. package/types/uni-app.d.ts +63 -63
@@ -1,566 +1,579 @@
1
- <template>
2
- <button
3
- id="u-wave-btn"
4
- class="u-btn u-line-1 u-fix-ios-appearance"
5
- :class="[
6
- 'u-size-' + size,
7
- plain ? 'u-btn--' + type + '--plain' : '',
8
- loading ? 'u-loading' : '',
9
- shape === 'circle' ? 'u-round-circle' : '',
10
- hairLine ? showHairLineBorder : 'u-btn--bold-border',
11
- 'u-btn--' + type,
12
- disabled ? `u-btn--${type}--disabled` : ''
13
- ]"
14
- :hover-start-time="Number(hoverStartTime)"
15
- :hover-stay-time="Number(hoverStayTime)"
16
- :disabled="disabled"
17
- :form-type="formType"
18
- :open-type="disabled || loading ? undefined : openType"
19
- :app-parameter="appParameter"
20
- :hover-stop-propagation="hoverStopPropagation"
21
- :send-message-title="sendMessageTitle"
22
- send-message-path="sendMessagePath"
23
- :lang="lang"
24
- :data-name="dataName"
25
- :session-from="sessionFrom"
26
- :send-message-img="sendMessageImg"
27
- :show-message-card="showMessageCard"
28
- @getAuthorize="getAuthorize"
29
- @getuserinfo="getuserinfo"
30
- @contact="contact"
31
- @getphonenumber="getphonenumber"
32
- @error="error"
33
- @launchapp="launchapp"
34
- @opensetting="opensetting"
35
- @chooseavatar="chooseavatar"
36
- @agreeprivacyauthorization="agreeprivacyauthorization"
37
- :style="[
38
- customStyle,
39
- {
40
- overflow: ripple ? 'hidden' : 'visible'
41
- }
42
- ]"
43
- @tap.stop="click($event)"
44
- :hover-class="getHoverClass"
45
- :loading="loading"
46
- >
47
- <slot></slot>
48
- <view
49
- v-if="ripple"
50
- class="u-wave-ripple"
51
- :class="[waveActive ? 'u-wave-active' : '']"
52
- :style="{
53
- top: rippleTop + 'px',
54
- left: rippleLeft + 'px',
55
- width: fields.targetWidth + 'px',
56
- height: fields.targetWidth + 'px',
57
- 'background-color': rippleBgColor || 'rgba(0, 0, 0, 0.15)'
58
- }"
59
- ></view>
60
- </button>
61
- </template>
62
-
63
- <script setup lang="ts">
64
- import { ref, computed, nextTick } from 'vue';
65
- import { $u } from '../../';
66
- import { ButtonProps } from './types';
67
-
68
- defineOptions({
69
- name: 'u-button'
70
- });
71
- /**
72
- * button 按钮
73
- * @description Button 按钮
74
- * @tutorial https://uviewpro.cn/zh/components/button.html
75
- * @property {String} size 按钮的大小
76
- * @property {Boolean} ripple 是否开启点击水波纹效果
77
- * @property {String} ripple-bg-color 水波纹的背景色,ripple为true时有效
78
- * @property {String} type 按钮的样式类型
79
- * @property {Boolean} plain 按钮是否镂空,背景色透明
80
- * @property {Boolean} disabled 是否禁用
81
- * @property {Boolean} hair-line 是否显示按钮的细边框(默认true)
82
- * @property {String} shape 按钮外观形状,见文档说明
83
- * @property {Boolean} loading 按钮名称前是否带 loading 图标(App-nvue 平台,在 ios 上为雪花,Android上为圆圈)
84
- * @property {String} form-type 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件
85
- * @property {String} open-type 开放能力
86
- * @property {String} data-name 额外传参参数,用于小程序的data-xxx属性,通过target.dataset.name获取
87
- * @property {String} hover-class 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果(App-nvue 平台暂不支持)
88
- * @property {Number} hover-start-time 按住后多久出现点击态,单位毫秒
89
- * @property {Number} hover-stay-time 手指松开后点击态保留时间,单位毫秒
90
- * @property {Object} custom-style 对按钮的自定义样式,对象形式,见文档说明
91
- * @property {String} app-parameter 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效
92
- * @property {Boolean} hover-stop-propagation 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效
93
- * @property {String} lang 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。只微信小程序有效
94
- * @property {String} session-from 会话来源,open-type="contact"时有效。只微信小程序有效
95
- * @property {String} send-message-title 会话内消息卡片标题,open-type="contact"时有效
96
- * @property {String} send-message-path 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效
97
- * @property {String} send-message-img 会话内消息卡片图片,open-type="contact"时有效
98
- * @property {Boolean} show-message-card 是否显示会话内消息卡片,open-type="contact"时有效
99
- * @property {Number|String} throttle-time 节流,一定时间内只能触发一次,单位毫秒
100
- * @property {String} scope 支付宝小程序,当 open-type getAuthorize 时有效。可选值:'phoneNumber' | 'userInfo'
101
- * @event {Function} click 按钮点击
102
- * @event {Function} getphonenumber open-type="getPhoneNumber"时有效
103
- * @event {Function} getuserinfo 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
104
- * @event {Function} error 当使用开放能力时,发生错误的回调
105
- * @event {Function} opensetting 在打开授权设置页并关闭后回调
106
- * @event {Function} launchapp 打开 APP 成功的回调
107
- * @event {Function} contact 客服消息回调
108
- * @event {Function} chooseavatar 头像选择回调
109
- * @event {Function} agreeprivacyauthorization 用户点击允许授权回调
110
- * @example <u-button>月落</u-button>
111
- */
112
-
113
- const emit = defineEmits([
114
- 'click',
115
- 'getuserinfo',
116
- 'contact',
117
- 'getphonenumber',
118
- 'error',
119
- 'launchapp',
120
- 'opensetting',
121
- 'chooseavatar',
122
- 'agreeprivacyauthorization'
123
- ]);
124
-
125
- const props = defineProps(ButtonProps);
126
-
127
- /**
128
- * 按钮水波纹相关状态
129
- */
130
- const rippleTop = ref(0); // 水波纹的起点Y坐标到按钮上边界的距离
131
- const rippleLeft = ref(0); // 水波纹起点X坐标到按钮左边界的距离
132
- const fields = ref<Record<string, any>>({}); // 波纹按钮节点信息
133
- const waveActive = ref(false); // 激活水波纹
134
-
135
- /**
136
- * 当没有传bgColor变量时,按钮按下去的颜色类名
137
- * @returns {string}
138
- */
139
- const getHoverClass = computed(() => {
140
- // 如果开启水波纹效果,则不启用hover-class效果
141
- if (props.loading || props.disabled || props.ripple || props.hoverClass) return '';
142
- let hoverClass = '';
143
- hoverClass = props.plain ? 'u-' + props.type + '-plain-hover' : 'u-' + props.type + '-hover';
144
- return hoverClass;
145
- });
146
-
147
- /**
148
- * 在'primary', 'success', 'error', 'warning'类型下,不显示边框,否则会造成四角有毛刺现象
149
- * @returns {string}
150
- */
151
- const showHairLineBorder = computed(() => {
152
- if (['primary', 'success', 'error', 'warning'].indexOf(props.type) >= 0 && !props.plain) {
153
- return '';
154
- } else {
155
- return 'u-hairline-border';
156
- }
157
- });
158
-
159
- /**
160
- * 按钮点击
161
- * @param e 事件对象
162
- * @emits click
163
- */
164
- function click(e: any) {
165
- $u.throttle(() => {
166
- // 如果按钮时disabled和loading状态,不触发水波纹效果
167
- if (props.loading === true || props.disabled === true) return;
168
- // 是否开启水波纹效果
169
- if (props.ripple) {
170
- // 每次点击时,移除上一次的类,再次添加,才能触发动画效果
171
- waveActive.value = false;
172
- nextTick(() => {
173
- getWaveQuery(e);
174
- });
175
- }
176
- emit('click', e);
177
- }, Number(props.throttleTime));
178
- }
179
-
180
- /**
181
- * 查询按钮的节点信息
182
- * @param e 事件对象
183
- */
184
- function getWaveQuery(e: any) {
185
- getElQuery().then((res: any[]) => {
186
- // 查询返回的是一个数组节点
187
- let data = res[0];
188
- // 查询不到节点信息,不操作
189
- if (!data.width || !data.width) return;
190
- // 水波纹的最终形态是一个正方形(通过border-radius让其变为一个圆形),这里要保证正方形的边长等于按钮的最长边
191
- // 最终的方形(变换后的圆形)才能覆盖整个按钮
192
- data.targetWidth = data.height > data.width ? data.height : data.width;
193
- if (!data.targetWidth) return;
194
- fields.value = data;
195
- let touchesX = '',
196
- touchesY = '';
197
- // #ifdef MP-BAIDU
198
- // @ts-ignore
199
- touchesX = e.changedTouches[0].clientX;
200
- touchesY = e.changedTouches[0].clientY;
201
- // #endif
202
- // #ifdef MP-ALIPAY
203
- // @ts-ignore
204
- touchesX = e.detail.clientX;
205
- touchesY = e.detail.clientY;
206
- // #endif
207
- // #ifndef MP-BAIDU || MP-ALIPAY
208
- // @ts-ignore
209
- touchesX = e.touches[0].clientX;
210
- touchesY = e.touches[0].clientY;
211
- // #endif
212
- // 获取触摸点相对于按钮上边和左边的x和y坐标,原理是通过屏幕的触摸点(touchesY),减去按钮的上边界data.top
213
- // 但是由于`transform-origin`默认是center,所以这里再减去半径才是水波纹view应该的位置
214
- // 总的来说,就是把水波纹的矩形(变换后的圆形)的中心点,移动到我们的触摸点位置
215
- rippleTop.value = Number(touchesY) - data.top - data.targetWidth / 2;
216
- rippleLeft.value = Number(touchesX) - data.left - data.targetWidth / 2;
217
- nextTick(() => {
218
- waveActive.value = true;
219
- });
220
- });
221
- }
222
-
223
- /**
224
- * 获取节点信息
225
- * @returns {Promise<any[]>}
226
- */
227
- function getElQuery(): Promise<any[]> {
228
- return new Promise(resolve => {
229
- let queryInfo: any = '';
230
- // 获取元素节点信息,请查看uniapp相关文档
231
- // https://uniapp.dcloud.io/api/ui/nodes-info?id=nodesrefboundingclientrect
232
- // @ts-ignore
233
- queryInfo = uni.createSelectorQuery().in(null);
234
- // #ifdef MP-ALIPAY
235
- // @ts-ignore
236
- queryInfo = uni.createSelectorQuery();
237
- // #endif
238
- queryInfo.select('.u-btn').boundingClientRect();
239
- queryInfo.exec((data: any) => {
240
- resolve(data);
241
- });
242
- });
243
- }
244
-
245
- // 下面为对接uniapp官方按钮开放能力事件回调的对接
246
- /**
247
- * open-type="getPhoneNumber"时有效
248
- */
249
- function getphonenumber(event: any) {
250
- emit('getphonenumber', event);
251
- }
252
- /**
253
- * 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
254
- */
255
- function getuserinfo(event: any) {
256
- emit('getuserinfo', event);
257
- }
258
- /**
259
- * 当使用开放能力时,发生错误的回调
260
- */
261
- function error(event: any) {
262
- emit('error', event);
263
- }
264
- /**
265
- * 在打开授权设置页并关闭后回调
266
- */
267
- function opensetting(event: any) {
268
- emit('opensetting', event);
269
- }
270
- /**
271
- * 打开 APP 成功的回调
272
- */
273
- function launchapp(event: any) {
274
- emit('launchapp', event);
275
- }
276
-
277
- /**
278
- * 支付宝小程序授权
279
- * @param event
280
- */
281
- function getAuthorize(event: any) {
282
- if (props.scope === 'phoneNumber') {
283
- getphonenumber(event);
284
- } else if (props.scope === 'userInfo') {
285
- getuserinfo(event);
286
- }
287
- }
288
-
289
- /**
290
- * 客服消息回调
291
- * @param event
292
- */
293
- function contact(event: any) {
294
- emit('contact', event);
295
- }
296
- /**
297
- * 头像选择回调
298
- * @param event
299
- */
300
- function chooseavatar(event: any) {
301
- emit('chooseavatar', event);
302
- }
303
- /**
304
- * 用户点击允许授权回调
305
- * @param event
306
- */
307
- function agreeprivacyauthorization(event: any) {
308
- emit('agreeprivacyauthorization', event);
309
- }
310
- </script>
311
-
312
- <style scoped lang="scss">
313
- @import '../../libs/css/style.components.scss';
314
- .u-btn::after {
315
- border: none;
316
- }
317
-
318
- .u-btn {
319
- position: relative;
320
- border: 0;
321
- //border-radius: 10rpx;
322
- /* #ifndef APP-NVUE */
323
- display: inline-flex;
324
- /* #endif */
325
- // 避免边框某些场景可能被“裁剪”,不能设置为hidden
326
- overflow: visible;
327
- line-height: 1;
328
- @include vue-flex;
329
- align-items: center;
330
- justify-content: center;
331
- cursor: pointer;
332
- padding: 0 40rpx;
333
- z-index: 1;
334
- box-sizing: border-box;
335
- transition: all 0.15s;
336
-
337
- &--bold-border {
338
- border: 1px solid #ffffff;
339
- }
340
-
341
- &--default {
342
- color: $u-content-color;
343
- border-color: #c0c4cc;
344
- background-color: #ffffff;
345
- }
346
-
347
- &--primary {
348
- color: #ffffff;
349
- border-color: $u-type-primary;
350
- background-color: $u-type-primary;
351
- }
352
-
353
- &--success {
354
- color: #ffffff;
355
- border-color: $u-type-success;
356
- background-color: $u-type-success;
357
- }
358
-
359
- &--error {
360
- color: #ffffff;
361
- border-color: $u-type-error;
362
- background-color: $u-type-error;
363
- }
364
-
365
- &--warning {
366
- color: #ffffff;
367
- border-color: $u-type-warning;
368
- background-color: $u-type-warning;
369
- }
370
-
371
- &--default--disabled {
372
- color: #ffffff;
373
- border-color: #e4e7ed;
374
- background-color: #ffffff;
375
- }
376
-
377
- &--primary--disabled {
378
- color: #ffffff !important;
379
- border-color: $u-type-primary-disabled !important;
380
- background-color: $u-type-primary-disabled !important;
381
- }
382
-
383
- &--success--disabled {
384
- color: #ffffff !important;
385
- border-color: $u-type-success-disabled !important;
386
- background-color: $u-type-success-disabled !important;
387
- }
388
-
389
- &--error--disabled {
390
- color: #ffffff !important;
391
- border-color: $u-type-error-disabled !important;
392
- background-color: $u-type-error-disabled !important;
393
- }
394
-
395
- &--warning--disabled {
396
- color: #ffffff !important;
397
- border-color: $u-type-warning-disabled !important;
398
- background-color: $u-type-warning-disabled !important;
399
- }
400
-
401
- &--primary--plain {
402
- color: $u-type-primary !important;
403
- border-color: $u-type-primary-disabled !important;
404
- background-color: $u-type-primary-light !important;
405
- }
406
-
407
- &--success--plain {
408
- color: $u-type-success !important;
409
- border-color: $u-type-success-disabled !important;
410
- background-color: $u-type-success-light !important;
411
- }
412
-
413
- &--error--plain {
414
- color: $u-type-error !important;
415
- border-color: $u-type-error-disabled !important;
416
- background-color: $u-type-error-light !important;
417
- }
418
-
419
- &--warning--plain {
420
- color: $u-type-warning !important;
421
- border-color: $u-type-warning-disabled !important;
422
- background-color: $u-type-warning-light !important;
423
- }
424
- }
425
-
426
- .u-hairline-border:after {
427
- content: ' ';
428
- position: absolute;
429
- pointer-events: none;
430
- // 设置为border-box,意味着下面的scale缩小为0.5,实际上缩小的是伪元素的内容(border-box意味着内容不含border)
431
- box-sizing: border-box;
432
- // 中心点作为变形(scale())的原点
433
- -webkit-transform-origin: 0 0;
434
- transform-origin: 0 0;
435
- left: 0;
436
- top: 0;
437
- width: 199.8%;
438
- height: 199.7%;
439
- -webkit-transform: scale(0.5, 0.5);
440
- transform: scale(0.5, 0.5);
441
- border: 1px solid currentColor;
442
- z-index: 1;
443
- }
444
-
445
- .u-wave-ripple {
446
- z-index: 0;
447
- position: absolute;
448
- border-radius: 100%;
449
- background-clip: padding-box;
450
- pointer-events: none;
451
- user-select: none;
452
- transform: scale(0);
453
- opacity: 1;
454
- transform-origin: center;
455
- }
456
-
457
- .u-wave-ripple.u-wave-active {
458
- opacity: 0;
459
- transform: scale(2);
460
- transition:
461
- opacity 1s linear,
462
- transform 0.4s linear;
463
- }
464
-
465
- .u-round-circle {
466
- border-radius: 100rpx;
467
- }
468
-
469
- .u-round-circle::after {
470
- border-radius: 100rpx;
471
- }
472
-
473
- .u-loading::after {
474
- background-color: hsla(0, 0%, 100%, 0.35);
475
- }
476
-
477
- .u-size-default {
478
- font-size: 30rpx;
479
- height: 80rpx;
480
- line-height: 80rpx;
481
- }
482
-
483
- .u-size-medium {
484
- /* #ifndef APP-NVUE */
485
- display: inline-flex;
486
- /* #endif */
487
- width: auto;
488
- font-size: 26rpx;
489
- height: 70rpx;
490
- line-height: 70rpx;
491
- padding: 0 80rpx;
492
- }
493
-
494
- .u-size-mini {
495
- /* #ifndef APP-NVUE */
496
- display: inline-flex;
497
- /* #endif */
498
- width: auto;
499
- font-size: 22rpx;
500
- padding-top: 1px;
501
- height: 50rpx;
502
- line-height: 50rpx;
503
- padding: 0 20rpx;
504
- }
505
-
506
- .u-primary-plain-hover {
507
- color: #ffffff !important;
508
- background: $u-type-primary-dark !important;
509
- }
510
-
511
- .u-default-plain-hover {
512
- color: $u-type-primary-dark !important;
513
- background: $u-type-primary-light !important;
514
- }
515
-
516
- .u-success-plain-hover {
517
- color: #ffffff !important;
518
- background: $u-type-success-dark !important;
519
- }
520
-
521
- .u-warning-plain-hover {
522
- color: #ffffff !important;
523
- background: $u-type-warning-dark !important;
524
- }
525
-
526
- .u-error-plain-hover {
527
- color: #ffffff !important;
528
- background: $u-type-error-dark !important;
529
- }
530
-
531
- .u-info-plain-hover {
532
- color: #ffffff !important;
533
- background: $u-type-info-dark !important;
534
- }
535
-
536
- .u-default-hover {
537
- color: $u-type-primary-dark !important;
538
- border-color: $u-type-primary-dark !important;
539
- background-color: $u-type-primary-light !important;
540
- }
541
-
542
- .u-primary-hover {
543
- background: $u-type-primary-dark !important;
544
- color: #fff;
545
- }
546
-
547
- .u-success-hover {
548
- background: $u-type-success-dark !important;
549
- color: #fff;
550
- }
551
-
552
- .u-info-hover {
553
- background: $u-type-info-dark !important;
554
- color: #fff;
555
- }
556
-
557
- .u-warning-hover {
558
- background: $u-type-warning-dark !important;
559
- color: #fff;
560
- }
561
-
562
- .u-error-hover {
563
- background: $u-type-error-dark !important;
564
- color: #fff;
565
- }
566
- </style>
1
+ <template>
2
+ <button
3
+ id="u-wave-btn"
4
+ class="u-btn u-line-1 u-fix-ios-appearance"
5
+ :class="[
6
+ 'u-size-' + size,
7
+ plain ? 'u-btn--' + type + '--plain' : '',
8
+ loading ? 'u-loading' : '',
9
+ shape === 'circle' ? 'u-round-circle' : '',
10
+ hairLine ? showHairLineBorder : 'u-btn--bold-border',
11
+ 'u-btn--' + type,
12
+ disabled ? `u-btn--${type}--disabled` : '',
13
+ customClass
14
+ ]"
15
+ :hover-start-time="Number(hoverStartTime)"
16
+ :hover-stay-time="Number(hoverStayTime)"
17
+ :disabled="disabled"
18
+ :form-type="formType"
19
+ :open-type="disabled || loading ? undefined : openType"
20
+ :app-parameter="appParameter"
21
+ :hover-stop-propagation="hoverStopPropagation"
22
+ :send-message-title="sendMessageTitle"
23
+ send-message-path="sendMessagePath"
24
+ :lang="lang"
25
+ :data-name="dataName"
26
+ :session-from="sessionFrom"
27
+ :send-message-img="sendMessageImg"
28
+ :show-message-card="showMessageCard"
29
+ @getAuthorize="getAuthorize"
30
+ @getuserinfo="getuserinfo"
31
+ @contact="contact"
32
+ @getphonenumber="getphonenumber"
33
+ @error="error"
34
+ @launchapp="launchapp"
35
+ @opensetting="opensetting"
36
+ @chooseavatar="chooseavatar"
37
+ @agreeprivacyauthorization="agreeprivacyauthorization"
38
+ :style="
39
+ $u.toStyle(
40
+ {
41
+ overflow: ripple ? 'hidden' : 'visible'
42
+ },
43
+ customStyle
44
+ )
45
+ "
46
+ @tap.stop="click($event)"
47
+ :hover-class="getHoverClass"
48
+ :loading="loading"
49
+ >
50
+ <slot></slot>
51
+ <view
52
+ v-if="ripple"
53
+ class="u-wave-ripple"
54
+ :class="[waveActive ? 'u-wave-active' : '']"
55
+ :style="{
56
+ top: rippleTop + 'px',
57
+ left: rippleLeft + 'px',
58
+ width: fields.targetWidth + 'px',
59
+ height: fields.targetWidth + 'px',
60
+ 'background-color': rippleBgColor || 'rgba(0, 0, 0, 0.15)'
61
+ }"
62
+ ></view>
63
+ </button>
64
+ </template>
65
+
66
+ <script lang="ts">
67
+ export default {
68
+ name: 'u-button',
69
+ options: {
70
+ addGlobalClass: true,
71
+ // #ifndef MP-TOUTIAO
72
+ virtualHost: true,
73
+ // #endif
74
+ styleIsolation: 'shared'
75
+ }
76
+ };
77
+ </script>
78
+
79
+ <script setup lang="ts">
80
+ import { ref, computed, nextTick } from 'vue';
81
+ import { $u } from '../../';
82
+ import { ButtonProps } from './types';
83
+
84
+ /**
85
+ * button 按钮
86
+ * @description Button 按钮
87
+ * @tutorial https://uviewpro.cn/zh/components/button.html
88
+ * @property {String} size 按钮的大小
89
+ * @property {Boolean} ripple 是否开启点击水波纹效果
90
+ * @property {String} ripple-bg-color 水波纹的背景色,ripple为true时有效
91
+ * @property {String} type 按钮的样式类型
92
+ * @property {Boolean} plain 按钮是否镂空,背景色透明
93
+ * @property {Boolean} disabled 是否禁用
94
+ * @property {Boolean} hair-line 是否显示按钮的细边框(默认true)
95
+ * @property {String} shape 按钮外观形状,见文档说明
96
+ * @property {Boolean} loading 按钮名称前是否带 loading 图标(App-nvue 平台,在 ios 上为雪花,Android上为圆圈)
97
+ * @property {String} form-type 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件
98
+ * @property {String} open-type 开放能力
99
+ * @property {String} data-name 额外传参参数,用于小程序的data-xxx属性,通过target.dataset.name获取
100
+ * @property {String} hover-class 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果(App-nvue 平台暂不支持)
101
+ * @property {Number} hover-start-time 按住后多久出现点击态,单位毫秒
102
+ * @property {Number} hover-stay-time 手指松开后点击态保留时间,单位毫秒
103
+ * @property {Object} custom-style 对按钮的自定义样式,对象形式,见文档说明
104
+ * @property {String} app-parameter 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效
105
+ * @property {Boolean} hover-stop-propagation 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效
106
+ * @property {String} lang 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。只微信小程序有效
107
+ * @property {String} session-from 会话来源,open-type="contact"时有效。只微信小程序有效
108
+ * @property {String} send-message-title 会话内消息卡片标题,open-type="contact"时有效
109
+ * @property {String} send-message-path 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效
110
+ * @property {String} send-message-img 会话内消息卡片图片,open-type="contact"时有效
111
+ * @property {Boolean} show-message-card 是否显示会话内消息卡片,open-type="contact"时有效
112
+ * @property {Number|String} throttle-time 节流,一定时间内只能触发一次,单位毫秒
113
+ * @property {String} scope 支付宝小程序,当 open-type 为 getAuthorize 时有效。可选值:'phoneNumber' | 'userInfo'
114
+ * @event {Function} click 按钮点击
115
+ * @event {Function} getphonenumber open-type="getPhoneNumber"时有效
116
+ * @event {Function} getuserinfo 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
117
+ * @event {Function} error 当使用开放能力时,发生错误的回调
118
+ * @event {Function} opensetting 在打开授权设置页并关闭后回调
119
+ * @event {Function} launchapp 打开 APP 成功的回调
120
+ * @event {Function} contact 客服消息回调
121
+ * @event {Function} chooseavatar 头像选择回调
122
+ * @event {Function} agreeprivacyauthorization 用户点击允许授权回调
123
+ * @example <u-button>月落</u-button>
124
+ */
125
+
126
+ const emit = defineEmits([
127
+ 'click',
128
+ 'getuserinfo',
129
+ 'contact',
130
+ 'getphonenumber',
131
+ 'error',
132
+ 'launchapp',
133
+ 'opensetting',
134
+ 'chooseavatar',
135
+ 'agreeprivacyauthorization'
136
+ ]);
137
+
138
+ const props = defineProps(ButtonProps);
139
+
140
+ /**
141
+ * 按钮水波纹相关状态
142
+ */
143
+ const rippleTop = ref(0); // 水波纹的起点Y坐标到按钮上边界的距离
144
+ const rippleLeft = ref(0); // 水波纹起点X坐标到按钮左边界的距离
145
+ const fields = ref<Record<string, any>>({}); // 波纹按钮节点信息
146
+ const waveActive = ref(false); // 激活水波纹
147
+
148
+ /**
149
+ * 当没有传bgColor变量时,按钮按下去的颜色类名
150
+ * @returns {string}
151
+ */
152
+ const getHoverClass = computed(() => {
153
+ // 如果开启水波纹效果,则不启用hover-class效果
154
+ if (props.loading || props.disabled || props.ripple || props.hoverClass) return '';
155
+ let hoverClass = '';
156
+ hoverClass = props.plain ? 'u-' + props.type + '-plain-hover' : 'u-' + props.type + '-hover';
157
+ return hoverClass;
158
+ });
159
+
160
+ /**
161
+ * 在'primary', 'success', 'error', 'warning'类型下,不显示边框,否则会造成四角有毛刺现象
162
+ * @returns {string}
163
+ */
164
+ const showHairLineBorder = computed(() => {
165
+ if (['primary', 'success', 'error', 'warning'].indexOf(props.type) >= 0 && !props.plain) {
166
+ return '';
167
+ } else {
168
+ return 'u-hairline-border';
169
+ }
170
+ });
171
+
172
+ /**
173
+ * 按钮点击
174
+ * @param e 事件对象
175
+ * @emits click
176
+ */
177
+ function click(e: any) {
178
+ $u.throttle(() => {
179
+ // 如果按钮时disabled和loading状态,不触发水波纹效果
180
+ if (props.loading === true || props.disabled === true) return;
181
+ // 是否开启水波纹效果
182
+ if (props.ripple) {
183
+ // 每次点击时,移除上一次的类,再次添加,才能触发动画效果
184
+ waveActive.value = false;
185
+ nextTick(() => {
186
+ getWaveQuery(e);
187
+ });
188
+ }
189
+ emit('click', e);
190
+ }, Number(props.throttleTime));
191
+ }
192
+
193
+ /**
194
+ * 查询按钮的节点信息
195
+ * @param e 事件对象
196
+ */
197
+ function getWaveQuery(e: any) {
198
+ getElQuery().then((res: any[]) => {
199
+ // 查询返回的是一个数组节点
200
+ let data = res[0];
201
+ // 查询不到节点信息,不操作
202
+ if (!data.width || !data.width) return;
203
+ // 水波纹的最终形态是一个正方形(通过border-radius让其变为一个圆形),这里要保证正方形的边长等于按钮的最长边
204
+ // 最终的方形(变换后的圆形)才能覆盖整个按钮
205
+ data.targetWidth = data.height > data.width ? data.height : data.width;
206
+ if (!data.targetWidth) return;
207
+ fields.value = data;
208
+ let touchesX = '',
209
+ touchesY = '';
210
+ // #ifdef MP-BAIDU
211
+ // @ts-ignore
212
+ touchesX = e.changedTouches[0].clientX;
213
+ touchesY = e.changedTouches[0].clientY;
214
+ // #endif
215
+ // #ifdef MP-ALIPAY
216
+ // @ts-ignore
217
+ touchesX = e.detail.clientX;
218
+ touchesY = e.detail.clientY;
219
+ // #endif
220
+ // #ifndef MP-BAIDU || MP-ALIPAY
221
+ // @ts-ignore
222
+ touchesX = e.touches[0].clientX;
223
+ touchesY = e.touches[0].clientY;
224
+ // #endif
225
+ // 获取触摸点相对于按钮上边和左边的x和y坐标,原理是通过屏幕的触摸点(touchesY),减去按钮的上边界data.top
226
+ // 但是由于`transform-origin`默认是center,所以这里再减去半径才是水波纹view应该的位置
227
+ // 总的来说,就是把水波纹的矩形(变换后的圆形)的中心点,移动到我们的触摸点位置
228
+ rippleTop.value = Number(touchesY) - data.top - data.targetWidth / 2;
229
+ rippleLeft.value = Number(touchesX) - data.left - data.targetWidth / 2;
230
+ nextTick(() => {
231
+ waveActive.value = true;
232
+ });
233
+ });
234
+ }
235
+
236
+ /**
237
+ * 获取节点信息
238
+ * @returns {Promise<any[]>}
239
+ */
240
+ function getElQuery(): Promise<any[]> {
241
+ return new Promise(resolve => {
242
+ let queryInfo: any = '';
243
+ // 获取元素节点信息,请查看uniapp相关文档
244
+ // https://uniapp.dcloud.io/api/ui/nodes-info?id=nodesrefboundingclientrect
245
+ // @ts-ignore
246
+ queryInfo = uni.createSelectorQuery().in(null);
247
+ // #ifdef MP-ALIPAY
248
+ // @ts-ignore
249
+ queryInfo = uni.createSelectorQuery();
250
+ // #endif
251
+ queryInfo.select('.u-btn').boundingClientRect();
252
+ queryInfo.exec((data: any) => {
253
+ resolve(data);
254
+ });
255
+ });
256
+ }
257
+
258
+ // 下面为对接uniapp官方按钮开放能力事件回调的对接
259
+ /**
260
+ * open-type="getPhoneNumber"时有效
261
+ */
262
+ function getphonenumber(event: any) {
263
+ emit('getphonenumber', event);
264
+ }
265
+ /**
266
+ * 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
267
+ */
268
+ function getuserinfo(event: any) {
269
+ emit('getuserinfo', event);
270
+ }
271
+ /**
272
+ * 当使用开放能力时,发生错误的回调
273
+ */
274
+ function error(event: any) {
275
+ emit('error', event);
276
+ }
277
+ /**
278
+ * 在打开授权设置页并关闭后回调
279
+ */
280
+ function opensetting(event: any) {
281
+ emit('opensetting', event);
282
+ }
283
+ /**
284
+ * 打开 APP 成功的回调
285
+ */
286
+ function launchapp(event: any) {
287
+ emit('launchapp', event);
288
+ }
289
+
290
+ /**
291
+ * 支付宝小程序授权
292
+ * @param event
293
+ */
294
+ function getAuthorize(event: any) {
295
+ if (props.scope === 'phoneNumber') {
296
+ getphonenumber(event);
297
+ } else if (props.scope === 'userInfo') {
298
+ getuserinfo(event);
299
+ }
300
+ }
301
+
302
+ /**
303
+ * 客服消息回调
304
+ * @param event
305
+ */
306
+ function contact(event: any) {
307
+ emit('contact', event);
308
+ }
309
+ /**
310
+ * 头像选择回调
311
+ * @param event
312
+ */
313
+ function chooseavatar(event: any) {
314
+ emit('chooseavatar', event);
315
+ }
316
+ /**
317
+ * 用户点击允许授权回调
318
+ * @param event
319
+ */
320
+ function agreeprivacyauthorization(event: any) {
321
+ emit('agreeprivacyauthorization', event);
322
+ }
323
+ </script>
324
+
325
+ <style scoped lang="scss">
326
+ @import '../../libs/css/style.components.scss';
327
+ .u-btn::after {
328
+ border: none;
329
+ }
330
+
331
+ .u-btn {
332
+ position: relative;
333
+ border: 0;
334
+ //border-radius: 10rpx;
335
+ /* #ifndef APP-NVUE */
336
+ display: inline-flex;
337
+ /* #endif */
338
+ // 避免边框某些场景可能被“裁剪”,不能设置为hidden
339
+ overflow: visible;
340
+ line-height: 1;
341
+ @include vue-flex;
342
+ align-items: center;
343
+ justify-content: center;
344
+ cursor: pointer;
345
+ padding: 0 40rpx;
346
+ z-index: 1;
347
+ box-sizing: border-box;
348
+ transition: all 0.15s;
349
+
350
+ &--bold-border {
351
+ border: 1px solid #ffffff;
352
+ }
353
+
354
+ &--default {
355
+ color: $u-content-color;
356
+ border-color: #c0c4cc;
357
+ background-color: #ffffff;
358
+ }
359
+
360
+ &--primary {
361
+ color: #ffffff;
362
+ border-color: $u-type-primary;
363
+ background-color: $u-type-primary;
364
+ }
365
+
366
+ &--success {
367
+ color: #ffffff;
368
+ border-color: $u-type-success;
369
+ background-color: $u-type-success;
370
+ }
371
+
372
+ &--error {
373
+ color: #ffffff;
374
+ border-color: $u-type-error;
375
+ background-color: $u-type-error;
376
+ }
377
+
378
+ &--warning {
379
+ color: #ffffff;
380
+ border-color: $u-type-warning;
381
+ background-color: $u-type-warning;
382
+ }
383
+
384
+ &--default--disabled {
385
+ color: #ffffff;
386
+ border-color: #e4e7ed;
387
+ background-color: #ffffff;
388
+ }
389
+
390
+ &--primary--disabled {
391
+ color: #ffffff !important;
392
+ border-color: $u-type-primary-disabled !important;
393
+ background-color: $u-type-primary-disabled !important;
394
+ }
395
+
396
+ &--success--disabled {
397
+ color: #ffffff !important;
398
+ border-color: $u-type-success-disabled !important;
399
+ background-color: $u-type-success-disabled !important;
400
+ }
401
+
402
+ &--error--disabled {
403
+ color: #ffffff !important;
404
+ border-color: $u-type-error-disabled !important;
405
+ background-color: $u-type-error-disabled !important;
406
+ }
407
+
408
+ &--warning--disabled {
409
+ color: #ffffff !important;
410
+ border-color: $u-type-warning-disabled !important;
411
+ background-color: $u-type-warning-disabled !important;
412
+ }
413
+
414
+ &--primary--plain {
415
+ color: $u-type-primary !important;
416
+ border-color: $u-type-primary-disabled !important;
417
+ background-color: $u-type-primary-light !important;
418
+ }
419
+
420
+ &--success--plain {
421
+ color: $u-type-success !important;
422
+ border-color: $u-type-success-disabled !important;
423
+ background-color: $u-type-success-light !important;
424
+ }
425
+
426
+ &--error--plain {
427
+ color: $u-type-error !important;
428
+ border-color: $u-type-error-disabled !important;
429
+ background-color: $u-type-error-light !important;
430
+ }
431
+
432
+ &--warning--plain {
433
+ color: $u-type-warning !important;
434
+ border-color: $u-type-warning-disabled !important;
435
+ background-color: $u-type-warning-light !important;
436
+ }
437
+ }
438
+
439
+ .u-hairline-border:after {
440
+ content: ' ';
441
+ position: absolute;
442
+ pointer-events: none;
443
+ // 设置为border-box,意味着下面的scale缩小为0.5,实际上缩小的是伪元素的内容(border-box意味着内容不含border)
444
+ box-sizing: border-box;
445
+ // 中心点作为变形(scale())的原点
446
+ -webkit-transform-origin: 0 0;
447
+ transform-origin: 0 0;
448
+ left: 0;
449
+ top: 0;
450
+ width: 199.8%;
451
+ height: 199.7%;
452
+ -webkit-transform: scale(0.5, 0.5);
453
+ transform: scale(0.5, 0.5);
454
+ border: 1px solid currentColor;
455
+ z-index: 1;
456
+ }
457
+
458
+ .u-wave-ripple {
459
+ z-index: 0;
460
+ position: absolute;
461
+ border-radius: 100%;
462
+ background-clip: padding-box;
463
+ pointer-events: none;
464
+ user-select: none;
465
+ transform: scale(0);
466
+ opacity: 1;
467
+ transform-origin: center;
468
+ }
469
+
470
+ .u-wave-ripple.u-wave-active {
471
+ opacity: 0;
472
+ transform: scale(2);
473
+ transition:
474
+ opacity 1s linear,
475
+ transform 0.4s linear;
476
+ }
477
+
478
+ .u-round-circle {
479
+ border-radius: 100rpx;
480
+ }
481
+
482
+ .u-round-circle::after {
483
+ border-radius: 100rpx;
484
+ }
485
+
486
+ .u-loading::after {
487
+ background-color: hsla(0, 0%, 100%, 0.35);
488
+ }
489
+
490
+ .u-size-default {
491
+ font-size: 30rpx;
492
+ height: 80rpx;
493
+ line-height: 80rpx;
494
+ }
495
+
496
+ .u-size-medium {
497
+ /* #ifndef APP-NVUE */
498
+ display: inline-flex;
499
+ /* #endif */
500
+ width: auto;
501
+ font-size: 26rpx;
502
+ height: 70rpx;
503
+ line-height: 70rpx;
504
+ padding: 0 80rpx;
505
+ }
506
+
507
+ .u-size-mini {
508
+ /* #ifndef APP-NVUE */
509
+ display: inline-flex;
510
+ /* #endif */
511
+ width: auto;
512
+ font-size: 22rpx;
513
+ padding-top: 1px;
514
+ height: 50rpx;
515
+ line-height: 50rpx;
516
+ padding: 0 20rpx;
517
+ }
518
+
519
+ .u-primary-plain-hover {
520
+ color: #ffffff !important;
521
+ background: $u-type-primary-dark !important;
522
+ }
523
+
524
+ .u-default-plain-hover {
525
+ color: $u-type-primary-dark !important;
526
+ background: $u-type-primary-light !important;
527
+ }
528
+
529
+ .u-success-plain-hover {
530
+ color: #ffffff !important;
531
+ background: $u-type-success-dark !important;
532
+ }
533
+
534
+ .u-warning-plain-hover {
535
+ color: #ffffff !important;
536
+ background: $u-type-warning-dark !important;
537
+ }
538
+
539
+ .u-error-plain-hover {
540
+ color: #ffffff !important;
541
+ background: $u-type-error-dark !important;
542
+ }
543
+
544
+ .u-info-plain-hover {
545
+ color: #ffffff !important;
546
+ background: $u-type-info-dark !important;
547
+ }
548
+
549
+ .u-default-hover {
550
+ color: $u-type-primary-dark !important;
551
+ border-color: $u-type-primary-dark !important;
552
+ background-color: $u-type-primary-light !important;
553
+ }
554
+
555
+ .u-primary-hover {
556
+ background: $u-type-primary-dark !important;
557
+ color: #fff;
558
+ }
559
+
560
+ .u-success-hover {
561
+ background: $u-type-success-dark !important;
562
+ color: #fff;
563
+ }
564
+
565
+ .u-info-hover {
566
+ background: $u-type-info-dark !important;
567
+ color: #fff;
568
+ }
569
+
570
+ .u-warning-hover {
571
+ background: $u-type-warning-dark !important;
572
+ color: #fff;
573
+ }
574
+
575
+ .u-error-hover {
576
+ background: $u-type-error-dark !important;
577
+ color: #fff;
578
+ }
579
+ </style>