WebApp【公共组件库】@前端(For Git Submodule)
‘chensiAb’
2025-03-26 7c51280f1cf4b796f9215133b2f99b397cf5325c
plugins/infiniteScroll/CInfiniteScroll.vue
@@ -5,14 +5,15 @@
<template>
    <scroll-view
        :id="elmId"
        class="c-infinite-scroll"
        :scrollY="true"
        lowerThreshold="100"
        @scroll="evt=>onScroll(evt)"
        @touchstart="evt=>onTouch(evt)"
        @touchmove="evt=>onTouch(evt)"
        @touchend="evt=>onTouch(evt)"
        @scrollToLower="evt=>onScrollToLower(evt)"
        lowerThreshold="100"
    >
        <view
            class="c-infinite-top"
@@ -53,14 +54,16 @@
                <text
                    class="c-infinite-empty"
                    v-else
                >暂无数据...</text>
                >(暂无数据)</text>
            </view>
        </view>
    </scroll-view>
</template>
<script>
import Taro from '@tarojs/taro';
import { AtActivityIndicator } from 'taro-ui-vue';
import { Tools } from '@components/common/Tools';
import './cInfiniteScroll.scss';
export default {
@@ -85,6 +88,7 @@
    },
    data() {
        return {
            elmId: 'cis-' + Tools.createGUID(),
            // 初始化状态
            inital: false,
            // 当前页面
@@ -137,6 +141,7 @@
                            // 没有数据
                            if (!options.pageTotal || options.pageTotal <= 0) {
                                this.ending = true;
                                this.pageTotal = 0;
                            }
                            // 有数据
                            else {
@@ -159,6 +164,8 @@
                    // 加载失败
                    fail: () => {
                        this.loading = false;
                        this.ending = true;
                        this.pageTotal = 0;
                        // 如果下拉刷新,还原下拉
                        if (this.touch.dargState === 2) {
                            this.touch.driftTop = 0;
@@ -295,10 +302,18 @@
            this.hanldeLoadMore();
        },
        // 刷新加载
        $refresh() {
        $refresh(autoStart) {
            Taro.pageScrollTo({
                selector: '#' + this.elmId,
                scrollTop: 0,
            });
            this.ending = false;
            this.current = 0;
            this.hanldeLoadMore();
            if (autoStart === 'off') {
                this.inital = false;
            } else {
                this.hanldeLoadMore();
            }
        },
    },
    mounted() {