aqsc-mobile-com
Version:
基于uni-ui实现的二次封装
42 lines (37 loc) • 1.17 kB
JavaScript
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
export function isExternalLink(path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
export function hasPermission(code) {
if (userStore.permission.includes(code) || userStore.userInfo.stafftype === '1') {
return true
} else {
return false
}
}
// 下面两个方法用于页面有弹出层且滚动时,阻止底层页面跟随滚动
// 阻止页面滚动
export function stopPageScroll() {
let box = function (e) {
false
}
document.body.style.overflow = 'hidden'
document.addEventListener('touchmove', box, false)
}
// 允许页面滚动
export function enablePageScroll() {
let box = function (e) {
false
}
document.body.style.overflow = '' // 出现滚动条
document.removeEventListener('touchmove', box, false)
}
// 文件下载和预览添加工厂前缀
export function getFilePath(uuid) {
let url = '/fileservice/downloadfile?uuid=' + uuid
if (import.meta.env.MODE !== 'development' && uni.getStorageSync('werks')) {
url = '/' + uni.getStorageSync('werks') + url
}
return url
}