@10yun/cv-mobile-ui 0.5.57 → 0.5.58

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.
@@ -0,0 +1,476 @@
1
+ <template>
2
+ <!-- #ifndef APP-NVUE -->
3
+ <button
4
+ :hover-start-time="Number(hoverStartTime)"
5
+ :hover-stay-time="Number(hoverStayTime)"
6
+ :form-type="formType"
7
+ :open-type="openType"
8
+ :app-parameter="appParameter"
9
+ :hover-stop-propagation="hoverStopPropagation"
10
+ :send-message-title="sendMessageTitle"
11
+ :send-message-path="sendMessagePath"
12
+ :lang="lang"
13
+ :data-name="dataName"
14
+ :session-from="sessionFrom"
15
+ :send-message-img="sendMessageImg"
16
+ :show-message-card="showMessageCard"
17
+ @getphonenumber="getphonenumber"
18
+ @getuserinfo="getuserinfo"
19
+ @error="error"
20
+ @opensetting="opensetting"
21
+ @launchapp="launchapp"
22
+ @agreeprivacyauthorization="agreeprivacyauthorization"
23
+ :hover-class="!disabled && !loading ? 'u-button--active' : ''"
24
+ class="u-button u-reset-button"
25
+ :style="[baseColor, addStyle(customStyle)]"
26
+ @tap="clickHandler"
27
+ :class="bemClass"
28
+ >
29
+ <template v-if="loading">
30
+ <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
31
+ <text class="u-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">{{ loadingText || text }}</text>
32
+ </template>
33
+ <template v-else>
34
+ <up-icon
35
+ v-if="icon"
36
+ :name="icon"
37
+ :color="iconColorCom"
38
+ :size="textSize * 1.35"
39
+ :customStyle="{ marginRight: '2px' }"
40
+ ></up-icon>
41
+ <slot>
42
+ <text class="u-button__text" :style="[{ fontSize: textSize + 'px' }]">{{ text }}</text>
43
+ </slot>
44
+ </template>
45
+ </button>
46
+ <!-- #endif -->
47
+ <!-- #ifdef APP-NVUE -->
48
+ <view
49
+ :hover-start-time="Number(hoverStartTime)"
50
+ :hover-stay-time="Number(hoverStayTime)"
51
+ class="u-button"
52
+ :hover-class="
53
+ !disabled && !loading && !color && (plain || type === 'info')
54
+ ? 'u-button--active--plain'
55
+ : !disabled && !loading && !plain
56
+ ? 'u-button--active'
57
+ : ''
58
+ "
59
+ @tap="clickHandler"
60
+ :class="bemClass"
61
+ :style="[baseColor, addStyle(customStyle)]"
62
+ >
63
+ <template v-if="loading">
64
+ <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
65
+ <text class="u-button__loading-text" :style="[nvueTextStyle]" :class="[plain && `u-button__text--plain--${type}`]">
66
+ {{ loadingText || text }}
67
+ </text>
68
+ </template>
69
+ <template v-else>
70
+ <up-icon v-if="icon" :name="icon" :color="iconColorCom" :size="textSize * 1.35"></up-icon>
71
+ <text
72
+ class="u-button__text"
73
+ :style="[
74
+ {
75
+ marginLeft: icon ? '2px' : 0
76
+ },
77
+ nvueTextStyle
78
+ ]"
79
+ :class="[plain && `u-button__text--plain--${type}`]"
80
+ >
81
+ {{ text }}
82
+ </text>
83
+ </template>
84
+ </view>
85
+ <!-- #endif -->
86
+ </template>
87
+ <script>
88
+ import { buttonMixin } from '../../libs/mixin/button';
89
+ import { openType } from '../../libs/mixin/openType';
90
+ import { mpMixin } from '../../libs/mixin/mpMixin';
91
+ import { mixin } from '../../libs/mixin/mixin';
92
+ import { props } from './props';
93
+ import { addStyle } from '../../libs/function/index';
94
+ import { throttle } from '../../libs/function/throttle';
95
+ import color from '../../libs/config/color';
96
+ /**
97
+ * button 按钮
98
+ * @description Button 按钮
99
+ * @tutorial https://uview-plus.jiangruyi.com/components/button.html
100
+ *
101
+ * @property {Boolean} hairline 是否显示按钮的细边框 (默认 true )
102
+ * @property {String} type 按钮的预置样式,info,primary,error,warning,success (默认 'info' )
103
+ * @value info 默认按钮
104
+ * @value primary 主题按钮
105
+ * @value error 危险按钮
106
+ * @value warning 警告按钮
107
+ * @value success 成功按钮
108
+ * @property {String} size 按钮尺寸,large,normal,mini (默认 normal)
109
+ * @value large 超大尺寸
110
+ * @value normal 普通尺寸
111
+ * @value mini 迷你尺寸
112
+ * @property {String} shape 按钮形状,circle(两边为半圆),square(带圆角) (默认 'square' )
113
+ * @value circle 两边为半圆
114
+ * @value square 带有一定的圆角
115
+ * @property {Boolean} plain 按钮是否镂空,背景色透明 (默认 false)
116
+ * @property {Boolean} disabled 是否禁用 (默认 false)
117
+ * @property {Boolean} loading 按钮名称前是否带 loading 图标(App-nvue 平台,在 ios 上为雪花,Android上为圆圈) (默认 false)
118
+ * @property {String | Number} loadingText 加载中提示文字
119
+ * @property {String} loadingMode 加载状态图标类型 (默认 'spinner' )
120
+ * @property {String | Number} loadingSize 加载图标大小 (默认 15 )
121
+ * @property {String} openType 开放能力,具体请看uniapp稳定关于button组件部分说明
122
+ * @property {String} formType 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件
123
+ * @property {String} appParameter 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 (注:只微信小程序、QQ小程序有效)
124
+ * @property {Boolean} hoverStopPropagation 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效(默认 true )
125
+ * @property {String} lang 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文(默认 en )
126
+ * @property {String} sessionFrom 会话来源,openType="contact"时有效
127
+ * @property {String} sendMessageTitle 会话内消息卡片标题,openType="contact"时有效
128
+ * @property {String} sendMessagePath 会话内消息卡片点击跳转小程序路径,openType="contact"时有效
129
+ * @property {String} sendMessageImg 会话内消息卡片图片,openType="contact"时有效
130
+ * @property {Boolean} showMessageCard 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,openType="contact"时有效(默认false)
131
+ * @property {String} dataName 额外传参参数,用于小程序的data-xxx属性,通过target.dataset.name获取
132
+ * @property {String | Number} throttleTime 节流,一定时间内只能触发一次 (默认 0 )
133
+ * @property {String | Number} hoverStartTime 按住后多久出现点击态,单位毫秒 (默认 0 )
134
+ * @property {String | Number} hoverStayTime 手指松开后点击态保留时间,单位毫秒 (默认 200 )
135
+ * @property {String | Number} text 按钮文字,之所以通过props传入,是因为slot传入的话(注:nvue中无法控制文字的样式)
136
+ * @property {String} icon 按钮图标
137
+ * @property {String} iconColor 按钮图标颜色
138
+ * @property {String} color 按钮颜色,支持传入linear-gradient渐变色
139
+ * @property {Object} customStyle 定义需要用到的外部样式
140
+ *
141
+ * @event {Function} click 非禁止并且非加载中,才能点击
142
+ * @event {Function} getphonenumber open-type="getPhoneNumber"时有效
143
+ * @event {Function} getuserinfo 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
144
+ * @event {Function} error 当使用开放能力时,发生错误的回调
145
+ * @event {Function} opensetting 在打开授权设置页并关闭后回调
146
+ * @event {Function} launchapp 打开 APP 成功的回调
147
+ * @event {Function} agreeprivacyauthorization 用户同意隐私协议事件回调
148
+ * @example <up-button>月落</up-button>
149
+ */
150
+ export default {
151
+ name: 'u-button',
152
+ // #ifdef MP
153
+ mixins: [mpMixin, mixin, buttonMixin, openType, props],
154
+ // #endif
155
+ // #ifndef MP
156
+ mixins: [mpMixin, mixin, props],
157
+ // #endif
158
+ data() {
159
+ return {};
160
+ },
161
+ computed: {
162
+ // 生成bem风格的类名
163
+ bemClass() {
164
+ // this.bem为一个computed变量,在mixin中
165
+ if (!this.color) {
166
+ return this.bem('button', ['type', 'shape', 'size'], ['disabled', 'plain', 'hairline']);
167
+ } else {
168
+ // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
169
+ return this.bem('button', ['shape', 'size'], ['disabled', 'plain', 'hairline']);
170
+ }
171
+ },
172
+ loadingColor() {
173
+ if (this.plain) {
174
+ // 如果有设置color值,则用color值,否则使用type主题颜色
175
+ return this.color ? this.color : color[`u-${this.type}`];
176
+ }
177
+ if (this.type === 'info') {
178
+ return '#c9c9c9';
179
+ }
180
+ return 'rgb(200, 200, 200)';
181
+ },
182
+ iconColorCom() {
183
+ // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
184
+ // up-icon的color能接受一个主题颜色的值
185
+ if (this.iconColor) return this.iconColor;
186
+ if (this.plain) {
187
+ return this.color ? this.color : this.type;
188
+ } else {
189
+ return this.type === 'info' ? '#000000' : '#ffffff';
190
+ }
191
+ },
192
+ baseColor() {
193
+ let style = {};
194
+ if (this.color) {
195
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
196
+ style.color = this.plain ? this.color : 'white';
197
+ if (!this.plain) {
198
+ // 非镂空,背景色使用自定义的颜色
199
+ style['background-color'] = this.color;
200
+ }
201
+ if (this.color.indexOf('gradient') !== -1) {
202
+ // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
203
+ // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
204
+ // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
205
+ style.borderTopWidth = 0;
206
+ style.borderRightWidth = 0;
207
+ style.borderBottomWidth = 0;
208
+ style.borderLeftWidth = 0;
209
+ if (!this.plain) {
210
+ style.backgroundImage = this.color;
211
+ }
212
+ } else {
213
+ // 非渐变色,则设置边框相关的属性
214
+ style.borderColor = this.color;
215
+ style.borderWidth = '1px';
216
+ style.borderStyle = 'solid';
217
+ }
218
+ }
219
+ return style;
220
+ },
221
+ // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
222
+ nvueTextStyle() {
223
+ let style = {};
224
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
225
+ if (this.type === 'info') {
226
+ style.color = '#323233';
227
+ }
228
+ if (this.color) {
229
+ style.color = this.plain ? this.color : 'white';
230
+ }
231
+ style.fontSize = this.textSize + 'px';
232
+ return style;
233
+ },
234
+ // 字体大小
235
+ textSize() {
236
+ let fontSize = 14,
237
+ { size } = this;
238
+ if (size === 'large') fontSize = 16;
239
+ if (size === 'normal') fontSize = 14;
240
+ if (size === 'small') fontSize = 12;
241
+ if (size === 'mini') fontSize = 10;
242
+ return fontSize;
243
+ }
244
+ },
245
+ emits: ['click', 'getphonenumber', 'getuserinfo', 'error', 'opensetting', 'launchapp', 'agreeprivacyauthorization'],
246
+ methods: {
247
+ addStyle,
248
+ clickHandler(e) {
249
+ // 非禁止并且非加载中,才能点击
250
+ if (!this.disabled && !this.loading) {
251
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
252
+ throttle(() => {
253
+ this.$emit('click', e);
254
+ }, this.throttleTime);
255
+ }
256
+ // 是否阻止事件传播
257
+ this.stop && this.preventEvent(e);
258
+ },
259
+ // 下面为对接uniapp官方按钮开放能力事件回调的对接
260
+ getphonenumber(res) {
261
+ this.$emit('getphonenumber', res);
262
+ },
263
+ getuserinfo(res) {
264
+ this.$emit('getuserinfo', res);
265
+ },
266
+ error(res) {
267
+ this.$emit('error', res);
268
+ },
269
+ opensetting(res) {
270
+ this.$emit('opensetting', res);
271
+ },
272
+ launchapp(res) {
273
+ this.$emit('launchapp', res);
274
+ },
275
+ agreeprivacyauthorization(res) {
276
+ this.$emit('agreeprivacyauthorization', res);
277
+ }
278
+ }
279
+ };
280
+ </script>
281
+ <style scoped>
282
+ /* #ifndef APP-NVUE */
283
+ .u-button {
284
+ width: 100%;
285
+ white-space: nowrap;
286
+ }
287
+ .u-button__text {
288
+ white-space: nowrap;
289
+ line-height: 1;
290
+ }
291
+ .u-button:before {
292
+ position: absolute;
293
+ top: 50%;
294
+ left: 50%;
295
+ width: 100%;
296
+ height: 100%;
297
+ border: inherit;
298
+ border-radius: inherit;
299
+ transform: translate(-50%, -50%);
300
+ opacity: 0;
301
+ content: ' ';
302
+ background-color: #000;
303
+ border-color: #000;
304
+ }
305
+ .u-button--active:before {
306
+ opacity: 0.15;
307
+ }
308
+ .u-button__icon + .u-button__text:not(:empty),
309
+ .u-button__loading-text {
310
+ margin-left: 4px;
311
+ }
312
+ .u-button--plain.u-button--primary {
313
+ color: var(--u-primary);
314
+ }
315
+ .u-button--plain.u-button--info {
316
+ color: var(--u-info);
317
+ }
318
+ .u-button--plain.u-button--success {
319
+ color: var(--u-success);
320
+ }
321
+ .u-button--plain.u-button--error {
322
+ color: var(--u-error);
323
+ }
324
+ .u-button--plain.u-button--warning {
325
+ color: var(--u-warning);
326
+ }
327
+ /* #endif */
328
+ /* #ifdef APP-NVUE */
329
+ .u-button--active {
330
+ opacity: 0.75;
331
+ }
332
+ .u-button--active--plain {
333
+ background-color: rgb(217, 217, 217);
334
+ }
335
+ .u-button__loading-text {
336
+ margin-left: 4px;
337
+ }
338
+ .u-button__text,
339
+ .u-button__loading-text {
340
+ color: #ffffff;
341
+ }
342
+ .u-button__text--plain--error {
343
+ color: var(--u-error);
344
+ }
345
+ .u-button__text--plain--warning {
346
+ color: var(--u-warning);
347
+ }
348
+ .u-button__text--plain--success {
349
+ color: var(--u-success);
350
+ }
351
+ .u-button__text--plain--info {
352
+ color: var(--u-info);
353
+ }
354
+ .u-button__text--plain--primary {
355
+ color: var(--u-primary);
356
+ }
357
+ /* #endif */
358
+ .u-button {
359
+ height: 40px;
360
+ position: relative;
361
+ align-items: center;
362
+ justify-content: center;
363
+ /* #ifndef APP-NVUE */
364
+ display: flex;
365
+ /* #endif */
366
+ flex-direction: row;
367
+ /* #ifndef APP-NVUE */
368
+ box-sizing: border-box;
369
+ /* #endif */
370
+ flex-direction: row;
371
+ }
372
+ .u-button__text {
373
+ font-size: 15px;
374
+ }
375
+ .u-button__loading-text {
376
+ font-size: 15px;
377
+ margin-left: 4px;
378
+ }
379
+ .u-button--large {
380
+ /* #ifndef APP-NVUE */
381
+ width: 100%;
382
+ /* #endif */
383
+ height: 50px;
384
+ padding: 0 15px;
385
+ }
386
+ .u-button--normal {
387
+ padding: 0 12px;
388
+ font-size: 14px;
389
+ }
390
+ .u-button--small {
391
+ /* #ifndef APP-NVUE */
392
+ min-width: 60px;
393
+ /* #endif */
394
+ height: 30px;
395
+ padding: 0px 8px;
396
+ font-size: 12px;
397
+ }
398
+ .u-button--mini {
399
+ height: 22px;
400
+ font-size: 10px;
401
+ /* #ifndef APP-NVUE */
402
+ min-width: 50px;
403
+ /* #endif */
404
+ padding: 0px 8px;
405
+ }
406
+ .u-button--disabled {
407
+ opacity: 0.5;
408
+ }
409
+ .u-button--info {
410
+ color: #323233;
411
+ background-color: #fff;
412
+ border-color: #ebedf0;
413
+ border-width: 1px;
414
+ border-style: solid;
415
+ }
416
+ .u-button--success {
417
+ color: #fff;
418
+ background-color: var(--u-success);
419
+ border-color: var(--u-success);
420
+ border-width: 1px;
421
+ border-style: solid;
422
+ }
423
+ .u-button--primary {
424
+ color: #fff;
425
+ background-color: var(--u-primary);
426
+ border-color: var(--u-primary);
427
+ border-width: 1px;
428
+ border-style: solid;
429
+ }
430
+ .u-button--error {
431
+ color: #fff;
432
+ background-color: var(--u-error);
433
+ border-color: var(--u-error);
434
+ border-width: 1px;
435
+ border-style: solid;
436
+ }
437
+ .u-button--warning {
438
+ color: #fff;
439
+ background-color: var(--u-warning);
440
+ border-color: var(--u-warning);
441
+ border-width: 1px;
442
+ border-style: solid;
443
+ }
444
+ .u-button--block {
445
+ /* #ifndef APP-NVUE */
446
+ display: flex;
447
+ /* #endif */
448
+ flex-direction: row;
449
+ width: 100%;
450
+ }
451
+ .u-button--circle {
452
+ border-top-right-radius: 100px;
453
+ border-top-left-radius: 100px;
454
+ border-bottom-left-radius: 100px;
455
+ border-bottom-right-radius: 100px;
456
+ }
457
+ .u-button--square {
458
+ border-bottom-left-radius: 3px;
459
+ border-bottom-right-radius: 3px;
460
+ border-top-left-radius: 3px;
461
+ border-top-right-radius: 3px;
462
+ }
463
+ .u-button__icon {
464
+ /* #ifndef APP-NVUE */
465
+ min-width: 1em;
466
+ line-height: inherit !important;
467
+ vertical-align: top;
468
+ /* #endif */
469
+ }
470
+ .u-button--plain {
471
+ background-color: #fff;
472
+ }
473
+ .u-button--hairline {
474
+ border-width: 0.5px !important;
475
+ }
476
+ </style>
@@ -18,11 +18,11 @@
18
18
  :session-from="sessionFrom"
