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