Skip to content

Commit 0d65357

Browse files
committed
1. 新增upload组件的before-upload钩子
2. 修复form表单综合演示中,switch没有垂直居中的问题
1 parent c2f3c8d commit 0d65357

File tree

6 files changed

+34
-79
lines changed

6 files changed

+34
-79
lines changed

pages/componentsB/picker/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export default {
6565
second: true,
6666
province: true,
6767
city: true,
68-
area: true
68+
area: true,
69+
timestamp: true
6970
}
7071
};
7172
},
@@ -115,6 +116,7 @@ export default {
115116
this.show = true;
116117
},
117118
confirm(e) {
119+
console.log(e);
118120
this.input = '';
119121
if (this.mode == 'time') {
120122
if (this.params.year) this.input += e.year;

pages/componentsB/upload/index.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:percent="item.progress"></u-line-progress>
1515
</view>
1616
</view>
17-
<u-upload :beforeUpload="beforeUpload" ref="uUpload" :custom-btn="customBtn" :show-upload-list="showUploadList" :action="action" :auto-upload="autoUpload" :file-list="fileList"
17+
<u-upload ref="uUpload" :custom-btn="customBtn" :show-upload-list="showUploadList" :action="action" :auto-upload="autoUpload" :file-list="fileList"
1818
:show-progress="showProgress" :deletable="deletable" :max-count="maxCount" @on-list-change="onListChange">
1919
<view v-if="customBtn" slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
2020
<u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon>
@@ -140,9 +140,6 @@
140140
// console.log('onListChange', lists);
141141
this.lists = lists;
142142
},
143-
beforeUpload(index, lists) {
144-
return true;
145-
}
146143
}
147144
}
148145
</script>

pages/componentsC/test/index.vue

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,22 @@
11
<template>
2-
<view class="wrap">
3-
<u-swiper :list="list"></u-swiper>
4-
</view>
2+
<u-upload :before-upload="beforeUpload"></u-upload>
53
</template>
64

75
<script>
86
export default {
9-
data() {
10-
return {
11-
list: [{
12-
image: '/static/uView/swiper/swiper1.jpg',
13-
title: '蒹葭苍苍,白露为霜。所谓伊人,在水一方'
14-
},
15-
{
16-
image: '/static/uView/swiper/swiper2.jpg',
17-
title: '溯洄从之,道阻且长。溯游从之,宛在水中央'
18-
},
19-
{
20-
image: '/static/uView/swiper/swiper3.jpg',
21-
title: '蒹葭萋萋,白露未晞。所谓伊人,在水之湄'
22-
}
23-
]
24-
}
25-
},
26-
onLoad() {
27-
setTimeout(() => {
28-
this.list.pop();
29-
}, 2000)
30-
},
317
methods: {
32-
8+
beforeUpload(index, list) {
9+
// 返回一个promise
10+
return new Promise((resolve, reject) => {
11+
this.$u.post('http://www.tp5.com/index.php/index/index/hello').then(res => {
12+
// resolve()之后,将会进入promise的组件内部的then回调,相当于返回true
13+
resolve();
14+
}).catch(err => {
15+
// reject()之后,将会进入promise的组件内部的catch回调,相当于返回false
16+
reject();
17+
})
18+
})
19+
}
3320
}
3421
}
3522
</script>

