1
0
forked from dyf/APP

添加token过期,跳转到登录页

This commit is contained in:
fengerli
2025-11-12 09:51:35 +08:00
parent 426fdeddee
commit dadad6ed19
5 changed files with 217 additions and 68 deletions

View File

@ -28,7 +28,7 @@ export function deviceSendMessage(data) {
data: data data: data
}) })
} }
// 灯光模式设置 // 灯光模式设置
export function lightModeSettings(data) { export function lightModeSettings(data) {
return request({ return request({
url: `/app/bjq6075/device/lightModeSettings`, url: `/app/bjq6075/device/lightModeSettings`,
@ -36,6 +36,14 @@ export function lightModeSettings(data) {
data: data data: data
}) })
} }
// 辅灯模式设置
export function auxiliaryLightModeSettings(data) {
return request({
url: `/app/bjq6075/device/auxiliaryLightModeSettings`,
method: 'post',
data: data
})
}
// 激光模式设置 // 激光模式设置
export function laserModeSettings(data) { export function laserModeSettings(data) {
return request({ return request({
@ -52,6 +60,14 @@ export function lightBrightnessSettings(data) {
data: data data: data
}) })
} }
// 声光报警
export function salaModeSettings(data) {
return request({
url: `/app/bjq6075/device/salaModeSettings`,
method: 'post',
data: data
})
}
// 地图逆解析 // 地图逆解析
export function mapReverseGeocoding(data) { export function mapReverseGeocoding(data) {
return request({ return request({

View File

@ -238,11 +238,12 @@
<button class="agree" @click="handleupload">确定</button> <button class="agree" @click="handleupload">确定</button>
</view> </view>
</view> </view>
</view>
<!-- ======各个弹框类型======= --> <!-- ======各个弹框类型======= -->
<CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm" <CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" /> @cancel="handleCancel" />
</view> </view>
</view>
</view> </view>
</template> </template>

View File

@ -35,7 +35,13 @@
<view> <view>
</view> </view>
</view> </view>
<view class="callpolice">
<view class="">设备疑似受到外力碰撞</view>
<view>
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
></uni-icons>
</view>
</view>
<!-- 设备基本信息 --> <!-- 设备基本信息 -->
<view class="info-card"> <view class="info-card">
<view class="info-row"> <view class="info-row">
@ -44,13 +50,16 @@
</view> </view>
<view class="info-row"> <view class="info-row">
<text class="info-label">设备状态</text> <text class="info-label">设备状态</text>
<text class="info-value status-running">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}</text> <text
class="info-value status-running">{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}</text>
</view> </view>
<view class="info-row"> <view class="info-row">
<text class="info-label">定位信息</text> <text class="info-label">定位信息</text>
<view class="info-value status-running" @click="gpsPosition"> <view class="info-value status-running" @click="gpsPosition">
<view class="info-value status-running"> {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }} <view class="info-value status-running">
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}</view> {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
</view>
<view class="info-value status-running"> <view class="info-value status-running">
<uni-icons @click="toggleForm" type="location" size="17" <uni-icons @click="toggleForm" type="location" size="17"
color="rgba(255, 255, 255, 0.8)" style="vertical-align: bottom;" /> color="rgba(255, 255, 255, 0.8)" style="vertical-align: bottom;" />
@ -308,8 +317,10 @@
registerPersonInfo, registerPersonInfo,
deviceSendMessage, deviceSendMessage,
deviceShareId, deviceShareId,
lightModeSettings, //灯模式设置 lightModeSettings, //灯模式设置
auxiliaryLightModeSettings, //辅灯模式
laserModeSettings, //激光模式设置 laserModeSettings, //激光模式设置
salaModeSettings, //声光报警
mapReverseGeocoding //地图逆解析 mapReverseGeocoding //地图逆解析
} from '@/api/6075/6075.js' } from '@/api/6075/6075.js'
import { import {
@ -361,10 +372,10 @@
selectedImage: null, // 添加这个变量来存储选择的图片 selectedImage: null, // 添加这个变量来存储选择的图片
file: '', file: '',
selectedItemIndex: 0, selectedItemIndex: 0,
radioList: ['M', 'S'],
radioSelected: 0, // -1表示未选中任何项
deviceType: '', deviceType: '',
popupType: '', //弹框类型 popupType: '', //弹框类型
pendingMainMode: null, // 选中的索引
items: [],
} }
}, },
computed: { computed: {
@ -424,19 +435,53 @@
url: '/pages/common/map/index' url: '/pages/common/map/index'
}) })
}, },
// 激光模式
lasermode() {
this.lightModeC = true
},
// 声光报警 // 声光报警
audible() { audible() {
this.showPopup('audibleAlarm'); this.showPopup('audibleAlarm');
}, },
// 激光模式
lasermode() {
this.lightModeC = true;
},
// 激光确认框提交
handleBtn() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
icon: 'none'
});
return;
}
const instructValue = this.isLaserOn ? 0 : 1;
let data = {
deviceId: this.computedDeviceId,
instructValue: instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
laserModeSettings(data).then((res) => {
if (res.code == 200) {
uni.showToast({
icon: 'none',
title: res.msg
});
// 更新状态
this.isLaserOn = !this.isLaserOn;
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
this.lightModeC = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
})
},
//激光取消
handleDisagree() { handleDisagree() {
this.lightModeC = false this.lightModeC = false
}, },
// 取消按钮 handleDisagree() {
handleBtn() {
this.lightModeC = false this.lightModeC = false
}, },
// 主灯模式 // 主灯模式
@ -531,7 +576,6 @@
this.isFormExpanded = !this.isFormExpanded; this.isFormExpanded = !this.isFormExpanded;
}, },
onItemClick(index) { onItemClick(index) {
console.log(index, 'index');
const item = this.items[index]; const item = this.items[index];
this.selectedItemIndex = index; this.selectedItemIndex = index;
this.items = this.items.map((item, i) => ({ this.items = this.items.map((item, i) => ({
@ -539,14 +583,73 @@
selected: i === index selected: i === index
})); }));
this.pendingMainMode = item.text; this.pendingMainMode = item.text;
// 主灯 console.log(this.pendingMainMode, 'this.pendingMainModethis.pendingMainMode');
this.currentMainMode = item.text;
// 辅灯
this.currentSubMode = item.text;
}, },
// 灯光模式的确认 // 灯光模式的确认
handleSumbit() { handleSumbit() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
icon: 'none'
});
return;
}
if (this.popupTitle == '主灯模式') {
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
let data = {
deviceId: this.computedDeviceId,
instructValue: selectedItem.instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
lightModeSettings(data).then((res) => {
if (res.code == 200) {
this.currentMainMode = this.pendingMainMode;
this.selectedItemIndex = selectedItem;
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
this.lightModeA = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
}
})
} else {
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
let data = {
deviceId: this.computedDeviceId,
instructValue: selectedItem.instructValue,
deviceImei: this.itemInfo.deviceImei,
typeName: this.itemInfo.typeName,
};
auxiliaryLightModeSettings(data).then((res) => {
if (res.code == 200) {
this.currentSubMode = this.pendingMainMode;
this.selectedItemIndex = selectedItem;
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
this.lightModeA = false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
uni.hideLoading();
}
})
}
this.lightModeA = false this.lightModeA = false
}, },
// 上传开机画面 // 上传开机画面
@ -605,7 +708,7 @@
}); });
uni.uploadFile({ uni.uploadFile({
url: baseURL + '/app/device/uploadLogo', url: baseURL + '/app/bjq6075/device/uploadLogo',
filePath: this.selectedImage, filePath: this.selectedImage,
name: 'file', name: 'file',
formData: { formData: {
@ -1136,7 +1239,17 @@
margin-left: 40rpx; margin-left: 40rpx;
} }
.callpolice {
display: flex;
justify-content: space-between;
border-radius: 16rpx;
background: rgba(224, 52, 52, 1);
padding: 15rpx;
margin-bottom: 15rpx;
color: #fff;
line-height: 35rpx;
font-size: 26rpx;
}
.example-body { .example-body {
position: absolute; position: absolute;
left: 50%; left: 50%;

View File

@ -536,6 +536,7 @@
}, },
// 灯光模式的确认 // 灯光模式的确认
handleSumbit() { handleSumbit() {
if (this.deviceInfo.onlineStatus !== 1) { if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({ uni.showToast({
title: '设备已离线', title: '设备已离线',

View File

@ -22,7 +22,25 @@ const request = (options) => {
header: options.header || {}, header: options.header || {},
timeout: 30000, timeout: 30000,
success: (res) => { success: (res) => {
// console.log("res=",res); console.log(res, 'resss');
if (res.data.code === 401) {
uni.removeStorageSync('token');
uni.removeStorageSync('clientID');
uni.showToast({
title: '登录已过期,请重新登录',
icon: 'none',
duration: 2000,
complete: () => {
setTimeout(() => {
uni.reLaunch({
url: '/pages/common/login/index'
});
}, 3000);
}
});
// 返回一个pending的Promise中断当前的Promise链
return new Promise(() => { });
}
resolve(res.data); resolve(res.data);
}, },
fail: (err) => { fail: (err) => {