Commit 0d653570 authored by wlxuqu's avatar wlxuqu

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

2. 修复form表单综合演示中,switch没有垂直居中的问题
parent c2f3c8da
......@@ -65,7 +65,8 @@ export default {
second: true,
province: true,
city: true,
area: true
area: true,
timestamp: true
}
};
},
......@@ -115,6 +116,7 @@ export default {
this.show = true;
},
confirm(e) {
console.log(e);
this.input = '';
if (this.mode == 'time') {
if (this.params.year) this.input += e.year;
......
......@@ -14,7 +14,7 @@
:percent="item.progress"></u-line-progress>
</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">
<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>
......@@ -140,9 +140,6 @@
// console.log('onListChange', lists);
this.lists = lists;
},
beforeUpload(index, lists) {
return true;
}
}
}
</script>
......
<template>
<view class="wrap">
<u-swiper :list="list"></u-swiper>
</view>
<u-upload :before-upload="beforeUpload"></u-upload>
</template>
<script>
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: {
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>
......
......@@ -4,3 +4,4 @@
* uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用
*/
@import 'uview-ui/theme.scss';
......@@ -7,7 +7,7 @@
plain ? 'u-btn--' + type + '--plain' : '',
loading ? 'u-loading' : '',
shape == 'circle' ? 'u-round-circle' : '',
hairLine ? showHairLineBorder : 'u-bold-border',
hairLine ? showHairLineBorder : 'u-btn--bold-border',
'u-btn--' + type,
disabled ? `u-btn--${type}--disabled` : '',
......@@ -28,7 +28,7 @@
@error="error"
@opensetting="opensetting"
@launchapp="launchapp"
:style="[buttonStyle]"
:style="[customStyle]"
@tap.stop="click($event)"
:hover-class="getHoverClass"
:loading="loading"
......@@ -209,45 +209,6 @@ export default {
hoverClass = this.plain ? 'u-' + this.type + '-plain-hover' : 'u-' + this.type + '-hover';
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'类型下,不显示边框,否则会造成四角有毛刺现象
showHairLineBorder() {
if (['primary', 'success', 'error', 'warning'].indexOf(this.type) >= 0 && !this.plain) {
......@@ -374,9 +335,13 @@ export default {
box-sizing: border-box;
transition: all 0.15s;
&--bold-border {
border: 1px solid #ffffff;
}
&--default {
color: $u-content-color;
border-color: $u-type-warning;
border-color: #c0c4cc;
background-color: #ffffff;
}
......@@ -478,10 +443,6 @@ export default {
z-index: 1;
}
.u-bold-border {
border: 1px solid #ffffff;
}
.u-wave-ripple {
z-index: 0;
position: absolute;
......
......@@ -135,7 +135,8 @@ export default {
second: false,
province: true,
city: true,
area: true
area: true,
timestamp: true,
};
}
},
......@@ -546,6 +547,7 @@ export default {
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.second) result.second = this.formatNumber(this.second || 0);
if (this.params.timestamp) result.timestamp = this.getTimestamp();
} else if (this.mode == 'region') {
if (this.params.province) result.province = provinces[this.province];
if (this.params.city) result.city = citys[this.province][this.city];
......@@ -557,6 +559,11 @@ export default {
}
if (event) this.$emit(event, result);
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