19
19
  :send-message-img="sendMessageImg"
20
20
  :show-message-card="showMessageCard"
21
- @getphonenumber="onGetPhoneNumber"
22
- @getuserinfo="onGetUserInfo"
23
- @error="onError"
24
- @opensetting="onOpenSetting"
25
- @launchapp="onLaunchApp"
21
+ @getphonenumber="getphonenumber"
22
+ @getuserinfo="getuserinfo"
23
+ @error="error"
24
+ @opensetting="opensetting"
25
+ @launchapp="launchapp"
26
26
  @contact="onContact"
27
27
  @chooseavatar="onChooseavatar"
28
28
  @addgroupapp="onAddgroupapp"
@@ -108,8 +108,8 @@
108
108
  !disabled && !loading && !color && (plain || type === 'info')
109
109
  ? 'u-button--active--plain'
110
110
  : !disabled && !loading && !plain
111
- ? 'u-button--active'
112
- : ''
111
+ ? 'u-button--active'
112
+ : ''
113
113
  "
114
114
  @tap="clickHandler"
115
115
  :class="bemClass"
@@ -157,6 +157,7 @@ import { props } from '../u-button/props.js';
157
157
  * button 按钮
158
158
  * @description Button 按钮
159
159
  * @tutorial https://uview-plus.jiangruyi.com/components/button.html
