重构请求拦截

This commit is contained in:
Double-_-Z 2025-10-21 12:02:35 +08:00
parent fc1898fb65
commit 9fa6d92ea7
15 changed files with 51 additions and 217 deletions

View File

@ -1,167 +0,0 @@
<!-- 纯富文本展示页-暂时无用搬运为修改 -->
<template>
<!-- #ifdef APP -->
<view class="rich-detail" :style="{ backgroundImage: `url(${myFileUrl+background})`,paddingTop: CustomBar+'rpx' }">
<view class="app-top" :style="{ height: CustomBar+'rpx',
background: topLevel===0? '#ffffff00' : `rgba(255, 255, 255,${topLevel})` }"></view>
<!-- #endif -->
<!-- #ifndef APP -->
<view class="rich-detail" :style="{ backgroundImage: `url(${myFileUrl+background})` }">
<!-- #endif -->
<view class="rdt-top">
<!-- #ifdef MP -->
<view :style="{height: `${StatusBar}px`}"></view>
<view class="app-top" :style="{height: `${StatusBar}px`,background: topLevel===0? '#ffffff00' : `rgba(255, 255, 255,${topLevel})`}"></view>
<view class="mobile-logo" :style="{height: `${CustomBarHeight}px`,backgroundColor: `rgba(255, 255, 255,${topLevel})`}">
<!-- #endif -->
<!-- #ifndef MP -->
<view class="mobile-logo" :style="{backgroundColor: `rgba(255, 255, 255,${topLevel})`}">
<!-- #endif -->
<u-icon name="arrow-left" size="40" class="back" @click="back"
:color="topLevel===0? '#f9f9f9' : `rgba(194, 234, 4,${topLevel})`"></u-icon>
<image :src="myFileUrl+logo"></image>
<view style="width: 75rpx;"></view>
</view>
<view class="detail-content">
<u-parse :html="content"></u-parse>
</view>
</view>
<Loading :show="loading" />
</view>
</template>
<script>
import configService from '@/common/config.service.js';
export default {
data(){
return{
// #ifdef MP
//
StatusBar: this.StatusBar || 0,
CustomBarHeight: this.Custom.height+(this.Custom.top-this.StatusBar)*2 || 0,
// #endif
content: '',
loading: true,//
//
myFileUrl: configService.fileUrl + 'pixel/my/',
//
background: 'background.png',
// logo
logo: 'logo-new.png',
//
topLevel: 0,
}
},
// #ifndef H5
onPageScroll(e) {
const level = e.scrollTop/60;
if(level<=1) this.topLevel = level;
else this.topLevel = 1;
},
// #endif
// #ifdef H5
mounted(){
let that = this;
window.onscroll = function () {
//
//scrollTop
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
const level = scrollTop/60;
if(level<=1) that.topLevel = level;
else that.topLevel = 1;
}
},
onHide() {
window.onscroll = null;
},
// #endif
methods:{
//
back(){
uni.navigateBack();
},
//
async getAgreement(name){
if(!name) {
this.content = '暂无协议内容';
return;
}
try{
this.loading = true;
let res = await this.$api.getArticles({title: name});
if(res.success){
this.content = res.data.records[0].text;
}else{
this.content = name + '\n暂无协议内容';
}
}catch(e){
}finally{
this.loading = false;
}
}
},
onLoad(options) {
uni.setNavigationBarTitle({
title: options.name || '协议内容'
});
this.getAgreement(options.name);
},
}
</script>
<style scoped lang="scss">
.rich-detail{
display: flex;
flex-direction: column;
min-height: 100vh;
background-size: cover;
// #ifdef APP || MP
.app-top{
width: 100%;
position: fixed;
z-index: 81;
top: 0;
}
// #endif
.rdt-top{
// #ifdef APP
.app-top{
width: 100%;
position: fixed;
z-index: 81;
top: 0;
}
// #endif
.mobile-logo{
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.back{
margin-left: 35rpx;
margin-top: 5rpx
}
position: fixed;
z-index: 81;
padding: 15rpx 0;
image{
width: 200rpx;
height: 45rpx;
}
// .u-icon{
// }
}
}
// padding: 40rpx;
.detail-content{
margin: 80rpx 40rpx 32rpx;
background-color: rgba(160, 160, 160, 0.4);
border-radius: 20rpx;
padding: 40rpx 25rpx 20rpx;
color: #f9f9f9;
}
}
</style>

View File

