From dadad6ed194f88dceff90dcaa6c20d6513bf0282 Mon Sep 17 00:00:00 2001
From: fengerli <528575642@qq.com>
Date: Wed, 12 Nov 2025 09:51:35 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0token=E8=BF=87=E6=9C=9F?=
=?UTF-8?q?=EF=BC=8C=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=99=BB=E5=BD=95=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/6075/6075.js | 20 +++-
pages/210/deviceControl/index.vue | 7 +-
pages/6075/BJQ6075.vue | 155 +++++++++++++++++++++++++----
pages/6170/deviceControl/index.vue | 1 +
utils/request.js | 102 +++++++++++--------
5 files changed, 217 insertions(+), 68 deletions(-)
diff --git a/api/6075/6075.js b/api/6075/6075.js
index 2c20546..63540cf 100644
--- a/api/6075/6075.js
+++ b/api/6075/6075.js
@@ -6,7 +6,7 @@ export function deviceDetail(id) {
})
}
// 获取设备分享详细信息
-export function deviceShareId(id) {
+export function deviceShareId (id) {
return request({
url: `/app/bjq6075/device/getShareInfo/${id}`,
method: 'get',
@@ -28,7 +28,7 @@ export function deviceSendMessage(data) {
data: data
})
}
-// 灯光模式设置
+// 主灯光模式设置
export function lightModeSettings(data) {
return request({
url: `/app/bjq6075/device/lightModeSettings`,
@@ -36,6 +36,14 @@ export function lightModeSettings(data) {
data: data
})
}
+// 辅灯模式设置
+export function auxiliaryLightModeSettings(data) {
+ return request({
+ url: `/app/bjq6075/device/auxiliaryLightModeSettings`,
+ method: 'post',
+ data: data
+ })
+}
// 激光模式设置
export function laserModeSettings(data) {
return request({
@@ -52,6 +60,14 @@ export function lightBrightnessSettings(data) {
data: data
})
}
+// 声光报警
+export function salaModeSettings(data) {
+ return request({
+ url: `/app/bjq6075/device/salaModeSettings`,
+ method: 'post',
+ data: data
+ })
+}
// 地图逆解析
export function mapReverseGeocoding(data) {
return request({
diff --git a/pages/210/deviceControl/index.vue b/pages/210/deviceControl/index.vue
index 80f02b9..80be925 100644
--- a/pages/210/deviceControl/index.vue
+++ b/pages/210/deviceControl/index.vue
@@ -238,10 +238,11 @@
+
+
-
-
+
diff --git a/pages/6075/BJQ6075.vue b/pages/6075/BJQ6075.vue
index 146bf60..6acfe98 100644
--- a/pages/6075/BJQ6075.vue
+++ b/pages/6075/BJQ6075.vue
@@ -35,7 +35,13 @@
-
+
+ 设备疑似受到外力碰撞!
+
+
+
+
@@ -44,13 +50,16 @@
设备状态
- {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
+ {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
定位信息
- {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
- {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
+
+ {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
+ {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
+
@@ -293,7 +302,7 @@
icon: '/static/images/210/bj_1.png',
message: '确定开启设备声光报警?',
confirmBtnBg: 'rgba(255, 200, 78, 1)',
- popupBorder:'1rpx solid rgba(255, 200, 78, 0.3)',
+ popupBorder: '1rpx solid rgba(255, 200, 78, 0.3)',
showCancel: true
},
confirm() {
@@ -308,8 +317,10 @@
registerPersonInfo,
deviceSendMessage,
deviceShareId,
- lightModeSettings, //灯光模式设置
+ lightModeSettings, //主灯模式设置
+ auxiliaryLightModeSettings, //辅灯模式
laserModeSettings, //激光模式设置
+ salaModeSettings, //声光报警
mapReverseGeocoding //地图逆解析
} from '@/api/6075/6075.js'
import {
@@ -361,10 +372,10 @@
selectedImage: null, // 添加这个变量来存储选择的图片
file: '',
selectedItemIndex: 0,
- radioList: ['M', 'S'],
- radioSelected: 0, // -1表示未选中任何项
deviceType: '',
popupType: '', //弹框类型
+ pendingMainMode: null, // 选中的索引
+ items: [],
}
},
computed: {
@@ -424,19 +435,53 @@
url: '/pages/common/map/index'
})
},
- // 激光模式
- lasermode() {
- this.lightModeC = true
- },
// 声光报警
audible() {
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() {
this.lightModeC = false
},
- // 取消按钮
- handleBtn() {
+ handleDisagree() {
this.lightModeC = false
},
// 主灯模式
@@ -531,7 +576,6 @@
this.isFormExpanded = !this.isFormExpanded;
},
onItemClick(index) {
- console.log(index, 'index');
const item = this.items[index];
this.selectedItemIndex = index;
this.items = this.items.map((item, i) => ({
@@ -539,14 +583,73 @@
selected: i === index
}));
this.pendingMainMode = item.text;
- // 主灯
- this.currentMainMode = item.text;
- // 辅灯
- this.currentSubMode = item.text;
+ console.log(this.pendingMainMode, 'this.pendingMainModethis.pendingMainMode');
},
// 灯光模式的确认
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
},
// 上传开机画面
@@ -605,7 +708,7 @@
});
uni.uploadFile({
- url: baseURL + '/app/device/uploadLogo',
+ url: baseURL + '/app/bjq6075/device/uploadLogo',
filePath: this.selectedImage,
name: 'file',
formData: {
@@ -1136,7 +1239,17 @@
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 {
position: absolute;
left: 50%;
diff --git a/pages/6170/deviceControl/index.vue b/pages/6170/deviceControl/index.vue
index 4e84187..0c2ab74 100644
--- a/pages/6170/deviceControl/index.vue
+++ b/pages/6170/deviceControl/index.vue
@@ -536,6 +536,7 @@
},
// 灯光模式的确认
handleSumbit() {
+
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
diff --git a/utils/request.js b/utils/request.js
index 681b921..a25cc90 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -2,51 +2,69 @@ import config from '../config/index.js';
export const env = 'production'; //production development //开发of线上 改这里就行
const BASE = config[env];
const request = (options) => {
- console.log("options"+JSON.stringify(options),BASE.BASE_URL)
- return new Promise((resolve, reject) => {
- // 处理GET请求参数
- let url = BASE.BASE_URL + options.url;
- console.log("url"+url)
- if (options.method === 'GET' && options.data) {
- // 使用qs序列化参数
- const params = Object.keys(options.data)
- .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(options.data[key])}`)
- .join('&');
- url += `?${params}`;
- }
+ console.log("options" + JSON.stringify(options), BASE.BASE_URL)
+ return new Promise((resolve, reject) => {
+ // 处理GET请求参数
+ let url = BASE.BASE_URL + options.url;
+ console.log("url" + url)
+ if (options.method === 'GET' && options.data) {
+ // 使用qs序列化参数
+ const params = Object.keys(options.data)
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(options.data[key])}`)
+ .join('&');
+ url += `?${params}`;
+ }
- const config = {
- url: url,
- method: options.method || 'GET',
- data: options.method !== 'GET' ? options.data : {},
- header: options.header || {},
- timeout: 30000,
- success: (res) => {
- // console.log("res=",res);
- resolve(res.data);
- },
- fail: (err) => {
- console.log("ex=",err);
- reject(err);
- }
- };
+ const config = {
+ url: url,
+ method: options.method || 'GET',
+ data: options.method !== 'GET' ? options.data : {},
+ header: options.header || {},
+ timeout: 30000,
+ success: (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);
+ },
+ fail: (err) => {
+ console.log("ex=", err);
+ reject(err);
+ }
+ };
- if (!options.url.includes('/login')) {
- const token = uni.getStorageSync('token');
- const clientid = uni.getStorageSync('clientID');
- if (token) {
- config.header['Authorization'] = 'Bearer ' + token;
- config.header['clientid'] = clientid;
- }
- }
- if (!config.header['Content-Type']) {
- config.header['Content-Type'] = 'application/json';
- }
- uni.request(config);
- });
+ if (!options.url.includes('/login')) {
+ const token = uni.getStorageSync('token');
+ const clientid = uni.getStorageSync('clientID');
+ if (token) {
+ config.header['Authorization'] = 'Bearer ' + token;
+ config.header['clientid'] = clientid;
+ }
+ }
+ if (!config.header['Content-Type']) {
+ config.header['Content-Type'] = 'application/json';
+ }
+ uni.request(config);
+ });
};
// 导出基础URL以便其他地方使用
export const baseURL = BASE.BASE_URL;
export const getToken = () => uni.getStorageSync('token'); // 获取token的方法
-export const clientid =() => uni.getStorageSync('clientID');
-export default request;
+export const clientid = () => uni.getStorageSync('clientID');
+export default request;
\ No newline at end of file