@kengic/uni 0.5.1 → 0.5.2-beta.1

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