<template>
<view
class="u-load-more-wrap"
:style="{
backgroundColor: bgColor,
marginBottom: marginBottom + 'rpx',
marginTop: marginTop + 'rpx',
height: $u.addUnit(height)
}"
>
<view
:class="status == 'loadmore' || status == 'nomore' ? 'u-more' : ''"
class="u-load-more-inner"
>
<u-loading
class="u-loadmore-icon"
:color="iconColor"
:mode="iconType == 'circle' ? 'circle' : 'flower'"
:show="status == 'loading' && icon"
></u-loading>
<view
:style="[loadTextStyle]"
:class="[(status == 'nomore' && isDot == true) ? 'u-dot-text' : 'u-more-text']"
@tap="loadMore"
>{{ showText }}</view>
</view>
</view>
</template>
<script>
export default {
name: 'u-loadmore',
props: {
bgColor: {
type: String,
default: '#ffffff'
},
icon: {
type: Boolean,
default: true
},
fontSize: {
type: String,
default: '14'
},
color: {
type: String,
default: '#606266'
},
status: {
type: String,
default: 'loadmore'
},
iconType: {
type: String,
default: 'circle'
},
loadText: {
type: Object,
default() {
return {
loadmore: '加载更多',
loading: '正在加载...',
nomore: '没有更多了'
}
}
},
isDot: {
type: Boolean,
default: false
},
iconColor: {
type: String,
default: '#b7b7b7'
},
marginTop: {
type: [String, Number],
default: 0
},
marginBottom: {
type: [String, Number],
default: 0
},
height: {
type: [String, Number],
default: 'auto'
}
},
data() {
return {
dotText: '●'
}
},
computed: {
loadTextStyle() {
return {
color: this.color,
fontSize: this.fontSize + 'rpx',
position: 'relative',
zIndex: 1,
backgroundColor: this.bgColor,
padding: this.status == 'loading' ? '0 8px' : '0 12px'
}
},
cricleStyle() {
return {
borderColor: `#e5e5e5 #e5e5e5 #e5e5e5 ${this.circleColor}`
}
},
flowerStyle() {
return {}
},
showText() {
let text = ''
if (this.status == 'loadmore') text = this.loadText.loadmore
else if (this.status == 'loading') text = this.loadText.loading
else if (this.status == 'nomore' && this.isDot) text = this.dotText
else text = this.loadText.nomore
return text
}
},
methods: {
loadMore() {
if (this.status == 'loadmore') this.$emit('loadmore')
}
}
}
</script>
<style scoped lang="scss">
@import '../../libs/css/style.components.scss';
.u-load-more-wrap {
width: 100%;
display: flex;
justify-content: center;
}
.u-load-more-inner {
display: flex;
justify-content: center;
align-items: center;
}
.u-more {
width: 60%;
position: relative;
display: flex;
justify-content: center;
}
.u-more::before {
content: ' ';
position: absolute;
border-bottom: 1px solid #d4d4d4;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
width: 100%;
top: 50%;
left: 0;
}
.u-dot-text {
font-size: 14rpx;
}
.u-loadmore-icon {
display: flex;
align-items: center;
justify-content: center;
}
</style>