为了兼容 easycom 模式,不和应用自身的 cXxx 组件冲突,把 cXxx 改名为 ucXxx
BIN
ucPager/img/left.png
Normal file
|
After Width: | Height: | Size: 777 B |
1
ucPager/img/left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582598922240" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5489" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M348.8 512L742.4 118.4c12.8-12.8 12.8-32 0-44.8s-32-12.8-44.8 0l-416 416c-12.8 12.8-12.8 32 0 44.8l416 416c6.4 6.4 16 9.6 22.4 9.6s16-3.2 22.4-9.6c12.8-12.8 12.8-32 0-44.8L348.8 512z" p-id="5490" fill="#1881EE"></path></svg>
|
||||
|
After Width: | Height: | Size: 599 B |
BIN
ucPager/img/leftend.png
Normal file
|
After Width: | Height: | Size: 985 B |
1
ucPager/img/leftend.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582598840797" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5117" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M320 896c19.2 0 32-12.8 32-32v-307.2l329.6 329.6c12.8 12.8 32 12.8 44.8 0s12.8-32 0-44.8L396.8 512 726.4 182.4c12.8-12.8 12.8-32 0-44.8-6.4-6.4-12.8-9.6-22.4-9.6s-16 3.2-22.4 9.6L352 467.2V160c0-19.2-12.8-32-32-32s-32 12.8-32 32v704c0 19.2 12.8 32 32 32z" p-id="5118" fill="#1881EE"></path></svg>
|
||||
|
After Width: | Height: | Size: 671 B |
BIN
ucPager/img/next.png
Normal file
|
After Width: | Height: | Size: 649 B |
1
ucPager/img/next.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582336139634" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5189" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M364.8 106.666667L298.666667 172.8 637.866667 512 298.666667 851.2l66.133333 66.133333L768 512z" fill="#2196F3" p-id="5190"></path></svg>
|
||||
|
After Width: | Height: | Size: 512 B |
BIN
ucPager/img/prev.png
Normal file
|
After Width: | Height: | Size: 702 B |
1
ucPager/img/prev.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582336133875" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5051" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M659.2 917.333333l66.133333-66.133333L386.133333 512 725.333333 172.8 659.2 106.666667 256 512z" fill="#2196F3" p-id="5052"></path></svg>
|
||||
|
After Width: | Height: | Size: 512 B |
BIN
ucPager/img/right.png
Normal file
|
After Width: | Height: | Size: 780 B |
1
ucPager/img/right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582598889722" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5303" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M742.4 489.6l-416-416c-12.8-12.8-32-12.8-44.8 0s-12.8 32 0 44.8L675.2 512 281.6 905.6c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 12.8 9.6 22.4 9.6s16-3.2 22.4-9.6l416-416c12.8-12.8 12.8-32 0-44.8z" p-id="5304" fill="#1881EE"></path></svg>
|
||||
|
After Width: | Height: | Size: 604 B |
BIN
ucPager/img/rightend.png
Normal file
|
After Width: | Height: | Size: 994 B |
1
ucPager/img/rightend.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582598822551" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4931" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M704 128c-19.2 0-32 12.8-32 32v307.2L342.4 137.6c-12.8-12.8-32-12.8-44.8 0s-12.8 32 0 44.8L627.2 512 297.6 841.6c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 12.8 9.6 22.4 9.6s16-3.2 22.4-9.6L672 556.8V864c0 19.2 12.8 32 32 32s32-12.8 32-32V160c0-19.2-12.8-32-32-32z" p-id="4932" fill="#1881EE"></path></svg>
|
||||
|
After Width: | Height: | Size: 672 B |
254
ucPager/ucPager.vue
Normal file
@@ -0,0 +1,254 @@
|
||||
<!--
|
||||
// based on Pagination 分页器组件: https://ext.dcloud.net.cn/plugin?id=32
|
||||
// 我修改过的版本,使用本地图标文件,不用 uni-icons。
|
||||
-->
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
leftText: {
|
||||
type: String,
|
||||
default: 'Prev'
|
||||
},
|
||||
rightText: {
|
||||
type: String,
|
||||
default: 'Next'
|
||||
},
|
||||
current: {
|
||||
type: [Number, String],
|
||||
default: 1
|
||||
},
|
||||
total: { // 数据总量
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
},
|
||||
pageSize: { // 每页数据量
|
||||
type: [Number, String],
|
||||
default: 10
|
||||
},
|
||||
showIcon: { // 是否以 icon 形式展示按钮
|
||||
type: [Boolean, String],
|
||||
default: true
|
||||
},
|
||||
showEdge: {
|
||||
type: [Boolean, String],
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentIndex: 1
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
maxPage() {
|
||||
let maxPage = 1
|
||||
let total = Number(this.total)
|
||||
let pageSize = Number(this.pageSize)
|
||||
if (total && pageSize) {
|
||||
maxPage = Math.ceil(total / pageSize)
|
||||
}
|
||||
return maxPage
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
current(val) {
|
||||
this.currentIndex = +val
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.currentIndex = +this.current
|
||||
},
|
||||
methods: {
|
||||
clickLeftEnd(){
|
||||
this.currentIndex = 1
|
||||
this.change('LEFT_END')
|
||||
},
|
||||
clickLeft() {
|
||||
if (Number(this.currentIndex) === 1) {
|
||||
return
|
||||
}
|
||||
this.currentIndex -= 1
|
||||
this.change('LEFT')
|
||||
},
|
||||
clickRight() {
|
||||
if (Number(this.currentIndex) === this.maxPage) {
|
||||
return
|
||||
}
|
||||
this.currentIndex += 1
|
||||
this.change('RIGHT')
|
||||
},
|
||||
clickRightEnd() {
|
||||
if (Number(this.currentIndex) === this.maxPage) {
|
||||
return
|
||||
}
|
||||
this.currentIndex = this.maxPage
|
||||
this.change('RIGHT_END')
|
||||
},
|
||||
change(e) {
|
||||
this.$emit('change', {
|
||||
type: e,
|
||||
current: this.currentIndex
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="uni-pagination">
|
||||
|
||||
<view class="uni-pagination__btns">
|
||||
<view v-if="(showEdge===true || showEdge==='true')" class="uni-pagination__btn" @click="clickLeftEnd"> <!-- always enabled so as to refresh -->
|
||||
<template v-if="showIcon===true || showIcon === 'true'">
|
||||
<view class="sLeftEndButton"></view>
|
||||
</template>
|
||||
<template v-else><text class="uni-pagination__child-btn">{{ leftEndText }}</text></template>
|
||||
</view>
|
||||
<view class="uni-pagination__btn" :class="currentIndex === 1 ? 'uni-pagination--disabled' : 'uni-pagination--enabled'"
|
||||
:hover-class="currentIndex === 1 ? '' : 'uni-pagination--hover'" :hover-start-time="20" :hover-stay-time="70"
|
||||
@click="clickLeft">
|
||||
<template v-if="showIcon===true || showIcon === 'true'">
|
||||
<view class="sLeftButton"></view>
|
||||
</template>
|
||||
<template v-else><text class="uni-pagination__child-btn">{{ leftText }}</text></template>
|
||||
</view>
|
||||
<view class="uni-pagination__btn" :class="currentIndex === maxPage ? 'uni-pagination--disabled' : 'uni-pagination--enabled'"
|
||||
:hover-class="currentIndex === maxPage ? '' : 'uni-pagination--hover'" :hover-start-time="20" :hover-stay-time="70"
|
||||
@click="clickRight">
|
||||
<template v-if="showIcon===true || showIcon === 'true'">
|
||||
<view class="sRightButton"></view>
|
||||
</template>
|
||||
<template v-else><text class="uni-pagination__child-btn">{{ rightText }}</text></template>
|
||||
</view>
|
||||
<view v-if="(showEdge===true || showEdge==='true')" class="uni-pagination__btn" :class="currentIndex === maxPage ? 'uni-pagination--disabled' : 'uni-pagination--enabled'"
|
||||
:hover-class="currentIndex === maxPage ? '' : 'uni-pagination--hover'" :hover-start-time="20" :hover-stay-time="70"
|
||||
@click="clickRightEnd">
|
||||
<template v-if="showIcon===true || showIcon === 'true'">
|
||||
<view class="sRightEndButton"></view>
|
||||
</template>
|
||||
<template v-else><text class="uni-pagination__child-btn">{{ rightEndText }}</text></template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-pagination__num">
|
||||
<view class="uni-pagination__num-current">
|
||||
<text class="uni-pagination__num-current-text" style="color:#007aff">{{ currentIndex }}</text><text class="uni-pagination__num-current-text">/{{ maxPage || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.uni-pagination {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
/* #ifdef APP-NVUE */
|
||||
padding: 0 20px;
|
||||
/* #endif */
|
||||
width: 400px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-pagination__btns {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex: 1;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.uni-pagination__btn {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
width: 60px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
font-size: $uni-font-size-base;
|
||||
position: relative;
|
||||
// background-color: $uni-bg-color-grey;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uni-pagination__child-btn {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
font-size: $uni-font-size-base;
|
||||
position: relative;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uni-pagination__num {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
position: absolute;
|
||||
margin: 0 auto;
|
||||
top: 0;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
font-size: $uni-font-size-base;
|
||||
color: $uni-text-color;
|
||||
}
|
||||
|
||||
.uni-pagination__num-current {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.uni-pagination__num-current-text {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.uni-pagination--enabled {
|
||||
color: #333333;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.uni-pagination--disabled {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.uni-pagination--hover {
|
||||
color: rgba(0, 0, 0, .6);
|
||||
background-color: $uni-bg-color-hover;
|
||||
}
|
||||
|
||||
.sLeftEndButton, .sLeftButton, .sRightButton, .sRightEndButton{
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: no-repeat center center / contain;
|
||||
}
|
||||
.sLeftEndButton{
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTgyNTk4ODQwNzk3IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjUxMTciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PC9zdHlsZT48L2RlZnM+PHBhdGggZD0iTTMyMCA4OTZjMTkuMiAwIDMyLTEyLjggMzItMzJ2LTMwNy4ybDMyOS42IDMyOS42YzEyLjggMTIuOCAzMiAxMi44IDQ0LjggMHMxMi44LTMyIDAtNDQuOE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UxMnoiIHAtaWQ9IjU0OTAiIGZpbGw9IiMxODgxRUUiPjwvcGF0aD48L3N2Zz4=')
|
||||
}
|
||||
.sRightButton{
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTgyNTk4ODg5NzIyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjUzMDMiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PC9zdHlsZT48L2RlZnM+PHBhdGggZD0iTTc0Mi40IDQ4OS42bC00MTYtNDE2Yy0xMi44LTEyLjgtMzItMTIuOC00NC44IDBzLTEyLjggMzIgMCA0NC44TDY3NS4yIDUxMiAyODEuNiA5MDUuNmMtMTIuOCAxMi44LTEyLjggMzIgMCA0NC44IDYuNCA2LjQgMTIuOCA5LjYgMjIuNCA5LjZzMTYtMy4yIDIyLjQtOS42bDQxNi00MTZjMTIuOC0xMi44IDEyLjgtMzIgMC00NC44eiIgcC1pZD0iNTMwNCIgZmlsbD0iIzE4ODFFRSI+PC9wYXRoPjwvc3ZnPg==')
|
||||
}
|
||||
.sRightEndButton{
|
||||
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcg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