|
@@ -0,0 +1,114 @@
|
|
|
+<template>
|
|
|
+ <view class="container">
|
|
|
+ <view id="mylisttop" />
|
|
|
+ <scroll-view class="scroll-view" scroll-y :refresher-enabled='pullDown' :refresher-triggered='inRefresh'
|
|
|
+ :style="{ height: height + 'px' }" :triggered='true' @refresherrefresh='pullToRefresh'
|
|
|
+ :scroll-into-view="scrollIntoView" :lower-threshold='300' :scroll-with-animation="true"
|
|
|
+ @scrolltolower='loadThePage'>
|
|
|
+ <view id="header">
|
|
|
+ <slot />
|
|
|
+ </view>
|
|
|
+ <view v-if="empty">
|
|
|
+ <view :style="{ height: tovw(occupyHeight) }" />
|
|
|
+ <u-empty :mode="mode" text="暂无数据" />
|
|
|
+ </view>
|
|
|
+ <view id="bottom" />
|
|
|
+ <view v-if="pagingText" class="paging">
|
|
|
+ {{ pagingText }}
|
|
|
+ </view>
|
|
|
+ </scroll-view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: 'My_listbox',
|
|
|
+ props: {
|
|
|
+ getlist: Function,
|
|
|
+ automatic: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ mode: {
|
|
|
+ type: String,
|
|
|
+ default: "data"
|
|
|
+ },
|
|
|
+ pullDown: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ occupyHeight: {
|
|
|
+ type: Number,
|
|
|
+ default: 50
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ inRefresh: false, //下拉开启自定义项
|
|
|
+ height: 0,
|
|
|
+ scrollIntoView: "",
|
|
|
+ pagingText: "",
|
|
|
+ empty: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (this.automatic) this.setHeight()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 下拉刷新 */
|
|
|
+ pullToRefresh() {
|
|
|
+ this.inRefresh = true
|
|
|
+ this.$emit("getlist", true)
|
|
|
+ },
|
|
|
+ /* 刷新完成 */
|
|
|
+ RefreshToComplete() {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.inRefresh = false
|
|
|
+ }, 500)
|
|
|
+ },
|
|
|
+ /* 加载分页 */
|
|
|
+ loadThePage() {
|
|
|
+ this.$emit("getlist", false)
|
|
|
+ },
|
|
|
+ /* 设置组件高度 */
|
|
|
+ setHeight(mode, num) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.getHeight("#mylisttop", this).then(res => {
|
|
|
+ let height = res;
|
|
|
+ switch (mode) {
|
|
|
+ case 'add':
|
|
|
+ height = (res - 0) + (num - 0);
|
|
|
+ break;
|
|
|
+ case 'minus':
|
|
|
+ height = res - num;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (this.height != height) this.height = height;
|
|
|
+ resolve(height)
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 分页 */
|
|
|
+ paging(content, res) {
|
|
|
+ content.pageNumber = res.pageNumber;
|
|
|
+ content.pageTotal = res.pageTotal;
|
|
|
+ this.pagingText = content.pageNumber + ' / ' + content.pageTotal;
|
|
|
+ this.empty = res.total == 0;
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.scroll-view {
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .paging {
|
|
|
+ width: 100vw;
|
|
|
+ text-align: center;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 15px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|