export default { getuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }, // 提示信息 toast(msg, icon = 'none', duration = 2000, mask) { uni.showToast({ "icon": icon, "title": msg, "mask": mask || false, "duration": duration }) }, showLoading(msg) { uni.showLoading({ 'title': msg, 'mask': true }) }, hidingLoading() { uni.hideLoading(); }, // 提示信息 底部 toastBottom(msg, icon = 'none', duration = 2000, mask = false) { uni.showToast({ "icon": icon, "title": msg, "mask": mask, "duration": duration, "position": 'bottom' }) }, // 路由跳转 to(url) { uni.navigateTo({ url: url, animationType: 'slide-in-right', animationDuration: 300 }) }, toBar(url) { uni.switchTab({ url: url }) }, // 返回上一页 back() { uni.navigateBack({ delta: 1, animationType: 'pop-out', animationDuration: 200 }) }, // 验证邮箱 isEmail(email) { let reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/; if (!reg.test(email)) { this.$common.toast('请输入正确邮箱格式') } return reg.test(email) } }