1
0
forked from dyf/APP

Compare commits

...

2 Commits

Author SHA1 Message Date
497cce1e45 670 SOS转到服务端进行 2025-09-24 11:34:15 +08:00
8a54aa85d1 670增加跳转至地图,修改mqtt.js,使用request中的环境配置 2025-09-24 10:18:31 +08:00
7 changed files with 94 additions and 24 deletions

View File

@ -9,11 +9,13 @@ function getdata(data,url,method){
if(!method){ if(!method){
method='POST'; method='POST';
} }
request({ let cfg={
url: url, url: url,
method: method, method: method,
data:data data:data
}).then((res)=>{ };
request(cfg).then((res)=>{
console.log("res=",res); console.log("res=",res);
resolve(res); resolve(res);
}).catch(ex=>{ }).catch(ex=>{
@ -90,11 +92,22 @@ function getDetail(id){
method: 'get', method: 'get',
}) })
} }
//发送SOS
function sendSos(data){
return request({
url: '/app/xinghan/device/SOSGradeSettings',
method: 'post',
data:data
})
}
export default{ export default{
sendUsr:sendUsr, sendUsr:sendUsr,
warnMsg:warnMsg, warnMsg:warnMsg,
sendPic:sendPic, sendPic:sendPic,
getDetail:getDetail getDetail:getDetail,
sendSos:sendSos,
getdata:getdata
} }

View File

