袁磊 8 months ago
parent
commit
ebb329f3e1
  1. 90
      plugins/modal.js
  2. 16
      plugins/pluginTool.js
  3. 86
      plugins/tab.js

90
plugins/modal.js

@ -1,72 +1,72 @@
// 消息提示
export function msg(content) {
uni.showToast({
title: content,
icon: 'none'
})
uni.showToast({
title: content,
icon: 'none'
})
}
// 错误消息
export function msgError(content) {
uni.showToast({
title: content,
icon: 'error'
})
uni.showToast({
title: content,
icon: 'error'
})
}
// 成功消息
export function msgSuccess(content) {
uni.showToast({
title: content,
icon: 'success'
})
uni.showToast({
title: content,
icon: 'success'
})
}
// 隐藏消息
export function hideMsg(content) {
uni.hideToast()
uni.hideToast()
}
// 弹出提示
export function alert(content, title) {
uni.showModal({
title: title || '系统提示',
content: content,
showCancel: false
})
uni.showModal({
title: title || '系统提示',
content: content,
showCancel: false
})
}
// 确认窗体
export function confirm(content, title) {
return new Promise((resolve, reject) => {
uni.showModal({
title: title || '系统提示',
content: content,
cancelText: '取消',
confirmText: '确定',
success: function(res) {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
return new Promise((resolve, reject) => {
uni.showModal({
title: title || '系统提示',
content: content,
cancelText: '取消',
confirmText: '确定',
success: function(res) {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
}
// 提示信息
export function showToast(option) {
if (typeof option === "object") {
uni.showToast(option)
} else {
uni.showToast({
title: option,
icon: "none",
duration: 2500
})
}
if (typeof option === "object") {
uni.showToast(option)
} else {
uni.showToast({
title: option,
icon: "none",
duration: 2500
})
}
}
// 打开遮罩层
export function loading(content) {
uni.showLoading({
title: content,
icon: 'none'
})
uni.showLoading({
title: content,
icon: 'none'
})
}
// 关闭遮罩层
export function closeLoading() {
uni.hideLoading()
uni.hideLoading()
}

16
plugins/pluginTool.js

@ -3,13 +3,13 @@ import * as modal from '@/plugins/modal.js'
export default {
install(app) {
// tab工具
Object.keys(tab).forEach((key) => {
app.config.globalProperties[key] = tab[key];
})
// modal工具
Object.keys(modal).forEach((key) => {
app.config.globalProperties[key] = modal[key];
});
// tab工具
Object.keys(tab).forEach((key) => {
app.config.globalProperties[key] = tab[key];
});
// modal工具
Object.keys(modal).forEach((key) => {
app.config.globalProperties[key] = modal[key];
});
}
};

86
plugins/tab.js

@ -1,74 +1,74 @@
// 关闭所有页面,打开到应用内的某个页面
export function reLaunch(url) {
return uni.reLaunch({
url: url
})
return uni.reLaunch({
url: url
})
}
export function reLaunchLogin() {
return uni.reLaunch({
url: '/pages/user/login'
})
return uni.reLaunch({
url: '/pages/user/login'
})
}
// 跳转到tabBar页面,并关闭其他所有非tabBar页面
export function switchTab(url) {
return uni.switchTab({
url: url
})
return uni.switchTab({
url: url
})
}
// 关闭当前页面,跳转到应用内的某个页面
export function redirectTo(url) {
return uni.redirectTo({
url: url
})
return uni.redirectTo({
url: url
})
}
// 保留当前页面,跳转到应用内的某个页面
export function navigateTo(url) {
return uni.navigateTo({
url: url
})
return uni.navigateTo({
url: url
})
}
// 保留当前页面,跳转到应用内的某个页面
export function navigateToLogin() {
return uni.navigateTo({
url: '/pages/user/login'
})
return uni.navigateTo({
url: '/pages/user/login'
})
}
// 关闭当前页面,返回上一页面或多级页面
export function navigateBack() {
return uni.navigateBack()
return uni.navigateBack()
}
export function openUrl(url) {
if(!url || typeof url == 'object' || url == '#'){
uni.showToast({
title: '此功能正开发中,敬请期待!',
icon: 'none'
})
return;
}
uni.navigateTo({
url: url
})
if(!url || typeof url == 'object' || url == '#'){
uni.showToast({
title: '此功能正开发中,敬请期待!',
icon: 'none'
})
return;
}
uni.navigateTo({
url: url
})
}
export function pageScrollTo(scrollTop, duration=0) {
uni.pageScrollTo({
scrollTop: scrollTop,
duration: duration
});
uni.pageScrollTo({
scrollTop: scrollTop,
duration: duration
});
}
// 复制
export function setClipboardData(content) {
return new Promise((resolve, reject) => {
uni.setClipboardData({
data: content,
success: (res) => {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
return new Promise((resolve, reject) => {
uni.setClipboardData({
data: content,
success: (res) => {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
}
Loading…
Cancel
Save