uni.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
* 使用的时候,请将下面的一行复制到您的uniapp项目根目录的uni.scss中即可
44
* uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用
55
*/
6-
@import 'uview-ui/theme.scss';
6+
@import 'uview-ui/theme.scss';
7+

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

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
plain ? 'u-btn--' + type + '--plain' : '',
88
loading ? 'u-loading' : '',
99
shape == 'circle' ? 'u-round-circle' : '',
10-
hairLine ? showHairLineBorder : 'u-bold-border',
10+
hairLine ? showHairLineBorder : 'u-btn--bold-border',
1111
'u-btn--' + type,
1212
disabled ? `u-btn--${type}--disabled` : '',
1313
@@ -28,7 +28,7 @@
2828
@error="error"
2929
@opensetting="opensetting"
3030
@launchapp="launchapp"
31-
:style="[buttonStyle]"
31+
:style="[customStyle]"
3232
@tap.stop="click($event)"
3333
:hover-class="getHoverClass"
3434
:loading="loading"
@@ -209,45 +209,6 @@ export default {
209209
hoverClass = this.plain ? 'u-' + this.type + '-plain-hover' : 'u-' + this.type + '-hover';
210210
return hoverClass;
211211
},
212-
// 按钮主题
213-
buttonStyle() {
214-
let style = {};
215-
// if (this.type == 'default') {
216-
// if (this.disabled) {
217-
// style.color = '#c0c4cc';
218-
// style.backgroundColor = '#ffffff';
219-
// style.borderColor = '#e4e7ed';
220-
// } else {
221-
// style.color = this.$u.color['contentColor'];
222-
// style.backgroundColor = '#ffffff';
223-
// style.borderColor = '#c0c4cc';
224-
// }
225-
// } else {
226-
// if (this.disabled) {
227-
// if (this.plain) {
228-
// style.color = this.$u.color[this.type + 'Disabled'];
229-
// style.backgroundColor = this.$u.color[this.type + 'Light'];
230-
// style.borderColor = this.$u.color[this.type + 'Disabled'];
231-
// } else {
232-
// style.color = '#ffffff';
233-
// style.backgroundColor = this.$u.color[this.type + 'Disabled'];
234-
// style.borderColor = this.$u.color[this.type + 'Disabled'];
235-
// }
236-
// } else {
237-
// if (this.plain) {
238-
// style.color = this.$u.color[this.type];
239-
// style.backgroundColor = this.$u.color[this.type + 'Light'];
240-
// style.borderColor = this.$u.color[this.type + 'Disabled'];
241-
// } else {
242-
// style.color = '#ffffff';
243-
// style.backgroundColor = this.$u.color[this.type];
244-
// style.borderColor = this.$u.color[this.type];
245-
// }
246-
// }
247-
// }
248-
249-
return Object.assign(style, this.customStyle);
250-
},
251212
// 在'primary', 'success', 'error', 'warning'类型下,不显示边框,否则会造成四角有毛刺现象
252213
showHairLineBorder() {
253214
if (['primary', 'success', 'error', 'warning'].indexOf(this.type) >= 0 && !this.plain) {
@@ -374,9 +335,13 @@ export default {
374335
box-sizing: border-box;
375336
transition: all 0.15s;
376337
338+
&--bold-border {
339+
border: 1px solid #ffffff;
340+
}
341+
377342
&--default {
378343
color: $u-content-color;
379-
border-color: $u-type-warning;
344+
border-color: #c0c4cc;
380345
background-color: #ffffff;
381346
}
382347
@@ -478,10 +443,6 @@ export default {
478443
z-index: 1;
479444
}
480445
481-
.u-bold-border {
482-
border: 1px solid #ffffff;
483-
}
484-
485446
.u-wave-ripple {
486447
z-index: 0;
487448
position: absolute;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export default {
135135
second: false,
136136
province: true,
137137
city: true,
138-
area: true
138+
area: true,
139+
timestamp: true,
139140
};
140141
}
141142
},
@@ -546,6 +547,7 @@ export default {
546547
if (this.params.hour) result.hour = this.formatNumber(this.hour || 0);
547548
if (this.params.minute) result.minute = this.formatNumber(this.minute || 0);
548549
if (this.params.second) result.second = this.formatNumber(this.second || 0);
550+
if (this.params.timestamp) result.timestamp = this.getTimestamp();
549551
} else if (this.mode == 'region') {
550552
if (this.params.province) result.province = provinces[this.province];
551553
if (this.params.city) result.city = citys[this.province][this.city];
@@ -557,6 +559,11 @@ export default {
557559
}
558560
if (event) this.$emit(event, result);
559561
this.close();
562+
},
563+
// 获取时间戳
564+
getTimestamp() {
565+
let time = this.year + '-' + this.month + '-' + this.day + ' ' + this.day + ':' + this.minute + ':' + this.second;
566+
return new Date(time).getTime() / 1000;
560567
}
561568
}
562569
};

0 commit comments

Comments
 (0)