first commit
This commit is contained in:
54
hooks/useNav.js
Normal file
54
hooks/useNav.js
Normal file
@@ -0,0 +1,54 @@
|
||||
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
|
||||
Reference in New Issue
Block a user