uview-pro 0.6.18 → 0.6.19

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