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