160
+ *
160
161
  * @property {Boolean} hairline 是否显示按钮的细边框 (默认 true )
161
162
  * @property {String} type 按钮的预置样式,info,primary,error,warning,success (默认 'info' )
162
163
  * @value info 默认按钮
@@ -168,7 +169,7 @@ import { props } from '../u-button/props.js';
168
169
  * @value large 超大尺寸
169
170
  * @value normal 普通尺寸
170
171
  * @value mini 迷你尺寸
171
- * @property {String} shape 按钮形状,circle(两边为半圆),square(带有一定的圆角) (默认 'square' )
172
+ * @property {String} shape 按钮形状,circle(两边为半圆),square(带圆角) (默认 'square' )
172
173
  * @value circle 两边为半圆
173
174
  * @value square 带有一定的圆角
174
175
  * @property {Boolean} plain 按钮是否镂空,背景色透明 (默认 false)
@@ -196,16 +197,18 @@ import { props } from '../u-button/props.js';
196
197
  * @property {String} iconColor 按钮图标颜色
197
198
  * @property {String} color 按钮颜色,支持传入linear-gradient渐变色
198
199
  * @property {Object} customStyle 定义需要用到的外部样式
200
+ *
199
201
  * @event {Function} click 非禁止并且非加载中,才能点击
