export const navToAsync = (url) => {
	return new Promise((resolve, reject) => {
		uni.navigateTo({
			url: url,
			success: res => {
				return true;
			},
			fail: err => {
				return false;
			}
		});
	});
}

export const navto = (url, replace = false) => {
	if (replace) {
		return uni.redirectTo({
			url: url
		});
	}
	return uni.navigateTo({
		url: url
	});
}



export const home = () => {
	return navto('/pages/index/index', true);
}



export const back = () => {
	return new Promise((resolve, reject) => {
		uni.navigateBack({
			success: res => {
				return true;
			},
			fail: err => {
				uni.reLaunch({
					url: '/pages/index/index',
				});
				return false;
			}
		});
	});

	// return uni.navigateBack();
}

export const login = () => {
	let url : String
	// #ifdef MP-WEIXIN
	url = '/pages/login/index'
	// #endif
	// #ifdef APP
	url = '/pages/login/index'
	// #endif
	uni.navigateTo({
		url: url,
	})
}

// 办件详情
export const goBJDetails = (id = null) => {
	if (id){
		navto('/pages/feedback/details?id=' + id)
	}else {
		navto('/pages/feedback/details')
	}
}