@ -64,7 +64,7 @@
async getDeviceList(){ async getDeviceList(){
this.form.isFinish = 'loading'; this.form.isFinish = 'loading';
let deviceRes = await this.$api.getDevices(this.form); let deviceRes = await this.$api.getDevices(this.form);
if(deviceRes){ if(!deviceRes.isError){
const { records, size, total, current } = deviceRes; const { records, size, total, current } = deviceRes;
if(current == 1) this.deviceList = records || []; if(current == 1) this.deviceList = records || [];
else this.deviceList.push(...records); else this.deviceList.push(...records);

View File

@ -212,7 +212,7 @@ export default {
try { try {
const detail = await this.$api.getDevicesDetail(this.deviceId); const detail = await this.$api.getDevicesDetail(this.deviceId);
console.log("设备详情:", detail); console.log("设备详情:", detail);
if (detail) { if (!detail.isError) {
this.equipmentDetail = detail; this.equipmentDetail = detail;
// //
if (detail.deviceImages && detail.deviceImages.length > 0) { if (detail.deviceImages && detail.deviceImages.length > 0) {

View File

@ -142,7 +142,7 @@ export default {
await this.getOrderList(); await this.getOrderList();
// //
let scenRes = await this.$api.allScenic(); let scenRes = await this.$api.allScenic();
if(!scenRes) if(scenRes.isError)
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{}; else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{};
}, },
@ -150,7 +150,7 @@ export default {
async getOrderList(){ async getOrderList(){
this.form.isFinish = 'loading'; this.form.isFinish = 'loading';
let ordRes = await this.$api.getOrders(this.form); let ordRes = await this.$api.getOrders(this.form);
if(ordRes){ if(!ordRes.isError){
const { records, size, total, current } = ordRes; const { records, size, total, current } = ordRes;
if(current == 1) this.orders = records || []; if(current == 1) this.orders = records || [];
else this.orders.push(...records); else this.orders.push(...records);

View File

@ -109,8 +109,8 @@ export default {
const isA = that.currentLoginType===1; const isA = that.currentLoginType===1;
let res = await that.$api[isA?'aLogin':'bLogin'] let res = await that.$api[isA?'aLogin':'bLogin']
({...that.loginForm,password:encrypt(that.loginForm.password)}); ({...that.loginForm,password:encrypt(that.loginForm.password)});
if(!res){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: "账号或密码错误!"}); that.$refs.uToast.show({type: 'error',title: res.message||"账号或密码错误!"});
}else{ }else{
// //
uni.setStorageSync('loginMemory',JSON.stringify({...that.loginForm,timer: new Date()})); uni.setStorageSync('loginMemory',JSON.stringify({...that.loginForm,timer: new Date()}));

View File

@ -56,7 +56,7 @@ export default {
oldPass: encrypt(oldPass), oldPass: encrypt(oldPass),
newPass: encrypt(newPass), newPass: encrypt(newPass),
}); });
if(res.status&&res.status===400){ if(res.isError){
this.$refs.uToast.show({type: 'error',title: "密码修改失败!"}); this.$refs.uToast.show({type: 'error',title: "密码修改失败!"});
}else{ }else{
this.form = { this.form = {

View File

@ -98,18 +98,18 @@ export default {
async init(){ async init(){
let resp = await this.$api.aSelfDetail(this.userMessage.id); let resp = await this.$api.aSelfDetail(this.userMessage.id);
let res = await this.$api.allAreas(); let res = await this.$api.allAreas();
if(!res){ if(res.isError){
this.$refs.uToast.show({type: 'error',title: "区域获取失败!"}); this.$refs.uToast.show({type: 'error',title: "区域获取失败!"});
}else{ }else{
this.areas = res || []; this.areas = res || [];
} }
if(!resp){ if(resp.isError){
this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"}); this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"});
}else{ }else{
this.form = resp; this.form = resp;
if(resp.areaId){ if(resp.areaId){
let resx = await this.$api.allScenicsByAreaId({areaId: this.form.areaId}); let resx = await this.$api.allScenicsByAreaId({areaId: this.form.areaId});
this.scenics = resx || []; this.scenics = resx.isError ? [] : resx;
} }
} }
}, },
@ -127,7 +127,7 @@ export default {
this.form.scenicName = ''; this.form.scenicName = '';
this.form.scenicId = ''; this.form.scenicId = '';
let res = await this.$api.allScenicsByAreaId({areaId: val.id}); let res = await this.$api.allScenicsByAreaId({areaId: val.id});
if(!res){ if(res.isError){
this.$refs.uToast.show({type: 'error',title: "景区获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区获取失败!"});
}else{ }else{
this.scenics = res || []; this.scenics = res || [];
@ -164,6 +164,11 @@ export default {
this.loading = true; this.loading = true;
delete this.form.password; delete this.form.password;
let res = await this.$api.aEditSelf(this.form); let res = await this.$api.aEditSelf(this.form);
console.log('res',res);
if(res.isError){
this.$refs.uToast.show({type: 'error',title: res.message || "个人信息修改失败!"});
return;
}
this.$refs.uToast.show({type: 'success',title: "个人信息修改成功!"}); this.$refs.uToast.show({type: 'success',title: "个人信息修改成功!"});
this.init(); this.init();
}catch(e){ }catch(e){

View File

@ -87,7 +87,7 @@ export default {
this.userMessage = this.isLogin === '' ? {} : JSON.parse(this.$store.state.user_message); this.userMessage = this.isLogin === '' ? {} : JSON.parse(this.$store.state.user_message);
if(this.userMessage.id){ if(this.userMessage.id){
let res = await this.$api.bSelfDetail(this.userMessage.id); let res = await this.$api.bSelfDetail(this.userMessage.id);
this.customer = res === undefined ? {} : res; this.customer = res.isError ? {} : res;
} }
}, },
// //

View File

@ -247,22 +247,22 @@ export default {
async init(){ async init(){
// //
let cusRes = await this.$api.allCustomers(); let cusRes = await this.$api.allCustomers();
if(!cusRes){ if(cusRes.isError){
this.$refs.uToast.show({type: 'error',title: "客户获取失败!"}); this.$refs.uToast.show({type: 'error',title: "客户获取失败!"});
}else{ }else{
this.customers = cusRes || []; this.customers = cusRes || [];
} }
// //
let selfRes = await this.$api.aSelfDetail(this.userMessage.id); let selfRes = await this.$api.aSelfDetail(this.userMessage.id);
if(!selfRes){ if(selfRes.isError){
this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"}); this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"});
}else{ }else{
if(selfRes.areaId){ if(selfRes.areaId){
let scenRes = await this.$api.allScenicsByAreaId({areaId: selfRes.areaId}); let scenRes = await this.$api.allScenicsByAreaId({areaId: selfRes.areaId});
// //
let opeRes = await this.$api.allEmployees({areaId: selfRes.areaId}); let opeRes = await this.$api.allEmployees({areaId: selfRes.areaId});
this.scenics = scenRes || []; this.scenics = scenRes.isError ? [] : scenRes;
this.operators = opeRes || []; this.operators = opeRes.isError ? [] : opeRes;
} }
} }
// //
@ -279,7 +279,7 @@ export default {
// //
async getOrderDetail(){ async getOrderDetail(){
let res = await this.$api.orderDetail(this.form.orderId); let res = await this.$api.orderDetail(this.form.orderId);
if(res){ if(!res.isError){
const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight, const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight,
orderNo, orderCreateTime, orderInitiator, orderInitiatorId, mainOrderStatus, orderNo, orderCreateTime, orderInitiator, orderInitiatorId, mainOrderStatus,
customerId, attractionId, routeIds, operatorIds, orderTaskDetailList } = res; customerId, attractionId, routeIds, operatorIds, orderTaskDetailList } = res;
@ -304,7 +304,7 @@ export default {
mainOrderStatus: mainOrderStatus mainOrderStatus: mainOrderStatus
} }
let resp = await this.$api.allRoutesByScenicId(attractionId); let resp = await this.$api.allRoutesByScenicId(attractionId);
if(resp){ if(!resp.isError){
this.routes = resp || []; this.routes = resp || [];
this.form.routeIds = resp.filter(item=> routeIds.includes(item.key)); this.form.routeIds = resp.filter(item=> routeIds.includes(item.key));
this.form.operatorIds = this.operators.filter(item=> operatorIds.includes(item.id)); this.form.operatorIds = this.operators.filter(item=> operatorIds.includes(item.id));
@ -326,8 +326,8 @@ export default {
if (res.confirm) { if (res.confirm) {
try { try {
let res = await that.$api.deleteOrder(that.form.orderId); let res = await that.$api.deleteOrder(that.form.orderId);
if(res === undefined){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: "订单详删除失败!"}); that.$refs.uToast.show({type: 'error',title: res.message || "订单详删除失败!"});
return; return;
} }
uni.navigateBack({complete() { uni.navigateBack({complete() {
@ -356,7 +356,7 @@ export default {
this.form.attractionId = val.id; this.form.attractionId = val.id;
this.form.routeIds = []; this.form.routeIds = [];
let res = await this.$api.allRoutesByScenicId(val.id); let res = await this.$api.allRoutesByScenicId(val.id);
if(res){ if(!res.isError){
this.routes = res || []; this.routes = res || [];
this.form.routeIds = res.length>0?[res[0]]:[]; this.form.routeIds = res.length>0?[res[0]]:[];
}else{ }else{
@ -383,8 +383,8 @@ export default {
console.log('验证通过',that.form); console.log('验证通过',that.form);
let res = that.form.orderId ? await that.$api.editOrder(data) : await that.$api.addOrder(data); let res = that.form.orderId ? await that.$api.editOrder(data) : await that.$api.addOrder(data);
console.log('res:',res); console.log('res:',res);
if(res === undefined){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: "订单新增失败!"}); that.$refs.uToast.show({type: 'error',title: res.message || "订单新增失败!"});
that.saveLoading = false; that.saveLoading = false;
return; return;
} }
@ -416,8 +416,8 @@ export default {
if (res.confirm) { if (res.confirm) {
try { try {
let res = await that.$api.completeOrder(that.form.orderId); let res = await that.$api.completeOrder(that.form.orderId);
if(res === undefined){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"}); that.$refs.uToast.show({type: 'error',title: res.message || "订单完成操作失败!"});
return; return;
} }
that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`}); that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`});

View File

@ -382,16 +382,16 @@ export default {
async init(id){ async init(id){
if(!id) return; if(!id) return;
let res = await this.$api.orderDetail(id); let res = await this.$api.orderDetail(id);
if(res) this.orderDetail = res; if(!res.isError) this.orderDetail = res;
else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"}); else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"});
let resp = await this.$api.allRoutesByScenicId(res.attractionId); let resp = await this.$api.allRoutesByScenicId(res.attractionId);
if(resp){ if(!resp.isError){
this.routes = resp.filter(item=>this.orderDetail.routeIds.includes(item.key)) || []; this.routes = resp.filter(item=>this.orderDetail.routeIds.includes(item.key)) || [];
} else { } else {
this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"});
} }
let respx = await this.$api.obtainDeviceList({attractionId: res.attractionId}); let respx = await this.$api.obtainDeviceList({attractionId: res.attractionId});
if(respx){ if(!respx.isError){
this.equipments = respx || []; this.equipments = respx || [];
} else { } else {
this.$refs.uToast.show({type: 'error',title: "景区设备获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区设备获取失败!"});
@ -428,7 +428,7 @@ export default {
// //
async getOrderDetail(id){ async getOrderDetail(id){
let res = await this.$api.orderDetail(id); let res = await this.$api.orderDetail(id);
if(res) this.orderDetail = res; if(!res.isError) this.orderDetail = res;
else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"}); else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"});
}, },
// //
@ -481,9 +481,9 @@ export default {
try { try {
this.dotLoading = true; this.dotLoading = true;
let res = await this.$api.addOrderTask(data); let res = await this.$api.addOrderTask(data);
if(res === undefined){ if(res.isError){
this.dotLoading = false; this.dotLoading = false;
this.$refs.uToast.show({type: 'error',title: '当前无法新增飞行任务!'}); this.$refs.uToast.show({type: 'error',title: res.message || '当前无法新增飞行任务!'});
return; return;
} }
await this.clearForm(); await this.clearForm();
@ -505,8 +505,8 @@ export default {
const { orderTaskId, taskStatus, oldStatus } = this.stateForm; const { orderTaskId, taskStatus, oldStatus } = this.stateForm;
let res = await this.$api.editOrderStatus(orderTaskId, taskStatus); let res = await this.$api.editOrderStatus(orderTaskId, taskStatus);
this.showChangeState = false; this.showChangeState = false;
if(res === undefined){ if(res.isError){
this.$refs.uToast.show({type: 'error',title: `订单任务状态不能进行状态变更,当前状态为:${oldStatus}`}); this.$refs.uToast.show({type: 'error',title: res.message || `订单任务状态不能进行状态变更,当前状态为:${oldStatus}`});
return; return;
} }
this.$refs.uToast.show({type: 'success',title: `飞行任务状态更改成功!`}); this.$refs.uToast.show({type: 'success',title: `飞行任务状态更改成功!`});
@ -549,8 +549,8 @@ export default {
try { try {
let res = await that.$api.deleteOrderTask(item.id); let res = await that.$api.deleteOrderTask(item.id);
console.log(res); console.log(res);
if(res === undefined){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: `订单飞行任务处于[${item.orderItemStatus}]状态,不能进行删除`}); that.$refs.uToast.show({type: 'error',title: res.message || `订单飞行任务处于[${item.orderItemStatus}]状态,不能进行删除`});
return; return;
} }
that.getOrderDetail(this.form.orderId); that.getOrderDetail(this.form.orderId);
@ -586,8 +586,8 @@ export default {
if (res.confirm) { if (res.confirm) {
try { try {
let res = await that.$api.completeOrder(that.orderDetail.id); let res = await that.$api.completeOrder(that.orderDetail.id);
if(res === undefined){ if(res.isError){
that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"}); that.$refs.uToast.show({type: 'error',title: res.message || "订单完成操作失败!"});
return; return;
} }
that.getOrderDetail(that.form.orderId); that.getOrderDetail(that.form.orderId);

View File

@ -117,12 +117,12 @@ export default {
await this.getOrderList(); await this.getOrderList();
// //
let cusRes = this.isPilot ? await this.$api.allCustomers() : await this.$api.allEmployees(); let cusRes = this.isPilot ? await this.$api.allCustomers() : await this.$api.allEmployees();
if(!cusRes){ if(cusRes.isError){
this.$refs.uToast.show({type: 'error',title: "客户获取失败!"}); this.$refs.uToast.show({type: 'error',title: "客户获取失败!"});
}else this.customers = await cusRes.reduce((obj, item) => ({...obj,[item.id]: item}), {})||{}; }else this.customers = await cusRes.reduce((obj, item) => ({...obj,[item.id]: item}), {})||{};
// //
let scenRes = await this.$api.allScenic(); let scenRes = await this.$api.allScenic();
if(!scenRes) if(scenRes.isError)
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{}; else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{};
}, },
@ -130,7 +130,7 @@ export default {
async getOrderList(){ async getOrderList(){
this.form.isFinish = 'loading'; this.form.isFinish = 'loading';
let ordRes = await this.$api.getOrders(this.form); let ordRes = await this.$api.getOrders(this.form);
if(ordRes){ if(!ordRes.isError){
const { records, size, total, current } = ordRes; const { records, size, total, current } = ordRes;
if(current == 1) this.orders = records || []; if(current == 1) this.orders = records || [];
else this.orders.push(...records); else this.orders.push(...records);

View File

@ -74,7 +74,7 @@ export default {
async init(id = this.form.id){ async init(id = this.form.id){
if(!id) return; if(!id) return;
let res = await this.$api.singleRoute(id); let res = await this.$api.singleRoute(id);
if(res){ if(!res.isError){
this.form = res; this.form = res;
}else{ }else{
this.$refs.uToast.show({type:'error',title: "路线详情获取失败!"}); this.$refs.uToast.show({type:'error',title: "路线详情获取失败!"});

View File

@ -97,7 +97,7 @@ export default {
await this.getRouteList(); await this.getRouteList();
// //
let scenRes = await this.$api.allScenic(); let scenRes = await this.$api.allScenic();
if(!scenRes) if(scenRes.isError)
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"}); this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
else this.scenics = await scenRes; else this.scenics = await scenRes;
}, },
@ -111,7 +111,7 @@ export default {
async getRouteList(){ async getRouteList(){
this.form.isFinish = 'loading'; this.form.isFinish = 'loading';
let routeRes = await this.$api.getRoutes(this.form); let routeRes = await this.$api.getRoutes(this.form);
if(routeRes){ if(!routeRes.isError){
const { records, size, total, current } = routeRes; const { records, size, total, current } = routeRes;
if(current == 1) this.routes = records || []; if(current == 1) this.routes = records || [];
else this.routes.push(...records); else this.routes.push(...records);

View File

@ -87,10 +87,11 @@ const install = (Vue, vm) => {
break; break;
} }
default: default:
if (res.statusCode == 200) { if ([200, 204].includes(Number(res.statusCode))) {
return res.data; return res.data;
} else { } else {
console.error(res) console.error(res)
return {isError: true,...res.data}
// vm.$u.toast('网络请求错误!'); // vm.$u.toast('网络请求错误!');
} }
} }

View File

@ -29,12 +29,7 @@
], ],
"subPackages": [{ "subPackages": [{
"root": "aircraft/index", "root": "aircraft/index",
"pages": [{ "pages": [
"path": "rich-detail",
"style": {
"navigationBarTitleText": "协议内容"
}
},
{ {
"path": "webview" "path": "webview"
} }