import {
	getCurrentInstance,
} from 'vue';
export function getElRect(elClass, dataVal) {
	const instance = getCurrentInstance();
	return new Promise((resolve, reject) => {
		const query = uni.createSelectorQuery().in(instance.proxy);
		query.select('.' + elClass).fields({
			size: true
		}, res => {
			// 如果节点尚未生成，res值为null，循环调用执行
			if (!res) {
				setTimeout(() => {
					getElRect(elClass);
				}, 10);
				return;
			}
			resolve(res);
		}).exec();
	})
}

export async function getSafeBottomHeight(className, height = 16) {
	const bottomEle = await getElRect(className)
	return bottomEle.height + height
}