重构请求拦截
This commit is contained in:
parent
fc1898fb65
commit
9fa6d92ea7
@ -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>
|
||||
@ -64,7 +64,7 @@
|
||||
async getDeviceList(){
|
||||
this.form.isFinish = 'loading';
|
||||
let deviceRes = await this.$api.getDevices(this.form);
|
||||
if(deviceRes){
|
||||
if(!deviceRes.isError){
|
||||
const { records, size, total, current } = deviceRes;
|
||||
if(current == 1) this.deviceList = records || [];
|
||||
else this.deviceList.push(...records);
|
||||
|
||||
@ -212,7 +212,7 @@ export default {
|
||||
try {
|
||||
const detail = await this.$api.getDevicesDetail(this.deviceId);
|
||||
console.log("设备详情:", detail);
|
||||
if (detail) {
|
||||
if (!detail.isError) {
|
||||
this.equipmentDetail = detail;
|
||||
// 设置设备图片
|
||||
if (detail.deviceImages && detail.deviceImages.length > 0) {
|
||||
|
||||
@ -142,7 +142,7 @@ export default {
|
||||
await this.getOrderList();
|
||||
// 查询全部景区
|
||||
let scenRes = await this.$api.allScenic();
|
||||
if(!scenRes)
|
||||
if(scenRes.isError)
|
||||
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
|
||||
else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{};
|
||||
},
|
||||
@ -150,7 +150,7 @@ export default {
|
||||
async getOrderList(){
|
||||
this.form.isFinish = 'loading';
|
||||
let ordRes = await this.$api.getOrders(this.form);
|
||||
if(ordRes){
|
||||
if(!ordRes.isError){
|
||||
const { records, size, total, current } = ordRes;
|
||||
if(current == 1) this.orders = records || [];
|
||||
else this.orders.push(...records);
|
||||
|
||||
@ -109,8 +109,8 @@ export default {
|
||||
const isA = that.currentLoginType===1;
|
||||
let res = await that.$api[isA?'aLogin':'bLogin']
|
||||
({...that.loginForm,password:encrypt(that.loginForm.password)});
|
||||
if(!res){
|
||||
that.$refs.uToast.show({type: 'error',title: "账号或密码错误!"});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message||"账号或密码错误!"});
|
||||
}else{
|
||||
// 存储登录记录
|
||||
uni.setStorageSync('loginMemory',JSON.stringify({...that.loginForm,timer: new Date()}));
|
||||
|
||||
@ -56,7 +56,7 @@ export default {
|
||||
oldPass: encrypt(oldPass),
|
||||
newPass: encrypt(newPass),
|
||||
});
|
||||
if(res.status&&res.status===400){
|
||||
if(res.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "密码修改失败!"});
|
||||
}else{
|
||||
this.form = {
|
||||
|
||||
@ -98,18 +98,18 @@ export default {
|
||||
async init(){
|
||||
let resp = await this.$api.aSelfDetail(this.userMessage.id);
|
||||
let res = await this.$api.allAreas();
|
||||
if(!res){
|
||||
if(res.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "区域获取失败!"});
|
||||
}else{
|
||||
this.areas = res || [];
|
||||
}
|
||||
if(!resp){
|
||||
if(resp.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"});
|
||||
}else{
|
||||
this.form = resp;
|
||||
if(resp.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.scenicId = '';
|
||||
let res = await this.$api.allScenicsByAreaId({areaId: val.id});
|
||||
if(!res){
|
||||
if(res.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "景区获取失败!"});
|
||||
}else{
|
||||
this.scenics = res || [];
|
||||
@ -164,6 +164,11 @@ export default {
|
||||
this.loading = true;
|
||||
delete this.form.password;
|
||||
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.init();
|
||||
}catch(e){
|
||||
|
||||
@ -87,7 +87,7 @@ export default {
|
||||
this.userMessage = this.isLogin === '' ? {} : JSON.parse(this.$store.state.user_message);
|
||||
if(this.userMessage.id){
|
||||
let res = await this.$api.bSelfDetail(this.userMessage.id);
|
||||
this.customer = res === undefined ? {} : res;
|
||||
this.customer = res.isError ? {} : res;
|
||||
}
|
||||
},
|
||||
// 功能栏点击
|
||||
|
||||
@ -247,22 +247,22 @@ export default {
|
||||
async init(){
|
||||
// 获取客户列表
|
||||
let cusRes = await this.$api.allCustomers();
|
||||
if(!cusRes){
|
||||
if(cusRes.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "客户获取失败!"});
|
||||
}else{
|
||||
this.customers = cusRes || [];
|
||||
}
|
||||
// 获取负责区域的景区列表
|
||||
let selfRes = await this.$api.aSelfDetail(this.userMessage.id);
|
||||
if(!selfRes){
|
||||
if(selfRes.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "个人信息获取失败!"});
|
||||
}else{
|
||||
if(selfRes.areaId){
|
||||
let scenRes = await this.$api.allScenicsByAreaId({areaId: selfRes.areaId});
|
||||
// 获取操作员列表
|
||||
let opeRes = await this.$api.allEmployees({areaId: selfRes.areaId});
|
||||
this.scenics = scenRes || [];
|
||||
this.operators = opeRes || [];
|
||||
this.scenics = scenRes.isError ? [] : scenRes;
|
||||
this.operators = opeRes.isError ? [] : opeRes;
|
||||
}
|
||||
}
|
||||
// 获取订单详情
|
||||
@ -279,7 +279,7 @@ export default {
|
||||
// 获取订单详情
|
||||
async getOrderDetail(){
|
||||
let res = await this.$api.orderDetail(this.form.orderId);
|
||||
if(res){
|
||||
if(!res.isError){
|
||||
const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight,
|
||||
orderNo, orderCreateTime, orderInitiator, orderInitiatorId, mainOrderStatus,
|
||||
customerId, attractionId, routeIds, operatorIds, orderTaskDetailList } = res;
|
||||
@ -304,7 +304,7 @@ export default {
|
||||
mainOrderStatus: mainOrderStatus
|
||||
}
|
||||
let resp = await this.$api.allRoutesByScenicId(attractionId);
|
||||
if(resp){
|
||||
if(!resp.isError){
|
||||
this.routes = resp || [];
|
||||
this.form.routeIds = resp.filter(item=> routeIds.includes(item.key));
|
||||
this.form.operatorIds = this.operators.filter(item=> operatorIds.includes(item.id));
|
||||
@ -326,8 +326,8 @@ export default {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
let res = await that.$api.deleteOrder(that.form.orderId);
|
||||
if(res === undefined){
|
||||
that.$refs.uToast.show({type: 'error',title: "订单详删除失败!"});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message || "订单详删除失败!"});
|
||||
return;
|
||||
}
|
||||
uni.navigateBack({complete() {
|
||||
@ -356,7 +356,7 @@ export default {
|
||||
this.form.attractionId = val.id;
|
||||
this.form.routeIds = [];
|
||||
let res = await this.$api.allRoutesByScenicId(val.id);
|
||||
if(res){
|
||||
if(!res.isError){
|
||||
this.routes = res || [];
|
||||
this.form.routeIds = res.length>0?[res[0]]:[];
|
||||
}else{
|
||||
@ -383,8 +383,8 @@ export default {
|
||||
console.log('验证通过',that.form);
|
||||
let res = that.form.orderId ? await that.$api.editOrder(data) : await that.$api.addOrder(data);
|
||||
console.log('res:',res);
|
||||
if(res === undefined){
|
||||
that.$refs.uToast.show({type: 'error',title: "订单新增失败!"});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message || "订单新增失败!"});
|
||||
that.saveLoading = false;
|
||||
return;
|
||||
}
|
||||
@ -416,8 +416,8 @@ export default {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
let res = await that.$api.completeOrder(that.form.orderId);
|
||||
if(res === undefined){
|
||||
that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message || "订单完成操作失败!"});
|
||||
return;
|
||||
}
|
||||
that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`});
|
||||
|
||||
@ -382,16 +382,16 @@ export default {
|
||||
async init(id){
|
||||
if(!id) return;
|
||||
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: "订单详情获取失败!"});
|
||||
let resp = await this.$api.allRoutesByScenicId(res.attractionId);
|
||||
if(resp){
|
||||
if(!resp.isError){
|
||||
this.routes = resp.filter(item=>this.orderDetail.routeIds.includes(item.key)) || [];
|
||||
} else {
|
||||
this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"});
|
||||
}
|
||||
let respx = await this.$api.obtainDeviceList({attractionId: res.attractionId});
|
||||
if(respx){
|
||||
if(!respx.isError){
|
||||
this.equipments = respx || [];
|
||||
} else {
|
||||
this.$refs.uToast.show({type: 'error',title: "景区设备获取失败!"});
|
||||
@ -428,7 +428,7 @@ export default {
|
||||
// 获取订单详情
|
||||
async getOrderDetail(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: "订单详情获取失败!"});
|
||||
},
|
||||
// 设备选择
|
||||
@ -481,9 +481,9 @@ export default {
|
||||
try {
|
||||
this.dotLoading = true;
|
||||
let res = await this.$api.addOrderTask(data);
|
||||
if(res === undefined){
|
||||
if(res.isError){
|
||||
this.dotLoading = false;
|
||||
this.$refs.uToast.show({type: 'error',title: '当前无法新增飞行任务!'});
|
||||
this.$refs.uToast.show({type: 'error',title: res.message || '当前无法新增飞行任务!'});
|
||||
return;
|
||||
}
|
||||
await this.clearForm();
|
||||
@ -505,8 +505,8 @@ export default {
|
||||
const { orderTaskId, taskStatus, oldStatus } = this.stateForm;
|
||||
let res = await this.$api.editOrderStatus(orderTaskId, taskStatus);
|
||||
this.showChangeState = false;
|
||||
if(res === undefined){
|
||||
this.$refs.uToast.show({type: 'error',title: `订单任务状态不能进行状态变更,当前状态为:${oldStatus}`});
|
||||
if(res.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: res.message || `订单任务状态不能进行状态变更,当前状态为:${oldStatus}`});
|
||||
return;
|
||||
}
|
||||
this.$refs.uToast.show({type: 'success',title: `飞行任务状态更改成功!`});
|
||||
@ -549,8 +549,8 @@ export default {
|
||||
try {
|
||||
let res = await that.$api.deleteOrderTask(item.id);
|
||||
console.log(res);
|
||||
if(res === undefined){
|
||||
that.$refs.uToast.show({type: 'error',title: `订单飞行任务处于[${item.orderItemStatus}]状态,不能进行删除`});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message || `订单飞行任务处于[${item.orderItemStatus}]状态,不能进行删除`});
|
||||
return;
|
||||
}
|
||||
that.getOrderDetail(this.form.orderId);
|
||||
@ -586,8 +586,8 @@ export default {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
let res = await that.$api.completeOrder(that.orderDetail.id);
|
||||
if(res === undefined){
|
||||
that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"});
|
||||
if(res.isError){
|
||||
that.$refs.uToast.show({type: 'error',title: res.message || "订单完成操作失败!"});
|
||||
return;
|
||||
}
|
||||
that.getOrderDetail(that.form.orderId);
|
||||
|
||||
@ -117,12 +117,12 @@ export default {
|
||||
await this.getOrderList();
|
||||
// 查询全部客户
|
||||
let cusRes = this.isPilot ? await this.$api.allCustomers() : await this.$api.allEmployees();
|
||||
if(!cusRes){
|
||||
if(cusRes.isError){
|
||||
this.$refs.uToast.show({type: 'error',title: "客户获取失败!"});
|
||||
}else this.customers = await cusRes.reduce((obj, item) => ({...obj,[item.id]: item}), {})||{};
|
||||
// 查询全部景区
|
||||
let scenRes = await this.$api.allScenic();
|
||||
if(!scenRes)
|
||||
if(scenRes.isError)
|
||||
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
|
||||
else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{};
|
||||
},
|
||||
@ -130,7 +130,7 @@ export default {
|
||||
async getOrderList(){
|
||||
this.form.isFinish = 'loading';
|
||||
let ordRes = await this.$api.getOrders(this.form);
|
||||
if(ordRes){
|
||||
if(!ordRes.isError){
|
||||
const { records, size, total, current } = ordRes;
|
||||
if(current == 1) this.orders = records || [];
|
||||
else this.orders.push(...records);
|
||||
|
||||
@ -74,7 +74,7 @@ export default {
|
||||
async init(id = this.form.id){
|
||||
if(!id) return;
|
||||
let res = await this.$api.singleRoute(id);
|
||||
if(res){
|
||||
if(!res.isError){
|
||||
this.form = res;
|
||||
}else{
|
||||
this.$refs.uToast.show({type:'error',title: "路线详情获取失败!"});
|
||||
|
||||
@ -97,7 +97,7 @@ export default {
|
||||
await this.getRouteList();
|
||||
// 查询全部景区
|
||||
let scenRes = await this.$api.allScenic();
|
||||
if(!scenRes)
|
||||
if(scenRes.isError)
|
||||
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
|
||||
else this.scenics = await scenRes;
|
||||
},
|
||||
@ -111,7 +111,7 @@ export default {
|
||||
async getRouteList(){
|
||||
this.form.isFinish = 'loading';
|
||||
let routeRes = await this.$api.getRoutes(this.form);
|
||||
if(routeRes){
|
||||
if(!routeRes.isError){
|
||||
const { records, size, total, current } = routeRes;
|
||||
if(current == 1) this.routes = records || [];
|
||||
else this.routes.push(...records);
|
||||
|
||||
@ -87,10 +87,11 @@ const install = (Vue, vm) => {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (res.statusCode == 200) {
|
||||
if ([200, 204].includes(Number(res.statusCode))) {
|
||||
return res.data;
|
||||
} else {
|
||||
console.error(res)
|
||||
return {isError: true,...res.data}
|
||||
// vm.$u.toast('网络请求错误!');
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,12 +29,7 @@
|
||||
],
|
||||
"subPackages": [{
|
||||
"root": "aircraft/index",
|
||||
"pages": [{
|
||||
"path": "rich-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "协议内容"
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "webview"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user