封装请求的方法,完成简易的问题解答页面
This commit is contained in:
@@ -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'
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user