12345678910111213141516171819202122232425262728293031323334353637 |
- import { router } from '@/router';
- import { LOGIN_URL, PHONE_LOGIN_URL } from '@/common/constants';
- import Store, { types } from '@/common/store/index.ts';
- const error_handle = function(err: any): void {
- let retcode = parseInt(err.status);
- if (retcode === 5001001 || retcode === 2000002 || retcode === 2000001) {
- toLogin();
- // Store.commit(types.LOGOUT);
- } else if (retcode === 5012004) {
- toLogin();
- // Store.commit(types.LOGOUT);
- } else if (retcode === 5001002) {
- toLogin();
- // Store.commit(types.LOGOUT);
- } else if (retcode >= 3001001 && retcode <= 3002000) {
- // window.location.href = '/'
- } else if (retcode >= 3002001 && retcode <= 3002999) {
- // window.location.href = '/user';
- }
- // uni.showModal({
- // content: err.msg,
- // confirmText: '知道了',
- // });
- setTimeout(() => {
- uni.showToast({ title: err.msg, duration: 2000, icon: 'none' });
- }, 100);
- };
- const toLogin = function(){
- Store.commit(`base/${types.LOGOUT}`);
- router.push({
- path: LOGIN_URL
- });
- }
- export default error_handle;
|