import { Error } from '../../../lib/utils/error/index' import Prompt from '../prompt/index' import Router from '../router/index' import Config from '../../config/index' class MyError extends Error { constructor() { super() this.instance = null } static getInstance() { if (!this.instance) { this.instance = new MyError() } return this.instance } errorNotLoggedIn(success, fail) { console.log(Prompt) Prompt.showModal({ title: '提示', content: '未登录,请先登录', confirmText: '登录', success: res => { if (res.confirm) { if (Config.pages && Config.pages.login) { Router.navigateTo({ url: Config.pages.login }) } else { Prompt.showToast({ title: '未配置登录页' }) } } success && success() }, fail: () => { fail && fail() }, complete: () => {} }) } } let _myError = MyError.getInstance() export default _myError