uview-pro 0.3.0 → 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 -574
  2. package/components/common/props.ts +22 -22
  3. package/components/u-action-sheet/types.ts +37 -37
  4. package/components/u-action-sheet/u-action-sheet.vue +178 -178
  5. package/components/u-alert-tips/types.ts +41 -41
  6. package/components/u-alert-tips/u-alert-tips.vue +238 -238
  7. package/components/u-avatar/types.ts +36 -36
  8. package/components/u-avatar/u-avatar.vue +217 -217
  9. package/components/u-avatar-cropper/types.ts +23 -23
  10. package/components/u-avatar-cropper/u-avatar-cropper.vue +297 -297
  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 -36
  15. package/components/u-back-top/u-back-top.vue +140 -140
  16. package/components/u-badge/types.ts +38 -38
  17. package/components/u-badge/u-badge.vue +183 -183
  18. package/components/u-button/types.ts +66 -66
  19. package/components/u-button/u-button.vue +579 -579
  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 -14
  23. package/components/u-car-keyboard/u-car-keyboard.vue +262 -262
  24. package/components/u-card/types.ts +61 -61
  25. package/components/u-card/u-card.vue +209 -209
  26. package/components/u-cell-group/types.ts +19 -19
  27. package/components/u-cell-group/u-cell-group.vue +60 -60
  28. package/components/u-cell-item/types.ts +56 -56
  29. package/components/u-cell-item/u-cell-item.vue +226 -226
  30. package/components/u-checkbox/types.ts +33 -33
  31. package/components/u-checkbox/u-checkbox.vue +282 -282
  32. package/components/u-checkbox-group/types.ts +34 -34
  33. package/components/u-checkbox-group/u-checkbox-group.vue +130 -130
  34. package/components/u-circle-progress/types.ts +54 -54
  35. package/components/u-circle-progress/u-circle-progress.vue +206 -206
  36. package/components/u-city-select/types.ts +22 -22
  37. package/components/u-city-select/u-city-select.vue +276 -276
  38. package/components/u-col/types.ts +32 -32
  39. package/components/u-col/u-col.vue +142 -142
  40. package/components/u-collapse/types.ts +33 -33
  41. package/components/u-collapse/u-collapse.vue +190 -190
  42. package/components/u-collapse-item/types.ts +27 -27
  43. package/components/u-collapse-item/u-collapse-item.vue +290 -290
  44. package/components/u-column-notice/types.ts +50 -50
  45. package/components/u-column-notice/u-column-notice.vue +222 -222
  46. package/components/u-count-down/types.ts +44 -44
  47. package/components/u-count-down/u-count-down.vue +286 -286
  48. package/components/u-count-to/types.ts +34 -34
  49. package/components/u-count-to/u-count-to.vue +266 -266
  50. package/components/u-divider/types.ts +33 -33
  51. package/components/u-divider/u-divider.vue +145 -145
  52. package/components/u-dropdown/types.ts +34 -34
  53. package/components/u-dropdown/u-dropdown.vue +330 -330
  54. package/components/u-dropdown-item/types.ts +29 -29
  55. package/components/u-dropdown-item/u-dropdown-item.vue +120 -120
  56. package/components/u-empty/types.ts +38 -38
  57. package/components/u-empty/u-empty.vue +103 -103
  58. package/components/u-field/types.ts +71 -71
  59. package/components/u-field/u-field.vue +388 -388
  60. package/components/u-form/types.ts +29 -29
  61. package/components/u-form/u-form.vue +130 -130
  62. package/components/u-form-item/types.ts +72 -72
  63. package/components/u-form-item/u-form-item.vue +447 -447
  64. package/components/u-full-screen/types.ts +16 -16
  65. package/components/u-full-screen/u-full-screen.vue +103 -103
  66. package/components/u-gap/types.ts +20 -20
  67. package/components/u-gap/u-gap.vue +50 -50
  68. package/components/u-grid/types.ts +21 -21
  69. package/components/u-grid/u-grid.vue +91 -91
  70. package/components/u-grid-item/types.ts +16 -16
  71. package/components/u-grid-item/u-grid-item.vue +130 -130
  72. package/components/u-icon/types.ts +61 -61
  73. package/components/u-icon/u-icon.vue +296 -296
  74. package/components/u-image/types.ts +51 -51
  75. package/components/u-image/u-image.vue +239 -239
  76. package/components/u-index-anchor/types.ts +16 -16
  77. package/components/u-index-anchor/u-index-anchor.vue +94 -94
  78. package/components/u-index-list/types.ts +43 -43
  79. package/components/u-index-list/u-index-list.vue +352 -352
  80. package/components/u-input/types.ts +137 -137
  81. package/components/u-input/u-input.vue +288 -288
  82. package/components/u-keyboard/types.ts +40 -40
  83. package/components/u-keyboard/u-keyboard.vue +178 -178
  84. package/components/u-lazy-load/types.ts +37 -37
  85. package/components/u-lazy-load/u-lazy-load.vue +246 -246
  86. package/components/u-line/types.ts +44 -44
  87. package/components/u-line/u-line.vue +68 -68
  88. package/components/u-line-progress/types.ts +58 -58
  89. package/components/u-line-progress/u-line-progress.vue +126 -126
  90. package/components/u-link/types.ts +43 -43
  91. package/components/u-link/u-link.vue +84 -84
  92. package/components/u-loading/types.ts +35 -35
  93. package/components/u-loading/u-loading.vue +105 -105
  94. package/components/u-loading-popup/types.ts +26 -26
  95. package/components/u-loading-popup/u-loading-popup.vue +253 -253
  96. package/components/u-loadmore/types.ts +79 -79
  97. package/components/u-loadmore/u-loadmore.vue +156 -156
  98. package/components/u-mask/types.ts +40 -40
  99. package/components/u-mask/u-mask.vue +113 -113
  100. package/components/u-message-input/types.ts +74 -74
  101. package/components/u-message-input/u-message-input.vue +281 -281
  102. package/components/u-modal/types.ts +118 -118
  103. package/components/u-modal/u-modal.vue +220 -220
  104. package/components/u-navbar/types.ts +103 -103
  105. package/components/u-navbar/u-navbar.vue +251 -251
  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 -303
  109. package/components/u-notice-bar/types.ts +111 -111
  110. package/components/u-notice-bar/u-notice-bar.vue +189 -189
  111. package/components/u-number-box/types.ts +42 -42
  112. package/components/u-number-box/u-number-box.vue +321 -321
  113. package/components/u-number-keyboard/types.ts +26 -26
  114. package/components/u-number-keyboard/u-number-keyboard.vue +188 -188
  115. package/components/u-picker/types.ts +123 -123
  116. package/components/u-picker/u-picker.vue +685 -685
  117. package/components/u-popup/types.ts +59 -59
  118. package/components/u-popup/u-popup.vue +385 -385
  119. package/components/u-radio/types.ts +27 -27
  120. package/components/u-radio/u-radio.vue +279 -279
  121. package/components/u-radio-group/types.ts +31 -31
  122. package/components/u-radio-group/u-radio-group.vue +96 -96
  123. package/components/u-rate/types.ts +42 -42
  124. package/components/u-rate/u-rate.vue +249 -249
  125. package/components/u-read-more/types.ts +37 -37
  126. package/components/u-read-more/u-read-more.vue +172 -172
  127. package/components/u-root-portal/u-root-portal.vue +56 -56
  128. package/components/u-row/types.ts +22 -22
  129. package/components/u-row/u-row.vue +105 -105
  130. package/components/u-row-notice/types.ts +41 -41
  131. package/components/u-row-notice/u-row-notice.vue +256 -256
  132. package/components/u-safe-bottom/u-safe-bottom.vue +57 -57
  133. package/components/u-search/types.ts +55 -55
  134. package/components/u-search/u-search.vue +279 -279
  135. package/components/u-section/types.ts +34 -34
  136. package/components/u-section/u-section.vue +150 -150
  137. package/components/u-select/types.ts +45 -45
  138. package/components/u-select/u-select.vue +388 -388
  139. package/components/u-skeleton/types.ts +22 -22
  140. package/components/u-skeleton/u-skeleton.vue +231 -231
  141. package/components/u-slider/types.ts +34 -34
  142. package/components/u-slider/u-slider.vue +255 -255
  143. package/components/u-status-bar/u-status-bar.vue +74 -74
  144. package/components/u-steps/types.ts +30 -30
  145. package/components/u-steps/u-steps.vue +181 -181
  146. package/components/u-sticky/types.ts +24 -24
  147. package/components/u-sticky/u-sticky.vue +178 -178
  148. package/components/u-subsection/types.ts +38 -38
  149. package/components/u-subsection/u-subsection.vue +339 -339
  150. package/components/u-swipe-action/types.ts +52 -52
  151. package/components/u-swipe-action/u-swipe-action.vue +276 -276
  152. package/components/u-swiper/types.ts +49 -49
  153. package/components/u-swiper/u-swiper.vue +308 -308
  154. package/components/u-switch/types.ts +30 -30
  155. package/components/u-switch/u-switch.vue +150 -150
  156. package/components/u-tabbar/types.ts +38 -38
  157. package/components/u-tabbar/u-tabbar.vue +315 -315
  158. package/components/u-table/types.ts +27 -27
  159. package/components/u-table/u-table.vue +67 -67
  160. package/components/u-tabs/types.ts +53 -53
  161. package/components/u-tabs/u-tabs.vue +302 -302
  162. package/components/u-tabs-swiper/types.ts +55 -55
  163. package/components/u-tabs-swiper/u-tabs-swiper.vue +409 -409
  164. package/components/u-tag/types.ts +39 -39
  165. package/components/u-tag/u-tag.vue +268 -268
  166. package/components/u-td/types.ts +14 -14
  167. package/components/u-td/u-td.vue +98 -98
  168. package/components/u-text/types.ts +72 -72
  169. package/components/u-text/u-text.vue +343 -343
  170. package/components/u-th/types.ts +14 -14
  171. package/components/u-th/u-th.vue +92 -92
  172. package/components/u-time-line/u-time-line.vue +53 -53
  173. package/components/u-time-line-item/types.ts +16 -16
  174. package/components/u-time-line-item/u-time-line-item.vue +90 -90
  175. package/components/u-toast/types.ts +38 -38
  176. package/components/u-toast/u-toast.vue +240 -240
  177. package/components/u-top-tips/types.ts +16 -16
  178. package/components/u-top-tips/u-top-tips.vue +130 -130
  179. package/components/u-tr/types.ts +11 -11
  180. package/components/u-tr/u-tr.vue +39 -39
  181. package/components/u-upload/types.ts +82 -82
  182. package/components/u-upload/u-upload.vue +568 -568
  183. package/components/u-verification-code/types.ts +24 -24
  184. package/components/u-verification-code/u-verification-code.vue +176 -176
  185. package/components/u-waterfall/types.ts +18 -18
  186. package/components/u-waterfall/u-waterfall.vue +187 -187
  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 -4
  225. package/libs/hooks/useCompRelation.ts +364 -364
  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 -337
  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,579 +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
- 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>
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>