封装请求的方法,完成简易的问题解答页面

This commit is contained in:
2024-02-27 17:23:33 +08:00
parent 66bc2262e4
commit 3205aa25c7
15 changed files with 312 additions and 15 deletions

View File

@@ -126,3 +126,42 @@ function debounce(fn, interval) {
}, gapTime);
}
}
export const showLoading = async (options = {}) => {
const { title } = options;
return new Promise((resolve, reject) => {
wx.showLoading({
title: title || '加载中',
success: () => {
resolve()
}
})
})
}
export const hideLoading = async () => {
return new Promise((resolve, reject) => {
wx.hideLoading({
success: () => {
resolve()
}
})
})
}
export const alertInfo = (message) => {
return wx.showToast({
title: message,
icon: 'none',
})
}
export const alertSuccess = (message) => {
return wx.showToast({
title: message,
icon: 'success'
})
}
export const alertError = (message) => {
return wx.showToast({
title: message,
icon: 'error'
})
}