@kengic/uni 0.3.2-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-pagination">
|
|
3
|
+
<!-- #ifndef MP -->
|
|
4
|
+
<picker v-if="showPageSize === true || showPageSize === 'true'" class="select-picker" mode="selector"
|
|
5
|
+
:value="pageSizeIndex" :range="pageSizeRange" @change="pickerChange" @cancel="pickerClick"
|
|
6
|
+
@click.native="pickerClick">
|
|
7
|
+
<button type="default" size="mini" :plain="true">
|
|
8
|
+
<text>{{pageSizeRange[pageSizeIndex]}} {{piecePerPage}}</text>
|
|
9
|
+
<uni-icons class="select-picker-icon" type="arrowdown" size="12" color="#999"></uni-icons>
|
|
10
|
+
</button>
|
|
11
|
+
</picker>
|
|
12
|
+
<!-- #endif -->
|
|
13
|
+
<!-- #ifndef APP-NVUE -->
|
|
14
|
+
<view class="uni-pagination__total is-phone-hide">共 {{ total }} 条</view>
|
|
15
|
+
<!-- #endif -->
|
|
16
|
+
<view class="uni-pagination__btn"
|
|
17
|
+
:class="currentIndex === 1 ? 'uni-pagination--disabled' : 'uni-pagination--enabled'"
|
|
18
|
+
:hover-class="currentIndex === 1 ? '' : 'uni-pagination--hover'" :hover-start-time="20"
|
|
19
|
+
:hover-stay-time="70" @click="clickLeft">
|
|
20
|
+
<template v-if="showIcon === true || showIcon === 'true'">
|
|
21
|
+
<uni-icons color="#666" size="16" type="left" />
|
|
22
|
+
</template>
|
|
23
|
+
<template v-else>
|
|
24
|
+
<text class="uni-pagination__child-btn">{{ prevPageText }}</text>
|
|
25
|
+
</template>
|
|
26
|
+
</view>
|
|
27
|
+
<view class="uni-pagination__num uni-pagination__num-flex-none">
|
|
28
|
+
<view class="uni-pagination__num-current">
|
|
29
|
+
<text class="uni-pagination__num-current-text is-pc-hide current-index-text">{{ currentIndex }}</text>
|
|
30
|
+
<text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text>
|
|
31
|
+
<!-- #ifndef APP-NVUE -->
|
|
32
|
+
<view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }"
|
|
33
|
+
class="uni-pagination__num-tag tag--active is-phone-hide" @click.top="selectPage(item, index)">
|
|
34
|
+
<text>{{ item }}</text>
|
|
35
|
+
</view>
|
|
36
|
+
<!-- #endif -->
|
|
37
|
+
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
<view class="uni-pagination__btn"
|
|
41
|
+
:class="currentIndex >= maxPage ? 'uni-pagination--disabled' : 'uni-pagination--enabled'"
|
|
42
|
+
:hover-class="currentIndex === maxPage ? '' : 'uni-pagination--hover'" :hover-start-time="20"
|
|
43
|
+
:hover-stay-time="70" @click="clickRight">
|
|
44
|
+
<template v-if="showIcon === true || showIcon === 'true'">
|
|
45
|
+
<uni-icons color="#666" size="16" type="right" />
|
|
46
|
+
</template>
|
|
47
|
+
<template v-else>
|
|
48
|
+
<text class="uni-pagination__child-btn">{{ nextPageText }}</text>
|
|
49
|
+
</template>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
/**
|
|
56
|
+
* Pagination 分页器
|
|
57
|
+
* @description 分页器组件,用于展示页码、请求数据等
|
|
58
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=32
|
|
59
|
+
* @property {String} prevText 左侧按钮文字
|
|
60
|
+
* @property {String} nextText 右侧按钮文字
|
|
61
|
+
* @property {String} piecePerPageText 条/页文字
|
|
62
|
+
* @property {Number} current 当前页
|
|
63
|
+
* @property {Number} total 数据总量
|
|
64
|
+
* @property {Number} pageSize 每页数据量
|
|
65
|
+
* @property {Boolean} showIcon = [true|false] 是否以 icon 形式展示按钮
|
|
66
|
+
* @property {Boolean} showPageSize = [true|false] 是否展示每页条数
|
|
67
|
+
* @property {Array} pageSizeRange = [20, 50, 100, 500] 每页条数选框
|
|
68
|
+
* @event {Function} change 点击页码按钮时触发 ,e={type,current} current为当前页,type值为:next/prev,表示点击的是上一页还是下一个
|
|
69
|
+
* * @event {Function} pageSizeChange 当前每页条数改变时触发 ,e={pageSize} pageSize 为当前所选的每页条数
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
import {
|
|
73
|
+
initVueI18n
|
|
74
|
+
} from '@dcloudio/uni-i18n'
|
|
75
|
+
import messages from './i18n'
|
|
76
|
+
const {
|
|
77
|
+
t
|
|
78
|
+
} = initVueI18n(messages)
|
|
79
|
+
export default {
|
|
80
|
+
name: 'UniPagination',
|
|
81
|
+
emits: ['update:modelValue', 'input', 'change', 'pageSizeChange'],
|
|
82
|
+
props: {
|
|
83
|
+
value: {
|
|
84
|
+
type: [Number, String],
|
|
85
|
+
default: 1
|
|
86
|
+
},
|
|
87
|
+
modelValue: {
|
|
88
|
+
type: [Number, String],
|
|
89
|
+
default: 1
|
|
90
|
+
},
|
|
91
|
+
prevText: {
|
|
92
|
+
type: String,
|
|
93
|
+
},
|
|
94
|
+
nextText: {
|
|
95
|
+
type: String,
|
|
96
|
+
},
|
|
97
|
+
piecePerPageText: {
|
|
98
|
+
type: String
|
|
99
|
+
},
|
|
100
|
+
current: {
|
|
101
|
+
type: [Number, String],
|
|
102
|
+
default: 1
|
|
103
|
+
},
|
|
104
|
+
total: {
|
|
105
|
+
// 数据总量
|
|
106
|
+
type: [Number, String],
|
|
107
|
+
default: 0
|
|
108
|
+
},
|
|
109
|
+
pageSize: {
|
|
110
|
+
// 每页数据量
|
|
111
|
+
type: [Number, String],
|
|
112
|
+
default: 10
|
|
113
|
+
},
|
|
114
|
+
showIcon: {
|
|
115
|
+
// 是否以 icon 形式展示按钮
|
|
116
|
+
type: [Boolean, String],
|
|
117
|
+
default: false
|
|
118
|
+
},
|
|
119
|
+
showPageSize: {
|
|
120
|
+
// 是否以 icon 形式展示按钮
|
|
121
|
+
type: [Boolean, String],
|
|
122
|
+
default: false
|
|
123
|
+
},
|
|
124
|
+
pagerCount: {
|
|
125
|
+
type: Number,
|
|
126
|
+
default: 7
|
|
127
|
+
},
|
|
128
|
+
pageSizeRange: {
|
|
129
|
+
type: Array,
|
|
130
|
+
default: () => [20, 50, 100, 500]
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
data() {
|
|
134
|
+
return {
|
|
135
|
+
pageSizeIndex: 0,
|
|
136
|
+
currentIndex: 1,
|
|
137
|
+
paperData: [],
|
|
138
|
+
pickerShow: false
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
computed: {
|
|
142
|
+
piecePerPage() {
|
|
143
|
+
return this.piecePerPageText || t('uni-pagination.piecePerPage')
|
|
144
|
+
},
|
|
145
|
+
prevPageText() {
|
|
146
|
+
return this.prevText || t('uni-pagination.prevText')
|
|
147
|
+
},
|
|
148
|
+
nextPageText() {
|
|
149
|
+
return this.nextText || t('uni-pagination.nextText')
|
|
150
|
+
},
|
|
151
|
+
maxPage() {
|
|
152
|
+
let maxPage = 1
|
|
153
|
+
let total = Number(this.total)
|
|
154
|
+
let pageSize = Number(this.pageSize)
|
|
155
|
+
if (total && pageSize) {
|
|
156
|
+
maxPage = Math.ceil(total / pageSize)
|
|
157
|
+
}
|
|
158
|
+
return maxPage
|
|
159
|
+
},
|
|
160
|
+
paper() {
|
|
161
|
+
const num = this.currentIndex
|
|
162
|
+
// TODO 最大页数
|
|
163
|
+
const pagerCount = this.pagerCount
|
|
164
|
+
// const total = 181
|
|
165
|
+
const total = this.total
|
|
166
|
+
const pageSize = this.pageSize
|
|
167
|
+
let totalArr = []
|
|
168
|
+
let showPagerArr = []
|
|
169
|
+
let pagerNum = Math.ceil(total / pageSize)
|
|
170
|
+
for (let i = 0; i < pagerNum; i++) {
|
|
171
|
+
totalArr.push(i + 1)
|
|
172
|
+
}
|
|
173
|
+
showPagerArr.push(1)
|
|
174
|
+
const totalNum = totalArr[totalArr.length - (pagerCount + 1) / 2]
|
|
175
|
+
totalArr.forEach((item, index) => {
|
|
176
|
+
if ((pagerCount + 1) / 2 >= num) {
|
|
177
|
+
if (item < pagerCount + 1 && item > 1) {
|
|
178
|
+
showPagerArr.push(item)
|
|
179
|
+
}
|
|
180
|
+
} else if (num + 2 <= totalNum) {
|
|
181
|
+
if (item > num - (pagerCount + 1) / 2 && item < num + (pagerCount + 1) / 2) {
|
|
182
|
+
showPagerArr.push(item)
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
if ((item > num - (pagerCount + 1) / 2 || pagerNum - pagerCount < item) && item < totalArr[
|
|
186
|
+
totalArr.length - 1]) {
|
|
187
|
+
showPagerArr.push(item)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
if (pagerNum > pagerCount) {
|
|
192
|
+
if ((pagerCount + 1) / 2 >= num) {
|
|
193
|
+
showPagerArr[showPagerArr.length - 1] = '...'
|
|
194
|
+
} else if (num + 2 <= totalNum) {
|
|
195
|
+
showPagerArr[1] = '...'
|
|
196
|
+
showPagerArr[showPagerArr.length - 1] = '...'
|
|
197
|
+
} else {
|
|
198
|
+
showPagerArr[1] = '...'
|
|
199
|
+
}
|
|
200
|
+
showPagerArr.push(totalArr[totalArr.length - 1])
|
|
201
|
+
} else {
|
|
202
|
+
if ((pagerCount + 1) / 2 >= num) {} else if (num + 2 <= totalNum) {} else {
|
|
203
|
+
showPagerArr.shift()
|
|
204
|
+
showPagerArr.push(totalArr[totalArr.length - 1])
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return showPagerArr
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
watch: {
|
|
212
|
+
current: {
|
|
213
|
+
immediate: true,
|
|
214
|
+
handler(val, old) {
|
|
215
|
+
if (val < 1) {
|
|
216
|
+
this.currentIndex = 1
|
|
217
|
+
} else {
|
|
218
|
+
this.currentIndex = val
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
value: {
|
|
223
|
+
immediate: true,
|
|
224
|
+
handler(val) {
|
|
225
|
+
if (Number(this.current) !== 1) return
|
|
226
|
+
if (val < 1) {
|
|
227
|
+
this.currentIndex = 1
|
|
228
|
+
} else {
|
|
229
|
+
this.currentIndex = val
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
pageSizeIndex(val) {
|
|
234
|
+
this.$emit('pageSizeChange', this.pageSizeRange[val])
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
methods: {
|
|
238
|
+
pickerChange(e) {
|
|
239
|
+
this.pageSizeIndex = e.detail.value
|
|
240
|
+
this.pickerClick()
|
|
241
|
+
},
|
|
242
|
+
pickerClick() {
|
|
243
|
+
// #ifdef H5
|
|
244
|
+
const body = document.querySelector('body')
|
|
245
|
+
if (!body) return
|
|
246
|
+
|
|
247
|
+
const className = 'uni-pagination-picker-show'
|
|
248
|
+
this.pickerShow = !this.pickerShow
|
|
249
|
+
|
|
250
|
+
if (this.pickerShow) {
|
|
251
|
+
body.classList.add(className)
|
|
252
|
+
} else {
|
|
253
|
+
setTimeout(() => body.classList.remove(className), 300)
|
|
254
|
+
}
|
|
255
|
+
// #endif
|
|
256
|
+
},
|
|
257
|
+
// 选择标签
|
|
258
|
+
selectPage(e, index) {
|
|
259
|
+
if (parseInt(e)) {
|
|
260
|
+
this.currentIndex = e
|
|
261
|
+
this.change('current')
|
|
262
|
+
} else {
|
|
263
|
+
let pagerNum = Math.ceil(this.total / this.pageSize)
|
|
264
|
+
// let pagerNum = Math.ceil(181 / this.pageSize)
|
|
265
|
+
// 上一页
|
|
266
|
+
if (index <= 1) {
|
|
267
|
+
if (this.currentIndex - 5 > 1) {
|
|
268
|
+
this.currentIndex -= 5
|
|
269
|
+
} else {
|
|
270
|
+
this.currentIndex = 1
|
|
271
|
+
}
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
// 下一页
|
|
275
|
+
if (index >= 6) {
|
|
276
|
+
if (this.currentIndex + 5 > pagerNum) {
|
|
277
|
+
this.currentIndex = pagerNum
|
|
278
|
+
} else {
|
|
279
|
+
this.currentIndex += 5
|
|
280
|
+
}
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
clickLeft() {
|
|
286
|
+
if (Number(this.currentIndex) === 1) {
|
|
287
|
+
return
|
|
288
|
+
}
|
|
289
|
+
this.currentIndex -= 1
|
|
290
|
+
this.change('prev')
|
|
291
|
+
},
|
|
292
|
+
clickRight() {
|
|
293
|
+
if (Number(this.currentIndex) >= this.maxPage) {
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
this.currentIndex += 1
|
|
297
|
+
this.change('next')
|
|
298
|
+
},
|
|
299
|
+
change(e) {
|
|
300
|
+
this.$emit('input', this.currentIndex)
|
|
301
|
+
this.$emit('update:modelValue', this.currentIndex)
|
|
302
|
+
this.$emit('change', {
|
|
303
|
+
type: e,
|
|
304
|
+
current: this.currentIndex
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
</script>
|
|
310
|
+
|
|
311
|
+
<style lang="scss" scoped>
|
|
312
|
+
$uni-primary: #2979ff !default;
|
|
313
|
+
.uni-pagination {
|
|
314
|
+
/* #ifndef APP-NVUE */
|
|
315
|
+
display: flex;
|
|
316
|
+
/* #endif */
|
|
317
|
+
position: relative;
|
|
318
|
+
overflow: hidden;
|
|
319
|
+
flex-direction: row;
|
|
320
|
+
justify-content: center;
|
|
321
|
+
align-items: center;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.uni-pagination__total {
|
|
325
|
+
font-size: 14px;
|
|
326
|
+
color: #999;
|
|
327
|
+
margin-right: 15px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.uni-pagination__btn {
|
|
331
|
+
/* #ifndef APP-NVUE */
|
|
332
|
+
display: flex;
|
|
333
|
+
cursor: pointer;
|
|
334
|
+
/* #endif */
|
|
335
|
+
padding: 0 8px;
|
|
336
|
+
line-height: 30px;
|
|
337
|
+
font-size: 12px;
|
|
338
|
+
position: relative;
|
|
339
|
+
background-color: #F0F0F0;
|
|
340
|
+
flex-direction: row;
|
|
341
|
+
justify-content: center;
|
|
342
|
+
align-items: center;
|
|
343
|
+
text-align: center;
|
|
344
|
+
border-radius: 5px;
|
|
345
|
+
// border-width: 1px;
|
|
346
|
+
// border-style: solid;
|
|
347
|
+
// border-color: $uni-border-color;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.uni-pagination__child-btn {
|
|
351
|
+
/* #ifndef APP-NVUE */
|
|
352
|
+
display: flex;
|
|
353
|
+
/* #endif */
|
|
354
|
+
font-size: 12px;
|
|
355
|
+
position: relative;
|
|
356
|
+
flex-direction: row;
|
|
357
|
+
justify-content: center;
|
|
358
|
+
align-items: center;
|
|
359
|
+
text-align: center;
|
|
360
|
+
color: #666;
|
|
361
|
+
font-size: 12px;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.uni-pagination__num {
|
|
365
|
+
/* #ifndef APP-NVUE */
|
|
366
|
+
display: flex;
|
|
367
|
+
/* #endif */
|
|
368
|
+
flex: 1;
|
|
369
|
+
flex-direction: row;
|
|
370
|
+
justify-content: center;
|
|
371
|
+
align-items: center;
|
|
372
|
+
height: 30px;
|
|
373
|
+
line-height: 30px;
|
|
374
|
+
font-size: 12px;
|
|
375
|
+
color: #666;
|
|
376
|
+
margin: 0 5px;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.uni-pagination__num-tag {
|
|
380
|
+
/* #ifdef H5 */
|
|
381
|
+
cursor: pointer;
|
|
382
|
+
min-width: 30px;
|
|
383
|
+
/* #endif */
|
|
384
|
+
margin: 0 5px;
|
|
385
|
+
height: 30px;
|
|
386
|
+
text-align: center;
|
|
387
|
+
line-height: 30px;
|
|
388
|
+
// border: 1px red solid;
|
|
389
|
+
color: #999;
|
|
390
|
+
border-radius: 4px;
|
|
391
|
+
// border-width: 1px;
|
|
392
|
+
// border-style: solid;
|
|
393
|
+
// border-color: $uni-border-color;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.uni-pagination__num-current {
|
|
397
|
+
/* #ifndef APP-NVUE */
|
|
398
|
+
display: flex;
|
|
399
|
+
/* #endif */
|
|
400
|
+
flex-direction: row;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.uni-pagination__num-current-text {
|
|
404
|
+
font-size: 15px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.current-index-text{
|
|
408
|
+
color: $uni-primary;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.uni-pagination--enabled {
|
|
412
|
+
color: #333333;
|
|
413
|
+
opacity: 1;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.uni-pagination--disabled {
|
|
417
|
+
opacity: 0.5;
|
|
418
|
+
/* #ifdef H5 */
|
|
419
|
+
cursor: default;
|
|
420
|
+
/* #endif */
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.uni-pagination--hover {
|
|
424
|
+
color: rgba(0, 0, 0, 0.6);
|
|
425
|
+
background-color: #eee;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.tag--active:hover {
|
|
429
|
+
color: $uni-primary;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.page--active {
|
|
433
|
+
color: #fff;
|
|
434
|
+
background-color: $uni-primary;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.page--active:hover {
|
|
438
|
+
color: #fff;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* #ifndef APP-NVUE */
|
|
442
|
+
.is-pc-hide {
|
|
443
|
+
display: block;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.is-phone-hide {
|
|
447
|
+
display: none;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@media screen and (min-width: 450px) {
|
|
451
|
+
.is-pc-hide {
|
|
452
|
+
display: none;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.is-phone-hide {
|
|
456
|
+
display: block;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.uni-pagination__num-flex-none {
|
|
460
|
+
flex: none;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/* #endif */
|
|
465
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// #ifdef H5
|
|
2
|
+
export default {
|
|
3
|
+
name: 'Keypress',
|
|
4
|
+
props: {
|
|
5
|
+
disable: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
mounted() {
|
|
11
|
+
const keyNames = {
|
|
12
|
+
esc: ['Esc', 'Escape'],
|
|
13
|
+
tab: 'Tab',
|
|
14
|
+
enter: 'Enter',
|
|
15
|
+
space: [' ', 'Spacebar'],
|
|
16
|
+
up: ['Up', 'ArrowUp'],
|
|
17
|
+
left: ['Left', 'ArrowLeft'],
|
|
18
|
+
right: ['Right', 'ArrowRight'],
|
|
19
|
+
down: ['Down', 'ArrowDown'],
|
|
20
|
+
delete: ['Backspace', 'Delete', 'Del'],
|
|
21
|
+
};
|
|
22
|
+
const listener = ($event) => {
|
|
23
|
+
if (this.disable) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const keyName = Object.keys(keyNames).find((key) => {
|
|
27
|
+
const keyName = $event.key;
|
|
28
|
+
const value = keyNames[key];
|
|
29
|
+
return value === keyName || (Array.isArray(value) && value.includes(keyName));
|
|
30
|
+
});
|
|
31
|
+
if (keyName) {
|
|
32
|
+
// 避免和其他按键事件冲突
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.$emit(keyName, {});
|
|
35
|
+
}, 0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
document.addEventListener('keyup', listener);
|
|
39
|
+
// this.$once('hook:beforeDestroy', () => {
|
|
40
|
+
// document.removeEventListener('keyup', listener)
|
|
41
|
+
// })
|
|
42
|
+
},
|
|
43
|
+
render: () => {},
|
|
44
|
+
};
|
|
45
|
+
// #endif
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {};
|
|
4
|
+
},
|
|
5
|
+
created() {
|
|
6
|
+
this.popup = this.getParent();
|
|
7
|
+
},
|
|
8
|
+
methods: {
|
|
9
|
+
/**
|
|
10
|
+
* 获取父元素实例
|
|
11
|
+
*/
|
|
12
|
+
getParent(name = 'uniPopup') {
|
|
13
|
+
let parent = this.$parent;
|
|
14
|
+
let parentName = parent.$options.name;
|
|
15
|
+
while (parentName !== name) {
|
|
16
|
+
parent = parent.$parent;
|
|
17
|
+
if (!parent) return false;
|
|
18
|
+
parentName = parent.$options.name;
|
|
19
|
+
}
|
|
20
|
+
return parent;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|