Commit 0d653570 authored by wlxuqu's avatar wlxuqu

1. 新增upload组件的before-upload钩子

2. 修复form表单综合演示中,switch没有垂直居中的问题
parent c2f3c8da
...@@ -65,7 +65,8 @@ export default { ...@@ -65,7 +65,8 @@ export default {
second: true, second: true,
province: true, province: true,
city: true, city: true,
area: true area: true,
timestamp: true
} }
}; };
}, },
...@@ -115,6 +116,7 @@ export default { ...@@ -115,6 +116,7 @@ export default {
this.show = true; this.show = true;
}, },
confirm(e) { confirm(e) {
console.log(e);
this.input = ''; this.input = '';
if (this.mode == 'time') { if (this.mode == 'time') {
if (this.params.year) this.input += e.year; if (this.params.year) this.input += e.year;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
:percent="item.progress"></u-line-progress> :percent="item.progress"></u-line-progress>
</view> </view>
</view> </view>
<u-upload :beforeUpload="beforeUpload" ref="uUpload" :custom-btn="customBtn" :show-upload-list="showUploadList" :action="action" :auto-upload="autoUpload" :file-list="fileList" <u-upload ref="uUpload" :custom-btn="customBtn" :show-upload-list="showUploadList" :action="action" :auto-upload="autoUpload" :file-list="fileList"
:show-progress="showProgress" :deletable="deletable" :max-count="maxCount" @on-list-change="onListChange"> :show-progress="showProgress" :deletable="deletable" :max-count="maxCount" @on-list-change="onListChange">
<view v-if="customBtn" slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150"> <view v-if="customBtn" slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
<u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon> <u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon>
...@@ -140,9 +140,6 @@ ...@@ -140,9 +140,6 @@
// console.log('onListChange', lists); // console.log('onListChange', lists);
this.lists = lists; this.lists = lists;
}, },
beforeUpload(index, lists) {
return true;
}
} }
} }
</script> </script>
......
<template> <template>
<view class="wrap"> <u-upload :before-upload="beforeUpload"></u-upload>
<u-swiper :list="list"></u-swiper>
</view>
</template> </template>
<script> <script>
export default { export default {
data() {
return {
list: [{
image: '/static/uView/swiper/swiper1.jpg',
title: '蒹葭苍苍,白露为霜。所谓伊人,在水一方'
},
{
image: '/static/uView/swiper/swiper2.jpg',
title: '溯洄从之,道阻且长。溯游从之,宛在水中央'
},
{
image: '/static/uView/swiper/swiper3.jpg',
title: '蒹葭萋萋,白露未晞。所谓伊人,在水之湄'
}
]
}
},
onLoad() {
setTimeout(() => {
this.list.pop();
}, 2000)
},
methods: { methods: {
beforeUpload(index, list) {
// 返回一个promise
return new Promise((resolve, reject) => {
this.$u.post('http://www.tp5.com/index.php/index/index/hello').then(res => {
// resolve()之后,将会进入promise的组件内部的then回调,相当于返回true
resolve();
}).catch(err => {
// reject()之后,将会进入promise的组件内部的catch回调,相当于返回false
reject();
})
})
}
} }
} }
</script> </script>
......
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
* uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用 * uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用
*/ */
@import 'uview-ui/theme.scss'; @import 'uview-ui/theme.scss';
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
plain ? 'u-btn--' + type + '--plain' : '', plain ? 'u-btn--' + type + '--plain' : '',
loading ? 'u-loading' : '', loading ? 'u-loading' : '',
shape == 'circle' ? 'u-round-circle' : '', shape == 'circle' ? 'u-round-circle' : '',
hairLine ? showHairLineBorder : 'u-bold-border', hairLine ? showHairLineBorder : 'u-btn--bold-border',
'u-btn--' + type, 'u-btn--' + type,
disabled ? `u-btn--${type}--disabled` : '', disabled ? `u-btn--${type}--disabled` : '',
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
@error="error" @error="error"
@opensetting="opensetting" @opensetting="opensetting"
@launchapp="launchapp" @launchapp="launchapp"
:style="[buttonStyle]" :style="[customStyle]"
@tap.stop="click($event)" @tap.stop="click($event)"
:hover-class="getHoverClass" :hover-class="getHoverClass"
:loading="loading" :loading="loading"
...@@ -209,45 +209,6 @@ export default { ...@@ -209,45 +209,6 @@ export default {
hoverClass = this.plain ? 'u-' + this.type + '-plain-hover' : 'u-' + this.type + '-hover'; hoverClass = this.plain ? 'u-' + this.type + '-plain-hover' : 'u-' + this.type + '-hover';
return hoverClass; return hoverClass;
}, },
// 按钮主题
buttonStyle() {
let style = {};
// if (this.type == 'default') {
// if (this.disabled) {
// style.color = '#c0c4cc';
// style.backgroundColor = '#ffffff';
// style.borderColor = '#e4e7ed';
// } else {
// style.color = this.$u.color['contentColor'];
// style.backgroundColor = '#ffffff';
// style.borderColor = '#c0c4cc';
// }
// } else {
// if (this.disabled) {
// if (this.plain) {
// style.color = this.$u.color[this.type + 'Disabled'];
// style.backgroundColor = this.$u.color[this.type + 'Light'];
// style.borderColor = this.$u.color[this.type + 'Disabled'];
// } else {
// style.color = '#ffffff';
// style.backgroundColor = this.$u.color[this.type + 'Disabled'];
// style.borderColor = this.$u.color[this.type + 'Disabled'];
// }
// } else {
// if (this.plain) {
// style.color = this.$u.color[this.type];
// style.backgroundColor = this.$u.color[this.type + 'Light'];
// style.borderColor = this.$u.color[this.type + 'Disabled'];
// } else {
// style.color = '#ffffff';
// style.backgroundColor = this.$u.color[this.type];
// style.borderColor = this.$u.color[this.type];
// }
// }
// }
return Object.assign(style, this.customStyle);
},
// 在'primary', 'success', 'error', 'warning'类型下,不显示边框,否则会造成四角有毛刺现象 // 在'primary', 'success', 'error', 'warning'类型下,不显示边框,否则会造成四角有毛刺现象
showHairLineBorder() { showHairLineBorder() {
if (['primary', 'success', 'error', 'warning'].indexOf(this.type) >= 0 && !this.plain) { if (['primary', 'success', 'error', 'warning'].indexOf(this.type) >= 0 && !this.plain) {
...@@ -374,9 +335,13 @@ export default { ...@@ -374,9 +335,13 @@ export default {
box-sizing: border-box; box-sizing: border-box;
transition: all 0.15s; transition: all 0.15s;
&--bold-border {
border: 1px solid #ffffff;
}
&--default { &--default {
color: $u-content-color; color: $u-content-color;
border-color: $u-type-warning; border-color: #c0c4cc;
background-color: #ffffff; background-color: #ffffff;
} }
...@@ -478,10 +443,6 @@ export default { ...@@ -478,10 +443,6 @@ export default {
z-index: 1; z-index: 1;
} }
.u-bold-border {
border: 1px solid #ffffff;
}
.u-wave-ripple { .u-wave-ripple {
z-index: 0; z-index: 0;
position: absolute; position: absolute;
......
...@@ -135,7 +135,8 @@ export default { ...@@ -135,7 +135,8 @@ export default {
second: false, second: false,
province: true, province: true,
city: true, city: true,
area: true area: true,
timestamp: true,
}; };
} }
}, },
...@@ -546,6 +547,7 @@ export default { ...@@ -546,6 +547,7 @@ export default {
if (this.params.hour) result.hour = this.formatNumber(this.hour || 0); if (this.params.hour) result.hour = this.formatNumber(this.hour || 0);
if (this.params.minute) result.minute = this.formatNumber(this.minute || 0); if (this.params.minute) result.minute = this.formatNumber(this.minute || 0);
if (this.params.second) result.second = this.formatNumber(this.second || 0); if (this.params.second) result.second = this.formatNumber(this.second || 0);
if (this.params.timestamp) result.timestamp = this.getTimestamp();
} else if (this.mode == 'region') { } else if (this.mode == 'region') {
if (this.params.province) result.province = provinces[this.province]; if (this.params.province) result.province = provinces[this.province];
if (this.params.city) result.city = citys[this.province][this.city]; if (this.params.city) result.city = citys[this.province][this.city];
...@@ -557,6 +559,11 @@ export default { ...@@ -557,6 +559,11 @@ export default {
} }
if (event) this.$emit(event, result); if (event) this.$emit(event, result);
this.close(); this.close();
},
// 获取时间戳
getTimestamp() {
let time = this.year + '-' + this.month + '-' + this.day + ' ' + this.day + ':' + this.minute + ':' + this.second;
return new Date(time).getTime() / 1000;
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment