You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB
JavaScript

import {
$url
} from '@/api/index.js'
import {
getToken
} from './token.js'
const actionPathChange = (path) => {
path = path.split('[URL]').join($url)
const hospital_id = uni.getStorageSync('HOSPITAL_ID')
path = path.split('[HOSPITAL]').join(hospital_id)
const token = getToken()
path = path.split('[TOKEN]').join(token)
return path
}
const switch_tab_arr = [
'/pages/main/user/user',
'/pages/main/home/home',
'/pages/main/order/order',
'/pages/main/combo/combo',
]
const jump = (info) => {
if (info.login_type === 1) {
let token = getToken() ? getToken() : '';
if (token === '') return uni.$lu.toast("请登录")
}
const path = actionPathChange(info.jump_path)
switch (info.jump_type) {
case 2:
if (switch_tab_arr.indexOf(path) !== -1) {
uni.switchTab({
url: path
})
} else {
uni.navigateTo({
url: path
})
}
break;
case 3:
uni.navigateTo({
url: '/pages/main/h5/h5?url=' + encodeURIComponent(path)
})
break;
case 4:
let path_break = path.split(';')
let func = path_break.splice(0, 1)
uni.$lu.open[func[0]](...path_break)
break;
}
}
export default jump