From accaf01dabdf317e67b7f24c13c81c1023d51cd4 Mon Sep 17 00:00:00 2001 From: qingyiay <2386314947@qq.com> Date: 星期四, 23 三月 2023 16:49:50 +0800 Subject: [PATCH] 首页增加历史提煤单 --- api/publicInterface.js | 2 pages/login/userPassword.vue | 2 uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue | 465 +++++++++++++++++++++++++++++++ uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hant.json | 5 uni_modules/uni-pagination/package.json | 83 +++++ pages/customer-page/customer-index/customer-index.vue | 65 ++++ uni_modules/uni-pagination/components/uni-pagination/i18n/en.json | 5 uni_modules/uni-pagination/components/uni-pagination/i18n/es.json | 5 uni_modules/uni-pagination/components/uni-pagination/i18n/fr.json | 5 api/globalApi.js | 9 api/request.js | 4 manifest.json | 146 ++++---- uni_modules/uni-pagination/components/uni-pagination/i18n/index.js | 12 uni_modules/uni-pagination/changelog.md | 27 + pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue | 10 uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hans.json | 5 uni_modules/uni-pagination/readme.md | 11 17 files changed, 775 insertions(+), 86 deletions(-) diff --git a/api/globalApi.js b/api/globalApi.js index 0cc3752..badd8ce 100644 --- a/api/globalApi.js +++ b/api/globalApi.js @@ -36,7 +36,7 @@ // method: "POST" // }, /** - * @杞彂淇敼 + * @description 杞彂淇敼 */ forward: { url: "/wrzs/userOperation/forwardList", @@ -56,6 +56,13 @@ url: "/wrzs/userOperation/deleteForward", method: "POST" }, + /** + * @description 鑾峰彇鍘嗗彶鎻愮叅鍗� + */ + getJhOrderPlanDataPage: { + url: '/wrzs/userOperation/getJhOrderPlanDataPage', + method: "GET" + }, // 璐т唬棣栭〉鍒楄〃 // huoDaiList: { // url: "/wrzs/wx/huoDaiList", diff --git a/api/publicInterface.js b/api/publicInterface.js index bba27cf..c295cff 100644 --- a/api/publicInterface.js +++ b/api/publicInterface.js @@ -4,7 +4,7 @@ // const BaseUrl = "http://192.168.3.159:9999/"; import {BaseUrl as wrBaseUrl} from '@/api/request.js' // const BaseUrl = "http://192.168.0.120:9999" -const BaseUrl = "http://192.168.3.109:9999" +const BaseUrl = "http://192.168.110.101:9999" // 鐧诲綍 // function apiLogin({ diff --git a/api/request.js b/api/request.js index ed6e018..1912f06 100644 --- a/api/request.js +++ b/api/request.js @@ -80,8 +80,8 @@ // const BaseUrl = "http://192.168.0.120:9997" // const webSocketUrl = "ws://192.168.0.120:9997/wrzs/ws/info" -const BaseUrl = "http://192.168.3.109:9997"; -const webSocketUrl = "ws://192.168.3.109:9997/wrzs/ws/info" +const BaseUrl = "http://192.168.110.101:9997"; +const webSocketUrl = "ws://192.168.110.101:9997/wrzs/ws/info" // 璇锋眰鎷︽埅 const fetch = (url, opt) => { diff --git a/manifest.json b/manifest.json index c97e162..3570baa 100644 --- a/manifest.json +++ b/manifest.json @@ -1,75 +1,75 @@ { - "name" : "unattended-app", - "appid" : "__UNI__103882A", - "description" : "", - "versionName" : "1.0.0", - "versionCode" : "100", - "transformPx" : false, - /* 5+App鐗规湁鐩稿叧 */ - "app-plus" : { - "usingComponents" : true, - "nvueStyleCompiler" : "uni-app", - "compilerVersion" : 3, - "splashscreen" : { - "alwaysShowBeforeRender" : true, - "waiting" : true, - "autoclose" : true, - "delay" : 0 - }, - /* 妯″潡閰嶇疆 */ - "modules" : {}, - /* 搴旂敤鍙戝竷淇℃伅 */ - "distribute" : { - /* android鎵撳寘閰嶇疆 */ - "android" : { - "permissions" : [ - "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", - "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", - "<uses-permission android:name=\"android.permission.VIBRATE\"/>", - "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", - "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", - "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", - "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", - "<uses-permission android:name=\"android.permission.CAMERA\"/>", - "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", - "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", - "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", - "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", - "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", - "<uses-feature android:name=\"android.hardware.camera\"/>", - "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" - ] - }, - /* ios鎵撳寘閰嶇疆 */ - "ios" : {}, - /* SDK閰嶇疆 */ - "sdkConfigs" : {} - } - }, - /* 蹇簲鐢ㄧ壒鏈夌浉鍏� */ - "quickapp" : {}, - /* 灏忕▼搴忕壒鏈夌浉鍏� */ - "mp-weixin" : { - "appid" : "wx4a62fc1684c429a9", - "setting" : { - "urlCheck" : false, - "es6" : true, - "minified" : true, - "postcss" : false - }, - "usingComponents" : true - }, - "mp-alipay" : { - "usingComponents" : true - }, - "mp-baidu" : { - "usingComponents" : true - }, - "mp-toutiao" : { - "usingComponents" : true - }, - "uniStatistics" : { - "enable" : false - }, - "vueVersion" : "2" + "name": "unattended-app", + "appid": "__UNI__103882A", + "description": "", + "versionName": "1.0.0", + "versionCode": "100", + "transformPx": false, + /* 5+App鐗规湁鐩稿叧 */ + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + /* 妯″潡閰嶇疆 */ + "modules": {}, + /* 搴旂敤鍙戝竷淇℃伅 */ + "distribute": { + /* android鎵撳寘閰嶇疆 */ + "android": { + "permissions": [ + "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", + "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", + "<uses-permission android:name=\"android.permission.VIBRATE\"/>", + "<uses-permission android:name=\"android.permission.READ_LOGS\"/>", + "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", + "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", + "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", + "<uses-permission android:name=\"android.permission.CAMERA\"/>", + "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", + "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", + "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", + "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", + "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", + "<uses-feature android:name=\"android.hardware.camera\"/>", + "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" + ] + }, + /* ios鎵撳寘閰嶇疆 */ + "ios": {}, + /* SDK閰嶇疆 */ + "sdkConfigs": {} + } + }, + /* 蹇簲鐢ㄧ壒鏈夌浉鍏� */ + "quickapp": {}, + /* 灏忕▼搴忕壒鏈夌浉鍏� */ + "mp-weixin": { + "appid": "wx2463f9b1ba3b9651", + "setting": { + "urlCheck": false, + "es6": true, + "minified": true, + "postcss": false + }, + "usingComponents": true + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "uniStatistics": { + "enable": false + }, + "vueVersion": "2" } diff --git a/pages/customer-page/customer-index/customer-index.vue b/pages/customer-page/customer-index/customer-index.vue index 7afe7a7..d35997e 100644 --- a/pages/customer-page/customer-index/customer-index.vue +++ b/pages/customer-page/customer-index/customer-index.vue @@ -46,7 +46,32 @@ </template> </card> </view> - + <view class="history-numbers"> + <combined-title title="鍘嗗彶鎻愮叅鍗�"></combined-title> + <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y"> + <uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁" :loading="loading"> + <uni-tr> + <uni-th width="100" align="center">鍙戣繍鏃ユ湡</uni-th> + <uni-th width="100" align="center">鎵�灞炲崟浣�</uni-th> + <uni-th align="center" width="150">鐓ゅ満鍚嶇О</uni-th> + <uni-th align="center" width="100">鐓ょ鍚嶇О</uni-th> + <uni-th align="center" width="150">璁㈠崟缂栧彿</uni-th> + <uni-th align="center" width="100">璁㈠崟鍓╀綑閲�</uni-th> + <uni-th align="center" width="80">鎻愮叅鍗曚釜鏁�</uni-th> + </uni-tr> + <uni-tr v-for="(item, index) in historyCoalData" :key="index"> + <uni-td align="center">{{ item.sendDate }}</uni-td> + <uni-td align="left">{{ item.deptName }}</uni-td> + <uni-td align="center">{{ item.filedName }}</uni-td> + <uni-td align="center">{{ item.coalName }}</uni-td> + <uni-td align="center">{{ item.orderCode }}</uni-td> + <uni-td align="center">{{ item.carNumSurplus }}</uni-td> + <uni-td align="center">{{ item.tmCount }}</uni-td> + </uni-tr> + </uni-table> + </scroll-view> + <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="change2" /></view> + </view> <!-- 棰嗗彇寮瑰嚭妗� --> <u-popup :show="show" @close="close" @open="open" mode="center" round="10"> <view class="receiverPopup"> @@ -60,10 +85,12 @@ <script> import card from '@/components/card/card.vue'; +import combinedTitle from '@/components/combined-title/combined-title.vue'; import { customerId } from '@/utils/status'; export default { components: { - card + card, + combinedTitle }, data() { return { @@ -73,15 +100,27 @@ getOrderNum: { num: '', id: null - } + }, + historyCoalData: [], + // 琛ㄦ牸鍔犺浇鐘舵�� + loading: false, + scrollTop: 0, + // 姣忛〉鏁版嵁閲� + pageSize: 5, + // 褰撳墠椤� + pageCurrent: 1, + // 鏁版嵁鎬婚噺 + total: 0 }; }, + onLoad() {}, onShow() { this.init(); }, methods: { init() { this.GetOrderPlan(); + this.getJhOrderPlanDataPage(); }, // 鑾峰彇鍙戣繍璁″垝鍒楄〃 GetOrderPlan() { @@ -92,6 +131,20 @@ this.orderPlanData = res.data; uni.hideLoading(); }); + }, + // 鑾峰彇鍘嗗彶鎻愮叅鍗� + getJhOrderPlanDataPage() { + this.loading = true; + this.$reqGet('getJhOrderPlanDataPage', { current: this.pageCurrent, size: this.pageSize }).then(res => { + this.historyCoalData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + change2(e) { + console.log(e, '椤电爜鏀瑰彉'); + this.pageCurrent = e.current; + this.getJhOrderPlanDataPage(); }, popupDetermineClick() { if (this.receiveNum) { @@ -161,6 +214,12 @@ </script> <style lang="scss" scoped> +.uni-pagination-box { + height: 60rpx; +} +.scroll-Y { + height: 600rpx; +} ::v-deep.customer-index { width: 94%; margin: 0 auto; diff --git a/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue b/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue index 06b9046..18699c5 100644 --- a/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue +++ b/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue @@ -14,17 +14,17 @@ <view class="right-top"> <view class="card-right-top-row"> <view> - <text>杞彂鍓╀綑锛歿{ item.carNumSurplusHuodai||'' }}</text> + <text>杞彂鍓╀綑锛歿{ item.carNumSurplusHuodai || '' }}</text> </view> <view> - <text>{{ item.coalName||'' }}</text> + <text>{{ item.coalName || '' }}</text> </view> </view> </view> </template> <template v-slot:right-bottom> <view class="code"> - <text>缂栧彿锛歿{ item.orderCode||'' }}</text> + <text>缂栧彿锛歿{ item.orderCode || '' }}</text> </view> </template> </card> @@ -64,7 +64,7 @@ // 杞彂 forwardClick(value) { uni.navigateTo({ - url: `/pages/public-page/forward/forward?orderPlanId=${value.id}&carNumSurplusHuodai=${value.carNumSurplusHuodai}` + url: `/pages/public-page/forward/forward?orderPlanId=${value.orderPlanId}&carNumSurplusHuodai=${value.carNumSurplusHuodai}` }); } } @@ -81,7 +81,7 @@ // 鍗$墖鏍峰紡 .card-left__top { - margin-top:vww(26); + margin-top: vww(26); text-align: center; color: #ffffff; text { diff --git a/pages/login/userPassword.vue b/pages/login/userPassword.vue index 053900f..8886b53 100644 --- a/pages/login/userPassword.vue +++ b/pages/login/userPassword.vue @@ -44,7 +44,7 @@ data() { return { // username: '12222222222', // 瀹㈡埛 - username: '13333333332', // 鍙告満 + username: '13333333332',// 鍙告満 password: '123456', remember: true, baseUrl: '' diff --git a/uni_modules/uni-pagination/changelog.md b/uni_modules/uni-pagination/changelog.md new file mode 100644 index 0000000..2e94adc --- /dev/null +++ b/uni_modules/uni-pagination/changelog.md @@ -0,0 +1,27 @@ +## 1.2.4锛�2022-09-19锛� +- 淇锛屾湭瀵逛富棰樿壊璁剧疆榛樿鑹诧紝瀵艰嚧鏈紩鍏� uni-scss 鍙橀噺鏂囦欢鎶ラ敊銆� +- 淇锛屾湭瀵圭Щ鍔ㄧ褰撳墠椤垫枃瀛楀仛涓婚鑹查�傞厤銆� +## 1.2.3锛�2022-09-15锛� +- 淇鏈娇鐢� uni-scss 涓婚鑹茬殑 bug銆� +## 1.2.2锛�2022-07-06锛� +- 淇 es 璇█ i18n 閿欒 +## 1.2.1锛�2021-11-22锛� +- 淇 vue3涓煇浜泂css鍙橀噺鏃犳硶鎵惧埌鐨勯棶棰� +## 1.2.0锛�2021-11-19锛� +- 浼樺寲 缁勪欢UI锛屽苟鎻愪緵璁捐璧勬簮锛岃瑙�:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 鏂囨。杩佺Щ锛岃瑙�:[https://uniapp.dcloud.io/component/uniui/uni-pagination](https://uniapp.dcloud.io/component/uniui/uni-pagination) +## 1.1.2锛�2021-10-08锛� +- 淇 current 銆乿alue 灞炴�ф湭鐩戝惉锛屽鑷撮珮浜牱寮忓け鏁堢殑 bug +## 1.1.1锛�2021-08-20锛� +- 鏂板 鏀寔鍥介檯鍖� +## 1.1.0锛�2021-07-30锛� +- 缁勪欢鍏煎 vue3锛屽浣曞垱寤簐ue3椤圭洰锛岃瑙� [uni-app 椤圭洰鏀寔 vue3 浠嬬粛](https://ask.dcloud.net.cn/article/37834) +## 1.0.7锛�2021-05-12锛� +- 鏂板 缁勪欢绀轰緥鍦板潃 +## 1.0.6锛�2021-04-12锛� +- 鏂板 PC 鍜� 绉诲姩绔�傞厤涓嶅悓鐨� ui +## 1.0.5锛�2021-02-05锛� +- 浼樺寲 缁勪欢寮曠敤鍏崇郴锛岄�氳繃uni_modules寮曠敤缁勪欢 + +## 1.0.4锛�2021-02-05锛� +- 璋冩暣涓簎ni_modules鐩綍瑙勮寖 diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/en.json b/uni_modules/uni-pagination/components/uni-pagination/i18n/en.json new file mode 100644 index 0000000..d6e2897 --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/en.json @@ -0,0 +1,5 @@ +{ + "uni-pagination.prevText": "prev", + "uni-pagination.nextText": "next", + "uni-pagination.piecePerPage": "piece/page" +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/es.json b/uni_modules/uni-pagination/components/uni-pagination/i18n/es.json new file mode 100644 index 0000000..604a113 --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/es.json @@ -0,0 +1,5 @@ +{ + "uni-pagination.prevText": "anterior", + "uni-pagination.nextText": "prxima", + "uni-pagination.piecePerPage": "Artículo/Página" +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/fr.json b/uni_modules/uni-pagination/components/uni-pagination/i18n/fr.json new file mode 100644 index 0000000..a7a0c77 --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/fr.json @@ -0,0 +1,5 @@ +{ + "uni-pagination.prevText": "pr茅c茅dente", + "uni-pagination.nextText": "suivante", + "uni-pagination.piecePerPage": "Articles/Pages" +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/index.js b/uni_modules/uni-pagination/components/uni-pagination/i18n/index.js new file mode 100644 index 0000000..2469dd0 --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/index.js @@ -0,0 +1,12 @@ +import en from './en.json' +import es from './es.json' +import fr from './fr.json' +import zhHans from './zh-Hans.json' +import zhHant from './zh-Hant.json' +export default { + en, + es, + fr, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hans.json b/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hans.json new file mode 100644 index 0000000..782bbe4 --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hans.json @@ -0,0 +1,5 @@ +{ + "uni-pagination.prevText": "涓婁竴椤�", + "uni-pagination.nextText": "涓嬩竴椤�", + "uni-pagination.piecePerPage": "鏉�/椤�" +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hant.json b/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hant.json new file mode 100644 index 0000000..180fddb --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/i18n/zh-Hant.json @@ -0,0 +1,5 @@ +{ + "uni-pagination.prevText": "涓婁竴闋�", + "uni-pagination.nextText": "涓嬩竴闋�", + "uni-pagination.piecePerPage": "姊�/闋�" +} diff --git a/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue b/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue new file mode 100644 index 0000000..5305b5f --- /dev/null +++ b/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue @@ -0,0 +1,465 @@ +<template> + <view class="uni-pagination"> + <!-- #ifndef MP --> + <picker v-if="showPageSize === true || showPageSize === 'true'" class="select-picker" mode="selector" + :value="pageSizeIndex" :range="pageSizeRange" @change="pickerChange" @cancel="pickerClick" + @click.native="pickerClick"> + <button type="default" size="mini" :plain="true"> + <text>{{pageSizeRange[pageSizeIndex]}} {{piecePerPage}}</text> + <uni-icons class="select-picker-icon" type="arrowdown" size="12" color="#999"></uni-icons> + </button> + </picker> + <!-- #endif --> + <!-- #ifndef APP-NVUE --> + <view class="uni-pagination__total is-phone-hide">鍏� {{ total }} 鏉�</view> + <!-- #endif --> + <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'"> + <uni-icons color="#666" size="16" type="left" /> + </template> + <template v-else> + <text class="uni-pagination__child-btn">{{ prevPageText }}</text> + </template> + </view> + <view class="uni-pagination__num uni-pagination__num-flex-none"> + <view class="uni-pagination__num-current"> + <text class="uni-pagination__num-current-text is-pc-hide current-index-text">{{ currentIndex }}</text> + <text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text> + <!-- #ifndef APP-NVUE --> + <view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }" + class="uni-pagination__num-tag tag--active is-phone-hide" @click.top="selectPage(item, index)"> + <text>{{ item }}</text> + </view> + <!-- #endif --> + + </view> + </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'"> + <uni-icons color="#666" size="16" type="right" /> + </template> + <template v-else> + <text class="uni-pagination__child-btn">{{ nextPageText }}</text> + </template> + </view> + </view> +</template> + +<script> + /** + * Pagination 鍒嗛〉鍣� + * @description 鍒嗛〉鍣ㄧ粍浠讹紝鐢ㄤ簬灞曠ず椤电爜銆佽姹傛暟鎹瓑 + * @tutorial https://ext.dcloud.net.cn/plugin?id=32 + * @property {String} prevText 宸︿晶鎸夐挳鏂囧瓧 + * @property {String} nextText 鍙充晶鎸夐挳鏂囧瓧 + * @property {String} piecePerPageText 鏉�/椤垫枃瀛� + * @property {Number} current 褰撳墠椤� + * @property {Number} total 鏁版嵁鎬婚噺 + * @property {Number} pageSize 姣忛〉鏁版嵁閲� + * @property {Boolean} showIcon = [true|false] 鏄惁浠� icon 褰㈠紡灞曠ず鎸夐挳 + * @property {Boolean} showPageSize = [true|false] 鏄惁灞曠ず姣忛〉鏉℃暟 + * @property {Array} pageSizeRange = [20, 50, 100, 500] 姣忛〉鏉℃暟閫夋 + * @event {Function} change 鐐瑰嚮椤电爜鎸夐挳鏃惰Е鍙� ,e={type,current} current涓哄綋鍓嶉〉锛宼ype鍊间负锛歯ext/prev锛岃〃绀虹偣鍑荤殑鏄笂涓�椤佃繕鏄笅涓�涓� + * * @event {Function} pageSizeChange 褰撳墠姣忛〉鏉℃暟鏀瑰彉鏃惰Е鍙� ,e={pageSize} pageSize 涓哄綋鍓嶆墍閫夌殑姣忛〉鏉℃暟 + */ + + import { + initVueI18n + } from '@dcloudio/uni-i18n' + import messages from './i18n/index.js' + const { + t + } = initVueI18n(messages) + export default { + name: 'UniPagination', + emits: ['update:modelValue', 'input', 'change', 'pageSizeChange'], + props: { + value: { + type: [Number, String], + default: 1 + }, + modelValue: { + type: [Number, String], + default: 1 + }, + prevText: { + type: String, + }, + nextText: { + type: String, + }, + piecePerPageText: { + type: String + }, + current: { + type: [Number, String], + default: 1 + }, + total: { + // 鏁版嵁鎬婚噺 + type: [Number, String], + default: 0 + }, + pageSize: { + // 姣忛〉鏁版嵁閲� + type: [Number, String], + default: 10 + }, + showIcon: { + // 鏄惁浠� icon 褰㈠紡灞曠ず鎸夐挳 + type: [Boolean, String], + default: false + }, + showPageSize: { + // 鏄惁浠� icon 褰㈠紡灞曠ず鎸夐挳 + type: [Boolean, String], + default: false + }, + pagerCount: { + type: Number, + default: 7 + }, + pageSizeRange: { + type: Array, + default: () => [20, 50, 100, 500] + } + }, + data() { + return { + pageSizeIndex: 0, + currentIndex: 1, + paperData: [], + pickerShow: false + } + }, + computed: { + piecePerPage() { + return this.piecePerPageText || t('uni-pagination.piecePerPage') + }, + prevPageText() { + return this.prevText || t('uni-pagination.prevText') + }, + nextPageText() { + return this.nextText || t('uni-pagination.nextText') + }, + maxPage() { + let maxPage = 1 + let total = Number(this.total) + let pageSize = Number(this.pageSize) + if (total && pageSize) { + maxPage = Math.ceil(total / pageSize) + } + return maxPage + }, + paper() { + const num = this.currentIndex + // TODO 鏈�澶ч〉鏁� + const pagerCount = this.pagerCount + // const total = 181 + const total = this.total + const pageSize = this.pageSize + let totalArr = [] + let showPagerArr = [] + let pagerNum = Math.ceil(total / pageSize) + for (let i = 0; i < pagerNum; i++) { + totalArr.push(i + 1) + } + showPagerArr.push(1) + const totalNum = totalArr[totalArr.length - (pagerCount + 1) / 2] + totalArr.forEach((item, index) => { + if ((pagerCount + 1) / 2 >= num) { + if (item < pagerCount + 1 && item > 1) { + showPagerArr.push(item) + } + } else if (num + 2 <= totalNum) { + if (item > num - (pagerCount + 1) / 2 && item < num + (pagerCount + 1) / 2) { + showPagerArr.push(item) + } + } else { + if ((item > num - (pagerCount + 1) / 2 || pagerNum - pagerCount < item) && item < totalArr[ + totalArr.length - 1]) { + showPagerArr.push(item) + } + } + }) + if (pagerNum > pagerCount) { + if ((pagerCount + 1) / 2 >= num) { + showPagerArr[showPagerArr.length - 1] = '...' + } else if (num + 2 <= totalNum) { + showPagerArr[1] = '...' + showPagerArr[showPagerArr.length - 1] = '...' + } else { + showPagerArr[1] = '...' + } + showPagerArr.push(totalArr[totalArr.length - 1]) + } else { + if ((pagerCount + 1) / 2 >= num) {} else if (num + 2 <= totalNum) {} else { + showPagerArr.shift() + showPagerArr.push(totalArr[totalArr.length - 1]) + } + } + + return showPagerArr + } + }, + watch: { + current: { + immediate: true, + handler(val, old) { + if (val < 1) { + this.currentIndex = 1 + } else { + this.currentIndex = val + } + } + }, + value: { + immediate: true, + handler(val) { + if (Number(this.current) !== 1) return + if (val < 1) { + this.currentIndex = 1 + } else { + this.currentIndex = val + } + } + }, + pageSizeIndex(val) { + this.$emit('pageSizeChange', this.pageSizeRange[val]) + } + }, + methods: { + pickerChange(e) { + this.pageSizeIndex = e.detail.value + this.pickerClick() + }, + pickerClick() { + // #ifdef H5 + const body = document.querySelector('body') + if (!body) return + + const className = 'uni-pagination-picker-show' + this.pickerShow = !this.pickerShow + + if (this.pickerShow) { + body.classList.add(className) + } else { + setTimeout(() => body.classList.remove(className), 300) + } + // #endif + }, + // 閫夋嫨鏍囩 + selectPage(e, index) { + if (parseInt(e)) { + this.currentIndex = e + this.change('current') + } else { + let pagerNum = Math.ceil(this.total / this.pageSize) + // let pagerNum = Math.ceil(181 / this.pageSize) + // 涓婁竴椤� + if (index <= 1) { + if (this.currentIndex - 5 > 1) { + this.currentIndex -= 5 + } else { + this.currentIndex = 1 + } + return + } + // 涓嬩竴椤� + if (index >= 6) { + if (this.currentIndex + 5 > pagerNum) { + this.currentIndex = pagerNum + } else { + this.currentIndex += 5 + } + return + } + } + }, + clickLeft() { + if (Number(this.currentIndex) === 1) { + return + } + this.currentIndex -= 1 + this.change('prev') + }, + clickRight() { + if (Number(this.currentIndex) >= this.maxPage) { + return + } + this.currentIndex += 1 + this.change('next') + }, + change(e) { + this.$emit('input', this.currentIndex) + this.$emit('update:modelValue', this.currentIndex) + this.$emit('change', { + type: e, + current: this.currentIndex + }) + } + } + } +</script> + +<style lang="scss" scoped> + $uni-primary: #2979ff !default; + .uni-pagination { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + position: relative; + overflow: hidden; + flex-direction: row; + justify-content: center; + align-items: center; + } + + .uni-pagination__total { + font-size: 14px; + color: #999; + margin-right: 15px; + } + + .uni-pagination__btn { + /* #ifndef APP-NVUE */ + display: flex; + cursor: pointer; + /* #endif */ + padding: 0 8px; + line-height: 30px; + font-size: 12px; + position: relative; + background-color: #F0F0F0; + flex-direction: row; + justify-content: center; + align-items: center; + text-align: center; + border-radius: 5px; + // border-width: 1px; + // border-style: solid; + // border-color: $uni-border-color; + } + + .uni-pagination__child-btn { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + font-size: 12px; + position: relative; + flex-direction: row; + justify-content: center; + align-items: center; + text-align: center; + color: #666; + font-size: 12px; + } + + .uni-pagination__num { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + flex: 1; + flex-direction: row; + justify-content: center; + align-items: center; + height: 30px; + line-height: 30px; + font-size: 12px; + color: #666; + margin: 0 5px; + } + + .uni-pagination__num-tag { + /* #ifdef H5 */ + cursor: pointer; + min-width: 30px; + /* #endif */ + margin: 0 5px; + height: 30px; + text-align: center; + line-height: 30px; + // border: 1px red solid; + color: #999; + border-radius: 4px; + // border-width: 1px; + // border-style: solid; + // border-color: $uni-border-color; + } + + .uni-pagination__num-current { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + flex-direction: row; + } + + .uni-pagination__num-current-text { + font-size: 15px; + } + + .current-index-text{ + color: $uni-primary; + } + + .uni-pagination--enabled { + color: #333333; + opacity: 1; + } + + .uni-pagination--disabled { + opacity: 0.5; + /* #ifdef H5 */ + cursor: default; + /* #endif */ + } + + .uni-pagination--hover { + color: rgba(0, 0, 0, 0.6); + background-color: #eee; + } + + .tag--active:hover { + color: $uni-primary; + } + + .page--active { + color: #fff; + background-color: $uni-primary; + } + + .page--active:hover { + color: #fff; + } + + /* #ifndef APP-NVUE */ + .is-pc-hide { + display: block; + } + + .is-phone-hide { + display: none; + } + + @media screen and (min-width: 450px) { + .is-pc-hide { + display: none; + } + + .is-phone-hide { + display: block; + } + + .uni-pagination__num-flex-none { + flex: none; + } + } + + /* #endif */ +</style> diff --git a/uni_modules/uni-pagination/package.json b/uni_modules/uni-pagination/package.json new file mode 100644 index 0000000..862d5ab --- /dev/null +++ b/uni_modules/uni-pagination/package.json @@ -0,0 +1,83 @@ +{ + "id": "uni-pagination", + "displayName": "uni-pagination 鍒嗛〉鍣�", + "version": "1.2.4", + "description": "Pagination 鍒嗛〉鍣ㄧ粍浠讹紝鐢ㄤ簬灞曠ず椤电爜銆佽姹傛暟鎹瓑銆�", + "keywords": [ + "uni-ui", + "uniui", + "鍒嗛〉鍣�", + "椤电爜" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "鏃�", + "data": "鏃�", + "permissions": "鏃�" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": ["uni-scss","uni-icons"], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "寰俊娴忚鍣�(Android)": "y", + "QQ娴忚鍣�(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "灏忕▼搴�": { + "寰俊": "y", + "闃块噷": "y", + "鐧惧害": "y", + "瀛楄妭璺冲姩": "y", + "QQ": "y" + }, + "蹇簲鐢�": { + "鍗庝负": "u", + "鑱旂洘": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-pagination/readme.md b/uni_modules/uni-pagination/readme.md new file mode 100644 index 0000000..97ea1d6 --- /dev/null +++ b/uni_modules/uni-pagination/readme.md @@ -0,0 +1,11 @@ + + +## Pagination 鍒嗛〉鍣� +> **缁勪欢鍚嶏細uni-pagination** +> 浠g爜鍧楋細 `uPagination` + + +鍒嗛〉鍣ㄧ粍浠讹紝鐢ㄤ簬灞曠ず椤电爜銆佽姹傛暟鎹瓑銆� + +### [鏌ョ湅鏂囨。](https://uniapp.dcloud.io/component/uniui/uni-pagination) +#### 濡備娇鐢ㄨ繃绋嬩腑鏈変换浣曢棶棰橈紝鎴栬�呮偍瀵箄ni-ui鏈変竴浜涘ソ鐨勫缓璁紝娆㈣繋鍔犲叆 uni-ui 浜ゆ祦缇わ細871950839 -- Gitblit v1.9.1