h5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.5 KiB

import { stringify } from 'qs';
export default {
/**
* 显示toast
* @param {string} title 提示内容
* @param {number} duration 显示时间 默认2000
*/
showToast(title, duration = 2000) {
return uni.showToast({
title,
icon: 'none',
duration,
mask: true,
});
},
// 隐藏toast
hideToast() {
return uni.hideToast();
},
/**
* 显示加载雪花
* @param {string} title
*/
showLoading(title = '玩命加载中...') {
return uni.showLoading({
title,
mask: true,
});
},
// 隐藏loading
hideLoading() {
return uni.hideLoading();
},
/**
* 显示modal弹出框
* @param {string} title 标题
* @param {string} content 内容
* @param {boolean} showCancel 是否显示取消按钮 默认true
*/
showModal(title, content, showCancel = true) {
return new Promise(function (resolve, reject) {
uni.showModal({
title,
content,
showCancel,
success: ({ confirm, cancel }) => {
confirm && resolve();
cancel && reject();
},
});
});
},
/**
* 打开详情页
* @param {object} options
*/
openDetail(options) {
if (!options) {
throw new Error('缺少参数');
}
if (!options.url) {
throw new Error('缺少url参数');
}
const query = stringify(options);
const path = `/pages/detailWebview/detailWebview?${query}`;
uni.navigateTo({ url: path });
},
};