
/**
 *  @des 获取头部高度
 *  @return {Object} {} 获取手机头部高度
 */
export function getHeaderHeight() {
	// 获取手机信息
	let sysinfo = uni.getSystemInfoSync(),
		// 状态栏高度
		statusBarHeight = sysinfo.statusBarHeight,
		// 判断是否是ios
		isiOS = sysinfo.system.indexOf("iOS") > -1,
		headHeight;

	// 标题栏高度：安卓：48px，iOS：44px
	if (!isiOS) {
		headHeight = 48;
	} else {
		headHeight = 44;
	}

	return {
		statusBarHeight,
		headHeight,
		headAllHeight: statusBarHeight + headHeight,
	};
}

/**
 * @des 设置状态栏高度和标题高度
 */
export function setHeaderHeight() {
	let heightObj = getHeaderHeight();

	uni.setStorageSync("statusBarHeight", heightObj.statusBarHeight);
	uni.setStorageSync("headHeight", heightObj.headHeight);
	uni.setStorageSync("headAllHeight", heightObj.headAllHeight);
}

/**
 * @des 获取当前路由
 */
export function getCurPage() {
	let pages = getCurrentPages();
	let curPage = pages[pages.length - 1];
	return curPage;
}

/**
 * @des 获取当前平台
 */
export function getOrigin() {
	let origin = "";

	// #ifdef APP-PLUS
	origin = "APP_PLUS";
	// #endif
	// #ifdef H5
	origin = "H5";
	// #endif
	// #ifdef MP-WEIXIN
	origin = "MP_WEIXIN";
	// #endif
	// #ifdef MP-ALIPAY
	origin = "MP_ALIPAY";
	// #endif
	return origin;
}

/**
 * @des 获取tabbar索引
 */
// export function getTabbarIndex() {
//   const routes = getCurrentPages(),
//     last = routes[routes.length - 1],
//     index = tabbar.indexOf(last.route);

//   return index;
// }