sadais-piui 1.2.4-beta2 → 1.2.4-beta5
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 +512 -512
- package/LICENSE +20 -20
- package/README.md +166 -166
- package/components/pi-action-sheet/index.vue +247 -247
- package/components/pi-badge/index.vue +136 -136
- package/components/pi-bottom-bar/index.vue +139 -139
- package/components/pi-button/index.vue +492 -492
- package/components/pi-calendar/index.vue +178 -178
- package/components/pi-calendar-panel/index.vue +436 -432
- package/components/pi-canvas/index.vue +400 -400
- package/components/pi-card/index.vue +127 -127
- package/components/pi-checkbox/index.vue +345 -345
- package/components/pi-checkbox-group/index.vue +215 -215
- package/components/pi-circle-progress/index.vue +224 -224
- package/components/pi-code-input/index.vue +262 -262
- package/components/pi-count-down/index.vue +245 -245
- package/components/pi-count-up/index.vue +209 -209
- package/components/pi-date-picker/index.vue +366 -366
- package/components/pi-divider/index.vue +109 -109
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -62
- package/components/pi-dropdown/index.vue +316 -316
- package/components/pi-dropdown-item/index.vue +233 -233
- package/components/pi-form/index.vue +237 -237
- package/components/pi-form-item/index.vue +534 -534
- package/components/pi-gap/index.vue +72 -72
- package/components/pi-grid/index.vue +92 -92
- package/components/pi-grid-item/index.vue +220 -220
- package/components/pi-icon/index.vue +147 -147
- package/components/pi-img/index.vue +267 -267
- package/components/pi-img-cropper/canvas.js +112 -112
- package/components/pi-img-cropper/index.vue +357 -357
- package/components/pi-img-cropper/touch.js +163 -163
- package/components/pi-img-cropper/vector.js +34 -34
- package/components/pi-input/index.vue +299 -299
- package/components/pi-line/index.vue +78 -78
- package/components/pi-line-progress/index.vue +198 -198
- package/components/pi-list/index.vue +115 -115
- package/components/pi-list-item/index.vue +331 -331
- package/components/pi-loading/index.vue +188 -188
- package/components/pi-marquee/index.vue +281 -281
- package/components/pi-marquee-item/index.vue +47 -47
- package/components/pi-mask/index.vue +198 -198
- package/components/pi-modal/index.vue +303 -303
- package/components/pi-navbar/index.vue +421 -421
- package/components/pi-notify/index.vue +239 -239
- package/components/pi-number-keyboard/index.vue +189 -189
- package/components/pi-opentype-button/index.vue +501 -501
- package/components/pi-pagination/index.vue +277 -277
- package/components/pi-picker/index.vue +317 -317
- package/components/pi-popup/index.vue +353 -353
- package/components/pi-popup-select/index.vue +291 -291
- package/components/pi-radio/index.vue +387 -387
- package/components/pi-radio-group/index.vue +262 -262
- package/components/pi-rate/index.vue +212 -212
- package/components/pi-regions-select/index.vue +318 -318
- package/components/pi-search/index.vue +351 -351
- package/components/pi-section/index.vue +218 -218
- package/components/pi-select/index.vue +391 -391
- package/components/pi-skeleton/index.vue +280 -280
- package/components/pi-status-bar/index.vue +56 -56
- package/components/pi-stepper/index.vue +394 -394
- package/components/pi-steps/index.vue +299 -299
- package/components/pi-swiper/index.vue +344 -344
- package/components/pi-switch/index.vue +227 -227
- package/components/pi-tabs/index.vue +398 -398
- package/components/pi-upload-img/index.vue +508 -506
- package/components/pi-waterfall/index.vue +130 -130
- package/components/pi-webview/index.vue +82 -82
- package/config/actionSheet.js +25 -25
- package/config/badge.js +9 -9
- package/config/bottomBar.js +11 -11
- package/config/button.js +29 -29
- package/config/calendar.js +19 -19
- package/config/calendarPanel.js +24 -24
- package/config/card.js +8 -8
- package/config/checkbox.js +14 -14
- package/config/checkboxGroup.js +14 -14
- package/config/circleProgress.js +13 -13
- package/config/codeInput.js +12 -12
- package/config/countDown.js +12 -12
- package/config/countUp.js +13 -13
- package/config/datePicker.js +22 -22
- package/config/divider.js +10 -10
- package/config/dropdown.js +21 -21
- package/config/dropdownItem.js +26 -26
- package/config/form.js +27 -27
- package/config/formItem.js +25 -25
- package/config/gap.js +8 -8
- package/config/grid.js +9 -9
- package/config/gridItem.js +12 -12
- package/config/icon.js +11 -11
- package/config/img.js +21 -21
- package/config/imgCropper.js +26 -26
- package/config/index.js +28 -28
- package/config/input.js +25 -25
- package/config/line.js +8 -8
- package/config/lineProgress.js +14 -14
- package/config/list.js +12 -12
- package/config/listItem.js +25 -25
- package/config/loading.js +10 -10
- package/config/marquee.js +8 -8
- package/config/mask.js +12 -12
- package/config/modal.js +36 -36
- package/config/navbar.js +32 -32
- package/config/notify.js +13 -13
- package/config/numberKeyboard.js +21 -21
- package/config/pagination.js +10 -10
- package/config/picker.js +19 -19
- package/config/popup.js +23 -23
- package/config/popupSelect.js +35 -35
- package/config/radio.js +15 -15
- package/config/radioGroup.js +16 -16
- package/config/rate.js +15 -15
- package/config/regionsData.js +58 -58
- package/config/regionsSelect.js +18 -18
- package/config/search.js +27 -27
- package/config/section.js +23 -23
- package/config/select.js +28 -28
- package/config/skeleton.js +13 -13
- package/config/statusBar.js +5 -5
- package/config/stepper.js +19 -19
- package/config/steps.js +19 -19
- package/config/swiper.js +22 -22
- package/config/switch.js +13 -13
- package/config/tabs.js +23 -23
- package/config/uploadImg.js +63 -63
- package/config/waterfall.js +6 -6
- package/index.js +41 -41
- package/mixin/component-custom.js +24 -24
- package/mixin/emitter.js +45 -45
- package/mixin/props-sync.js +65 -65
- package/mixin/value-sync.js +32 -32
- package/mixin/wx-code.js +30 -30
- package/package.json +25 -25
- package/plugins/async-validator.js +1511 -1511
- package/scss/animation.scss +260 -260
- package/scss/icon/icon.scss +594 -594
- package/scss/index.scss +5 -5
- package/scss/mixin.scss +47 -47
- package/tools/index.js +11 -11
|
@@ -1,501 +1,501 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<button
|
|
3
|
-
class="pi-button fix-webkit-appearance"
|
|
4
|
-
:style="[getCustomStyle, customStyle]"
|
|
5
|
-
:class="[customClass, { round: round }]"
|
|
6
|
-
:size="size"
|
|
7
|
-
:type="type"
|
|
8
|
-
:plain="plain"
|
|
9
|
-
:disabled="disabled"
|
|
10
|
-
:form-type="formType"
|
|
11
|
-
:open-type="openType"
|
|
12
|
-
:app-parameter="appParameter"
|
|
13
|
-
:hover-stop-propagation="hoverStopPropagation"
|
|
14
|
-
:send-message-title="sendMessageTitle"
|
|
15
|
-
:send-message-path="sendMessagePath"
|
|
16
|
-
:lang="lang"
|
|
17
|
-
:session-from="sessionFrom"
|
|
18
|
-
:send-message-img="sendMessageImg"
|
|
19
|
-
:show-message-card="showMessageCard"
|
|
20
|
-
:hover-class="getHoverClass"
|
|
21
|
-
:hover-start-time="hoverStartTime"
|
|
22
|
-
:hover-stay-time="hoverStayTime"
|
|
23
|
-
:loading="loading"
|
|
24
|
-
@tap.stop="handleButtonTap"
|
|
25
|
-
@getphonenumber="handleGetPhoneNumber($event)"
|
|
26
|
-
@getuserinfo="handleGetUserInfo($event)"
|
|
27
|
-
@error="handleError($event)"
|
|
28
|
-
@opensetting="handleOpenSetting($event)"
|
|
29
|
-
@launchapp="handleLaunchApp($event)"
|
|
30
|
-
>
|
|
31
|
-
<!-- 按钮内容 -->
|
|
32
|
-
<slot />
|
|
33
|
-
<view v-if="ripple" class="pi-abso-full pi-of-hidden" :class="[{ round }]">
|
|
34
|
-
<view class="wave-ripple" :class="[{ active: waveInfo.active }]" :style="[waveStyle]" />
|
|
35
|
-
</view>
|
|
36
|
-
</button>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script>
|
|
40
|
-
/**
|
|
41
|
-
* 属性和官方uniapp button属性保持一致,扩展了一部分常用属性
|
|
42
|
-
* 因为小程序不兼容v-bind="$attrs"写法,所以只能把官网属性重定义一遍
|
|
43
|
-
*/
|
|
44
|
-
import { getConfig } from '../../config'
|
|
45
|
-
|
|
46
|
-
import { debounce } from '@sadais/piui-tool/tools/common'
|
|
47
|
-
const TAG = 'PiOpentypeButton'
|
|
48
|
-
const { button } = getConfig()
|
|
49
|
-
|
|
50
|
-
export default {
|
|
51
|
-
name: 'PiOpentypeButton',
|
|
52
|
-
props: {
|
|
53
|
-
// 按钮尺寸
|
|
54
|
-
size: {
|
|
55
|
-
// `'default'` `'large'` `'medium'` `'small'` `'tiny'` `'mini'`
|
|
56
|
-
type: String,
|
|
57
|
-
// 'default'
|
|
58
|
-
default: button.size,
|
|
59
|
-
validator: function(value) {
|
|
60
|
-
return ['default', 'large', 'medium', 'small', 'tiny', 'mini'].includes(value)
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
// 按钮的预置样式
|
|
64
|
-
type: {
|
|
65
|
-
// `'default'` `'primary'` `'warn'` `'secondary'` `'line'`
|
|
66
|
-
type: String,
|
|
67
|
-
// 'default'
|
|
68
|
-
default: button.type,
|
|
69
|
-
validator: function(value) {
|
|
70
|
-
return ['default', 'primary', 'warn', 'secondary', 'line'].includes(value)
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
// 按钮是否镂空
|
|
74
|
-
plain: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
// false
|
|
77
|
-
default: button.plain
|
|
78
|
-
},
|
|
79
|
-
// 是否禁止状态
|
|
80
|
-
disabled: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
// false
|
|
83
|
-
default: button.disabled
|
|
84
|
-
},
|
|
85
|
-
// 是否加载中
|
|
86
|
-
loading: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
// false
|
|
89
|
-
default: button.loading
|
|
90
|
-
},
|
|
91
|
-
// 取值为submit(提交表单),reset(重置表单)
|
|
92
|
-
formType: {
|
|
93
|
-
type: String,
|
|
94
|
-
// ''
|
|
95
|
-
default: button.formType
|
|
96
|
-
},
|
|
97
|
-
// 开放能力,具体请看uniapp稳定关于button组件部分说明
|
|
98
|
-
openType: {
|
|
99
|
-
type: String,
|
|
100
|
-
// ''
|
|
101
|
-
default: button.openType
|
|
102
|
-
},
|
|
103
|
-
// 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果
|
|
104
|
-
hoverClass: {
|
|
105
|
-
type: String,
|
|
106
|
-
// 'button-hover'
|
|
107
|
-
default: button.hoverClass
|
|
108
|
-
},
|
|
109
|
-
// 按住后多久出现点击态,单位毫秒
|
|
110
|
-
hoverStartTime: {
|
|
111
|
-
type: Number,
|
|
112
|
-
// 20
|
|
113
|
-
default: button.hoverStartTime
|
|
114
|
-
},
|
|
115
|
-
// 手指松开后点击态保留时间,单位毫秒
|
|
116
|
-
hoverStayTime: {
|
|
117
|
-
type: Number,
|
|
118
|
-
// 70
|
|
119
|
-
default: button.hoverStayTime
|
|
120
|
-
},
|
|
121
|
-
// 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效
|
|
122
|
-
appParameter: {
|
|
123
|
-
type: String,
|
|
124
|
-
// ''
|
|
125
|
-
default: button.appParameter
|
|
126
|
-
},
|
|
127
|
-
// 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效
|
|
128
|
-
hoverStopPropagation: {
|
|
129
|
-
type: Boolean,
|
|
130
|
-
// false
|
|
131
|
-
default: button.hoverStopPropagation
|
|
132
|
-
},
|
|
133
|
-
// 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。只微信小程序有效
|
|
134
|
-
lang: {
|
|
135
|
-
type: String,
|
|
136
|
-
// 'en'
|
|
137
|
-
default: button.lang
|
|
138
|
-
},
|
|
139
|
-
// 会话来源,open-type="contact"时有效。只微信小程序有效
|
|
140
|
-
sessionFrom: {
|
|
141
|
-
type: String,
|
|
142
|
-
// ''
|
|
143
|
-
default: button.sessionFrom
|
|
144
|
-
},
|
|
145
|
-
// 会话内消息卡片标题,open-type="contact"时有效
|
|
146
|
-
// 默认当前标题,只微信小程序有效
|
|
147
|
-
sendMessageTitle: {
|
|
148
|
-
type: String,
|
|
149
|
-
// ''
|
|
150
|
-
default: button.sendMessageTitle
|
|
151
|
-
},
|
|
152
|
-
// 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效
|
|
153
|
-
// 默认当前分享路径,只微信小程序有效
|
|
154
|
-
sendMessagePath: {
|
|
155
|
-
type: String,
|
|
156
|
-
// ''
|
|
157
|
-
default: button.sendMessagePath
|
|
158
|
-
},
|
|
159
|
-
// 会话内消息卡片图片,open-type="contact"时有效
|
|
160
|
-
// 默认当前页面截图,只微信小程序有效
|
|
161
|
-
sendMessageImg: {
|
|
162
|
-
type: String,
|
|
163
|
-
// ''
|
|
164
|
-
default: button.sendMessageImg
|
|
165
|
-
},
|
|
166
|
-
// 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,
|
|
167
|
-
// 用户点击后可以快速发送小程序消息,open-type="contact"时有效
|
|
168
|
-
showMessageCard: {
|
|
169
|
-
type: Boolean,
|
|
170
|
-
// false
|
|
171
|
-
default: button.showMessageCard
|
|
172
|
-
},
|
|
173
|
-
// 自定义样式,对象形式
|
|
174
|
-
customStyle: {
|
|
175
|
-
type: Object,
|
|
176
|
-
// {}
|
|
177
|
-
default() {
|
|
178
|
-
return button.customStyle
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
// 自定义样式类,字符串形式
|
|
182
|
-
customClass: {
|
|
183
|
-
type: String,
|
|
184
|
-
// {}
|
|
185
|
-
default() {
|
|
186
|
-
return button.customClass
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
// 按钮宽度,不设置默认自动撑开,如果需要占满一行,填写’100%‘
|
|
190
|
-
width: {
|
|
191
|
-
type: [String, Number],
|
|
192
|
-
// ''
|
|
193
|
-
default: button.width
|
|
194
|
-
},
|
|
195
|
-
// 自定义颜色按钮(type为default,可自定义设置)
|
|
196
|
-
color: {
|
|
197
|
-
type: String,
|
|
198
|
-
// ''
|
|
199
|
-
default: button.color
|
|
200
|
-
},
|
|
201
|
-
// 自定义背景色按钮(type为default,可自定义设置)
|
|
202
|
-
bgColor: {
|
|
203
|
-
type: String,
|
|
204
|
-
// ''
|
|
205
|
-
default: button.bgColor
|
|
206
|
-
},
|
|
207
|
-
// 按钮是否椭圆
|
|
208
|
-
round: {
|
|
209
|
-
type: Boolean,
|
|
210
|
-
// false
|
|
211
|
-
default: button.round
|
|
212
|
-
},
|
|
213
|
-
// 是否开启水波纹效果(默认值:true)
|
|
214
|
-
ripple: {
|
|
215
|
-
type: Boolean,
|
|
216
|
-
// true
|
|
217
|
-
default: button.ripple
|
|
218
|
-
},
|
|
219
|
-
// 水波纹的背景颜色(默认值:'')
|
|
220
|
-
rippleBgColor: {
|
|
221
|
-
type: String,
|
|
222
|
-
// ''
|
|
223
|
-
default: button.rippleBgColor
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
data() {
|
|
227
|
-
return {
|
|
228
|
-
waveInfo: {
|
|
229
|
-
active: false, // 激活水波纹
|
|
230
|
-
top: '', // 水波纹的起点Y坐标到按钮上边界的距离
|
|
231
|
-
left: '', // 水波纹起点X坐标到按钮左边界的距离
|
|
232
|
-
fields: { targetWidth: 0 } // 波纹按钮节点信息
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
computed: {
|
|
237
|
-
getCustomStyle() {
|
|
238
|
-
const style = {}
|
|
239
|
-
|
|
240
|
-
if (this.color) style.color = this.color
|
|
241
|
-
if (this.bgColor) style.backgroundColor = this.bgColor
|
|
242
|
-
if (this.width) style.width = this.$pi.common.addUnit(this.width)
|
|
243
|
-
|
|
244
|
-
if (style.width === '100%') {
|
|
245
|
-
style.display = 'block'
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return style
|
|
249
|
-
},
|
|
250
|
-
getHoverClass() {
|
|
251
|
-
if (this.loading || this.disabled || this.ripple) return 'none'
|
|
252
|
-
return this.hoverClass
|
|
253
|
-
},
|
|
254
|
-
waveStyle() {
|
|
255
|
-
return {
|
|
256
|
-
'top': this.waveInfo.top + 'px',
|
|
257
|
-
'left': this.waveInfo.left + 'px',
|
|
258
|
-
'width': this.waveInfo.fields.targetWidth + 'px',
|
|
259
|
-
'height': this.waveInfo.fields.targetWidth + 'px',
|
|
260
|
-
'background-color': this.rippleBgColor || 'rgba(0, 0, 0, 0.05)'
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
canIUseGetUserProfile() {
|
|
264
|
-
// 兼容最新版本的用户获取授权信息
|
|
265
|
-
return uni.canIUse('getUserProfile') && uni.getUserProfile
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
methods: {
|
|
269
|
-
handleButtonTap(e) {
|
|
270
|
-
if (this.loading || this.disabled) return
|
|
271
|
-
// 兼容微信获取用户信息
|
|
272
|
-
// #ifdef MP-WEIXIN
|
|
273
|
-
if (this.openType === 'getUserInfo' && this.canIUseGetUserProfile) {
|
|
274
|
-
uni.getUserProfile({
|
|
275
|
-
desc: '授权登录',
|
|
276
|
-
complete: res => {
|
|
277
|
-
this.$emit('getuserinfo', {
|
|
278
|
-
type: 'getuserinfo',
|
|
279
|
-
detail: res
|
|
280
|
-
})
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
}
|
|
284
|
-
// #endif
|
|
285
|
-
this.$emit('click', e)
|
|
286
|
-
// 点击事件
|
|
287
|
-
console.log(TAG, '触发按钮click事件')
|
|
288
|
-
if (!this.ripple) return
|
|
289
|
-
// 是否开启水波纹效果
|
|
290
|
-
this.waveInfo.active = false
|
|
291
|
-
this.$nextTick(function() {
|
|
292
|
-
this.queryWaveInfo(e)
|
|
293
|
-
})
|
|
294
|
-
},
|
|
295
|
-
// 查询按钮的节点信息
|
|
296
|
-
queryWaveInfo(e) {
|
|
297
|
-
this.getElRectQuery().then(res => {
|
|
298
|
-
// 查询返回的是一个数组节点
|
|
299
|
-
let data = res[0]
|
|
300
|
-
// 查询不到节点信息,不操作
|
|
301
|
-
if (!data.width || !data.width) return
|
|
302
|
-
// 水波纹的最终形态是一个正方形(通过border-radius让其变为一个圆形),这里要保证正方形的边长等于按钮的最长边
|
|
303
|
-
// 最终的方形(变换后的圆形)才能覆盖整个按钮
|
|
304
|
-
data.targetWidth = data.height > data.width ? data.height : data.width
|
|
305
|
-
if (!data.targetWidth) return
|
|
306
|
-
this.waveInfo.fields = data
|
|
307
|
-
let touchesX = '',
|
|
308
|
-
touchesY = ''
|
|
309
|
-
// #ifdef MP-BAIDU
|
|
310
|
-
touchesX = e.changedTouches[0].clientX
|
|
311
|
-
touchesY = e.changedTouches[0].clientY
|
|
312
|
-
// #endif
|
|
313
|
-
// #ifdef MP-ALIPAY
|
|
314
|
-
touchesX = e.detail.clientX
|
|
315
|
-
touchesY = e.detail.clientY
|
|
316
|
-
// #endif
|
|
317
|
-
// #ifndef MP-BAIDU || MP-ALIPAY
|
|
318
|
-
touchesX = e.touches[0].clientX
|
|
319
|
-
touchesY = e.touches[0].clientY
|
|
320
|
-
// #endif
|
|
321
|
-
// 获取触摸点相对于按钮上边和左边的x和y坐标,原理是通过屏幕的触摸点(touchesY),减去按钮的上边界data.top
|
|
322
|
-
// 但是由于`transform-origin`默认是center,所以这里再减去半径才是水波纹view应该的位置
|
|
323
|
-
// 总的来说,就是把水波纹的矩形(变换后的圆形)的中心点,移动到我们的触摸点位置
|
|
324
|
-
this.waveInfo.top = touchesY - data.top - data.targetWidth / 2
|
|
325
|
-
this.waveInfo.left = touchesX - data.left - data.targetWidth / 2
|
|
326
|
-
this.$nextTick(() => {
|
|
327
|
-
this.waveInfo.active = true
|
|
328
|
-
})
|
|
329
|
-
})
|
|
330
|
-
},
|
|
331
|
-
// 获取节点区域信息
|
|
332
|
-
getElRectQuery() {
|
|
333
|
-
return new Promise(resolve => {
|
|
334
|
-
let queryInfo = ''
|
|
335
|
-
queryInfo = uni.createSelectorQuery().in(this)
|
|
336
|
-
// #ifdef MP-ALIPAY
|
|
337
|
-
queryInfo = uni.createSelectorQuery()
|
|
338
|
-
// #endif
|
|
339
|
-
queryInfo.select('.pi-button').boundingClientRect()
|
|
340
|
-
queryInfo.exec(data => {
|
|
341
|
-
resolve(data)
|
|
342
|
-
})
|
|
343
|
-
})
|
|
344
|
-
},
|
|
345
|
-
handleGetPhoneNumber(e) {
|
|
346
|
-
// 微信小程序中获取用户手机号回调,需设置open-type="getPhoneNumber"
|
|
347
|
-
this.$emit('getphonenumber', e)
|
|
348
|
-
},
|
|
349
|
-
handleGetUserInfo(e) {
|
|
350
|
-
// 微信小程序中用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo,需设置open-type="getUserInfo"
|
|
351
|
-
if (this.canIUseGetUserProfile) return
|
|
352
|
-
this.$emit('getuserinfo', e)
|
|
353
|
-
},
|
|
354
|
-
handleError(e) {
|
|
355
|
-
// 微信小程序中当使用开放能力时,发生错误的回调
|
|
356
|
-
this.$emit('error', e)
|
|
357
|
-
},
|
|
358
|
-
handleOpenSetting(e) {
|
|
359
|
-
// 微信小程序中在打开授权设置页并关闭后回调,需设置open-type="openSetting"
|
|
360
|
-
this.$emit('opensetting', e)
|
|
361
|
-
},
|
|
362
|
-
handleLaunchApp(e) {
|
|
363
|
-
// 微信小程序中从小程序打开 App 成功的回调
|
|
364
|
-
this.$emit('launchapp', e)
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
</script>
|
|
369
|
-
|
|
370
|
-
<style lang="scss" scoped>
|
|
371
|
-
.round {
|
|
372
|
-
overflow: hidden;
|
|
373
|
-
border-radius: 500000rpx !important;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.pi-button {
|
|
377
|
-
position: relative;
|
|
378
|
-
display: inline-block;
|
|
379
|
-
padding: $pi-button-default-padding;
|
|
380
|
-
border: none;
|
|
381
|
-
border-radius: $pi-button-default-radius;
|
|
382
|
-
// 默认样式
|
|
383
|
-
&[type='default'] {
|
|
384
|
-
color: #333333;
|
|
385
|
-
background-color: #e5e5e5;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
&::after {
|
|
389
|
-
border: none;
|
|
390
|
-
}
|
|
391
|
-
&[disabled] {
|
|
392
|
-
opacity: $pi-disabled-opacity;
|
|
393
|
-
}
|
|
394
|
-
&[loading]::before {
|
|
395
|
-
margin-right: 12rpx;
|
|
396
|
-
}
|
|
397
|
-
// 椭圆
|
|
398
|
-
&.round {
|
|
399
|
-
&::after {
|
|
400
|
-
@extend .round;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
// 默认
|
|
404
|
-
&[size='default'] {
|
|
405
|
-
height: $pi-button-default-height;
|
|
406
|
-
padding: $pi-button-default-padding;
|
|
407
|
-
font-size: $pi-button-default-font-size;
|
|
408
|
-
line-height: $pi-button-default-height;
|
|
409
|
-
&[plain]::after {
|
|
410
|
-
border: 8rpx solid #e5e5e5;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
// 大
|
|
414
|
-
&[size='large'] {
|
|
415
|
-
height: $pi-button-large-height;
|
|
416
|
-
padding: $pi-button-large-padding;
|
|
417
|
-
font-size: $pi-button-large-font-size;
|
|
418
|
-
line-height: $pi-button-large-height;
|
|
419
|
-
border-radius: $pi-button-large-radius;
|
|
420
|
-
}
|
|
421
|
-
// 中
|
|
422
|
-
&[size='medium'] {
|
|
423
|
-
height: $pi-button-medium-height;
|
|
424
|
-
padding: $pi-button-medium-padding;
|
|
425
|
-
font-size: $pi-button-medium-font-size;
|
|
426
|
-
line-height: $pi-button-medium-height;
|
|
427
|
-
border-radius: $pi-button-medium-radius;
|
|
428
|
-
}
|
|
429
|
-
// 小
|
|
430
|
-
&[size='small'] {
|
|
431
|
-
height: $pi-button-small-height;
|
|
432
|
-
padding: $pi-button-small-padding;
|
|
433
|
-
font-size: $pi-button-small-font-size;
|
|
434
|
-
line-height: $pi-button-small-height;
|
|
435
|
-
border-radius: $pi-button-small-radius;
|
|
436
|
-
}
|
|
437
|
-
// 超小
|
|
438
|
-
&[size='tiny'] {
|
|
439
|
-
height: $pi-button-tiny-height;
|
|
440
|
-
padding: $pi-button-tiny-padding;
|
|
441
|
-
font-size: $pi-button-tiny-font-size;
|
|
442
|
-
line-height: $pi-button-tiny-height;
|
|
443
|
-
border-radius: $pi-button-tiny-radius;
|
|
444
|
-
}
|
|
445
|
-
// 迷你
|
|
446
|
-
&[size='mini'] {
|
|
447
|
-
height: $pi-button-mini-height;
|
|
448
|
-
padding: $pi-button-mini-padding;
|
|
449
|
-
font-size: $pi-button-mini-font-size;
|
|
450
|
-
line-height: $pi-button-mini-height;
|
|
451
|
-
border-radius: $pi-button-mini-radius;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// 主要样式
|
|
455
|
-
&[type='primary'] {
|
|
456
|
-
background-color: $pi-primary-color;
|
|
457
|
-
}
|
|
458
|
-
&.button-hover[type='primary'] {
|
|
459
|
-
background-color: rgba($pi-primary-color, 0.8);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// 次要
|
|
463
|
-
&[type='secondary'] {
|
|
464
|
-
color: $pi-primary-color;
|
|
465
|
-
background-color: rgba($pi-primary-color, 0.1);
|
|
466
|
-
}
|
|
467
|
-
&.button-hover[type='secondary'] {
|
|
468
|
-
background-color: rgba($pi-primary-color, 0.08);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// 线框
|
|
472
|
-
&[type='line'] {
|
|
473
|
-
color: $pi-primary-color;
|
|
474
|
-
background-color: #ffffff;
|
|
475
|
-
&::after {
|
|
476
|
-
border: 8rpx solid $pi-primary-color;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
&.button-hover[type='line'] {
|
|
480
|
-
background-color: rgba($pi-primary-color, 0.08);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
.wave-ripple {
|
|
484
|
-
position: absolute;
|
|
485
|
-
z-index: 0;
|
|
486
|
-
overflow: hidden;
|
|
487
|
-
pointer-events: none;
|
|
488
|
-
user-select: none;
|
|
489
|
-
background-clip: padding-box;
|
|
490
|
-
border-radius: 100%;
|
|
491
|
-
opacity: 1;
|
|
492
|
-
transform: scale(0);
|
|
493
|
-
transform-origin: center;
|
|
494
|
-
&.active {
|
|
495
|
-
opacity: 0;
|
|
496
|
-
transition: opacity 1s linear, transform 0.4s linear;
|
|
497
|
-
transform: scale(2);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
class="pi-button fix-webkit-appearance"
|
|
4
|
+
:style="[getCustomStyle, customStyle]"
|
|
5
|
+
:class="[customClass, { round: round }]"
|
|
6
|
+
:size="size"
|
|
7
|
+
:type="type"
|
|
8
|
+
:plain="plain"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:form-type="formType"
|
|
11
|
+
:open-type="openType"
|
|
12
|
+
:app-parameter="appParameter"
|
|
13
|
+
:hover-stop-propagation="hoverStopPropagation"
|
|
14
|
+
:send-message-title="sendMessageTitle"
|
|
15
|
+
:send-message-path="sendMessagePath"
|
|
16
|
+
:lang="lang"
|
|
17
|
+
:session-from="sessionFrom"
|
|
18
|
+
:send-message-img="sendMessageImg"
|
|
19
|
+
:show-message-card="showMessageCard"
|
|
20
|
+
:hover-class="getHoverClass"
|
|
21
|
+
:hover-start-time="hoverStartTime"
|
|
22
|
+
:hover-stay-time="hoverStayTime"
|
|
23
|
+
:loading="loading"
|
|
24
|
+
@tap.stop="handleButtonTap"
|
|
25
|
+
@getphonenumber="handleGetPhoneNumber($event)"
|
|
26
|
+
@getuserinfo="handleGetUserInfo($event)"
|
|
27
|
+
@error="handleError($event)"
|
|
28
|
+
@opensetting="handleOpenSetting($event)"
|
|
29
|
+
@launchapp="handleLaunchApp($event)"
|
|
30
|
+
>
|
|
31
|
+
<!-- 按钮内容 -->
|
|
32
|
+
<slot />
|
|
33
|
+
<view v-if="ripple" class="pi-abso-full pi-of-hidden" :class="[{ round }]">
|
|
34
|
+
<view class="wave-ripple" :class="[{ active: waveInfo.active }]" :style="[waveStyle]" />
|
|
35
|
+
</view>
|
|
36
|
+
</button>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
/**
|
|
41
|
+
* 属性和官方uniapp button属性保持一致,扩展了一部分常用属性
|
|
42
|
+
* 因为小程序不兼容v-bind="$attrs"写法,所以只能把官网属性重定义一遍
|
|
43
|
+
*/
|
|
44
|
+
import { getConfig } from '../../config'
|
|
45
|
+
|
|
46
|
+
import { debounce } from '@sadais/piui-tool/tools/common'
|
|
47
|
+
const TAG = 'PiOpentypeButton'
|
|
48
|
+
const { button } = getConfig()
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
name: 'PiOpentypeButton',
|
|
52
|
+
props: {
|
|
53
|
+
// 按钮尺寸
|
|
54
|
+
size: {
|
|
55
|
+
// `'default'` `'large'` `'medium'` `'small'` `'tiny'` `'mini'`
|
|
56
|
+
type: String,
|
|
57
|
+
// 'default'
|
|
58
|
+
default: button.size,
|
|
59
|
+
validator: function(value) {
|
|
60
|
+
return ['default', 'large', 'medium', 'small', 'tiny', 'mini'].includes(value)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// 按钮的预置样式
|
|
64
|
+
type: {
|
|
65
|
+
// `'default'` `'primary'` `'warn'` `'secondary'` `'line'`
|
|
66
|
+
type: String,
|
|
67
|
+
// 'default'
|
|
68
|
+
default: button.type,
|
|
69
|
+
validator: function(value) {
|
|
70
|
+
return ['default', 'primary', 'warn', 'secondary', 'line'].includes(value)
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
// 按钮是否镂空
|
|
74
|
+
plain: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
// false
|
|
77
|
+
default: button.plain
|
|
78
|
+
},
|
|
79
|
+
// 是否禁止状态
|
|
80
|
+
disabled: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
// false
|
|
83
|
+
default: button.disabled
|
|
84
|
+
},
|
|
85
|
+
// 是否加载中
|
|
86
|
+
loading: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
// false
|
|
89
|
+
default: button.loading
|
|
90
|
+
},
|
|
91
|
+
// 取值为submit(提交表单),reset(重置表单)
|
|
92
|
+
formType: {
|
|
93
|
+
type: String,
|
|
94
|
+
// ''
|
|
95
|
+
default: button.formType
|
|
96
|
+
},
|
|
97
|
+
// 开放能力,具体请看uniapp稳定关于button组件部分说明
|
|
98
|
+
openType: {
|
|
99
|
+
type: String,
|
|
100
|
+
// ''
|
|
101
|
+
default: button.openType
|
|
102
|
+
},
|
|
103
|
+
// 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果
|
|
104
|
+
hoverClass: {
|
|
105
|
+
type: String,
|
|
106
|
+
// 'button-hover'
|
|
107
|
+
default: button.hoverClass
|
|
108
|
+
},
|
|
109
|
+
// 按住后多久出现点击态,单位毫秒
|
|
110
|
+
hoverStartTime: {
|
|
111
|
+
type: Number,
|
|
112
|
+
// 20
|
|
113
|
+
default: button.hoverStartTime
|
|
114
|
+
},
|
|
115
|
+
// 手指松开后点击态保留时间,单位毫秒
|
|
116
|
+
hoverStayTime: {
|
|
117
|
+
type: Number,
|
|
118
|
+
// 70
|
|
119
|
+
default: button.hoverStayTime
|
|
120
|
+
},
|
|
121
|
+
// 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效
|
|
122
|
+
appParameter: {
|
|
123
|
+
type: String,
|
|
124
|
+
// ''
|
|
125
|
+
default: button.appParameter
|
|
126
|
+
},
|
|
127
|
+
// 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效
|
|
128
|
+
hoverStopPropagation: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
// false
|
|
131
|
+
default: button.hoverStopPropagation
|
|
132
|
+
},
|
|
133
|
+
// 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。只微信小程序有效
|
|
134
|
+
lang: {
|
|
135
|
+
type: String,
|
|
136
|
+
// 'en'
|
|
137
|
+
default: button.lang
|
|
138
|
+
},
|
|
139
|
+
// 会话来源,open-type="contact"时有效。只微信小程序有效
|
|
140
|
+
sessionFrom: {
|
|
141
|
+
type: String,
|
|
142
|
+
// ''
|
|
143
|
+
default: button.sessionFrom
|
|
144
|
+
},
|
|
145
|
+
// 会话内消息卡片标题,open-type="contact"时有效
|
|
146
|
+
// 默认当前标题,只微信小程序有效
|
|
147
|
+
sendMessageTitle: {
|
|
148
|
+
type: String,
|
|
149
|
+
// ''
|
|
150
|
+
default: button.sendMessageTitle
|
|
151
|
+
},
|
|
152
|
+
// 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效
|
|
153
|
+
// 默认当前分享路径,只微信小程序有效
|
|
154
|
+
sendMessagePath: {
|
|
155
|
+
type: String,
|
|
156
|
+
// ''
|
|
157
|
+
default: button.sendMessagePath
|
|
158
|
+
},
|
|
159
|
+
// 会话内消息卡片图片,open-type="contact"时有效
|
|
160
|
+
// 默认当前页面截图,只微信小程序有效
|
|
161
|
+
sendMessageImg: {
|
|
162
|
+
type: String,
|
|
163
|
+
// ''
|
|
164
|
+
default: button.sendMessageImg
|
|
165
|
+
},
|
|
166
|
+
// 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,
|
|
167
|
+
// 用户点击后可以快速发送小程序消息,open-type="contact"时有效
|
|
168
|
+
showMessageCard: {
|
|
169
|
+
type: Boolean,
|
|
170
|
+
// false
|
|
171
|
+
default: button.showMessageCard
|
|
172
|
+
},
|
|
173
|
+
// 自定义样式,对象形式
|
|
174
|
+
customStyle: {
|
|
175
|
+
type: Object,
|
|
176
|
+
// {}
|
|
177
|
+
default() {
|
|
178
|
+
return button.customStyle
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
// 自定义样式类,字符串形式
|
|
182
|
+
customClass: {
|
|
183
|
+
type: String,
|
|
184
|
+
// {}
|
|
185
|
+
default() {
|
|
186
|
+
return button.customClass
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
// 按钮宽度,不设置默认自动撑开,如果需要占满一行,填写’100%‘
|
|
190
|
+
width: {
|
|
191
|
+
type: [String, Number],
|
|
192
|
+
// ''
|
|
193
|
+
default: button.width
|
|
194
|
+
},
|
|
195
|
+
// 自定义颜色按钮(type为default,可自定义设置)
|
|
196
|
+
color: {
|
|
197
|
+
type: String,
|
|
198
|
+
// ''
|
|
199
|
+
default: button.color
|
|
200
|
+
},
|
|
201
|
+
// 自定义背景色按钮(type为default,可自定义设置)
|
|
202
|
+
bgColor: {
|
|
203
|
+
type: String,
|
|
204
|
+
// ''
|
|
205
|
+
default: button.bgColor
|
|
206
|
+
},
|
|
207
|
+
// 按钮是否椭圆
|
|
208
|
+
round: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
// false
|
|
211
|
+
default: button.round
|
|
212
|
+
},
|
|
213
|
+
// 是否开启水波纹效果(默认值:true)
|
|
214
|
+
ripple: {
|
|
215
|
+
type: Boolean,
|
|
216
|
+
// true
|
|
217
|
+
default: button.ripple
|
|
218
|
+
},
|
|
219
|
+
// 水波纹的背景颜色(默认值:'')
|
|
220
|
+
rippleBgColor: {
|
|
221
|
+
type: String,
|
|
222
|
+
// ''
|
|
223
|
+
default: button.rippleBgColor
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
data() {
|
|
227
|
+
return {
|
|
228
|
+
waveInfo: {
|
|
229
|
+
active: false, // 激活水波纹
|
|
230
|
+
top: '', // 水波纹的起点Y坐标到按钮上边界的距离
|
|
231
|
+
left: '', // 水波纹起点X坐标到按钮左边界的距离
|
|
232
|
+
fields: { targetWidth: 0 } // 波纹按钮节点信息
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
computed: {
|
|
237
|
+
getCustomStyle() {
|
|
238
|
+
const style = {}
|
|
239
|
+
|
|
240
|
+
if (this.color) style.color = this.color
|
|
241
|
+
if (this.bgColor) style.backgroundColor = this.bgColor
|
|
242
|
+
if (this.width) style.width = this.$pi.common.addUnit(this.width)
|
|
243
|
+
|
|
244
|
+
if (style.width === '100%') {
|
|
245
|
+
style.display = 'block'
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return style
|
|
249
|
+
},
|
|
250
|
+
getHoverClass() {
|
|
251
|
+
if (this.loading || this.disabled || this.ripple) return 'none'
|
|
252
|
+
return this.hoverClass
|
|
253
|
+
},
|
|
254
|
+
waveStyle() {
|
|
255
|
+
return {
|
|
256
|
+
'top': this.waveInfo.top + 'px',
|
|
257
|
+
'left': this.waveInfo.left + 'px',
|
|
258
|
+
'width': this.waveInfo.fields.targetWidth + 'px',
|
|
259
|
+
'height': this.waveInfo.fields.targetWidth + 'px',
|
|
260
|
+
'background-color': this.rippleBgColor || 'rgba(0, 0, 0, 0.05)'
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
canIUseGetUserProfile() {
|
|
264
|
+
// 兼容最新版本的用户获取授权信息
|
|
265
|
+
return uni.canIUse('getUserProfile') && uni.getUserProfile
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
methods: {
|
|
269
|
+
handleButtonTap(e) {
|
|
270
|
+
if (this.loading || this.disabled) return
|
|
271
|
+
// 兼容微信获取用户信息
|
|
272
|
+
// #ifdef MP-WEIXIN
|
|
273
|
+
if (this.openType === 'getUserInfo' && this.canIUseGetUserProfile) {
|
|
274
|
+
uni.getUserProfile({
|
|
275
|
+
desc: '授权登录',
|
|
276
|
+
complete: res => {
|
|
277
|
+
this.$emit('getuserinfo', {
|
|
278
|
+
type: 'getuserinfo',
|
|
279
|
+
detail: res
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
// #endif
|
|
285
|
+
this.$emit('click', e)
|
|
286
|
+
// 点击事件
|
|
287
|
+
console.log(TAG, '触发按钮click事件')
|
|
288
|
+
if (!this.ripple) return
|
|
289
|
+
// 是否开启水波纹效果
|
|
290
|
+
this.waveInfo.active = false
|
|
291
|
+
this.$nextTick(function() {
|
|
292
|
+
this.queryWaveInfo(e)
|
|
293
|
+
})
|
|
294
|
+
},
|
|
295
|
+
// 查询按钮的节点信息
|
|
296
|
+
queryWaveInfo(e) {
|
|
297
|
+
this.getElRectQuery().then(res => {
|
|
298
|
+
// 查询返回的是一个数组节点
|
|
299
|
+
let data = res[0]
|
|
300
|
+
// 查询不到节点信息,不操作
|
|
301
|
+
if (!data.width || !data.width) return
|
|
302
|
+
// 水波纹的最终形态是一个正方形(通过border-radius让其变为一个圆形),这里要保证正方形的边长等于按钮的最长边
|
|
303
|
+
// 最终的方形(变换后的圆形)才能覆盖整个按钮
|
|
304
|
+
data.targetWidth = data.height > data.width ? data.height : data.width
|
|
305
|
+
if (!data.targetWidth) return
|
|
306
|
+
this.waveInfo.fields = data
|
|
307
|
+
let touchesX = '',
|
|
308
|
+
touchesY = ''
|
|
309
|
+
// #ifdef MP-BAIDU
|
|
310
|
+
touchesX = e.changedTouches[0].clientX
|
|
311
|
+
touchesY = e.changedTouches[0].clientY
|
|
312
|
+
// #endif
|
|
313
|
+
// #ifdef MP-ALIPAY
|
|
314
|
+
touchesX = e.detail.clientX
|
|
315
|
+
touchesY = e.detail.clientY
|
|
316
|
+
// #endif
|
|
317
|
+
// #ifndef MP-BAIDU || MP-ALIPAY
|
|
318
|
+
touchesX = e.touches[0].clientX
|
|
319
|
+
touchesY = e.touches[0].clientY
|
|
320
|
+
// #endif
|
|
321
|
+
// 获取触摸点相对于按钮上边和左边的x和y坐标,原理是通过屏幕的触摸点(touchesY),减去按钮的上边界data.top
|
|
322
|
+
// 但是由于`transform-origin`默认是center,所以这里再减去半径才是水波纹view应该的位置
|
|
323
|
+
// 总的来说,就是把水波纹的矩形(变换后的圆形)的中心点,移动到我们的触摸点位置
|
|
324
|
+
this.waveInfo.top = touchesY - data.top - data.targetWidth / 2
|
|
325
|
+
this.waveInfo.left = touchesX - data.left - data.targetWidth / 2
|
|
326
|
+
this.$nextTick(() => {
|
|
327
|
+
this.waveInfo.active = true
|
|
328
|
+
})
|
|
329
|
+
})
|
|
330
|
+
},
|
|
331
|
+
// 获取节点区域信息
|
|
332
|
+
getElRectQuery() {
|
|
333
|
+
return new Promise(resolve => {
|
|
334
|
+
let queryInfo = ''
|
|
335
|
+
queryInfo = uni.createSelectorQuery().in(this)
|
|
336
|
+
// #ifdef MP-ALIPAY
|
|
337
|
+
queryInfo = uni.createSelectorQuery()
|
|
338
|
+
// #endif
|
|
339
|
+
queryInfo.select('.pi-button').boundingClientRect()
|
|
340
|
+
queryInfo.exec(data => {
|
|
341
|
+
resolve(data)
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
},
|
|
345
|
+
handleGetPhoneNumber(e) {
|
|
346
|
+
// 微信小程序中获取用户手机号回调,需设置open-type="getPhoneNumber"
|
|
347
|
+
this.$emit('getphonenumber', e)
|
|
348
|
+
},
|
|
349
|
+
handleGetUserInfo(e) {
|
|
350
|
+
// 微信小程序中用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo,需设置open-type="getUserInfo"
|
|
351
|
+
if (this.canIUseGetUserProfile) return
|
|
352
|
+
this.$emit('getuserinfo', e)
|
|
353
|
+
},
|
|
354
|
+
handleError(e) {
|
|
355
|
+
// 微信小程序中当使用开放能力时,发生错误的回调
|
|
356
|
+
this.$emit('error', e)
|
|
357
|
+
},
|
|
358
|
+
handleOpenSetting(e) {
|
|
359
|
+
// 微信小程序中在打开授权设置页并关闭后回调,需设置open-type="openSetting"
|
|
360
|
+
this.$emit('opensetting', e)
|
|
361
|
+
},
|
|
362
|
+
handleLaunchApp(e) {
|
|
363
|
+
// 微信小程序中从小程序打开 App 成功的回调
|
|
364
|
+
this.$emit('launchapp', e)
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
</script>
|
|
369
|
+
|
|
370
|
+
<style lang="scss" scoped>
|
|
371
|
+
.round {
|
|
372
|
+
overflow: hidden;
|
|
373
|
+
border-radius: 500000rpx !important;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.pi-button {
|
|
377
|
+
position: relative;
|
|
378
|
+
display: inline-block;
|
|
379
|
+
padding: $pi-button-default-padding;
|
|
380
|
+
border: none;
|
|
381
|
+
border-radius: $pi-button-default-radius;
|
|
382
|
+
// 默认样式
|
|
383
|
+
&[type='default'] {
|
|
384
|
+
color: #333333;
|
|
385
|
+
background-color: #e5e5e5;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
&::after {
|
|
389
|
+
border: none;
|
|
390
|
+
}
|
|
391
|
+
&[disabled] {
|
|
392
|
+
opacity: $pi-disabled-opacity;
|
|
393
|
+
}
|
|
394
|
+
&[loading]::before {
|
|
395
|
+
margin-right: 12rpx;
|
|
396
|
+
}
|
|
397
|
+
// 椭圆
|
|
398
|
+
&.round {
|
|
399
|
+
&::after {
|
|
400
|
+
@extend .round;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// 默认
|
|
404
|
+
&[size='default'] {
|
|
405
|
+
height: $pi-button-default-height;
|
|
406
|
+
padding: $pi-button-default-padding;
|
|
407
|
+
font-size: $pi-button-default-font-size;
|
|
408
|
+
line-height: $pi-button-default-height;
|
|
409
|
+
&[plain]::after {
|
|
410
|
+
border: 8rpx solid #e5e5e5;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// 大
|
|
414
|
+
&[size='large'] {
|
|
415
|
+
height: $pi-button-large-height;
|
|
416
|
+
padding: $pi-button-large-padding;
|
|
417
|
+
font-size: $pi-button-large-font-size;
|
|
418
|
+
line-height: $pi-button-large-height;
|
|
419
|
+
border-radius: $pi-button-large-radius;
|
|
420
|
+
}
|
|
421
|
+
// 中
|
|
422
|
+
&[size='medium'] {
|
|
423
|
+
height: $pi-button-medium-height;
|
|
424
|
+
padding: $pi-button-medium-padding;
|
|
425
|
+
font-size: $pi-button-medium-font-size;
|
|
426
|
+
line-height: $pi-button-medium-height;
|
|
427
|
+
border-radius: $pi-button-medium-radius;
|
|
428
|
+
}
|
|
429
|
+
// 小
|
|
430
|
+
&[size='small'] {
|
|
431
|
+
height: $pi-button-small-height;
|
|
432
|
+
padding: $pi-button-small-padding;
|
|
433
|
+
font-size: $pi-button-small-font-size;
|
|
434
|
+
line-height: $pi-button-small-height;
|
|
435
|
+
border-radius: $pi-button-small-radius;
|
|
436
|
+
}
|
|
437
|
+
// 超小
|
|
438
|
+
&[size='tiny'] {
|
|
439
|
+
height: $pi-button-tiny-height;
|
|
440
|
+
padding: $pi-button-tiny-padding;
|
|
441
|
+
font-size: $pi-button-tiny-font-size;
|
|
442
|
+
line-height: $pi-button-tiny-height;
|
|
443
|
+
border-radius: $pi-button-tiny-radius;
|
|
444
|
+
}
|
|
445
|
+
// 迷你
|
|
446
|
+
&[size='mini'] {
|
|
447
|
+
height: $pi-button-mini-height;
|
|
448
|
+
padding: $pi-button-mini-padding;
|
|
449
|
+
font-size: $pi-button-mini-font-size;
|
|
450
|
+
line-height: $pi-button-mini-height;
|
|
451
|
+
border-radius: $pi-button-mini-radius;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// 主要样式
|
|
455
|
+
&[type='primary'] {
|
|
456
|
+
background-color: $pi-primary-color;
|
|
457
|
+
}
|
|
458
|
+
&.button-hover[type='primary'] {
|
|
459
|
+
background-color: rgba($pi-primary-color, 0.8);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// 次要
|
|
463
|
+
&[type='secondary'] {
|
|
464
|
+
color: $pi-primary-color;
|
|
465
|
+
background-color: rgba($pi-primary-color, 0.1);
|
|
466
|
+
}
|
|
467
|
+
&.button-hover[type='secondary'] {
|
|
468
|
+
background-color: rgba($pi-primary-color, 0.08);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// 线框
|
|
472
|
+
&[type='line'] {
|
|
473
|
+
color: $pi-primary-color;
|
|
474
|
+
background-color: #ffffff;
|
|
475
|
+
&::after {
|
|
476
|
+
border: 8rpx solid $pi-primary-color;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
&.button-hover[type='line'] {
|
|
480
|
+
background-color: rgba($pi-primary-color, 0.08);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.wave-ripple {
|
|
484
|
+
position: absolute;
|
|
485
|
+
z-index: 0;
|
|
486
|
+
overflow: hidden;
|
|
487
|
+
pointer-events: none;
|
|
488
|
+
user-select: none;
|
|
489
|
+
background-clip: padding-box;
|
|
490
|
+
border-radius: 100%;
|
|
491
|
+
opacity: 1;
|
|
492
|
+
transform: scale(0);
|
|
493
|
+
transform-origin: center;
|
|
494
|
+
&.active {
|
|
495
|
+
opacity: 0;
|
|
496
|
+
transition: opacity 1s linear, transform 0.4s linear;
|
|
497
|
+
transform: scale(2);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
</style>
|