import { ref, watch } from 'vue'; export function useNav() { const nav = (e) => { if (e.call) { uni.makePhoneCall({ phoneNumber: '4008005326' //仅为示例 }); return } if (!uni.getStorageSync('token')) { uni.showModal({ title: '提示', content: '为提供更好的服务,请前往登录', success: (res) => { if (res.confirm) { uni.navigateTo({ url: '/pages/login/login' }) } else if (res.cancel) { console.log('用户点击取消'); } } }) return } uni[e.type == 'nav' || !e.type ? 'navigateTo' : e.type == 'switchTab' ? 'switchTab' : 'navigateTo']({ url: e.path }) } const navTo = (path, token, call) => { if (!uni.getStorageSync('token')) { uni.showModal({ title: '提示', content: '为提供更好的服务,请前往登录', success: (res) => { if (res.confirm) { uni.navigateTo({ url: '/pages/login/login' }) } else if (res.cancel) { console.log('用户点击取消'); } } }) return } uni.navigateTo({ url: path }) } return { nav, navTo } } export default useNav