Files
dajiankang-uniapp/hooks/useNav.js
PC-202306242200\Administrator 1c24452b6c first commit
2026-03-28 23:10:55 +08:00

54 lines
920 B
JavaScript

import {
ref,
watch
} from 'vue';
import {
Store
} from '@/store';
const store = Store();
export function useNav() {
const navTo = (path, token, call) => {
if (call) {
uni.makePhoneCall({
phoneNumber: '17707569278'
});
return
}
const Authorization = uni.getStorageSync('Authorization') || ''
if (token && !Authorization) {
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