// import config from "./config"
// import store from "@/store/index.js"

import config from "./config.js"
export const setToken = (tokenVal) => {
	try {
		uni.setStorageSync(config.tokenKey, tokenVal);
	} catch (e) {
		// error
	}
}


export const getToken = () => {
	try {
		const value = uni.getStorageSync(config.tokenKey);
		return value || ''
	} catch (e) {
		// error
	}
}

// 判断是否登录
export const ifLogin_ = () => {
	return new Promise((resolve, reject) => {
		if (getToken()) {
			resolve()
		} else {
			uni.navigateTo({
				url: '/pages/login/index'
			});

			reject()
		};
	})
};



export const reverseBack = () => {
	const pages = getCurrentPages()
	if (pages.length <= 1) {
		uni.reLaunch({
			url: '/pages/index/index'
		});
	} else {
		uni.navigateBack({
			delta: 1,
			fail: err => {}
		})
	}
}
