emis-sapp/common/untool.js
2023-12-04 16:14:24 +08:00

68 lines
950 B
JavaScript

const tabBarUrls = [
'sending/sending',
'search/search',
'mine/mine'
]
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)
}
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: '加载中'
});
}
export {
reLaunch,
goto,
goBack,
setClipboardData,
confirmModal,
showLoading,
}