2025-03-25 16:35:39 +08:00
|
|
|
export const showToast = (options) => {
|
|
|
|
|
if (typeof options === 'string') {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: options,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
}).then();
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast(options).then();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const isWXWeb = () => {
|
|
|
|
|
const userAgent = navigator.userAgent;
|
|
|
|
|
return userAgent.includes('MicroMessenger');
|
|
|
|
|
}
|
2025-03-26 19:10:41 +08:00
|
|
|
|
|
|
|
|
export const toPage = (url) => {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: url,
|
|
|
|
|
}).then();
|
|
|
|
|
}
|
2025-03-27 15:38:21 +08:00
|
|
|
|
|
|
|
|
export const backPage = () => {
|
|
|
|
|
window.history.back();
|
|
|
|
|
}
|
2025-04-07 18:04:39 +08:00
|
|
|
|
|
|
|
|
export const copy = (context) => {
|
|
|
|
|
try {
|
|
|
|
|
navigator.clipboard.writeText(context)
|
|
|
|
|
.then(() => {
|
|
|
|
|
showToast('已复制');
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
showToast('复制失败');
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showToast('复制失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const download = (urls) => {
|
|
|
|
|
const promises = urls.map((url, index) => new Promise((resolve, reject) => {
|
|
|
|
|
const iframe = document.createElement('iframe');
|
|
|
|
|
iframe.src = url;
|
|
|
|
|
iframe.style.display = 'none';
|
|
|
|
|
document.body.appendChild(iframe);
|
|
|
|
|
resolve(true);
|
|
|
|
|
}));
|
|
|
|
|
Promise.all(promises).then(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
}
|