diff --git a/src/main.js b/src/main.js index a7d00c1..f54297d 100644 --- a/src/main.js +++ b/src/main.js @@ -24,9 +24,8 @@ import http from "@/utils/request"; Vue.prototype.$http = http; Vue.prototype.$dayjs = dayjs // 提示框封装 -// import { Tips } from '@/utils' - -// Vue.prototype.$tips = Tips +import { Tips } from '@/utils' +Vue.prototype.$tips = Tips //开发环境使用,生产环境自动取消 import Vconsole from 'vconsole' diff --git a/src/utils/index.js b/src/utils/index.js index 7f96288..4ab0491 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -8,6 +8,7 @@ * @param {string} cFormat * @returns {string} */ +import { Toast } from 'vant' import JSEncrypt from "jsencrypt"; //引入加密 export function parseTime(time, cFormat) { if (arguments.length === 0) { @@ -120,3 +121,23 @@ export function encryptedData(key, data) { // 加密数据 return encryptor.encrypt(data); } + +export const Tips = { + error: message => { + Toast({ message, icon: 'clear', className: 'toast-error' }) + }, + warning: message => { + Toast({ message, icon: 'warning', className: 'toast-warning' }) + }, + success: message => { + Toast({ message, icon: 'checked', className: 'toast-success' }) + }, + loading: message => { + Toast.loading({ + forbidClick: true, + message: message ? message : '加载中...', + duration: 0, + className: 'toast-loading' + }) + } +} diff --git a/src/utils/request.js b/src/utils/request.js index a6c75bb..32d987e 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,6 +3,7 @@ import store from '@/store' import { Toast } from 'vant' // 根据环境不同引入不同api地址 import { baseApi } from '@/config' +import { Tips } from '@/utils/index' // create an axios instance const service = axios.create({ baseURL: baseApi, // url = base api url + request url @@ -42,7 +43,7 @@ service.interceptors.response.use( localStorage.removeItem('token') router.replace('/login') } - // Tips.error(res.msg) + Tips.error(res.msg) return Promise.reject(res || 'error') } } @@ -57,7 +58,7 @@ service.interceptors.response.use( ) }) } else { - // Tips.error(error.response.data.message) + Tips.error(error.response.data.message) } return Promise.reject(error) } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 78bffa9..1f18753 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -38,7 +38,6 @@ export default { .post("/auth/govweb/getKey") .then((res) => { this.pubKey = res.data; // 获取到公钥; - console.log(this.pubKey); }) .catch((err) => { console.log(err); @@ -51,7 +50,6 @@ export default { } let { data, code, msg } = await getCustomerlist(parms) if (code === 0) { - console.log(data); this.customerId = data[0].customerId } else { console.log(msg); @@ -68,7 +66,7 @@ export default { } let { data, code, msg } = await login(parms) if (code === 0) { - + } else { console.log(msg); }