import { ref } from "vue";
import { onPageScroll } from "@dcloudio/uni-app";

/**
 * listPage页面公共方法
 *
 * @param options
 */
export function usePages(type) {
	const NavBgColor = ref('transparent');
	const NavTitleStyle = ref()



	const initData = () => {
		switch (type) {
			case 1:
				NavTitleStyle.value = {
					color: '#fff'
				};
				NavBgColor.value = 'transparent';
				break;
			default:
				NavBgColor.value = 'transparent';
		}
	}
	onPageScroll((e) => {
		const { scrollTop } = e;
		if (scrollTop > 50) {
			console.log()
			switch (type) {
				case 1:
					NavTitleStyle.value = {};
					NavBgColor.value = "#fff";
					break;
				default:
					NavBgColor.value = "#fff";
			}
		} else {
			initData()
		}
	})


	initData()

	return { NavBgColor, NavTitleStyle }
}