Showing
2 changed files
with
6 additions
and
15 deletions
| ... | @@ -2,13 +2,12 @@ | ... | @@ -2,13 +2,12 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-28 10:17:40 | 3 | * @Date: 2022-05-28 10:17:40 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-06-22 09:22:56 | 5 | + * @LastEditTime: 2022-06-29 22:32:15 |
| 6 | * @FilePath: /tswj/src/utils/axios.js | 6 | * @FilePath: /tswj/src/utils/axios.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| 9 | import axios from 'axios'; | 9 | import axios from 'axios'; |
| 10 | import router from '@/router'; | 10 | import router from '@/router'; |
| 11 | -import _ from 'lodash' | ||
| 12 | import qs from 'Qs' | 11 | import qs from 'Qs' |
| 13 | // import { parseQueryString } from '@/utils/tools' | 12 | // import { parseQueryString } from '@/utils/tools' |
| 14 | 13 | ||
| ... | @@ -25,20 +24,13 @@ axios.interceptors.request.use( | ... | @@ -25,20 +24,13 @@ axios.interceptors.request.use( |
| 25 | // GET请求默认打上时间戳,避免从缓存中拿数据。 | 24 | // GET请求默认打上时间戳,避免从缓存中拿数据。 |
| 26 | const timestamp = config.method === 'get' ? (new Date()).valueOf() : ''; | 25 | const timestamp = config.method === 'get' ? (new Date()).valueOf() : ''; |
| 27 | // 上传相关接口需要屏蔽掉封装, 不能序列化数据会报错。 | 26 | // 上传相关接口需要屏蔽掉封装, 不能序列化数据会报错。 |
| 28 | - if ( | 27 | + const excludeUrl = ['a=upload', 'upload.qiniup.com']; |
| 29 | - config.method === 'post' && | 28 | + if (config.method === 'post' && !excludeUrl.includes(config.url)) { |
| 30 | - (config.url.indexOf('a=upload') === -1 && | ||
| 31 | - config.url.indexOf('upload.qiniup.com') === -1 | ||
| 32 | - ) | ||
| 33 | - ) | ||
| 34 | - { | ||
| 35 | // POST PHP需要修改数据格式 | 29 | // POST PHP需要修改数据格式 |
| 36 | config.data = qs.stringify(config.data) | 30 | config.data = qs.stringify(config.data) |
| 37 | } | 31 | } |
| 38 | // 绑定默认请求头 | 32 | // 绑定默认请求头 |
| 39 | - config.params = _.merge(config.params, { | 33 | + config.params = { ...config.params, timestamp } |
| 40 | - timestamp, | ||
| 41 | - }) | ||
| 42 | return config; | 34 | return config; |
| 43 | }, | 35 | }, |
| 44 | error => { | 36 | error => { |
| ... | @@ -55,7 +47,7 @@ axios.interceptors.response.use( | ... | @@ -55,7 +47,7 @@ axios.interceptors.response.use( |
| 55 | response.data.show = true; | 47 | response.data.show = true; |
| 56 | // 判断微信授权状态,进入页面时未授权需要授权跳转 | 48 | // 判断微信授权状态,进入页面时未授权需要授权跳转 |
| 57 | // C/B 授权拼接头特殊标识,openid_x | 49 | // C/B 授权拼接头特殊标识,openid_x |
| 58 | - let prefixAPI = router && router.currentRoute.value.href?.indexOf('business') > 0 ? 'b' : 'c'; | 50 | + let prefixAPI = router?.currentRoute.value.href?.indexOf('business') > 0 ? 'b' : 'c'; |
| 59 | if (response.data.code === 401) { | 51 | if (response.data.code === 401) { |
| 60 | // 特殊标识-带此标识报错不显示 | 52 | // 特殊标识-带此标识报错不显示 |
| 61 | response.data.show = false; | 53 | response.data.show = false; | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-04-18 15:59:42 | 2 | * @Date: 2022-04-18 15:59:42 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-06-15 18:29:40 | 4 | + * @LastEditTime: 2022-06-29 22:35:51 |
| 5 | * @FilePath: /tswj/src/utils/tools.js | 5 | * @FilePath: /tswj/src/utils/tools.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import moment from 'moment'; | 8 | import moment from 'moment'; |
| 9 | -import { ref } from 'vue' | ||
| 10 | 9 | ||
| 11 | // 格式化时间 | 10 | // 格式化时间 |
| 12 | const formatDate = (date) => { | 11 | const formatDate = (date) => { | ... | ... |
-
Please register or login to post a comment