feat(order): 订单更新接口增加加载提示
- 在订单更新请求中添加 needLoading 参数以显示加载动画 - 在请求拦截器中根据 needLoading 参数启动加载服务 - 在响应拦截器和错误处理中关闭加载服务 - 引入 Loading 服务以提升用户体验dev_1.0.0
parent
7cca3a439f
commit
993722e4a0
|
|
@ -31,7 +31,8 @@ export function updateOrder(data) {
|
|||
return request({
|
||||
url: '/project/order/vue',
|
||||
method: 'put',
|
||||
data: data
|
||||
data: data,
|
||||
needLoading:true
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import cache from '@/plugins/cache'
|
|||
import { saveAs } from 'file-saver'
|
||||
|
||||
let downloadLoadingInstance
|
||||
let loading
|
||||
// 是否显示重新登录
|
||||
export let isRelogin = { show: false }
|
||||
|
||||
|
|
@ -23,6 +24,14 @@ const service = axios.create({
|
|||
|
||||
// request拦截器
|
||||
service.interceptors.request.use(config => {
|
||||
if (config.needLoading) {
|
||||
loading = Loading.service({
|
||||
lock: true,
|
||||
text: '正在加载数据,请稍候',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
})
|
||||
}
|
||||
// 是否需要防止数据重复提交
|
||||
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
||||
config.headers['X-Requested-With'] = 'H5'
|
||||
|
|
@ -71,6 +80,9 @@ service.interceptors.request.use(config => {
|
|||
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(res => {
|
||||
if (loading) {
|
||||
loading.close()
|
||||
}
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.data.code || 200
|
||||
// 获取错误信息
|
||||
|
|
@ -106,6 +118,9 @@ service.interceptors.response.use(res => {
|
|||
}
|
||||
},
|
||||
error => {
|
||||
if (loading) {
|
||||
loading.close()
|
||||
}
|
||||
console.log('err' + error)
|
||||
let { message } = error
|
||||
if (message == "Network Error") {
|
||||
|
|
|
|||
Loading…
Reference in New Issue