import { ref, watch } from 'vue'; import store from '@/store/index.js'; export function useNav() { const navTo = (path, token, call) => { uni.navigateTo({ url: path }) // if (token && !store.state.token) { // return uni.showModal({ // title: '提示', // content: '你还未登录,是否前往登录?', // success: function(res) { // if (res.confirm) { // uni.navigateTo({ // url: '/pages/login/login' // }) // } else if (res.cancel) { // console.log('用户点击取消'); // } // } // }); // } else { // uni.navigateTo({ // url: path // }) // } } const nav = (e) => { uni[e.type == 'nav' || !e.type ? 'navigateTo' : e.type == 'switchTab' ? 'switchTab' : 'navigateTo']({ url: e.path }) } return { nav, navTo } } export default useNav