mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-05-16 00:49:33 +08:00
添加filters
This commit is contained in:
parent
09485e7952
commit
fcfd1c4f1c
6
src/filters/filter.js
Normal file
6
src/filters/filter.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* 隐藏用户手机号中间四位
|
||||||
|
*/
|
||||||
|
exports.hidePhone = phone => {
|
||||||
|
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||||
|
}
|
6
src/filters/index.js
Normal file
6
src/filters/index.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import filter from './filter'
|
||||||
|
|
||||||
|
Object.keys(filter).forEach(k => Vue.filter(k, filter[k]))
|
||||||
|
|
||||||
|
Vue.prototype.$hidePhone = Vue.filter('hidePhone')
|
@ -7,6 +7,7 @@ import 'lib-flexible/flexible.js'
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
import filters from './filter'
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
@ -34,22 +34,17 @@ service.interceptors.request.use(
|
|||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => {
|
response => {
|
||||||
Toast.clear()
|
Toast.clear()
|
||||||
// 如果是数据流
|
const res = response.data
|
||||||
if (response.config.responseType === 'arraybuffer') {
|
if (res.status && res.status !== 200) {
|
||||||
return response.data
|
// 登录超时,重新登录
|
||||||
} else {
|
if (res.status === 401) {
|
||||||
const res = response.data
|
store.dispatch('FedLogOut').then(() => {
|
||||||
if (res.status !== 200) {
|
location.reload()
|
||||||
// 登录超时,重新登录
|
})
|
||||||
if (res.status === 401) {
|
|
||||||
store.dispatch('FedLogOut').then(() => {
|
|
||||||
location.reload()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return Promise.reject(res || 'error')
|
|
||||||
} else {
|
|
||||||
return Promise.resolve(res)
|
|
||||||
}
|
}
|
||||||
|
return Promise.reject(res || 'error')
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Created by PanJiaChen on 16/11/18.
|
* Created by Sunnie on 19/06/04.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user