emis-sapp/common/untool.js

68 lines
971 B
JavaScript
Raw Normal View History

2023-12-02 08:54:31 +00:00
const tabBarUrls = [
2023-12-10 05:53:38 +00:00
'tabBar/sending/sending',
'tabBar/search/search',
'tabBar/mine/mine'
2023-12-02 08:54:31 +00:00
]
const goto = (url, type = 1)=> {
url = `/pages/${url}`
if(tabBarUrls.indexOf(url) > -1) {
return uni.switchTab({
url
});
}
if (type == 1){
uni.navigateTo({
url
});
} else {
uni.redirectTo({
url
});
}
}
const goBack = (opt = {})=> {
uni.navigateBack(opt)
}
const reLaunch = (opt = {})=> {
uni.reLaunch(opt)
}
2023-12-04 08:14:24 +00:00
const setClipboardData = (val)=> {
uni.setClipboardData({
data: val,
success: () => {
uni.showToast({ title: "复制成功", icon: 'none' })
},
})
}
const confirmModal = (title) => {
return new Promise((resolve)=> {
uni.showModal({ content: title, confirmColor: '#B12D29' }).then((res)=> {
if(res.confirm) {
resolve()
}
})
})
}
const showLoading = ()=> {
uni.showLoading({
mask: true,
title: '加载中'
});
}
2023-12-02 08:54:31 +00:00
export {
reLaunch,
goto,
2023-12-04 08:14:24 +00:00
goBack,
setClipboardData,
confirmModal,
showLoading,
2023-12-02 08:54:31 +00:00
}