/**
 * 做兼容相关的函数集文件
 */

/**
 * 阻止事件冒泡
 */
export const _stopPropagation = (e) => {
	// window.event ? window.event.cancelBubble = true : e.stopPropagation();
	if(window&&window.event){
		window.event.cancelBubble = true
	}else{
		e.stopPropagation();
	}
}

/* 
   在需要回退刷新的页面配置ifFromChildPage
 */
export const _goBackFresh = (pathName,bool)=>{
	const pages = getCurrentPages();
	const reversed = pages.reverse();
	const currentPageIndex = 0;
	console.log({reversed,pages});

	if(true){
		pages.some((item,index)=>{
			  // console.log('循环');
			  // console.log({item});
			  if(item.route == pathName){
				  let needdelta =index-currentPageIndex;
				  // console.log({needdelta,index,currentPageIndex});
				  //通知返回目标页面刷新数据
				  item.ifFromChildPage=true;
				  uni.navigateBack({
				      delta: needdelta
				  });
				  return true;
			  }
		});
	}

}
