| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | import {    getHeight} from "../../utils/GetRheRemainingHeight";Component({    properties: {        height: {            type: Number        }, //组件高度        getlist: {            type: Function        },        pullDown: { //是否开启下拉            type: Boolean,            value: true        },        safety: { //适配苹果底部安全距离            type: Boolean,            value: true        },        automatic: { //自动设置高度            type: Boolean,            value: true        },        scrollX: {            type: Boolean,            value: false        },        direction: {            type: Array,            value: ["bottom"]        }    },    lifetimes: {        attached: function () {            if (this.data.automatic) this.automaticSetHei()        },    },    data: {        inRefresh: false, //下拉开启自定义项    },    methods: {        /* 下拉刷新 */        pullToRefresh() {            this.setData({                inRefresh: true            })            this.triggerEvent("getlist", true)        },        /* 刷新完成 */        RefreshToComplete() {            setTimeout(() => {                this.setData({                    inRefresh: false                })            }, 500)        },        /* 加载分页 */        loadThePage(e) {            if (this.data.direction.includes(e.detail.direction)) this.triggerEvent("getlist", false)        },        automaticSetHei(mode, num) {            this.setHeight("#mylisttop", this, mode, num)        },        /* 设置组件高度 */        setHeight(element, that, mode, num) {            return new Promise((resolve) => {                getHeight(element, that).then(res => {                    let height = res;                    switch (mode) {                        case 'add':                            height = (res - 0) + (num - 0);                            break;                        case 'minus':                            height = res - num;                            break;                    }                    this.setData({                        height                    })                    resolve(height)                })            });        }    }})
 |