Skip to content

Commit 3765301

Browse files
committed
1. 1.3.3起,numberBox步进器推荐使用v-model双向绑定数值,无需在change回调中重新赋值
2. search组件新增clear清除内容事件 3. 优化程序选择模板在微信小程序上的问题 4. 优化countTo组件可能由于传入字符串数值而报错的问题 5. 由于form表单验证在某些表单域没有验证规则导致不会触发验证回调的问题 6. section组件新增可控制左边竖条的show-line参数 7. 优化验证码倒计时组件可能会触发多次的问题
1 parent 1043b6a commit 3765301

File tree

16 files changed

+60
-44
lines changed

16 files changed

+60
-44
lines changed

pages.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"easycom": {
33
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
44
},
5-
// "condition": { //模式配置,仅开发期间生效
6-
// "current": 0, //当前激活的模式(list 的索引项)
7-
// "list": [{
8-
// "name": "test", //模式名称
9-
// "path": "pages/components/changelog.html", //启动页面,必选
10-
// "query": "id=1&name=2" //启动参数,在页面的onLoad函数里面得到
11-
// }]
12-
// },
5+
"condition": { //模式配置,仅开发期间生效
6+
"current": 0, //当前激活的模式(list 的索引项)
7+
"list": [{
8+
"name": "test", //模式名称
9+
"path": "pages/template/citySelect/index", //启动页面,必选
10+
"query": "id=1&name=2" //启动参数,在页面的onLoad函数里面得到
11+
}]
12+
},
1313
"pages": [
1414
// 演示-组件
1515
{

pages/componentsA/form/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default {
229229
},
230230
{
231231
// 正则不能含有两边的引号
232-
pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{6,12}$/,
232+
pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,12}$/,
233233
message: '需同时含有字母和数字,长度在6-12之间',
234234
trigger: ['change','blur'],
235235
}
@@ -394,7 +394,8 @@ export default {
394394
if(this.$refs.uCode.canGetCode) {
395395
// 模拟向后端请求验证码
396396
uni.showLoading({
397-
title: '正在获取验证码'
397+
title: '正在获取验证码',
398+
mask: true
398399
})
399400
setTimeout(() => {
400401
uni.hideLoading();

pages/componentsB/form/index.vue

Lines changed: 0 additions & 8 deletions
This file was deleted.

pages/componentsC/numberBox/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<view class="u-demo-wrap">
44
<view class="u-demo-title">演示效果</view>
55
<view class="u-demo-area">
6-
<u-number-box :value="value" :bg-color="bgColor" :color="color" :min="0"
6+
<u-number-box v-model="value" :bg-color="bgColor" :color="color" :min="0"
77
:step="step" :disabled="disabled" @change="change"></u-number-box>
88
</view>
99
</view>
@@ -63,8 +63,7 @@ export default {
6363
this.step = index == 0 ? 1 : index == 1 ? 3 : index == 2 ? 5 : 8;
6464
},
6565
change(e) {
66-
// console.log(e);
67-
// this.value = e.value;
66+
// console.log(this.value);
6867
}
6968
}
7069
};

pages/template/citySelect/u-city-select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<u-popup v-model="value" mode="bottom" :popup="false" :mask="true" :closeable="true" :safe-area-inset-bottom="true"
33
close-icon-color="#ffffff" :z-index="uZIndex" :maskCloseAble="maskCloseAble" @close="close">
4-
<u-tabs :list="genTabsList" :is-scroll="true" :current="tabsIndex" @change="tabsChange" ref="tabs"></u-tabs>
4+
<u-tabs v-if="value" :list="genTabsList" :is-scroll="true" :current="tabsIndex" @change="tabsChange" ref="tabs"></u-tabs>
55
<view class="area-box">
66
<view class="u-flex" :class="{ 'change':isChange }">
77
<view class="area-item">

uview-ui/components/u-button/u-button.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ export default {
382382
transform-origin: 0 0;
383383
left: 0;
384384
top: 0;
385-
width: 200.1%;
386-
height: 200.1%;
385+
width: 199.8%;
386+
height: 199.7%;
387387
-webkit-transform: scale(0.5, 0.5);
388388
transform: scale(0.5, 0.5);
389389
border: 1px solid currentColor;
390-
z-index: 0;
390+
z-index: 1;
391391
}
392392
393393
.u-bold-border {

uview-ui/components/u-count-to/u-count-to.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ export default {
207207
return !isNaN(parseFloat(val));
208208
},
209209
formatNumber(num) {
210+
// 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
211+
num = Number(num);
210212
num = num.toFixed(Number(this.decimals));
211213
num += '';
212214
const x = num.split('.');

uview-ui/components/u-form-item/u-form-item.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ export default {
210210
validation(trigger, callback = () => {}) {
211211
// blur和change是否有当前方式的校验规则
212212
let rules = this.getFilteredRule(trigger);
213-
// 判断是否有验证规则
214-
if (!rules || rules.length === 0) return;
213+
// 判断是否有验证规则,如果没有规则,也调用回调方法,否则父组件u-form会因为
214+
// 对count变量的统计错误而无法进入上一层的回调
215+
if (!rules || rules.length === 0) {
216+
return callback('');
217+
}
215218
// 设置当前的装填,标识为校验中
216219
this.validateState = 'validating';
217220
// 调用async-validator的方法

uview-ui/components/u-number-box/u-number-box.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@
120120
}
121121
},
122122
watch: {
123-
value(val) {
124-
this.inputVal = Number(val);
123+
value(val, val1) {
124+
// 防止用户在change事件回调中将回调值赋值给valut变量,导致change事件触发两次
125+
if(Number(val) != this.inputVal) this.inputVal = Number(val);
125126
},
126127
inputVal(v1, v2) {
127128
// 为了让用户能够删除所有输入值,重新输入内容,删除所有值后,内容为空字符串
@@ -229,6 +230,8 @@
229230
},
230231
handleChange(value, type) {
231232
if (this.disabled) return;
233+
// 发出input事件,修改通过v-model绑定的值,达到双向绑定的效果
234+
this.$emit('input', Number(value));
232235
this.$emit(type, {
233236
// 转为Number类型
234237
value: Number(value),

uview-ui/components/u-search/u-search.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
* @event {Function} change 输入框内容发生变化时触发
7272
* @event {Function} search 用户确定搜索时触发,用户按回车键,或者手机键盘右下角的"搜索"键时触发
7373
* @event {Function} custom 用户点击右侧控件时触发
74+
* @event {Function} clear 用户点击清除按钮时触发
7475
* @example <u-search placeholder="日照香炉生紫烟" v-model="keyword"></u-search>
7576
*/
7677
export default {
@@ -230,6 +231,7 @@ export default {
230231
// 也可以作为用户通过this.$refs形式调用清空输入框内容
231232
clear() {
232233
this.keyword = '';
234+
this.$emit('clear');
233235
},
234236
// 确定搜索
235237
search() {

uview-ui/components/u-section/u-section.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<view class="u-section-title" :style="{
44
fontWeight: bold ? 'bold' : 'normal',
55
color: color,
6-
fontSize: fontSize + 'rpx'
6+
fontSize: fontSize + 'rpx',
7+
paddingLeft: showLine ? '10rpx' : 0
8+
}" :class="{
9+
'u-section--line': showLine
710
}">
811
{{title}}
912
</view>
@@ -26,6 +29,7 @@
2629
* @property {String} title 左边主标题
2730
* @property {String} sub-title 右边副标题(默认更多)
2831
* @property {Boolean} right 是否显示右边的内容(默认true)
32+
* @property {Boolean} showLine 是否显示左边的竖条(默认true)
2933
* @property {String Number} font-size 主标题的字体大小(默认28)
3034
* @property {Boolean} bold 主标题是否加粗(默认true)
3135
* @property {String} color 主标题颜色(默认#303133)
@@ -68,6 +72,11 @@
6872
subColor: {
6973
type: String,
7074
default: '#909399'
75+
},
76+
// 是否显示左边的竖条
77+
showLine: {
78+
type: Boolean,
79+
default: false
7180
}
7281
},
7382
data() {
@@ -94,11 +103,10 @@
94103
.u-section-title {
95104
position: relative;
96105
font-size: 28rpx;
97-
padding-left: 10px;
98106
line-height: 1;
99107
}
100108
101-
.u-section-title:after {
109+
.u-section--line:after {
102110
position: absolute;
103111
width: 4px;
104112
height: 100%;

uview-ui/components/u-verification-code/u-verification-code.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
},
8888
// 开始倒计时
8989
start() {
90+
// 防止快速点击获取验证码的按钮而导致内部产生多个定时器导致混乱
91+
if(this.timer) {
92+
clearInterval(this.timer);
93+
this.timer = null;
94+
}
9095
//this.secNum = this.seconds;
9196
this.$emit('start');
9297
this.canGetCode = false;
@@ -98,6 +103,7 @@
98103
this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
99104
} else {
100105
clearInterval(this.timer);
106+
this.timer = null;
101107
this.changeEvent(this.endText);
102108
this.secNum = this.seconds;
103109
this.$emit('end');

uview-ui/index.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ u-grid {
134134
-webkit-transform-origin: 0 0;
135135
transform-origin: 0 0;
136136
// 多加0.1%,能解决有时候边框缺失的问题
137-
width: 200.1%;
138-
height: 200.1%;
137+
width: 199.8%;
138+
height: 199.7%;
139139
transform: scale(0.5, 0.5);
140140
border: 0 solid $u-border-color;
141-
z-index: 1;
141+
z-index: 2;
142142
}
143143

144144
.u-border-top:after {

uview-ui/libs/config/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// 此版本发布于2020-06-09
2-
let version = '1.3.2';
1+
// 此版本发布于2020-06-10
2+
let version = '1.3.3';
33

44
export default {
55
v: version,

uview-ui/libs/request/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ class Request {
88
}
99

1010
// 主要请求部分
11-
async request(options = {}) {
11+
request(options = {}) {
1212
// 检查请求拦截
1313
if (this.interceptor.request && typeof this.interceptor.request === 'function') {
1414
let tmpConfig = {};
15-
let interceptorReuest = await this.interceptor.request(options);
15+
let interceptorReuest = this.interceptor.request(options);
1616
if (interceptorReuest === false) {
1717
return false;
1818
}
@@ -27,7 +27,7 @@ class Request {
2727
options.method = options.method || this.config.method;
2828

2929
return new Promise((resolve, reject) => {
30-
options.complete = async (response) => {
30+
options.complete = (response) => {
3131
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
3232
uni.hideLoading();
3333
// 清除定时器,如果请求回来了,就无需loading
@@ -36,7 +36,7 @@ class Request {
3636
if(this.config.originalData) {
3737
// 判断是否存在拦截器
3838
if (this.interceptor.response && typeof this.interceptor.response === 'function') {
39-
let resInterceptors = await this.interceptor.response(response);
39+
let resInterceptors = this.interceptor.response(response);
4040
// 如果拦截器不返回false,就将拦截器返回的内容给this.$u.post的then回调
4141
if (resInterceptors !== false) {
4242
resolve(resInterceptors);
@@ -51,11 +51,11 @@ class Request {
5151
} else {
5252
if (response.statusCode == 200) {
5353
if (this.interceptor.response && typeof this.interceptor.response === 'function') {
54-
let resInterceptors = await this.interceptor.response(response.data);
54+
let resInterceptors = this.interceptor.response(response.data);
5555
if (resInterceptors !== false) {
5656
resolve(resInterceptors);
5757
} else {
58-
reject(resInterceptors);
58+
reject(response.data);
5959
}
6060
} else {
6161
// 如果不是返回原始数据(originalData=false),且没有拦截器的情况下,返回纯数据给then回调

uview-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uview-ui",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
55
"main": "index.js",
66
"keywords": ["uview", "uView", "uni-app", "uni-app ui", "uniapp", "uviewui", "uview ui", "uviewUI", "uViewui", "uViewUI", "uView UI", "uni ui", "uni UI", "uniapp ui", "ui", "UI框架", "uniapp ui框架", "uniapp UI"],

0 commit comments

Comments
 (0)