@ -2,11 +2,11 @@
const config = { const config = {
// 开发环境 // 开发环境
development: { development: {
BASE_URL: 'http://192.168.2.34:8000', BASE_URL: 'http://192.168.110.56:8000',
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: 'www.cnxhyc.com', MQTT_HOST: '47.120.79.150',
MQTT_PORT: 9083, MQTT_PORT: 8083,
MQTT_USERNAME: 'admin', MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG' MQTT_PASSWORD: '#YtvpSfCNG'
}, },
@ -16,7 +16,7 @@ const config = {
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: 'www.cnxhyc.com', MQTT_HOST: 'www.cnxhyc.com',
MQTT_PORT: 9084, MQTT_PORT: 8083,
MQTT_USERNAME: 'admin', MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG' MQTT_PASSWORD: '#YtvpSfCNG'
} }

View File

@ -2,7 +2,7 @@
"name" : "星汉物联", "name" : "星汉物联",
"appid" : "__UNI__A21EF43", "appid" : "__UNI__A21EF43",
"description" : "设备管控", "description" : "设备管控",
"versionName" : "1.0.25", "versionName" : "1.0.28",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
@ -21,8 +21,8 @@
"Bluetooth" : {}, "Bluetooth" : {},
"Barcode" : {}, "Barcode" : {},
"Camera" : {}, "Camera" : {},
"OAuth" : {}, "Geolocation" : {},
"Geolocation" : {} "Maps" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {

View File

@ -39,7 +39,7 @@
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">定位信息</text> <text class="lbl">定位信息</text>
<view class="multiValue"> <view class="multiValue" @click.stop="gotoMap()">
<view class="valueItem valueFont"> <view class="valueItem valueFont">
{{formData.Lon}} {{formData.Lon}}
@ -51,7 +51,10 @@
</view> </view>
<view class="valueItem"> <view class="valueItem">
<view style="width:80%;float: right;text-align: right;" class="valueFont">{{formData.address}} <view style="width:80%;float: right;text-align: right;" class="valueFont">
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
style="vertical-align: bottom;" />
{{formData.address}}
</view> </view>
<view class="clear"></view> <view class="clear"></view>
</view> </view>
@ -406,7 +409,29 @@
rgb565Data: [], rgb565Data: [],
videoHexArray: [], videoHexArray: [],
picPath: "", picPath: "",
permissions: [] //权限列表 permissions: [], //权限列表
detailData: {
deviceId: null,
deviceName: null,
deviceImei: null,
deviceMac: null,
communicationMode: null,
devicePic: null,
typeName: null,
bluetoothName: null,
deviceStatus: null,
personnelInfo: null,
onlineStatus: null,
longitude: null,
latitude: null,
address: null,
staDetectGrade: null,
staLightGrade: null,
staSOSGrade: null,
staPowerTime: null,
staPowerPercent: null,
staDetectResult: null
}
} }
}, },
created() { created() {
@ -424,7 +449,8 @@
}, },
onLoad: function() { onLoad: function() {
// console.log("670页面加载");
these = this; these = this;
recei = BleReceive.getBleReceive(); recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool(); ble = BleTool.getBleTool();
@ -490,6 +516,21 @@
}, },
methods: { methods: {
gotoMap() {
this.detailData.longitude = this.formData.Lon;
this.detailData.latitude = this.formData.Lat;
uni.navigateTo({
url: '/pages/common/map/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('Map', {
data: this.detailData
});
}
})
},
getDetail() { getDetail() {
var that = this; var that = this;
api.getDetail(this.device.id).then(res => { api.getDetail(this.device.id).then(res => {
@ -497,6 +538,7 @@
if (res && res.code == 200) { if (res && res.code == 200) {
res = res.data; res = res.data;
let json = res; let json = res;
this.detailData = json;
console.log("res=", res); console.log("res=", res);
that.formData.Lon = res.longitude; that.formData.Lon = res.longitude;
that.formData.Lat = res.latitude; that.formData.Lat = res.latitude;
@ -677,8 +719,9 @@
}); });
}, },
sendMQ(message) { sendMQ(json, url) {
message = JSON.stringify(message);
let message = JSON.stringify(json);
console.log("imei=", this.formData.imei ? this.formData.imei : this.device.deviceImei); console.log("imei=", this.formData.imei ? this.formData.imei : this.device.deviceImei);
const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`; const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -706,6 +749,8 @@
reject(error); reject(error);
} }
}); });
}, },
parseDataMQ(json) { parseDataMQ(json) {
let receiveData = {}; let receiveData = {};
@ -1052,7 +1097,7 @@
}); });
}, },
sosSetting: function(type) { sosSetting: function(type) {
debugger; debugger;
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') { if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
this.showPop({ this.showPop({
@ -1096,7 +1141,9 @@ debugger;
let requestSend = () => { let requestSend = () => {
this.sendMQ(json).then((res) => { this.sendMQ(json).then((res) => {
console.log("4g发送成功"); console.log("4g发送成功");
json.deviceId = these.device.id;
json.deviceImei = these.device.deviceImei;
api.sendSos(json);
}).catch((ex) => { }).catch((ex) => {
console.log("ex=", ex); console.log("ex=", ex);

View File

@ -5,6 +5,9 @@ export const showLoading = (ev,options) => {
if(!ev){ if(!ev){
return; return;
} }
if(!ev.$refs.loading){
return;
}
let defaultTxt="请稍候..."; let defaultTxt="请稍候...";
if(!options){ if(!options){
options={text:defaultTxt}; options={text:defaultTxt};
@ -23,6 +26,9 @@ export const hideLoading = (ev) => {
if(!ev){ if(!ev){
return; return;
}
if(!ev.$refs.loading){
return;
} }
ev.$refs.loading.hide(); ev.$refs.loading.hide();
@ -34,6 +40,9 @@ export const updateLoading = (ev,options) => {
if(!ev){ if(!ev){
return; return;
} }
if(!ev.$refs.loading){
return;
}
if(!options){ if(!options){
options={a:1}; options={a:1};
} }

View File

@ -117,8 +117,9 @@
*/ */
import Paho from 'paho-mqtt'; import Paho from 'paho-mqtt';
import allConfigs from '../config/index.js'; import allConfigs from '../config/index.js';
import {env} from '@/utils/request.js'
// 根据环境选择正确的配置 // 根据环境选择正确的配置
const env = 'production'; //production development // const env = 'development'; //production development
const envConfig = allConfigs[env]; const envConfig = allConfigs[env];
const mqttProtocol = env === 'production' ? 'wss' : 'ws'; const mqttProtocol = env === 'production' ? 'wss' : 'ws';
const useSSL = env === 'production'; const useSSL = env === 'production';
@ -214,7 +215,7 @@ class MqttClient {
} }
}, },
onFailure: (message) => { onFailure: (message) => {
console.error('MQTT连接失败:', message.errorMessage); console.error('MQTT连接失败:', message);
if (!this.manualDisconnect) { if (!this.manualDisconnect) {
this.startReconnecting(); this.startReconnecting();
} }

View File

@ -1,5 +1,5 @@
import config from '../config/index.js'; import config from '../config/index.js';
const env = 'development'; //production development //开发of线上 改这里就行 export const env = 'development'; //production development //开发of线上 改这里就行
const BASE = config[env]; const BASE = config[env];
const request = (options) => { const request = (options) => {
console.log("options"+JSON.stringify(options),BASE.BASE_URL) console.log("options"+JSON.stringify(options),BASE.BASE_URL)
@ -46,7 +46,7 @@ const request = (options) => {
}); });
}; };
// 导出基础URL以便其他地方使用 // 导出基础URL以便其他地方使用
export const baseURL = BASE.BASE_URL export const baseURL = BASE.BASE_URL;
export const getToken = () => uni.getStorageSync('token') // 获取token的方法 export const getToken = () => uni.getStorageSync('token'); // 获取token的方法
export const clientid =() => uni.getStorageSync('clientID'); export const clientid =() => uni.getStorageSync('clientID');
export default request; export default request;