Files
PC-202306242200\Administrator f529129c93 first commit
2026-03-31 10:53:43 +08:00

73 lines
1.3 KiB
JavaScript

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 relTo = (path, token, call) => {
uni.reLaunch({
url: 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,
relTo
}
}
export default useNav