200
202
  * @event {Function} getphonenumber open-type="getPhoneNumber"时有效
201
203
  * @event {Function} getuserinfo 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
202
204
  * @event {Function} error 当使用开放能力时,发生错误的回调
203
205
  * @event {Function} opensetting 在打开授权设置页并关闭后回调
204
206
  * @event {Function} launchapp 打开 APP 成功的回调
205
- * @example <up-button>千金散尽还复来</up-button>
207
+ * @event {Function} agreeprivacyauthorization 用户同意隐私协议事件回调
208
+ * @example <up-button>月落</up-button>
206
209
  */
207
210
  export default {
208
- name: 'u-button-wu',
211
+ name: 'u-button',
209
212
  // #ifdef MP
210
213
  mixins: [mpMixin, mixin, buttonMixin, openType, props],
211
214
  // #endif
@@ -20,13 +20,13 @@
20
20
  @opensetting="opensetting"
21
21
  @launchapp="launchapp"
22
22
  @agreeprivacyauthorization="agreeprivacyauthorization"
23
- :hover-class="!disabled && !loading ? 'u-button--active' : ''"
23
+ :hover-class="!disabled && !localLoading ? 'u-button--active' : ''"
24
24
  class="u-button u-reset-button"
25
25
  :style="[baseColor, addStyle(customStyle)]"
26
26
  @tap="clickHandler"
27
27
  :class="bemClass"
28
28
  >
29
- <template v-if="loading">
29
+ <template v-if="localLoading">
30
30
  <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
31
31
  <text class="u-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">{{ loadingText || text }}</text>
32
32
  </template>
@@ -50,9 +50,9 @@
50
50
  :hover-stay-time="Number(hoverStayTime)"
51
51
  class="u-button"
52
52
  :hover-class="
53
- !disabled && !loading && !color && (plain || type === 'info')
53
+ !disabled && !localLoading && !color && (plain || type === 'info')
54
54
  ? 'u-button--active--plain'
55
- : !disabled && !loading && !plain
55
+ : !disabled && !localLoading && !plain
56
56
  ? 'u-button--active'
57
57
  : ''
58
58
  "
@@ -60,7 +60,7 @@
60
60
  :class="bemClass"
61
61
  :style="[baseColor, addStyle(customStyle)]"
62
62
  >
63
- <template v-if="loading">
63
+ <template v-if="localLoading">
64
64
  <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
65
65
  <text class="u-button__loading-text" :style="[nvueTextStyle]" :class="[plain && `u-button__text--plain--${type}`]">
66
66
  {{ loadingText || text }}
@@ -100,8 +100,18 @@ import color from '../../libs/config/color';
100
100
  *
101
101
  * @property {Boolean} hairline 是否显示按钮的细边框 (默认 true )
102
102
  * @property {String} type 按钮的预置样式,info,primary,error,warning,success (默认 'info' )
103
+ * @value info 默认按钮
104
+ * @value primary 主题按钮
105
+ * @value error 危险按钮
106
+ * @value warning 警告按钮
107
+ * @value success 成功按钮
103
108
  * @property {String} size 按钮尺寸,large,normal,mini (默认 normal)
109
+ * @value large 超大尺寸
110
+ * @value normal 普通尺寸
111
+ * @value mini 迷你尺寸
104
112
  * @property {String} shape 按钮形状,circle(两边为半圆),square(带圆角) (默认 'square' )
113
+ * @value circle 两边为半圆
114
+ * @value square 带有一定的圆角
105
115
  * @property {Boolean} plain 按钮是否镂空,背景色透明 (默认 false)
106
116
  * @property {Boolean} disabled 是否禁用 (默认 false)
107
117
  * @property {Boolean} loading 按钮名称前是否带 loading 图标(App-nvue 平台,在 ios 上为雪花,Android上为圆圈) (默认 false)
@@ -146,9 +156,14 @@ export default {
146
156
  mixins: [mpMixin, mixin, props],
147
157
  // #endif
148
158
  data() {
149
- return {};
159
+ return {
160
+ loadingStatus: false
161
+ };
150
162
  },
151
163
  computed: {
164
+ localLoading() {
165
+ return this.loadingStatus || this.loading;
166
+ },
152
167
  // 生成bem风格的类名
153
168
  bemClass() {
154
169
  // this.bem为一个computed变量,在mixin中
@@ -236,15 +251,33 @@ export default {
236
251
  methods: {
237
252
  addStyle,
238
253
  clickHandler(e) {
239
- // 非禁止并且非加载中,才能点击
240
- if (!this.disabled && !this.loading) {
241
- // 进行节流控制,每this.throttle毫秒内,只在开始处执行
242
- throttle(() => {
243
- this.$emit('click', e);
244
- }, this.throttleTime);
254
+ if (this.autoLoading) {
255
+ if (!this.loadingStatus) {
256
+ this.loadingStatus = true;
257
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
258
+ throttle(() => {
259
+ this.$emit(
260
+ 'click',
261
+ () => {
262
+ this.loadingStatus = false;
263
+ },
264
+ e
265
+ );
266
+ }, this.throttleTime);
267
+ // 是否阻止事件传播
268
+ this.stop && this.preventEvent(e);
269
+ }
270
+ } else {
271
+ // 非禁止并且非加载中,才能点击
272
+ if (!this.disabled && !this.loading) {
273
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
274
+ throttle(() => {
275
+ this.$emit('click', e);
276
+ }, this.throttleTime);
277
+ }
278
+ // 是否阻止事件传播
279
+ this.stop && this.preventEvent(e);
245
280
  }
246
- // 是否阻止事件传播
247
- this.stop && this.preventEvent(e);
248
281
  },
249
282
  // 下面为对接uniapp官方按钮开放能力事件回调的对接
250
283
  getphonenumber(res) {