尝试解决主分支冲突
This commit is contained in:
28
App.vue
28
App.vue
@ -1,13 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import request from '@/utils/request.js';
|
import bleTool from '@/utils/BleHelper.js'
|
||||||
import bleTool from '@/utils/BleHelper.js';
|
|
||||||
import upgrade from '@/utils/update.js'
|
import upgrade from '@/utils/update.js'
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
var ble = bleTool.getBleTool();
|
|
||||||
//以下代码仅在开发时使用,否则会出现不可预知的问题。
|
//以下代码仅在开发时使用,否则会出现不可预知的问题。
|
||||||
// uni.clearStorageSync();
|
//清除登陆之外的所有信息;
|
||||||
// let store=uni.getStorageInfoSync();
|
// let store=uni.getStorageInfoSync();
|
||||||
// store.keys.forEach((val,index,array)=>{
|
// store.keys.forEach((val,index,array)=>{
|
||||||
// if(val=="tokenTime"){
|
// if(val=="tokenTime"){
|
||||||
@ -28,21 +26,30 @@
|
|||||||
// uni.removeStorageSync(val);
|
// uni.removeStorageSync(val);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||||
|
|
||||||
|
uni.getSystemInfo({success:function(res){
|
||||||
|
if(res.uniPlatform=='app'){
|
||||||
|
bleTool.getBleTool();
|
||||||
|
upgrade.checkAndUpdateWgt();
|
||||||
|
|
||||||
|
}
|
||||||
|
}});
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
console.log('App Show');
|
console.log('App Show');
|
||||||
upgrade.checkAndUpdateWgt("http://114.55.111.217/app/CheckUpdate");
|
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
console.log('App Hide')
|
console.log('App Hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import 'vk-uview-ui/index.scss';
|
@import 'vk-uview-ui/index.scss';
|
||||||
|
/* #ifdef APP-ANDROID */
|
||||||
|
//苹果应用以下样式后Slider不可拖动
|
||||||
uni-slider .uni-slider-handle-wrapper {
|
uni-slider .uni-slider-handle-wrapper {
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
}
|
}
|
||||||
@ -57,7 +64,8 @@
|
|||||||
uni-slider .uni-slider-handle-wrapper {
|
uni-slider .uni-slider-handle-wrapper {
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
// }
|
||||||
|
/* #endif */
|
||||||
.custom-file-picker .file-picker__box-content {
|
.custom-file-picker .file-picker__box-content {
|
||||||
background: rgba(26, 26, 26, 1);
|
background: rgba(26, 26, 26, 1);
|
||||||
border: none !important;
|
border: none !important;
|
||||||
@ -87,4 +95,10 @@
|
|||||||
font-family: "PingFang SC";
|
font-family: "PingFang SC";
|
||||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "PingFangBold";
|
||||||
|
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import {request,baseURL} from '@/utils/request'
|
import request, { baseURL } from '@/utils/request'
|
||||||
|
|
||||||
function getdata(data,url,method){
|
function getdata(data,url,method){
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
@ -14,8 +14,10 @@ function getdata(data,url,method){
|
|||||||
method: method,
|
method: method,
|
||||||
data:data
|
data:data
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
|
console.log("res=",res);
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}).catch(ex=>{
|
}).catch(ex=>{
|
||||||
|
console.log("ex=",ex);
|
||||||
reject(ex);
|
reject(ex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -81,10 +83,18 @@ function sendPic(data){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设备详情
|
||||||
|
function getDetail(id){
|
||||||
|
return request({
|
||||||
|
url: '/api/xinghan/device/'+id,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
export default{
|
export default{
|
||||||
sendUsr:sendUsr,
|
sendUsr:sendUsr,
|
||||||
warnMsg:warnMsg,
|
warnMsg:warnMsg,
|
||||||
sendPic:sendPic
|
sendPic:sendPic,
|
||||||
|
getDetail:getDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
55
api/670/History.js
Normal file
55
api/670/History.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import request, { baseURL } from '@/utils/request'
|
||||||
|
|
||||||
|
function getdata(data,url,method){
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
if(!url){
|
||||||
|
reject('url为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!method){
|
||||||
|
method='POST';
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
url: url,
|
||||||
|
method: method,
|
||||||
|
data:data
|
||||||
|
}).then((res)=>{
|
||||||
|
console.log("res=",res);
|
||||||
|
resolve(res);
|
||||||
|
}).catch(ex=>{
|
||||||
|
console.log("ex=",ex);
|
||||||
|
reject(ex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取开关机数据
|
||||||
|
function getSwithData(data){
|
||||||
|
let url="";
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//报警信息
|
||||||
|
function getWarnData(data){
|
||||||
|
let url=""
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//故障信息
|
||||||
|
function getFaulData(data){
|
||||||
|
let url=""
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
export default{
|
||||||
|
getSwithData:getSwithData,
|
||||||
|
getWarnData:getWarnData,
|
||||||
|
getFaulData:getFaulData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,16 +15,65 @@ export function resourceSmsCode(params) {
|
|||||||
data: params
|
data: params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
export function Logout(data) {
|
export function Logout(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/app/auth/logout',
|
url: '/app/userCenter/logout',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册
|
||||||
|
export function register(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/auth/register',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户注册短信验证码
|
||||||
|
export function registerSmsCode(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/auth/registerSmsCode',
|
||||||
|
method: 'GET',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 忘记密码短信验证码
|
||||||
|
export function forgetPasswordSmsCode(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/auth/forgetPasswordSmsCode',
|
||||||
|
method: 'GET',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 找回密码登录
|
||||||
|
export function forgetPassword(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/auth/forgetPassword',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改密码
|
||||||
|
export function updatePassword(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/userCenter/updatePassword',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 用户注销
|
||||||
|
export function cancelAccount(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/userCenter/cancelAccount',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -177,17 +177,19 @@ export default {
|
|||||||
return styles[this.type][styleType]
|
return styles[this.type][styleType]
|
||||||
},
|
},
|
||||||
handleButtonClick() {
|
handleButtonClick() {
|
||||||
console.log('[MessagePopup] Button clicked with value:', this.inputValue)
|
|
||||||
this.$emit('buttonClick', this.inputValue)
|
this.$emit('buttonClick', this.inputValue)
|
||||||
},
|
},
|
||||||
handleMaskClick() {
|
handleMaskClick() {
|
||||||
console.log('[MessagePopup] Mask clicked')
|
|
||||||
this.$emit('maskClick')
|
this.$emit('maskClick')
|
||||||
},
|
},
|
||||||
closeClick(){
|
closeClick(){
|
||||||
|
|
||||||
this.$emit('closePop')
|
this.$emit('closePop')
|
||||||
},
|
},
|
||||||
handleCancelClick(){
|
handleCancelClick(){
|
||||||
|
|
||||||
this.$emit('cancelPop');
|
this.$emit('cancelPop');
|
||||||
},
|
},
|
||||||
handleInput(e) {
|
handleInput(e) {
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
* 估算单行文本所需的Canvas宽度
|
* 估算单行文本所需的Canvas宽度
|
||||||
*/
|
*/
|
||||||
calcLineWidth(textLine) {
|
calcLineWidth(textLine) {
|
||||||
return textLine.length * this.fontSize;
|
return textLine.length * 16;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
// 1. 动态调整Canvas尺寸
|
// 1. 动态调整Canvas尺寸
|
||||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||||
this.currentCanvasHeight = this.fontSize;
|
this.currentCanvasHeight = 16;
|
||||||
|
|
||||||
// 2. 清空Canvas(绘制背景)
|
// 2. 清空Canvas(绘制背景)
|
||||||
this.clearCanvas();
|
this.clearCanvas();
|
||||||
@ -120,8 +120,9 @@
|
|||||||
// 3. 设置文字样式
|
// 3. 设置文字样式
|
||||||
ctx.setFillStyle(this.color);
|
ctx.setFillStyle(this.color);
|
||||||
ctx.setTextBaseline('middle');
|
ctx.setTextBaseline('middle');
|
||||||
|
// ctx.setTextAlign('center')
|
||||||
ctx.setFontSize(this.fontSize);
|
ctx.setFontSize(this.fontSize);
|
||||||
ctx.font = `${this.fontSize}px "PingFang SC", PingFang SC, Arial, sans-serif`;
|
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||||
|
|
||||||
// 4. 绘制当前行文本
|
// 4. 绘制当前行文本
|
||||||
let currentX = 0;
|
let currentX = 0;
|
||||||
|
|||||||
@ -2,21 +2,21 @@
|
|||||||
const config = {
|
const config = {
|
||||||
// 开发环境
|
// 开发环境
|
||||||
development: {
|
development: {
|
||||||
BASE_URL: 'http://192.168.110.54:8000',
|
BASE_URL: 'http://192.168.2.34:8000',
|
||||||
API_PREFIX: '',
|
API_PREFIX: '',
|
||||||
// MQTT 配置
|
// MQTT 配置
|
||||||
MQTT_HOST: '47.120.79.150',
|
MQTT_HOST: 'www.cnxhyc.com',
|
||||||
MQTT_PORT: 8083,
|
MQTT_PORT: 9083,
|
||||||
MQTT_USERNAME: 'admin',
|
MQTT_USERNAME: 'admin',
|
||||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||||
},
|
},
|
||||||
// 生产环境
|
// 生产环境
|
||||||
production: {
|
production: {
|
||||||
BASE_URL: 'http://192.168.110.54:8000', // https://fuyuanshen.com/backend
|
BASE_URL: 'https://fuyuanshen.com/backend',
|
||||||
API_PREFIX: '',
|
API_PREFIX: '',
|
||||||
// MQTT 配置
|
// MQTT 配置
|
||||||
MQTT_HOST: '47.120.79.150',
|
MQTT_HOST: 'www.cnxhyc.com',
|
||||||
MQTT_PORT: 8083,
|
MQTT_PORT: 9084,
|
||||||
MQTT_USERNAME: 'admin',
|
MQTT_USERNAME: 'admin',
|
||||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||||
}
|
}
|
||||||
|
|||||||
2
main.js
2
main.js
@ -1,6 +1,6 @@
|
|||||||
import App from './App'
|
import App from './App'
|
||||||
|
|
||||||
// 引入 uView UI
|
//// 引入 uView UI
|
||||||
import uView from 'vk-uview-ui';
|
import uView from 'vk-uview-ui';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name" : "晶全-物联",
|
"name" : "星汉物联",
|
||||||
"appid" : "__UNI__A21EF43",
|
"appid" : "__UNI__A21EF43",
|
||||||
"description" : "设备管控",
|
"description" : "设备管控",
|
||||||
"versionName" : "1.0.9",
|
"versionName" : "1.0.25",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
@ -21,8 +21,7 @@
|
|||||||
"Bluetooth" : {},
|
"Bluetooth" : {},
|
||||||
"Barcode" : {},
|
"Barcode" : {},
|
||||||
"Camera" : {},
|
"Camera" : {},
|
||||||
"Record" : {},
|
"OAuth" : {},
|
||||||
"VideoPlayer" : {},
|
|
||||||
"Geolocation" : {}
|
"Geolocation" : {}
|
||||||
},
|
},
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
@ -157,8 +156,5 @@
|
|||||||
"enable" : false
|
"enable" : false
|
||||||
},
|
},
|
||||||
"vueVersion" : "2",
|
"vueVersion" : "2",
|
||||||
"locale" : "zh-Hans",
|
"locale" : "auto"
|
||||||
"fallbackLocale" : "zh-Hans"
|
|
||||||
}
|
}
|
||||||
/* 5+App特有相关 */
|
|
||||||
|
|
||||||
|
|||||||
16
package-lock.json
generated
16
package-lock.json
generated
@ -6,8 +6,10 @@
|
|||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
|
"blueimp-md5": "^2.19.0",
|
||||||
"cordova-sqlite-storage": "^7.0.0",
|
"cordova-sqlite-storage": "^7.0.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
|
"mescroll-uni": "^1.3.7",
|
||||||
"paho-mqtt": "^1.1.0",
|
"paho-mqtt": "^1.1.0",
|
||||||
"text-encoding": "^0.7.0",
|
"text-encoding": "^0.7.0",
|
||||||
"vk-uview-ui": "^1.5.2"
|
"vk-uview-ui": "^1.5.2"
|
||||||
@ -28,6 +30,11 @@
|
|||||||
"proxy-from-env": "^1.1.0"
|
"proxy-from-env": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/blueimp-md5": {
|
||||||
|
"version": "2.19.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz",
|
||||||
|
"integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w=="
|
||||||
|
},
|
||||||
"node_modules/call-bind-apply-helpers": {
|
"node_modules/call-bind-apply-helpers": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||||
@ -268,6 +275,12 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mescroll-uni": {
|
||||||
|
"version": "1.3.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/mescroll-uni/-/mescroll-uni-1.3.7.tgz",
|
||||||
|
"integrity": "sha512-1pQMtGA+iVRKhfJZZNXdBx05NnthIk6zm3hRbumswSA54eaKOMgpUDb9AQ2+rRdXmS6kLkEYSbW/fkb7/IyoAg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/mime-db": {
|
"node_modules/mime-db": {
|
||||||
"version": "1.52.0",
|
"version": "1.52.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
@ -290,7 +303,8 @@
|
|||||||
"node_modules/paho-mqtt": {
|
"node_modules/paho-mqtt": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/paho-mqtt/-/paho-mqtt-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/paho-mqtt/-/paho-mqtt-1.1.0.tgz",
|
||||||
"integrity": "sha512-KPbL9KAB0ASvhSDbOrZBaccXS+/s7/LIofbPyERww8hM5Ko71GUJQ6Nmg0BWqj8phAIT8zdf/Sd/RftHU9i2HA=="
|
"integrity": "sha512-KPbL9KAB0ASvhSDbOrZBaccXS+/s7/LIofbPyERww8hM5Ko71GUJQ6Nmg0BWqj8phAIT8zdf/Sd/RftHU9i2HA==",
|
||||||
|
"license": "EPL-1.0"
|
||||||
},
|
},
|
||||||
"node_modules/proxy-from-env": {
|
"node_modules/proxy-from-env": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
|
"blueimp-md5": "^2.19.0",
|
||||||
"cordova-sqlite-storage": "^7.0.0",
|
"cordova-sqlite-storage": "^7.0.0",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"paho-mqtt": "^1.1.0",
|
"paho-mqtt": "^1.1.0",
|
||||||
|
|||||||
125
pages.json
125
pages.json
@ -1,27 +1,27 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
|
// 登录
|
||||||
{
|
{
|
||||||
"path": "pages/common/login/index",
|
"path": "pages/common/login/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 注册
|
||||||
{
|
{
|
||||||
"path" : "pages/BlueTooth/ModeSetting/index",
|
"path": "pages/common/register/index",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
"navigationStyle": "custom"
|
||||||
"navigationBarTitleText" : "设备类型"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 忘记密码
|
||||||
{
|
{
|
||||||
"path" : "pages/670/HBY670",
|
"path": "pages/common/forgotPassword/index",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
"navigationStyle": "custom"
|
||||||
"navigationBarTitleText" : "HBY670"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/common/index/index",
|
"path": "pages/common/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -72,6 +72,27 @@
|
|||||||
"navigationBarTitleText": "关于我们"
|
"navigationBarTitleText": "关于我们"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 账号安全
|
||||||
|
{
|
||||||
|
"path": "pages/common/account/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "账户安全"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 注销账号
|
||||||
|
{
|
||||||
|
"path": "pages/common/account/deleteAccount/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "注销账号"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 修改密码
|
||||||
|
{
|
||||||
|
"path": "pages/common/account/changepassword/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "修改密码"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6170/deviceControl/index",
|
"path": "pages/6170/deviceControl/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -81,9 +102,11 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/6170/callPolice/index",
|
"path": "pages/6170/callPolice/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "报警"
|
"navigationBarTitleText": "报警",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/210/deviceControl/index",
|
"path": "pages/210/deviceControl/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -119,13 +142,13 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/common/addBLE/addEquip",
|
"path": "pages/common/addBLE/addEquip",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "添加设备"
|
"navigationBarTitleText": "扫描设备"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/common/addBLE/LinkBle",
|
"path": "pages/common/addBLE/LinkBle",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "扫描到的设备"
|
"navigationBarTitleText": "绑定设备"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -142,12 +165,6 @@
|
|||||||
"fullscreen": true
|
"fullscreen": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/650/HBY650",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY650"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/common/map/index",
|
"path": "pages/common/map/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -161,25 +178,26 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6170/allShare/index",
|
"path": "pages/common/allShare/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "所有分享"
|
"navigationBarTitleText": "所有分享"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/6170/share/index",
|
"path": "pages/common/share/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分享"
|
"navigationBarTitleText": "分享"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6170/shareDevices/index",
|
"path": "pages/common/shareDevices/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分享设备"
|
"navigationBarTitleText": "分享设备"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/6170/shareManagement/index",
|
"path": "pages/common/shareManagement/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分享管理"
|
"navigationBarTitleText": "分享管理"
|
||||||
}
|
}
|
||||||
@ -209,73 +227,29 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend",
|
"path": "pages/670/HBY670",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "发送视频"
|
"navigationBarTitleText": "HBY670",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_1",
|
"path": "pages/650/HBY650",
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "发送视频"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_670",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "发送视频"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY650",
|
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "HBY650"
|
"navigationBarTitleText": "HBY650"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY650_1",
|
"path": "pages/670/History",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "HBY650"
|
"navigationBarTitleText": "历史记录"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/BlueTooth/ModeSetting/ModeSetting",
|
"path": "pages/7305/BJQ7305",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "7307-0.96TFT"
|
"navigationBarTitleText": "BJQ7305"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/update",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "版本更新"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY6155",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY6155"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY6155V1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY6155_V1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY670V1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY670"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +259,7 @@
|
|||||||
"color": "#fff",
|
"color": "#fff",
|
||||||
"selectedColor": "#BBE600",
|
"selectedColor": "#BBE600",
|
||||||
"backgroundColor": "#202020",
|
"backgroundColor": "#202020",
|
||||||
"list": [
|
"list": [{
|
||||||
{
|
|
||||||
"pagePath": "pages/common/index/index",
|
"pagePath": "pages/common/index/index",
|
||||||
"text": "我的设备",
|
"text": "我的设备",
|
||||||
"iconPath": "/static/tabs/device.png",
|
"iconPath": "/static/tabs/device.png",
|
||||||
|
|||||||
@ -35,11 +35,11 @@
|
|||||||
handleCrop(e) {
|
handleCrop(e) {
|
||||||
|
|
||||||
var these = this;
|
var these = this;
|
||||||
|
const eventChannel = these.getOpenerEventChannel();
|
||||||
this.Statu = true;
|
this.Statu = true;
|
||||||
console.log("裁剪完成");
|
console.log("裁剪完成");
|
||||||
console.log(e.tempFilePath);
|
console.log(e.tempFilePath);
|
||||||
//
|
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
|
||||||
const ctx = uni.createCanvasContext('splashCanvas', this);
|
const ctx = uni.createCanvasContext('splashCanvas', this);
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
e.tempFilePath,
|
e.tempFilePath,
|
||||||
@ -56,9 +56,11 @@
|
|||||||
height: 80,
|
height: 80,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
// 处理像素数据并发送
|
// 处理像素数据并发送
|
||||||
const eventChannel = these.getOpenerEventChannel();
|
|
||||||
console.log("res.data.length="+res.data.length);
|
|
||||||
|
|
||||||
|
console.log("res.data.length="+res.data.length);
|
||||||
|
eventChannel.emit('ImgCutOverPath', {
|
||||||
|
picPath: e.tempFilePath
|
||||||
|
});
|
||||||
|
|
||||||
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
|
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<text class="value">{{formData.deviceName}}</text>
|
<text class="value">{{formData.deviceName}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">设备状态</text>
|
<text class="lbl">充电状态</text>
|
||||||
<text class="value">{{formData.statu}}</text>
|
<text class="value">{{formData.statu}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="rightTxt">
|
<view class="rightTxt">
|
||||||
<text class="bigTxt">主灯模式</text>
|
<text class="bigTxt">主灯模式</text>
|
||||||
<text class="smallTxt">强光模式</text>
|
<text class="smallTxt">{{getMode}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="mode marginLeft fleft" v-on:click.stop="ModeSetting('fu')">
|
<view class="mode marginLeft fleft" v-on:click.stop="ModeSetting('fu')">
|
||||||
@ -83,8 +83,8 @@
|
|||||||
<text class="usrtitle fleft">人员信息登记</text>
|
<text class="usrtitle fleft">人员信息登记</text>
|
||||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||||
<view class="clear"></view>
|
<view class="clear"></view>
|
||||||
<TextToHex class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#000000'"
|
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||||
:color="'#FFFFFF'" :fontSize="16" />
|
:color="'#000000'" :fontSize="14" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="item">
|
<view class="item">
|
||||||
@ -143,17 +143,26 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TextToHexVue from '@/components/TextToHex/TextToHex.vue';
|
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||||
import bleTool from '@/utils/BleHelper.js';
|
import bleTool from '@/utils/BleHelper.js';
|
||||||
|
import usrApi from '@/api/670/HBY670.js'
|
||||||
import {
|
import {
|
||||||
showLoading,
|
showLoading,
|
||||||
hideLoading,
|
hideLoading,
|
||||||
updateLoading
|
updateLoading
|
||||||
} from '@/utils/loading.js'
|
} from '@/utils/loading.js'
|
||||||
|
import BleReceive from '@/utils/BleReceive';
|
||||||
|
|
||||||
|
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
|
var BrighInteval = null;
|
||||||
|
var recei = null;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
TextToHexV1
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
@ -172,7 +181,8 @@
|
|||||||
visiblePrompt: false,
|
visiblePrompt: false,
|
||||||
promptTitle: '设备名称',
|
promptTitle: '设备名称',
|
||||||
modelValue: '',
|
modelValue: '',
|
||||||
visibleClose: false
|
visibleClose: false,
|
||||||
|
okCallback:null
|
||||||
},
|
},
|
||||||
BottomMenu: {
|
BottomMenu: {
|
||||||
show: false,
|
show: false,
|
||||||
@ -221,10 +231,29 @@
|
|||||||
liangDu: '100',
|
liangDu: '100',
|
||||||
id: '',
|
id: '',
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
textLines: ['我爱你', '中国', '五星红旗'],
|
textLines: ['', '', ''],
|
||||||
mode: ''
|
mode: ''
|
||||||
},
|
},
|
||||||
|
inteval: 200,
|
||||||
|
device: {
|
||||||
|
id: "",
|
||||||
|
deviceName: "",
|
||||||
|
deviceImei: "",
|
||||||
|
deviceMac: "",
|
||||||
|
communicationMode: 0,
|
||||||
|
devicePic: "",
|
||||||
|
typeName: "",
|
||||||
|
bluetoothName: null,
|
||||||
|
deviceStatus: null,
|
||||||
|
bindingTime: "",
|
||||||
|
onlineStatus: 0,
|
||||||
|
battery: "0",
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
alarmStatus: null,
|
||||||
|
detailPageUrl: "/pages/6155/deviceDetail",
|
||||||
|
showConfirm: false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -233,7 +262,54 @@
|
|||||||
},
|
},
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
these = this;
|
these = this;
|
||||||
|
recei = BleReceive.getBleReceive();
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
|
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
|
||||||
|
|
||||||
|
|
||||||
|
// let f = ble.data.LinkedList.find((v) => {
|
||||||
|
// if (v.name == bleName) {
|
||||||
|
// console.log("找到设备了", v);
|
||||||
|
// these.formData.deviceId = v.deviceId;
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// let link = () => {
|
||||||
|
// if (bleName == 'FB_Site_UART') {
|
||||||
|
// ble.LinkBlue(f.deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
|
||||||
|
// '0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
|
||||||
|
// } else {
|
||||||
|
// ble.LinkBlue(f.deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
|
||||||
|
// '0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// if (!f) {
|
||||||
|
|
||||||
|
|
||||||
|
// ble.addDeviceFound((res) => {
|
||||||
|
// // console.log("发现新设备", res);
|
||||||
|
// f = res.devices.find((v) => {
|
||||||
|
// return v.name == bleName;
|
||||||
|
// });
|
||||||
|
// if (f) {
|
||||||
|
|
||||||
|
// console.log("找到目标设备了", f);
|
||||||
|
// these.formData.deviceId = f.deviceId;
|
||||||
|
|
||||||
|
// link();
|
||||||
|
|
||||||
|
// ble.StopSearch();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// ble.StartSearch();
|
||||||
|
// } else {
|
||||||
|
// link();
|
||||||
|
// }
|
||||||
|
console.log("6155");
|
||||||
ble.addReceiveCallback(these.bleValueNotify);
|
ble.addReceiveCallback(these.bleValueNotify);
|
||||||
let eventChannel = this.getOpenerEventChannel();
|
let eventChannel = this.getOpenerEventChannel();
|
||||||
|
|
||||||
@ -241,7 +317,8 @@
|
|||||||
|
|
||||||
|
|
||||||
let device = data.data;
|
let device = data.data;
|
||||||
console.log("收到父页面的参数:" + JSON.stringify(device));
|
these.device = device;
|
||||||
|
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
if (v.macAddress == device.deviceMac) {
|
if (v.macAddress == device.deviceMac) {
|
||||||
console.log("找到设备了", v);
|
console.log("找到设备了", v);
|
||||||
@ -252,13 +329,8 @@
|
|||||||
});
|
});
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
|
||||||
|
these.getDetail();
|
||||||
these.showPop({
|
these.showBleUnConnect();
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let form = f.formData;
|
let form = f.formData;
|
||||||
@ -276,7 +348,7 @@
|
|||||||
these.formData.deviceId = f.deviceId;
|
these.formData.deviceId = f.deviceId;
|
||||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
|
these.getDetail();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -306,21 +378,54 @@
|
|||||||
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
|
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
|
||||||
remark = '微弱';
|
remark = '微弱';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getMode() {
|
||||||
|
let txt = "关闭";
|
||||||
|
if (this.Status.BottomMenu.type == 'fu') {
|
||||||
|
return txt;
|
||||||
|
}
|
||||||
|
switch (this.formData.mode) {
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
|
||||||
|
txt = "强光模式";
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
txt = "弱光模式";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
txt = "爆闪模式";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
txt = "关闭";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
txt = "关闭";
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return txt;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDevice: function() {
|
getDevice: function() {
|
||||||
console.log("LinkedList=", ble.data.LinkedList);
|
// console.log("LinkedList=", ble.data.LinkedList);
|
||||||
console.log("formData=", these.formData);
|
// console.log("formData=", these.formData);
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId == these.formData.deviceId;
|
return v.macAddress == these.device.deviceMac;
|
||||||
});
|
});
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive) {
|
bleValueNotify: function(receive, device, path) {
|
||||||
console.log("处理接收到的数据:" + receive);
|
|
||||||
|
|
||||||
|
let str = recei.ReceiveData(receive, device, path);
|
||||||
|
|
||||||
|
console.log("处理接收到的数据:" + str);
|
||||||
|
return;
|
||||||
|
let data = recei.ReceiveData(receive, device, path);
|
||||||
let bytes = receive.bytes;
|
let bytes = receive.bytes;
|
||||||
|
|
||||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
@ -383,6 +488,15 @@
|
|||||||
this.formData.statu = warn;
|
this.formData.statu = warn;
|
||||||
this.formData.xuhang = lightingTime;
|
this.formData.xuhang = lightingTime;
|
||||||
|
|
||||||
|
if (batteryLevel <= 20) {
|
||||||
|
this.showPop({
|
||||||
|
message: "设备电量低",
|
||||||
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
|
borderColor: "#e034344d",
|
||||||
|
buttonBgColor: "#E03434",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setBleFormData();
|
this.setBleFormData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
@ -416,16 +530,40 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkImgUpload: function() {
|
showBleUnConnect() {
|
||||||
let f = these.getDevice();
|
this.showPop({
|
||||||
|
|
||||||
if (!f) {
|
|
||||||
these.showPop({
|
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
|
buttonText: '去连接',
|
||||||
|
okCallback: function() {
|
||||||
|
console.log("1111");
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/common/addBLE/addEquip",
|
||||||
|
events: {
|
||||||
|
BindOver: function(data) {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
// 通过eventChannel向被打开页面传送数据
|
||||||
|
res.eventChannel.emit('detailData', {
|
||||||
|
data: these.device
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail(ex) {
|
||||||
|
console.log("跳转失败", ex);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
checkImgUpload: function() {
|
||||||
|
let f = these.getDevice();
|
||||||
|
|
||||||
|
if (!f) {
|
||||||
|
these.showBleUnConnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,10 +571,55 @@
|
|||||||
var processAndSendImageData = function(pixels) {
|
var processAndSendImageData = function(pixels) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 创建RGB565格式的像素数据
|
// 创建RGB565格式的像素数据
|
||||||
const rgb565Data = ble.convertToRGB565(pixels);
|
const arr = ble.convertToRGB565(pixels, 'bgr');
|
||||||
|
|
||||||
|
var list = [];
|
||||||
|
let index = 0; // 用于追踪arr的当前位置
|
||||||
|
let packetSize = 2048;
|
||||||
|
let cSize = 248;
|
||||||
|
// 外层循环:7个主要元素(i从1到7)
|
||||||
|
for (let i = 1; i < 8; i++) {
|
||||||
|
let secondLevel = [];
|
||||||
|
let secondCnt = 0;
|
||||||
|
// 中层循环:每个主要元素包含9个子数组(j从1到9)
|
||||||
|
for (let j = 1; j < 10; j++) {
|
||||||
|
// 确定当前子数组的长度:前8个是254,第9个是64
|
||||||
|
|
||||||
|
let thirdLevel = [];
|
||||||
|
|
||||||
|
// 从arr中提取相应数量的元素
|
||||||
|
for (let k = 0; k < cSize && index < arr.length; k++) {
|
||||||
|
|
||||||
|
if (secondCnt == packetSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
thirdLevel.push(arr[index]);
|
||||||
|
secondCnt++;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
secondLevel.push(thirdLevel);
|
||||||
|
}
|
||||||
|
list.push(secondLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("list=", list);
|
||||||
|
|
||||||
|
let length = 0;
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
const item = list[i];
|
||||||
|
let clength = 0;
|
||||||
|
for (let j = 0; j < item.length; j++) {
|
||||||
|
const element = item[j];
|
||||||
|
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
|
||||||
|
length += element.length;
|
||||||
|
clength += element.length;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
// 分包发送
|
// 分包发送
|
||||||
sendImagePackets(rgb565Data).then(resolve).catch(reject);
|
sendImagePackets(list).then(resolve).catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,90 +629,116 @@
|
|||||||
var sendImagePackets = function(imageData) {
|
var sendImagePackets = function(imageData) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 总数据包数
|
// 总数据包数
|
||||||
const totalPackets = 52;
|
const totalPackets = 7;
|
||||||
let currentPacket = 1;
|
let currentPacket = 1;
|
||||||
|
let childPacket = 1;
|
||||||
|
let totalChildPacket = 9;
|
||||||
|
|
||||||
|
|
||||||
// 发送单个数据包
|
// 发送单个数据包
|
||||||
const sendNextPacket = () => {
|
const sendNextPacket = () => {
|
||||||
if (currentPacket > totalPackets) {
|
if (currentPacket > totalPackets) {
|
||||||
|
setTimeout(() => {
|
||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
|
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "上传成功",
|
message: "上传成功",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
buttonBgColor: '#BBE600'
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
}, 20000)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算当前包的数据
|
var packetData = imageData[currentPacket - 1][childPacket - 1];
|
||||||
let packetSize = 250;
|
// if (packetData.length == 0) {
|
||||||
if (currentPacket <= 51) {
|
// hideLoading(these);
|
||||||
packetSize = 250; // 前51个包每个500字节
|
// these.Status.BottomMenu.show = false;
|
||||||
} else {
|
|
||||||
packetSize = 50; // 最后一个包100字节
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建数据包
|
// these.showPop({
|
||||||
const startIndex = (currentPacket - 1) * packetSize;
|
// message: "上传成功",
|
||||||
const endIndex = Math.min(startIndex + packetSize, imageData
|
// iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||||
.length);
|
// });
|
||||||
if (startIndex > endIndex) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const packetData = imageData.slice(startIndex,
|
|
||||||
endIndex); // imageData.subarray(startIndex, endIndex);
|
|
||||||
console.log("imageData.length=" + imageData.length +
|
|
||||||
",startIndex=" +
|
|
||||||
startIndex +
|
|
||||||
",endIndex=" + endIndex + ",数据包长度" + (endIndex -
|
|
||||||
startIndex) +
|
|
||||||
',packetData.length=' + packetData.length);
|
|
||||||
// 构建数据包
|
|
||||||
const bufferSize = 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
|
||||||
const buffer = new ArrayBuffer(bufferSize);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
// 填充头部
|
// resolve();
|
||||||
dataView.setUint8(0, 0x55); // 帧头
|
// return;
|
||||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
|
||||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
|
||||||
'0')); // 包序号
|
|
||||||
// if(packetData.length==250)
|
|
||||||
// {
|
|
||||||
// dataView.setUint8(3, 0x01);
|
|
||||||
// dataView.setUint8(4, 0xFF);
|
|
||||||
// }
|
// }
|
||||||
|
let start = 0;
|
||||||
|
let bufferSize = packetData.length * 2;
|
||||||
|
|
||||||
if (packetData.length == 250) {
|
if (currentPacket == 7) {
|
||||||
dataView.setUint8(3, 0x01);
|
if (childPacket > 2 && childPacket < 9) {
|
||||||
dataView.setUint8(4, 0xF4);
|
bufferSize = 496;
|
||||||
} else {
|
} else if (childPacket == 9) {
|
||||||
dataView.setUint8(3, 0x00);
|
bufferSize = 128;
|
||||||
dataView.setUint8(4, 0x64);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childPacket == 1) {
|
||||||
|
bufferSize = bufferSize + 8
|
||||||
|
start = 8;
|
||||||
|
}
|
||||||
|
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
|
||||||
|
bufferSize = bufferSize + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
|
||||||
|
var buffer = new ArrayBuffer(bufferSize);
|
||||||
|
var dataView = new DataView(buffer);
|
||||||
|
if (childPacket == 1) {
|
||||||
|
dataView.setUint8(0, 0xFA); // 帧头
|
||||||
|
dataView.setUint8(1, 0x09); // 帧头
|
||||||
|
dataView.setUint8(2, 0x10); // 帧头
|
||||||
|
dataView.setUint8(3, 0x04); // 帧头
|
||||||
|
dataView.setUint8(4, 0xFC); // 帧头
|
||||||
|
dataView.setUint8(5, 0x09); // 帧头
|
||||||
|
|
||||||
|
dataView.setUint8(6, 0x00); // 图序号,图片固定0,视频的话要写序号
|
||||||
|
dataView.setUint8(7, currentPacket); //子包序号
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充数据(每个RGB565值占2字节)
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
for (let i = 0; i < packetData.length; i++) {
|
||||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
|
||||||
|
}
|
||||||
|
console.log("packetData.length=", packetData.length);
|
||||||
|
console.log("bufferSize=", bufferSize)
|
||||||
|
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
|
||||||
|
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送数据包
|
//发送数据包
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||||
30)
|
30)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("发送一个包完成了");
|
|
||||||
|
|
||||||
|
let curr = childPacket + (currentPacket - 1) *
|
||||||
|
totalChildPacket;
|
||||||
|
console.log("第" + currentPacket + "大包,第" + childPacket +
|
||||||
|
"小包发送完成,总计:" + curr);
|
||||||
updateLoading(these, {
|
updateLoading(these, {
|
||||||
text: "正在发送" + currentPacket + "/" +
|
text: "正在发送" + curr + "/63"
|
||||||
totalPackets
|
|
||||||
})
|
})
|
||||||
|
if (childPacket == 9) {
|
||||||
currentPacket++;
|
currentPacket++;
|
||||||
|
childPacket = 1;
|
||||||
|
} else {
|
||||||
|
childPacket++;
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(sendNextPacket, 100);
|
setTimeout(sendNextPacket, 100);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
if (err.code == 10007) {
|
||||||
|
setTimeout(sendNextPacket, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.log("发送数据包失败了", err);
|
console.log("发送数据包失败了", err);
|
||||||
|
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
@ -567,7 +776,8 @@
|
|||||||
|
|
||||||
these.Status.BottomMenu.show = false;
|
these.Status.BottomMenu.show = false;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
processAndSendImageData(data.piexls).catch((ex) => {
|
processAndSendImageData(data.piexls).catch((
|
||||||
|
ex) => {
|
||||||
console.log("出现异常", ex);
|
console.log("出现异常", ex);
|
||||||
});
|
});
|
||||||
}, 0)
|
}, 0)
|
||||||
@ -606,10 +816,10 @@
|
|||||||
text: '强光',
|
text: '强光',
|
||||||
icon: '/static/images/6155/DeviceDetail/qiang.png'
|
icon: '/static/images/6155/DeviceDetail/qiang.png'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
text: '工作光',
|
// text: '工作光',
|
||||||
icon: '/static/images/6155/DeviceDetail/fan.png'
|
// icon: '/static/images/6155/DeviceDetail/fan.png'
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
text: '弱光',
|
text: '弱光',
|
||||||
icon: '/static/images/6155/DeviceDetail/ruo.png'
|
icon: '/static/images/6155/DeviceDetail/ruo.png'
|
||||||
@ -662,42 +872,40 @@
|
|||||||
}
|
}
|
||||||
this.closeMenu();
|
this.closeMenu();
|
||||||
},
|
},
|
||||||
|
|
||||||
setMode(mode, type) {
|
setMode(mode, type) {
|
||||||
|
|
||||||
let dataValue = 0;
|
let dataValue = 0;
|
||||||
this.setBleFormData();
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'main') {
|
|
||||||
|
|
||||||
type = 0x04;
|
|
||||||
} else if (type == 'fu') {
|
|
||||||
|
|
||||||
type = 0x05;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentMode = mode;
|
|
||||||
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
|
|
||||||
|
if (type == 'main') {
|
||||||
|
|
||||||
dataValue = 0x01;
|
dataValue = 0x01;
|
||||||
|
} else if (type == 'fu') {
|
||||||
|
|
||||||
|
dataValue = 0x04;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
dataValue = 0x04;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
dataValue = 0x02;
|
dataValue = 0x02;
|
||||||
break;
|
break;
|
||||||
case 3:
|
// case 2:
|
||||||
|
// dataValue = 0x02;
|
||||||
|
// break;
|
||||||
|
case 2:
|
||||||
dataValue = 0x03;
|
dataValue = 0x03;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
dataValue = 0x00;
|
dataValue = 0x0B;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// console.log("dataValue=", dataValue)
|
||||||
// 构建数据包
|
// 构建数据包
|
||||||
var buffer = new ArrayBuffer(6);
|
var buffer = new ArrayBuffer(6);
|
||||||
var dataView = new DataView(buffer);
|
var dataView = new DataView(buffer);
|
||||||
@ -713,12 +921,7 @@
|
|||||||
// 发送数据
|
// 发送数据
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
these.showPop({
|
these.showBleUnConnect();
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +930,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(() => {
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(() => {
|
||||||
|
this.formData.mode = mode;
|
||||||
|
this.setBleFormData();
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "发送失败," + ex.msg,
|
message: "发送失败," + ex.msg,
|
||||||
@ -771,38 +975,54 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
HidePop: function() {
|
HidePop: function() {
|
||||||
|
console.log("1111");
|
||||||
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
||||||
|
|
||||||
|
}
|
||||||
|
if (this.Status.Pop.okCallback) {
|
||||||
|
this.Status.Pop.okCallback();
|
||||||
}
|
}
|
||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
|
||||||
if (!option) {
|
hideLoading(this);
|
||||||
option = {
|
let defaultCfg = {
|
||||||
a: 1
|
showHeader: false,
|
||||||
|
headerTxt: "",
|
||||||
|
showHeader: false,
|
||||||
|
showCancel: false,
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
buttonBgColor: '#BBE600',
|
||||||
|
okCallback: null,
|
||||||
|
cancelCallback: null,
|
||||||
|
popType: 'custom',
|
||||||
|
buttonText: '确定',
|
||||||
|
clickEvt: ''
|
||||||
};
|
};
|
||||||
|
if (!option) {
|
||||||
|
|
||||||
}
|
}
|
||||||
let keys = Object.keys(option);
|
let keys = Object.keys(option);
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
these.Status.Pop[key] = option[key];
|
this.Status.Pop[key] = option[key];
|
||||||
}
|
}
|
||||||
if (!option.borderColor) {
|
keys = Object.keys(defaultCfg);
|
||||||
option.borderColor = '#BBE600';
|
for (var i = 0; i < keys.length; i++) {
|
||||||
option.buttonBgColor = '#BBE600';
|
let key = keys[i];
|
||||||
|
if (key in option) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
these.Status.Pop.showPop = true;
|
this.Status.Pop[key] = defaultCfg[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Status.Pop.showPop = true;
|
||||||
},
|
},
|
||||||
sendUsr() {
|
sendUsr() {
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
if (!f) {
|
if (!f) {
|
||||||
these.showPop({
|
these.showBleUnConnect()
|
||||||
text: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showLoading(these, {
|
showLoading(these, {
|
||||||
@ -817,8 +1037,8 @@
|
|||||||
|
|
||||||
let packetSize = rgbdata.length; //每包均分的数量
|
let packetSize = rgbdata.length; //每包均分的数量
|
||||||
let mode = rgbdata.length % packetSize; //最后一包的数量
|
let mode = rgbdata.length % packetSize; //最后一包的数量
|
||||||
let cnt = parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :
|
let cnt =
|
||||||
0); //总包数量
|
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
|
||||||
let curr = 1; //当前包序号
|
let curr = 1; //当前包序号
|
||||||
|
|
||||||
let sendNext = () => {
|
let sendNext = () => {
|
||||||
@ -831,6 +1051,7 @@
|
|||||||
let bufferSize = 261;
|
let bufferSize = 261;
|
||||||
|
|
||||||
console.log("bufferSize=", bufferSize)
|
console.log("bufferSize=", bufferSize)
|
||||||
|
|
||||||
let buffer = new ArrayBuffer(bufferSize);
|
let buffer = new ArrayBuffer(bufferSize);
|
||||||
let dataView = new DataView(buffer);
|
let dataView = new DataView(buffer);
|
||||||
let startIndex = (curr - 1) * packetSize;
|
let startIndex = (curr - 1) * packetSize;
|
||||||
@ -844,7 +1065,7 @@
|
|||||||
|
|
||||||
let packetData = rgbdata.slice(startIndex,
|
let packetData = rgbdata.slice(startIndex,
|
||||||
endIndex); //取一片数据发送
|
endIndex); //取一片数据发送
|
||||||
|
console.log("packetData.length=", packetData.length);
|
||||||
let start = 0;
|
let start = 0;
|
||||||
if (curr == 1) {
|
if (curr == 1) {
|
||||||
dataView.setUint8(0, 0xFA);
|
dataView.setUint8(0, 0xFA);
|
||||||
@ -852,7 +1073,7 @@
|
|||||||
dataView.setUint8(2, 0x01);
|
dataView.setUint8(2, 0x01);
|
||||||
dataView.setUint8(3, 0x00);
|
dataView.setUint8(3, 0x00);
|
||||||
|
|
||||||
// dataView.setUint16(2, str.length, false);
|
|
||||||
start = 4;
|
start = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,8 +1083,8 @@
|
|||||||
|
|
||||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
let inteval = parseInt(this.inteval ? this.inteval : 50);
|
||||||
|
console.log("inteval=", inteval)
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||||
.wirteCharactId, 30).then(() => {
|
.wirteCharactId, 30).then(() => {
|
||||||
|
|
||||||
@ -892,12 +1113,36 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("11111");
|
||||||
var result = await this.$refs.textToHex.drawAndGetPixels();
|
var result = null;
|
||||||
|
try {
|
||||||
|
console.log("this.$refs.textToHex=", this.$refs.textToHex);
|
||||||
|
result = await this.$refs.textToHex.drawAndGetPixels();
|
||||||
|
} catch (ex) {
|
||||||
|
console.log("ex=", ex);
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
hideLoading(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("result=", result);
|
||||||
result = result.map(level1 => {
|
result = result.map(level1 => {
|
||||||
return level1.flat(Infinity);
|
return level1.flat(Infinity);
|
||||||
});
|
});
|
||||||
|
console.log("result=", result);
|
||||||
|
|
||||||
|
// var str1="FA 06 01 00 FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 FF 81 03 ED BB DD B7 CB CF F3 C7 CD 39 BE FF FE FF C0 03 FE FB FD FB F3 F7 8F 87 FF FF FF FF FE FF FE FF FE FF C0 03 FF FB FD FB FD FB FD FB FD FB FB FB FB FF F7 F7 EF F7 9F 8F FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||||
|
// var str2="FA 07 01 00 FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EF 77 EF 73 EF 7F 80 01 EF 7F EF 7F EF 03 E7 3B 8E BB EE D7 EE EF ED E7 ED 9B 8B 7D FF FF FF FF FF FF F7 EF F7 F7 EF F7 DF FB FF FF FF FF FE FF 80 01 FE 7F FD BF FB DF F7 E7 9F F9 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||||
|
// var str3="FA 08 01 00 FF FF EF DF EC 01 EF FF AB FF AA 03 AA FB AE FB EE 03 EF DF EF DF EE DB ED DF ED DD EF 1F FF FF FF FF EF BF EF 87 81 77 EE F7 EC 03 81 7F EF 7F EF 7F EF 03 81 7F EF 7F EF 7D EF 7D EF 03 FF FF FF FF F9 F1 CF BF DF FF DF FF C1 FF DD 81 DD F7 DD F7 C1 F7 DF 77 FF 77 BF 77 BF 77 FF F7 FF FF FF FF FD FF FD FF FB FF FB FF F0 07 E7 F7 EF F7 D8 07 BF F7 FF F7 F8 07 FF F7 FF F7 FF C7 FF FF FF FF FF FF FF FF FF FF FE FF FE 7F FE 7F FE FF FD BF FD FF FB DF F7 EF EF F7 DF FB BF FD FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||||
|
|
||||||
|
// let arr1=('0x'+(str1.split(' ').join(",0x"))).split(',');
|
||||||
|
// let arr2=('0x'+(str2.split(' ').join(",0x"))).split(',');
|
||||||
|
// let arr3=('0x'+(str3.split(' ').join(",0x"))).split(',');
|
||||||
|
|
||||||
|
// result=[arr1,arr2,arr3];
|
||||||
|
|
||||||
|
|
||||||
|
// console.log("result=",result);
|
||||||
|
|
||||||
|
|
||||||
let h3dic = [0x06, 0x07, 0x08];
|
let h3dic = [0x06, 0x07, 0x08];
|
||||||
@ -913,9 +1158,9 @@
|
|||||||
var rgb = result[i];
|
var rgb = result[i];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("1111");
|
// console.log("1111");
|
||||||
await sendTxtPackge(rgb, h3dic[i], str);
|
await sendTxtPackge(rgb, h3dic[i], str);
|
||||||
console.log("222222");
|
// console.log("222222");
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
flag = false;
|
flag = false;
|
||||||
console.log("33333");
|
console.log("33333");
|
||||||
@ -930,8 +1175,23 @@
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
console.log("发送成功");
|
console.log("发送成功");
|
||||||
this.showPop({
|
this.showPop({
|
||||||
message: "发送成功"
|
message: "发送成功",
|
||||||
|
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
buttonBgColor: '#BBE600'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let json = {
|
||||||
|
deviceId: these.device.id,
|
||||||
|
name: these.formData.textLines[1],
|
||||||
|
position: these.formData.textLines[0],
|
||||||
|
unitName: these.formData.textLines[2],
|
||||||
|
code: ""
|
||||||
|
};
|
||||||
|
usrApi.sendUsr(json)
|
||||||
} else {
|
} else {
|
||||||
this.showPop({
|
this.showPop({
|
||||||
message: "出现异常发送失败",
|
message: "出现异常发送失败",
|
||||||
@ -944,7 +1204,22 @@
|
|||||||
|
|
||||||
setTimeout(task, 0);
|
setTimeout(task, 0);
|
||||||
},
|
},
|
||||||
|
getDetail() {
|
||||||
|
var that = this;
|
||||||
|
usrApi.getDetail(this.device.id).then(res => {
|
||||||
|
|
||||||
|
if (res && res.code == 200) {
|
||||||
|
res = res.data;
|
||||||
|
let personnelInfo = res.personnelInfo;
|
||||||
|
if (personnelInfo) {
|
||||||
|
these.formData.textLines[2] = personnelInfo.unitName;
|
||||||
|
these.formData.textLines[1] = personnelInfo.name;
|
||||||
|
these.formData.textLines[0] = personnelInfo.position;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
ack: function() {
|
ack: function() {
|
||||||
|
|
||||||
|
|
||||||
@ -956,23 +1231,25 @@
|
|||||||
},
|
},
|
||||||
sliderChange: function(evt) {
|
sliderChange: function(evt) {
|
||||||
this.formData.liangDu = evt.detail.value;
|
this.formData.liangDu = evt.detail.value;
|
||||||
|
clearTimeout(BrighInteval)
|
||||||
//给蓝牙设备发送信号更新亮度
|
//给蓝牙设备发送信号更新亮度
|
||||||
setTimeout(() => {
|
BrighInteval = setTimeout(() => {
|
||||||
this.sendBrightness();
|
this.sendBrightness();
|
||||||
this.setBleFormData();
|
this.setBleFormData();
|
||||||
}, 10);
|
}, 100);
|
||||||
},
|
},
|
||||||
sendBrightness: function() {
|
sendBrightness: function() {
|
||||||
const buffer = new ArrayBuffer(6);
|
const buffer = new ArrayBuffer(6);
|
||||||
const dataView = new DataView(buffer);
|
const dataView = new DataView(buffer);
|
||||||
let data = '0x' + parseInt(this.formData.liangDu).toString(16);
|
let data = '0x' + parseInt(this.formData.liangDu).toString(16);
|
||||||
console.log("亮度:" + this.formData.liangDu + ',16进制:' + data);
|
console.log("亮度:" + this.formData.liangDu + ',16进制:' + data);
|
||||||
dataView.setUint8(0, 0x55); // 帧头
|
dataView.setUint8(0, 0xFA); // 帧头
|
||||||
dataView.setUint8(1, 0x01); // 帧类型:亮度调节
|
dataView.setUint8(1, 0x05); // 帧类型:亮度调节
|
||||||
dataView.setUint8(2, 0x01); // 包序号
|
dataView.setUint8(2, 0x00); // 包序号
|
||||||
dataView.setUint8(3, 0x00); // 数据长度
|
dataView.setUint8(3, 0x01); // 包序号
|
||||||
dataView.setUint8(4, 0x01); // 数据长度
|
dataView.setUint8(4, data); // 数据长度
|
||||||
dataView.setUint8(5, data); // 数据
|
dataView.setUint8(5, 0xFF); // 数据长度
|
||||||
|
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
if (f) {
|
if (f) {
|
||||||
// 发送数据
|
// 发送数据
|
||||||
|
|||||||
@ -188,7 +188,7 @@
|
|||||||
const statusRes = await getdeviceSTatus({
|
const statusRes = await getdeviceSTatus({
|
||||||
functionMode: 2,
|
functionMode: 2,
|
||||||
batchId,
|
batchId,
|
||||||
typeName,
|
typeName:'FunctionAccessBatchStatusRule',
|
||||||
deviceImei,
|
deviceImei,
|
||||||
interval: 500
|
interval: 500
|
||||||
},
|
},
|
||||||
|
|||||||
@ -545,15 +545,6 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 防重复提交
|
|
||||||
if (this.isProcessing) return;
|
|
||||||
let loadingShown = false;
|
|
||||||
uni.showLoading({
|
|
||||||
title: '处理中...',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
loadingShown = true;
|
|
||||||
this.isProcessing = true
|
|
||||||
if (this.selectedItemIndex === null) return;
|
if (this.selectedItemIndex === null) return;
|
||||||
const selectedItem = this.items[this.selectedItemIndex];
|
const selectedItem = this.items[this.selectedItemIndex];
|
||||||
let data = {
|
let data = {
|
||||||
@ -573,15 +564,15 @@
|
|||||||
})
|
})
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
this.lightModeA = false;
|
this.lightModeA = false;
|
||||||
this.isProcessing = false
|
//this.isProcessing = false
|
||||||
loadingShown = false
|
//loadingShown = false
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
this.isProcessing = false
|
//this.isProcessing = false
|
||||||
loadingShown = false
|
//loadingShown = false
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -599,15 +590,6 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 防重复提交
|
|
||||||
if (this.isProcessing) return;
|
|
||||||
let loadingShown = false;
|
|
||||||
uni.showLoading({
|
|
||||||
title: '处理中...',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
loadingShown = true;
|
|
||||||
this.isProcessing = true
|
|
||||||
const instructValue = this.isLaserOn ? 0 : 1;
|
const instructValue = this.isLaserOn ? 0 : 1;
|
||||||
let data = {
|
let data = {
|
||||||
deviceId: this.computedDeviceId,
|
deviceId: this.computedDeviceId,
|
||||||
@ -625,15 +607,11 @@
|
|||||||
this.isLaserOn = !this.isLaserOn;
|
this.isLaserOn = !this.isLaserOn;
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
this.lightModeC = false;
|
this.lightModeC = false;
|
||||||
this.isProcessing = false
|
|
||||||
loadingShown = false
|
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
this.isProcessing = false
|
|
||||||
loadingShown = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -652,11 +630,9 @@
|
|||||||
sizeType: ['original', 'compressed'],
|
sizeType: ['original', 'compressed'],
|
||||||
sourceType: ['album', 'camera'],
|
sourceType: ['album', 'camera'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
// 将选择的图片赋值给selectedImage
|
|
||||||
const file = res.tempFiles[0];
|
const file = res.tempFiles[0];
|
||||||
const fileSize = file.size || 0;
|
const fileSize = file.size || 0;
|
||||||
if (fileSize > 2 * 1024 * 1024) {
|
if (fileSize > 2 * 1024 * 1024) {
|
||||||
console.log(`文件过大: ${fileSize} 字节`); // 调试日志
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '图片大小不能超过2MB',
|
title: '图片大小不能超过2MB',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
@ -664,13 +640,19 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.selectedImage = res.tempFilePaths[0];
|
let that = this;
|
||||||
console.log('选择的图片:', res);
|
uni.navigateTo({
|
||||||
|
url: "/pages/6155/ImgCrop",
|
||||||
|
events: {
|
||||||
|
ImgCutOverPath :function (data) {
|
||||||
|
that.selectedImage = data.picPath;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
success(ev) {
|
||||||
uni.showToast({
|
ev.eventChannel.emit('checkImg', {
|
||||||
title: '选择图片失败',
|
data: res.tempFiles[0].path,
|
||||||
icon: 'none'
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -725,12 +707,12 @@
|
|||||||
// 获取设备状态
|
// 获取设备状态
|
||||||
// 4. 获取设备状态
|
// 4. 获取设备状态
|
||||||
let deviceImei = this.itemInfo.deviceImei
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
let typeName = this.itemInfo.typeName
|
//let typeName = this.itemInfo.typeName
|
||||||
let batchId = ''
|
let batchId = ''
|
||||||
const statusRes = await getdeviceSTatus({
|
const statusRes = await getdeviceSTatus({
|
||||||
functionMode: 1,
|
functionMode: 1,
|
||||||
batchId,
|
batchId,
|
||||||
typeName,
|
typeName: 'FunctionAccessStatusRule',
|
||||||
deviceImei,
|
deviceImei,
|
||||||
interval: 800
|
interval: 800
|
||||||
},
|
},
|
||||||
@ -775,7 +757,7 @@
|
|||||||
// 分享
|
// 分享
|
||||||
shareUp() {
|
shareUp() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/6170/share/index',
|
url: '/pages/common/share/index',
|
||||||
events: {
|
events: {
|
||||||
ack: function(data) {}
|
ack: function(data) {}
|
||||||
},
|
},
|
||||||
@ -907,13 +889,13 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 4. 获取设备状态
|
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
|
||||||
let deviceImei = this.itemInfo.deviceImei
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
let typeName = this.itemInfo.typeName
|
let typeName = this.itemInfo.typeName
|
||||||
const statusRes = await getdeviceSTatus({
|
const statusRes = await getdeviceSTatus({
|
||||||
functionMode: 2,
|
functionMode: 2,
|
||||||
batchId,
|
batchId,
|
||||||
typeName,
|
typeName: 'FunctionAccessBatchStatusRule',
|
||||||
deviceImei,
|
deviceImei,
|
||||||
interval: 500
|
interval: 500
|
||||||
},
|
},
|
||||||
@ -991,11 +973,11 @@
|
|||||||
}
|
}
|
||||||
// 4. 获取设备状态
|
// 4. 获取设备状态
|
||||||
let deviceImei = this.itemInfo.deviceImei
|
let deviceImei = this.itemInfo.deviceImei
|
||||||
let typeName = this.itemInfo.typeName
|
//let typeName = this.itemInfo.typeName
|
||||||
const statusRes = await getdeviceSTatus({
|
const statusRes = await getdeviceSTatus({
|
||||||
functionMode: 2,
|
functionMode: 2,
|
||||||
batchId,
|
batchId,
|
||||||
typeName,
|
typeName: 'FunctionAccessBatchStatusRule',
|
||||||
deviceImei,
|
deviceImei,
|
||||||
interval: 500
|
interval: 500
|
||||||
},
|
},
|
||||||
@ -1178,25 +1160,30 @@
|
|||||||
// 1设备切换灯光实时返回
|
// 1设备切换灯光实时返回
|
||||||
switch (deviceState[0]) {
|
switch (deviceState[0]) {
|
||||||
case 1:
|
case 1:
|
||||||
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
this.currentMainMode = this.getMainLightModeLabel(
|
||||||
|
deviceState[
|
||||||
1]);
|
1]);
|
||||||
this.sliderValue = deviceState[2];
|
this.sliderValue = deviceState[2];
|
||||||
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
||||||
break;
|
break;
|
||||||
// 12为设备实时上报
|
// 12为设备实时上报
|
||||||
case 12:
|
case 12:
|
||||||
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
this.currentMainMode = this.getMainLightModeLabel(
|
||||||
|
deviceState[
|
||||||
1]);
|
1]);
|
||||||
this.isLaserOn = deviceState[2] === 1;
|
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
if (this.deviceInfo) {
|
if (this.deviceInfo) {
|
||||||
this.deviceInfo.batteryPercentage = deviceState[3];
|
this.deviceInfo.batteryPercentage = deviceState[
|
||||||
this.deviceInfo.chargeState = deviceState[4];
|
3]; //第4位电量百分比
|
||||||
this.deviceInfo.batteryRemainingTime = deviceState[5];
|
this.deviceInfo.chargeState = deviceState[
|
||||||
|
4]; //第5位为充电状态(0没有充电,1正在充电,2为已充满)
|
||||||
|
this.deviceInfo.batteryRemainingTime = deviceState[
|
||||||
|
5]; //第6位200代表电池剩余续航时间200分钟
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.deviceInfo.batteryPercentage <
|
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||||
20) {
|
this.deviceInfo.chargeState == 0) {
|
||||||
this.popupType = 'bettery';
|
this.popupType = 'bettery';
|
||||||
this.popupMessage = '请及时充电';
|
this.popupMessage = '请及时充电';
|
||||||
this.showPopupFlag = true;
|
this.showPopupFlag = true;
|
||||||
@ -1648,7 +1635,7 @@
|
|||||||
/* 弹窗主体 */
|
/* 弹窗主体 */
|
||||||
.agreement-popup {
|
.agreement-popup {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 50%;
|
/* height: 50%; */
|
||||||
background-color: rgb(42, 42, 42);
|
background-color: rgb(42, 42, 42);
|
||||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||||
padding: 40rpx;
|
padding: 40rpx;
|
||||||
|
|||||||
@ -173,6 +173,9 @@
|
|||||||
hideLoading,
|
hideLoading,
|
||||||
updateLoading
|
updateLoading
|
||||||
} from '@/utils/loading.js'
|
} from '@/utils/loading.js'
|
||||||
|
import {request,baseURL} from '../../utils/request';
|
||||||
|
|
||||||
|
import usrApi from '@/api/670/HBY670.js'
|
||||||
const pagePath = "pages/650/HBY650";
|
const pagePath = "pages/650/HBY650";
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
@ -197,7 +200,8 @@
|
|||||||
visiblePrompt: false,
|
visiblePrompt: false,
|
||||||
promptTitle: '设备名称',
|
promptTitle: '设备名称',
|
||||||
modelValue: '',
|
modelValue: '',
|
||||||
visibleClose: false
|
visibleClose: false,
|
||||||
|
okCallback:null
|
||||||
},
|
},
|
||||||
BottomMenu: {
|
BottomMenu: {
|
||||||
show: false,
|
show: false,
|
||||||
@ -252,14 +256,33 @@
|
|||||||
cMode: false,
|
cMode: false,
|
||||||
modeCurr: 'low',
|
modeCurr: 'low',
|
||||||
|
|
||||||
company: '黄石消防支队',
|
company: '',
|
||||||
name: '菜英俊',
|
name: '',
|
||||||
job: '小队长',
|
job: '',
|
||||||
id: 'HSXF01061',
|
id: '',
|
||||||
iswarn: false
|
iswarn: false
|
||||||
},
|
},
|
||||||
rgb565Data: [],
|
rgb565Data: [],
|
||||||
videoHexArray: []
|
videoHexArray: [],
|
||||||
|
device: {
|
||||||
|
id: "",
|
||||||
|
deviceName: "",
|
||||||
|
deviceImei: "",
|
||||||
|
deviceMac: "",
|
||||||
|
communicationMode: 0,
|
||||||
|
devicePic: "",
|
||||||
|
typeName: "",
|
||||||
|
bluetoothName: null,
|
||||||
|
deviceStatus: null,
|
||||||
|
bindingTime: "",
|
||||||
|
onlineStatus: 0,
|
||||||
|
battery: "0",
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
alarmStatus: null,
|
||||||
|
detailPageUrl: "/pages/650/HBY650",
|
||||||
|
showConfirm: false
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -271,6 +294,7 @@
|
|||||||
these = this;
|
these = this;
|
||||||
recei = BleReceive.getBleReceive();
|
recei = BleReceive.getBleReceive();
|
||||||
ble = BleTool.getBleTool();
|
ble = BleTool.getBleTool();
|
||||||
|
console.log("650")
|
||||||
ble.addReceiveCallback(these.bleValueNotify);
|
ble.addReceiveCallback(these.bleValueNotify);
|
||||||
let eventChannel = this.getOpenerEventChannel();
|
let eventChannel = this.getOpenerEventChannel();
|
||||||
|
|
||||||
@ -278,7 +302,7 @@
|
|||||||
|
|
||||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||||
var device = data.data;
|
var device = data.data;
|
||||||
|
these.device=device;
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
if (v.macAddress == device.deviceMac) {
|
if (v.macAddress == device.deviceMac) {
|
||||||
console.log("找到设备了", v);
|
console.log("找到设备了", v);
|
||||||
@ -290,12 +314,8 @@
|
|||||||
if (!f) {
|
if (!f) {
|
||||||
|
|
||||||
|
|
||||||
these.showPop({
|
these.showBleUnConnect();
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
these.getDetail();
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let form = f.formData;
|
let form = f.formData;
|
||||||
@ -313,7 +333,7 @@
|
|||||||
these.formData.deviceId = f.deviceId;
|
these.formData.deviceId = f.deviceId;
|
||||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
|
these.getDetail();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -374,9 +394,9 @@
|
|||||||
return className;
|
return className;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||||
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath);
|
let data = recei.ReceiveData(receive, device, pagePath);
|
||||||
console.log("收到设备的数据",data)
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if ("staBlue_picture" in data) {
|
if ("staBlue_picture" in data) {
|
||||||
//重发图片
|
//重发图片
|
||||||
@ -434,11 +454,28 @@ console.log("收到设备的数据",data)
|
|||||||
// console.log("LinkedList=", ble.data.LinkedList);
|
// console.log("LinkedList=", ble.data.LinkedList);
|
||||||
// console.log("formData=", these.formData);
|
// console.log("formData=", these.formData);
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId == these.formData.deviceId;
|
return v.macAddress == these.device.deviceMac;
|
||||||
});
|
});
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
|
getDetail() {
|
||||||
|
var that = this;
|
||||||
|
usrApi.getDetail(this.device.id).then(res => {
|
||||||
|
|
||||||
|
if (res && res.code == 200) {
|
||||||
|
res = res.data;
|
||||||
|
let personnelInfo = res.personnelInfo;
|
||||||
|
if (personnelInfo) {
|
||||||
|
that.formData.company = personnelInfo.unitName;
|
||||||
|
that.formData.name = personnelInfo.name;
|
||||||
|
that.formData.job = personnelInfo.position;
|
||||||
|
that.formData.id = personnelInfo.code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
setBleFormData() {
|
setBleFormData() {
|
||||||
ble.data.LinkedList.find((v) => {
|
ble.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == these.formData.deviceId) {
|
if (v.deviceId == these.formData.deviceId) {
|
||||||
@ -473,7 +510,7 @@ console.log("收到设备的数据",data)
|
|||||||
dataValue = 0x65;
|
dataValue = 0x65;
|
||||||
break;
|
break;
|
||||||
case "close": //关闭
|
case "close": //关闭
|
||||||
dataValue = 0x68;
|
dataValue = 0x64;
|
||||||
break;
|
break;
|
||||||
case true: //开灯
|
case true: //开灯
|
||||||
dataValue = 0x6E;
|
dataValue = 0x6E;
|
||||||
@ -533,12 +570,7 @@ console.log("收到设备的数据",data)
|
|||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
these.showPop({
|
these.showBleUnConnect();
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,6 +579,34 @@ console.log("收到设备的数据",data)
|
|||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
showBleUnConnect(){
|
||||||
|
|
||||||
|
this.showPop({
|
||||||
|
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||||
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
|
borderColor: "#e034344d",
|
||||||
|
buttonBgColor: "#E03434",
|
||||||
|
buttonText:'去连接',
|
||||||
|
okCallback:function(){
|
||||||
|
console.log("1111");
|
||||||
|
uni.navigateTo({
|
||||||
|
url:"/pages/common/addBLE/addEquip",
|
||||||
|
events: {
|
||||||
|
BindOver: function(data) {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
// 通过eventChannel向被打开页面传送数据
|
||||||
|
res.eventChannel.emit('detailData', { data: these.device })
|
||||||
|
},
|
||||||
|
fail(ex){
|
||||||
|
console.log("跳转失败",ex);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
LampToggle: function() {
|
LampToggle: function() {
|
||||||
|
|
||||||
this.formData.cMode = !this.formData.cMode;
|
this.formData.cMode = !this.formData.cMode;
|
||||||
@ -607,7 +667,8 @@ console.log("收到设备的数据",data)
|
|||||||
});
|
});
|
||||||
if (!ReSendNo) {
|
if (!ReSendNo) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
these.HoldYouHand("transmit complete", 0, f
|
||||||
|
.deviceId, f
|
||||||
.writeServiceId, f.wirteCharactId);
|
.writeServiceId, f.wirteCharactId);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
@ -775,8 +836,10 @@ console.log("收到设备的数据",data)
|
|||||||
if (currentPacket > totalPackets) {
|
if (currentPacket > totalPackets) {
|
||||||
if (!ReSendNo) {
|
if (!ReSendNo) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
these.HoldYouHand("transmit complete", 0, f
|
||||||
.writeServiceId, f.wirteCharactId).then(()=>{
|
.deviceId, f
|
||||||
|
.writeServiceId, f.wirteCharactId).then(
|
||||||
|
() => {
|
||||||
console.log("全部发送完毕")
|
console.log("全部发送完毕")
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
console.log("出现异常", ex);
|
console.log("出现异常", ex);
|
||||||
@ -902,13 +965,28 @@ console.log("收到设备的数据",data)
|
|||||||
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
|
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
|
||||||
f.wirteCharactId);
|
f.wirteCharactId);
|
||||||
let p2 = new Promise((succ, err) => {
|
let p2 = new Promise((succ, err) => {
|
||||||
|
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
const clientid = uni.getStorageSync('clientID');
|
||||||
|
if (!token) {
|
||||||
|
err({
|
||||||
|
code: 401,
|
||||||
|
msg: "请先登陆后再试"
|
||||||
|
});
|
||||||
|
hideLoading(these);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: 'http://114.55.111.217/video/upload',
|
url: 'http://114.55.111.217/video/upload',
|
||||||
|
// url: baseURL+"app/video/upload",
|
||||||
filePath: videoPath,
|
filePath: videoPath,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
header: {
|
header: {
|
||||||
"Method": "POST",
|
"Method": "POST",
|
||||||
"Content-Type": "multipart/form-data"
|
"Content-Type": "multipart/form-data",
|
||||||
|
"Authorization": 'Bearer ' + token,
|
||||||
|
"clientid": clientid
|
||||||
},
|
},
|
||||||
timeout: 600000,
|
timeout: 600000,
|
||||||
fail: (ex) => {
|
fail: (ex) => {
|
||||||
@ -1067,9 +1145,12 @@ console.log("收到设备的数据",data)
|
|||||||
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log("1111");
|
||||||
|
|
||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
|
if(this.Status.Pop.okCallback){
|
||||||
|
this.Status.Pop.okCallback();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
|
||||||
@ -1103,12 +1184,7 @@ console.log("收到设备的数据",data)
|
|||||||
|
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
if (!f) {
|
if (!f) {
|
||||||
these.showPop({
|
these.showBleUnConnect();
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
|
||||||
borderColor: "#e034344d",
|
|
||||||
buttonBgColor: "#E03434",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showLoading(this, {
|
showLoading(this, {
|
||||||
@ -1131,7 +1207,8 @@ console.log("收到设备的数据",data)
|
|||||||
if (currentPacket > totalPackets) {
|
if (currentPacket > totalPackets) {
|
||||||
if (!ReSendNo) {
|
if (!ReSendNo) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f.writeServiceId, f
|
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
||||||
|
.writeServiceId, f
|
||||||
.wirteCharactId);
|
.wirteCharactId);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
@ -1155,6 +1232,16 @@ console.log("收到设备的数据",data)
|
|||||||
visibleClose: true
|
visibleClose: true
|
||||||
});
|
});
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
|
|
||||||
|
|
||||||
|
let json = {
|
||||||
|
deviceId: these.device.id,
|
||||||
|
name: these.formData.company,
|
||||||
|
position: these.formData.name,
|
||||||
|
unitName: these.formData.job,
|
||||||
|
code: these.formData.id
|
||||||
|
};
|
||||||
|
usrApi.sendUsr(json)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,6 +1348,7 @@ console.log("收到设备的数据",data)
|
|||||||
}
|
}
|
||||||
console.log("开始握手");
|
console.log("开始握手");
|
||||||
|
|
||||||
|
let send = () => {
|
||||||
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
|
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
|
||||||
() => {
|
() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -1268,9 +1356,18 @@ console.log("收到设备的数据",data)
|
|||||||
resolve(true);
|
resolve(true);
|
||||||
}, pauseTime);
|
}, pauseTime);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log("握手没有成功", )
|
if (err.code == 10007) {
|
||||||
|
send();
|
||||||
|
} else {
|
||||||
|
console.log("握手没有成功", err)
|
||||||
reject(err);
|
reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
send();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
446
pages/670/History.vue
Normal file
446
pages/670/History.vue
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
<template>
|
||||||
|
<view class="content contentBg">
|
||||||
|
<view class="topTip">
|
||||||
|
<view class="item" @click="tabChange(0)" :class="Status.tabIndex===0?'active':''">开机</view>
|
||||||
|
<view class="item" @click="tabChange(1)" :class="Status.tabIndex===1?'active':''">报警</view>
|
||||||
|
<view class="item" @click="tabChange(2)" :class="Status.tabIndex===2?'active':''">故障</view>
|
||||||
|
</view>
|
||||||
|
<view class="tabs">
|
||||||
|
|
||||||
|
<view class="tab" :class="Status.tabIndex===0?'active':''">
|
||||||
|
<view class="li" v-for="item,index in SwithData">
|
||||||
|
<view>
|
||||||
|
<view class="label">开机时间</view>
|
||||||
|
<view class="value">{{item['open']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10">
|
||||||
|
<view class="label">关机时间</view>
|
||||||
|
<view class="value">{{item['close']}}</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="tab" :class="Status.tabIndex===1?'active':''">
|
||||||
|
<view class="li warn" v-for="item,index in WarnData">
|
||||||
|
<view class="row">
|
||||||
|
<view class="label">报警事项:</view>
|
||||||
|
<view class="value red">{{item['evtName']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">报警地点:</view>
|
||||||
|
<view class="value">{{item['address']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">报警时间:</view>
|
||||||
|
<view class="value">{{item['open']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">解除时间:</view>
|
||||||
|
<view class="value">{{item['close']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">报警时长:</view>
|
||||||
|
<view class="value">{{item['time']}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="tab" :class="Status.tabIndex===2?'active':''">
|
||||||
|
|
||||||
|
<view class="li warn" v-for="item,index in FaultData">
|
||||||
|
<view class="row">
|
||||||
|
<view class="label">故障部位:</view>
|
||||||
|
<view class="value red">{{item['evtName']}}</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">故障时间:</view>
|
||||||
|
<view class="value">{{item['open']}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="marginTop10 row">
|
||||||
|
<view class="label">处理时间:</view>
|
||||||
|
<view class="value">{{item['close']}}</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<global-loading ref="loading"></global-loading>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Common from '@/utils/Common.js';
|
||||||
|
import api from '@/api/670/History.js'
|
||||||
|
import {
|
||||||
|
showLoading,
|
||||||
|
hideLoading,
|
||||||
|
updateLoading
|
||||||
|
} from '@/utils/loading.js'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
Status: {
|
||||||
|
tabIndex: 1
|
||||||
|
},
|
||||||
|
device: {},
|
||||||
|
SwithData: [], //开关机的数据
|
||||||
|
FaultData: [], //故障数据
|
||||||
|
WarnData: [], //报警数据
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
var these = this;
|
||||||
|
let channel = this.getOpenerEventChannel();
|
||||||
|
channel.on('detailData', function(opt) {
|
||||||
|
console.log("我收到你的数据了,谢谢你。", opt.data);
|
||||||
|
these.device = opt.data;
|
||||||
|
these.tabChange(these.Status.tabIndex, true);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadWarnData() { //加载报警数据
|
||||||
|
var these = this;
|
||||||
|
let promise1 = new Promise((resolve, reject) => {
|
||||||
|
let arr = [];
|
||||||
|
let endDate = new Date();
|
||||||
|
|
||||||
|
arr.push({
|
||||||
|
evtName: '环境存在漏电电源',
|
||||||
|
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||||
|
open: Common.DateFormat(endDate),
|
||||||
|
time: '00:00:59'
|
||||||
|
});
|
||||||
|
for (var i = 1; i < 10; i++) {
|
||||||
|
arr.push({
|
||||||
|
evtName: '环境存在漏电电源',
|
||||||
|
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||||
|
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||||
|
time: '00:00:59'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
let item = new Date(arr[i].open);
|
||||||
|
let close = Common.DateFormat(item.setHours(4));
|
||||||
|
arr[i].close = close;
|
||||||
|
|
||||||
|
}
|
||||||
|
resolve(arr);
|
||||||
|
});
|
||||||
|
let promise2 = new Promise((resolve, reject) => {
|
||||||
|
api.getWarnData(this.device).then((res) => {
|
||||||
|
resolve(res);
|
||||||
|
}).catch((ex) => {
|
||||||
|
console.log("获取数据异常", ex);
|
||||||
|
reject(ex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.allSettled([promise1, promise2]).then(results => {
|
||||||
|
if (results[1].status == 'fulfilled') {
|
||||||
|
these.WarnData = results[1].value;
|
||||||
|
} else {
|
||||||
|
these.WarnData = results[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
loadSwithData() { //加载开关机数据
|
||||||
|
var these = this;
|
||||||
|
let promise1 = new Promise((resolve, reject) => {
|
||||||
|
let arr = [];
|
||||||
|
let endDate = new Date();
|
||||||
|
|
||||||
|
arr.push({
|
||||||
|
open: Common.DateFormat(endDate)
|
||||||
|
});
|
||||||
|
for (var i = 1; i < 10; i++) {
|
||||||
|
arr.push({
|
||||||
|
open: Common.DateFormat(endDate.setHours(i * -24))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
let item = new Date(arr[i].open);
|
||||||
|
let close = Common.DateFormat(item.setHours(4));
|
||||||
|
arr[i].close = close;
|
||||||
|
|
||||||
|
}
|
||||||
|
resolve(arr);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let promise2 = new Promise((resolve, reject) => {
|
||||||
|
api.getSwithData(this.device).then((res) => {
|
||||||
|
resolve(res);
|
||||||
|
}).catch((ex) => {
|
||||||
|
console.log("获取数据异常", ex);
|
||||||
|
reject(ex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.allSettled([promise1, promise2]).then(results => {
|
||||||
|
if (results[1].status == 'fulfilled') {
|
||||||
|
these.SwithData = results[1].value;
|
||||||
|
} else {
|
||||||
|
these.SwithData = results[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
loadFaultData() { //加载故障数据
|
||||||
|
var these = this;
|
||||||
|
let promise1 = new Promise((resolve, reject) => {
|
||||||
|
let arr = [];
|
||||||
|
let endDate = new Date();
|
||||||
|
|
||||||
|
let dic = ['报警灯', '蜂鸣器', '电池', '蓝牙模块', '定位器', '4G模块'];
|
||||||
|
arr.push({
|
||||||
|
evtName: '报警灯',
|
||||||
|
|
||||||
|
open: Common.DateFormat(endDate),
|
||||||
|
|
||||||
|
});
|
||||||
|
for (var i = 1; i < 10; i++) {
|
||||||
|
arr.push({
|
||||||
|
evtName: dic[i % 6],
|
||||||
|
|
||||||
|
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
let item = new Date(arr[i].open);
|
||||||
|
let close = Common.DateFormat(item.setHours(72), "yyyy-MM-dd");
|
||||||
|
arr[i].close = close;
|
||||||
|
|
||||||
|
}
|
||||||
|
resolve(arr);
|
||||||
|
});
|
||||||
|
|
||||||
|
let promise2 = new Promise((resolve, reject) => {
|
||||||
|
api.getFaulData(this.device).then((res) => {
|
||||||
|
resolve(res);
|
||||||
|
}).catch((ex) => {
|
||||||
|
console.log("获取数据异常", ex);
|
||||||
|
reject(ex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.allSettled([promise1, promise2]).then(results => {
|
||||||
|
if (results[1].status == 'fulfilled') {
|
||||||
|
these.FaultData = results[1].value;
|
||||||
|
} else {
|
||||||
|
these.FaultData = results[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
tabChange(index, ispostback) {
|
||||||
|
if (this.Status.tabIndex === index && !ispostback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.Status.tabIndex = index;
|
||||||
|
showLoading(this);
|
||||||
|
let promise = new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
if (index === 0) {
|
||||||
|
this.loadSwithData();
|
||||||
|
} else if (index === 1) {
|
||||||
|
this.loadWarnData();
|
||||||
|
} else if (index === 2) {
|
||||||
|
this.loadFaultData();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
//TODO handle the exception
|
||||||
|
} finally {
|
||||||
|
hideLoading(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tab .warn .value {
|
||||||
|
padding-left: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab .warn .value.red {
|
||||||
|
color: rgba(224, 52, 52, 1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab .warn .row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginTop10 {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab .li .value {
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
width: calc(100% - 110rpx);
|
||||||
|
height: auto;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab .li .label {
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 110rpx;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab .li {
|
||||||
|
font-family: 'PingFang SC';
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 35rpx;
|
||||||
|
letter-spacing: 0.14rpx;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
background: rgba(26, 26, 26, 1);
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 20rpx 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topTip .item.active {
|
||||||
|
color: rgba(187, 230, 0, 1) !important;
|
||||||
|
font-size: 36rpx !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.topTip .item.active::before {
|
||||||
|
background: rgba(187, 230, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.topTip .item::before {
|
||||||
|
content: "";
|
||||||
|
width: 50%;
|
||||||
|
height: 4px;
|
||||||
|
border-radius: 31px;
|
||||||
|
position: absolute;
|
||||||
|
background: #00000000;
|
||||||
|
bottom: -10px;
|
||||||
|
left: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topTip .item {
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
font-family: 'PingFang SC';
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
letter-spacing: 0.14rpx;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.topTip {
|
||||||
|
padding: 30rpx 0rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
position: sticky;
|
||||||
|
background-color: #121212;
|
||||||
|
height: 110rpx;
|
||||||
|
z-index: 9999;
|
||||||
|
margin-top: -30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #ifdef H5 */
|
||||||
|
/* 仅在 H5 平台生效的样式 */
|
||||||
|
.topTip {
|
||||||
|
top: 44px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
/* #ifdef APP-PLUS */
|
||||||
|
/* 仅在 App 平台生效的样式 */
|
||||||
|
.topTip {
|
||||||
|
top: 0rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 30rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contentBg {
|
||||||
|
background-color: #121212;
|
||||||
|
color: #ffffffde;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleft {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fright {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.displayNone {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p100 {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
1738
pages/7305/BJQ7305.vue
Normal file
1738
pages/7305/BJQ7305.vue
Normal file
File diff suppressed because it is too large
Load Diff
145
pages/common/account/changepassword/index.vue
Normal file
145
pages/common/account/changepassword/index.vue
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<template>
|
||||||
|
<div class="pageContent">
|
||||||
|
<view class="content">
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="password" v-model="password" placeholder="请输入密码" class="input" />
|
||||||
|
</view>
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="password" v-model="surePassword" placeholder="请输入确认密码" class="input" />
|
||||||
|
</view>
|
||||||
|
<button class="login-btn" @click="handleLogin">
|
||||||
|
确认
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
<!-- 成功提示弹框 -->
|
||||||
|
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
|
||||||
|
icon="/static/images/common/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||||
|
@confirm="onPopupConfirm" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
|
import {
|
||||||
|
updatePassword
|
||||||
|
} from '@/api/common/login.js';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
CustomPopup
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
password: "",
|
||||||
|
surePassword: "",
|
||||||
|
showPopupFlag: false,
|
||||||
|
popupTitle: '',
|
||||||
|
popupMessage: '修改成功!',
|
||||||
|
popupConfirmText: '确认',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 确认
|
||||||
|
async handleLogin() {
|
||||||
|
if (!this.password.trim()) {
|
||||||
|
return uni.showToast({
|
||||||
|
title: "请输入密码",
|
||||||
|
icon: "none",
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!this.surePassword.trim()) {
|
||||||
|
return uni.showToast({
|
||||||
|
title: "请输入确认密码",
|
||||||
|
icon: "none",
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (this.password.trim() !== this.surePassword.trim()) {
|
||||||
|
return uni.showToast({
|
||||||
|
title: "两次密码输入不一致",
|
||||||
|
icon: "none",
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中...'
|
||||||
|
})
|
||||||
|
// 调用忘记密码接口
|
||||||
|
const res = await updatePassword({
|
||||||
|
password: md5(this.password)
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.hideLoading()
|
||||||
|
this.showPopupFlag = true
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.msg || '登录失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 确认
|
||||||
|
onPopupConfirm(){
|
||||||
|
uni.navigateBack()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pageContent {
|
||||||
|
background-color: rgb(18, 18, 18);
|
||||||
|
height: 100vh;
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content_con {
|
||||||
|
position: absolute;
|
||||||
|
top: 220rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
left: 30rpx;
|
||||||
|
font-size: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
height: 80rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
margin-top: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ver_item {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-flex {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-login {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-btn {
|
||||||
|
margin-top: 200rpx;
|
||||||
|
background-color: rgb(187, 230, 0);
|
||||||
|
color: rgb(35, 35, 35);
|
||||||
|
border-radius: 50rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
122
pages/common/account/deleteAccount/index.vue
Normal file
122
pages/common/account/deleteAccount/index.vue
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<template>
|
||||||
|
<view class="cancel-account-page">
|
||||||
|
<view class="content">
|
||||||
|
<view class="warning-icon">
|
||||||
|
<text class="icon-text">!</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="tip-text">
|
||||||
|
注销账号后账号将永久失效且不可恢复,并将放弃以下权益与服务
|
||||||
|
</view>
|
||||||
|
<view class="rights-list">
|
||||||
|
<view class="right-item">1. 账号将无法登录;</view>
|
||||||
|
<view class="right-item">2. 设备数据将全部清除;</view>
|
||||||
|
<view class="right-item">3. 个人资料等内容永久失效;</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 确认注销按钮 -->
|
||||||
|
<button class="confirm-btn" @click="confirmBtn">确认注销</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
cancelAccount
|
||||||
|
} from '@/api/common/login.js'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
confirmBtn() {
|
||||||
|
let data = {}
|
||||||
|
cancelAccount(data).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '注销成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/login/index'
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.cancel-account-page {
|
||||||
|
background: rgba(18, 18, 18, 1);
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 60rpx 30rpx;
|
||||||
|
flex: 1;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning-icon {
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
background: rgba(224, 52, 52, 1);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-text {
|
||||||
|
color: #333;
|
||||||
|
font-size: 48rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tip-text {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 27rpx;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
padding: 40rpx 60rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rights-list {
|
||||||
|
width: 100%;
|
||||||
|
background: rgba(26, 26, 26, 1);
|
||||||
|
padding: 30rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
margin-bottom: 120rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-item {
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 26rpx;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-item:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-btn {
|
||||||
|
width: 80%;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 30rpx;
|
||||||
|
border-radius: 91px;
|
||||||
|
background: rgba(224, 52, 52, 1);
|
||||||
|
position: absolute;
|
||||||
|
bottom: 50rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
85
pages/common/account/index.vue
Normal file
85
pages/common/account/index.vue
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<template>
|
||||||
|
<div class="pageContent">
|
||||||
|
<view class="content">
|
||||||
|
<view class="menu-list">
|
||||||
|
<view class="menu-item" @click="changePassword">
|
||||||
|
<text class="title">修改登录密码</text>
|
||||||
|
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="menu-item" @click="deleteAccount">
|
||||||
|
<view class="title">注销账号</view>
|
||||||
|
<view class="menu_zx"> 注销后无法恢复,请谨慎操作</view>
|
||||||
|
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 修改密码
|
||||||
|
changePassword() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/account/changepassword/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 注销账号
|
||||||
|
deleteAccount() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/account/deleteAccount/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pageContent {
|
||||||
|
background-color: rgb(18, 18, 18);
|
||||||
|
height: 100vh;
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
padding: 30rpx 0;
|
||||||
|
border-bottom: 1rpx solid rgba(255, 255, 255, 0.04);
|
||||||
|
align-items: center;
|
||||||
|
background: rgba(26, 26, 26, 1);
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding-left: 20rpx;
|
||||||
|
padding-top: -8rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniIcon {
|
||||||
|
position: absolute;
|
||||||
|
right: 50rpx;
|
||||||
|
top: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-right {
|
||||||
|
margin-left: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu_zx {
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 28rpx;
|
||||||
|
padding-left: 20rpx;
|
||||||
|
padding-top: 8rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -8,18 +8,24 @@
|
|||||||
<view class="deviceName">
|
<view class="deviceName">
|
||||||
蓝牙名:{{device.name}}
|
蓝牙名:{{device.name}}
|
||||||
</view>
|
</view>
|
||||||
|
<view class="deviceName">
|
||||||
|
状态:{{deviceStatu}}
|
||||||
|
</view>
|
||||||
<view class="deviceName">
|
<view class="deviceName">
|
||||||
设备名:{{device.deviceName}}
|
设备名:{{device.deviceName}}
|
||||||
</view>
|
</view>
|
||||||
<view class="deviceId">
|
<view class="deviceId">
|
||||||
ID:{{device.deviceId}}
|
设备Mac:{{device.macAddress}}
|
||||||
|
</view>
|
||||||
|
<view class="deviceId">
|
||||||
|
设备IMEI:{{device.imei}}
|
||||||
</view>
|
</view>
|
||||||
<view class="bound" v-bind:class="boundStatu">
|
<view class="bound" v-bind:class="boundStatu">
|
||||||
{{Statu.boundRemark}}
|
{{Statu.boundRemark}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btnLink" @click="Link()">
|
<view class="btnLink" @click="Link()">
|
||||||
连接
|
绑定
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<global-loading ref="loading" />
|
<global-loading ref="loading" />
|
||||||
@ -40,11 +46,14 @@
|
|||||||
var these = null;
|
var these = null;
|
||||||
var eventChannel = null;
|
var eventChannel = null;
|
||||||
var ble = null;
|
var ble = null;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Statu: {
|
Statu: {
|
||||||
bound: null
|
bound: null,
|
||||||
|
timeInteval:null,
|
||||||
|
isSearch:false
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
"deviceId": "",
|
"deviceId": "",
|
||||||
@ -56,8 +65,11 @@
|
|||||||
|
|
||||||
],
|
],
|
||||||
"linkStatu": false,
|
"linkStatu": false,
|
||||||
"macAddress": ""
|
"macAddress": "",
|
||||||
}
|
"communicationMode":"",
|
||||||
|
"imei":""
|
||||||
|
},
|
||||||
|
serverDevice:null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -70,28 +82,52 @@
|
|||||||
} else {
|
} else {
|
||||||
return "red";
|
return "red";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
deviceStatu:function(){
|
||||||
|
if(!this.device.name){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if(!this.device.macAddress){
|
||||||
|
return '等待设备上报Mac地址';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.device.deviceName ){
|
||||||
|
if(this.Statu.isSearch){
|
||||||
|
return "无效设备";
|
||||||
|
}else{
|
||||||
|
if(this.Statu.timeInteval===null){
|
||||||
|
return "等待查询设备"
|
||||||
|
}else{
|
||||||
|
return "正在查询设备";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return "找到有效设备"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onBackPress() {
|
|
||||||
|
onUnload() {
|
||||||
console.log("返回时断开蓝牙连接,取消订阅");
|
console.log("返回时断开蓝牙连接,取消订阅");
|
||||||
ble.disconnectDevice(these.device.deviceId);
|
ble.disconnectDevice(these.device.deviceId);
|
||||||
ble.removeReceiveCallback(pagePath);
|
ble.removeReceiveCallback(pagePath);
|
||||||
},
|
},
|
||||||
onUnload() {
|
|
||||||
ble.removeReceiveCallback(pagePath);
|
|
||||||
},
|
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
these = this;
|
these = this;
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
|
console.log("LinkBle")
|
||||||
ble.addReceiveCallback((receive, f, path) => {
|
ble.addReceiveCallback((receive, f, path) => {
|
||||||
console.log("收到设备消息,", receive);
|
console.log("收到设备消息,", receive);
|
||||||
if (these.device.deviceId == receive.deviceId) {
|
if (these.device.deviceId == receive.deviceId) {
|
||||||
console.log("11111");
|
console.log("11111:",receive);
|
||||||
|
these.device.imei=f.imei;
|
||||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
||||||
if (f && f.macAddress) {
|
if (f && f.macAddress) {
|
||||||
these.device.macAddress = f.macAddress;
|
these.device.macAddress = f.macAddress;
|
||||||
console.log("222222");
|
console.log("222222");
|
||||||
|
these.Statu.isSearch=false;
|
||||||
these.initDevice();
|
these.initDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,24 +135,44 @@
|
|||||||
}, pagePath);
|
}, pagePath);
|
||||||
eventChannel = this.getOpenerEventChannel();
|
eventChannel = this.getOpenerEventChannel();
|
||||||
eventChannel.on('LinkItem', function(data) {
|
eventChannel.on('LinkItem', function(data) {
|
||||||
|
console.log("data=", data);
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId = data.deviceId;
|
return v.deviceId == data.deviceId;
|
||||||
});
|
});
|
||||||
if (f) {
|
if (f) {
|
||||||
these.device = Object.assign({}, these.device, f);
|
let keys = Object.keys(f);
|
||||||
console.log("获取到设备", f);
|
keys.forEach((v, index) => {
|
||||||
|
these.device[v] = f[v];
|
||||||
|
})
|
||||||
|
// console.log("LinkedList=", ble.data.LinkedList)
|
||||||
|
// console.log("f=", f);
|
||||||
|
// console.log("获取到设备", these.device);
|
||||||
|
if (f.macAddress) {
|
||||||
|
these.device.macAddress = f.macAddress;
|
||||||
|
|
||||||
|
these.initDevice();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("未获取到设备");
|
console.log("未获取到设备");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let inteval = setInterval(this.initDevice, 5000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
initDevice: function() {
|
initDevice: function() {
|
||||||
|
if(!these.device.macAddress){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearTimeout(this.Statu.timeInteval);
|
||||||
|
|
||||||
|
this.Statu.timeInteval = setTimeout(() => {
|
||||||
|
this.Statu.isSearch=true;
|
||||||
showLoading(these, {
|
showLoading(these, {
|
||||||
text: '正在获取设备信息'
|
text: '正在获取设备信息'
|
||||||
});
|
});
|
||||||
|
console.log("these.device=", these.device);
|
||||||
request({
|
request({
|
||||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -124,25 +180,30 @@
|
|||||||
deviceMac: these.device.macAddress
|
deviceMac: these.device.macAddress
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
|
||||||
console.log("获取设备信息", res);
|
console.log("获取设备信息", res);
|
||||||
if (res && res.code == 200) {
|
if (res && res.code == 200) {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
|
this.serverDevice=data;
|
||||||
if (data) {
|
if (data) {
|
||||||
let keys = Object.keys(data);
|
let keys = Object.keys(data);
|
||||||
ble.data.LinkedList.find((v) => {
|
ble.data.LinkedList.find((v) => {
|
||||||
if(v.deviceId = these.device.deviceId){
|
if (v.deviceId == these.device.deviceId) {
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
v[key] = data[key];
|
// if(!v.device){
|
||||||
console.log("key="+key);
|
// v.device={};
|
||||||
console.log("value="+data[key]);
|
// }
|
||||||
|
// v.device[key] = data[key];
|
||||||
|
// console.log("key="+key);
|
||||||
|
// console.log("value="+data[key]);
|
||||||
|
|
||||||
|
|
||||||
these.$set(these.device, key, data[key]);
|
these.$set(these.device, key, data[key]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ble.setBleData();
|
// ble.setBleData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -156,14 +217,19 @@
|
|||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
console.log("获取设备出现异常:", ex);
|
console.log("获取设备出现异常:", ex);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
this.Statu.timeInteval=null;
|
||||||
|
this.Statu.isSearch=false;
|
||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}, 500);
|
||||||
|
|
||||||
},
|
},
|
||||||
Link() {
|
Link() {
|
||||||
// 调用绑定设备接口
|
// 调用绑定设备接口
|
||||||
|
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId = these.device.deviceId;
|
return v.deviceId == these.device.deviceId;
|
||||||
});
|
});
|
||||||
if (!f) {
|
if (!f) {
|
||||||
these.Statu.bound = false;
|
these.Statu.bound = false;
|
||||||
@ -175,11 +241,16 @@
|
|||||||
these.Statu.boundRemark = "设备上报Mac地址异常";
|
these.Statu.boundRemark = "设备上报Mac地址异常";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!this.device.deviceName){
|
||||||
|
these.Statu.bound = false;
|
||||||
|
these.Statu.boundRemark = "设备未入库";
|
||||||
|
return;
|
||||||
|
}
|
||||||
these.Statu.bound = null;
|
these.Statu.bound = null;
|
||||||
these.Statu.boundRemark = "";
|
these.Statu.boundRemark = "";
|
||||||
showLoading(these, {
|
showLoading(these, {
|
||||||
|
|
||||||
text: "连接中..."
|
text: "绑定中..."
|
||||||
})
|
})
|
||||||
let promise = request({
|
let promise = request({
|
||||||
url: '/app/device/bind',
|
url: '/app/device/bind',
|
||||||
@ -187,7 +258,7 @@
|
|||||||
data: {
|
data: {
|
||||||
deviceImei: '',
|
deviceImei: '',
|
||||||
deviceMac: these.device.macAddress,
|
deviceMac: these.device.macAddress,
|
||||||
communicationMode: '1', //0是4g,1是蓝牙
|
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
promise.then((res) => {
|
promise.then((res) => {
|
||||||
@ -195,7 +266,23 @@
|
|||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
these.Statu.bound = true;
|
these.Statu.bound = true;
|
||||||
these.Statu.boundRemark = "设备绑定成功!";
|
these.Statu.boundRemark = "设备绑定成功!";
|
||||||
|
let data=these.serverDevice;
|
||||||
|
let keys = Object.keys(data);
|
||||||
|
ble.data.LinkedList.find((v) => {
|
||||||
|
if (v.deviceId == these.device.deviceId) {
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
if(!v.device){
|
||||||
|
v.device={};
|
||||||
|
}
|
||||||
|
v.device[key] = data[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
ble.updateCache();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ble.removeReceiveCallback(pagePath);
|
||||||
|
|
||||||
uni.$emit("refreshDeviceList");
|
uni.$emit("refreshDeviceList");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -210,6 +297,7 @@
|
|||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
these.Statu.bound = false;
|
these.Statu.bound = false;
|
||||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||||
|
console.log("ex=",ex);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
hideLoading(this);
|
hideLoading(this);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<view class="img center">
|
<view class="img center">
|
||||||
<image src="/static/images/bluetooth.png" class="titleIco" mode="aspectFit">
|
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="aspectFit">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||||
<view class="leftImg ">
|
<view class="leftImg ">
|
||||||
<image src="/static/images/BLEAdd/device.png" class="titleIco" mode="aspectFit">
|
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="centertxt ">
|
<view class="centertxt ">
|
||||||
@ -49,7 +49,7 @@
|
|||||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||||
v-show="!item['linkStatu']">
|
v-show="!item['linkStatu']">
|
||||||
<view class="leftImg ">
|
<view class="leftImg ">
|
||||||
<image src="/static/images/BLEAdd/device.png" class="titleIco" mode="aspectFit">
|
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="centertxt ">
|
<view class="centertxt ">
|
||||||
@ -97,6 +97,7 @@
|
|||||||
const pagePath = "pages/common/addBLE/addEquip";
|
const pagePath = "pages/common/addBLE/addEquip";
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
|
var eventChannel = null;
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -128,7 +129,11 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
PairEquip: [], //已配对设备
|
PairEquip: [], //已配对设备
|
||||||
EquipMents: [] //搜索出来的设备
|
EquipMents: [], //搜索出来的设备
|
||||||
|
device: null,
|
||||||
|
item: {
|
||||||
|
deviceId: ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -136,13 +141,8 @@
|
|||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
ble.removeReceiveCallback(pagePath);
|
|
||||||
},
|
|
||||||
onBackPress: (e) => {
|
|
||||||
ble.StopSearch();
|
|
||||||
ble.removeDeviceFound(pagePath);
|
|
||||||
ble.removeReceiveCallback(pagePath);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onUnload() {
|
onUnload() {
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
ble.removeDeviceFound(pagePath);
|
ble.removeDeviceFound(pagePath);
|
||||||
@ -150,7 +150,9 @@
|
|||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
these = this;
|
these = this;
|
||||||
|
this.EquipMents = [];
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
|
|
||||||
ble.addDeviceFound((arr) => {
|
ble.addDeviceFound((arr) => {
|
||||||
|
|
||||||
arr = arr.devices;
|
arr = arr.devices;
|
||||||
@ -171,28 +173,46 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// console.log("equip=", these.EquipMents)
|
||||||
}, pagePath);
|
}, pagePath);
|
||||||
|
// console.log("addEquip")
|
||||||
|
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||||
|
if (f.macAddress && these.device) {
|
||||||
|
showLoading(these, {
|
||||||
|
text: '正在验证设备'
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
these.DeviceVerdict(f.deviceId);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}, pagePath);
|
||||||
|
eventChannel = this.getOpenerEventChannel();
|
||||||
|
|
||||||
|
eventChannel.on('detailData', function(rec) {
|
||||||
|
console.log("接收到父页面的参数:", rec);
|
||||||
|
these.device = rec.data;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
|
|
||||||
|
|
||||||
this.EquipMents=[];
|
// this.EquipMents = [];
|
||||||
this.PairEquip = [];
|
this.PairEquip = [];
|
||||||
ble.StartSearch().catch((ex) => {
|
ble && ble.StartSearch().then(res=>{
|
||||||
|
console.log("开始搜索成功",res);
|
||||||
|
}).catch((ex) => {
|
||||||
|
console.log("开始搜索出现异常",ex);
|
||||||
if (ex.code == 10001) {
|
if (ex.code == 10001) {
|
||||||
these.showOpenSetting();
|
these.showOpenSetting();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ble.addReceiveCallback((receivData) => {
|
|
||||||
console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
|
|
||||||
console.log("LinkedList=",ble.data.LinkedList);
|
|
||||||
let data=uni.getStorageSync(ble.StorageKey);
|
|
||||||
console.log("data=",data);
|
|
||||||
},pagePath);
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -223,17 +243,52 @@
|
|||||||
this.Status.BottomMenu.show = false;
|
this.Status.BottomMenu.show = false;
|
||||||
ble.showBlueSetting(false);
|
ble.showBlueSetting(false);
|
||||||
},
|
},
|
||||||
Link: function(item, index) {
|
DeviceVerdict(deviceId) { //判断是否是目标设备
|
||||||
|
if (these.device) { //从设备详情过来的,回设备详情去
|
||||||
showLoading(this,{
|
let f = ble.data.LinkedList.find(v => {
|
||||||
text: "正在连接"
|
if (v.deviceId == deviceId) {
|
||||||
});
|
v.device = these.device;
|
||||||
setTimeout(() => {
|
return true;
|
||||||
let serviceid=null;
|
|
||||||
if(item.advertisServiceUUIDs.length>0){
|
|
||||||
serviceid=item.advertisServiceUUIDs[0];
|
|
||||||
}
|
}
|
||||||
ble.LinkBlue(item.deviceId,serviceid).then((res) => {
|
return false;
|
||||||
|
});
|
||||||
|
if (f.macAddress) {
|
||||||
|
|
||||||
|
|
||||||
|
if (f.macAddress != these.device.deviceMac) {
|
||||||
|
ble.disconnectDevice(deviceId);
|
||||||
|
updateLoading(these, {
|
||||||
|
text: "设备Mac地址错误,请重选设备连接"
|
||||||
|
})
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoading(these);
|
||||||
|
|
||||||
|
ble.updateCache();
|
||||||
|
uni.navigateBack();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
updateLoading(these, {
|
||||||
|
text: "等待设备上报Mac地址"
|
||||||
|
})
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
Link: function(item) {
|
||||||
|
this.item.deviceId = item.deviceId;
|
||||||
|
showLoading(this, {
|
||||||
|
text: "正在连接:第1次"
|
||||||
|
});
|
||||||
|
|
||||||
|
let index = 1;
|
||||||
|
let total = 5;
|
||||||
|
|
||||||
|
let linkCallback = (res) => {
|
||||||
let c = these.PairEquip.find(function(v) {
|
let c = these.PairEquip.find(function(v) {
|
||||||
return v.deviceId == item.deviceId;
|
return v.deviceId == item.deviceId;
|
||||||
});
|
});
|
||||||
@ -241,7 +296,10 @@
|
|||||||
|
|
||||||
these.PairEquip.push(item);
|
these.PairEquip.push(item);
|
||||||
}
|
}
|
||||||
ble.removeReceiveCallback(pagePath);
|
console.log("连接成功", these.device);
|
||||||
|
if (!these.device) {
|
||||||
|
console.log("跳转到绑定")
|
||||||
|
hideLoading(these);
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/common/addBLE/LinkBle",
|
url: "/pages/common/addBLE/LinkBle",
|
||||||
events: {
|
events: {
|
||||||
@ -252,16 +310,54 @@
|
|||||||
res.eventChannel.emit('LinkItem', item);
|
res.eventChannel.emit('LinkItem', item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("验证设备")
|
||||||
|
these.DeviceVerdict(item.deviceId);
|
||||||
|
}
|
||||||
|
let execLink = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
|
||||||
|
if (index > total) {
|
||||||
|
reject({
|
||||||
|
msg: "连接超时"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ble.LinkBlue(item.deviceId).then((res) => {
|
||||||
|
console.log("连接成功");
|
||||||
|
|
||||||
|
resolve(res);
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
if (index == total) {
|
||||||
|
console.log("连接了N次都没连上");
|
||||||
|
reject(ex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
updateLoading(this, {
|
||||||
|
text: ex.msg + ",正在重试第" + index + "次"
|
||||||
|
})
|
||||||
|
execLink().then(resolve).catch(reject);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
execLink().then((res) => {
|
||||||
|
linkCallback(res);
|
||||||
|
}).catch(ex => {
|
||||||
console.log("ex=", ex)
|
console.log("ex=", ex)
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
content: "连接失败:" + ex.msg
|
content: "连接失败:" + ex.msg
|
||||||
});
|
});
|
||||||
}).finally(()=>{
|
hideLoading(these);
|
||||||
hideLoading(this);
|
|
||||||
});
|
});
|
||||||
}, 0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -436,8 +532,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.list .item .leftImg {
|
.list .item .leftImg {
|
||||||
width: 100rpx;
|
width: 60rpx;
|
||||||
height: 70rpx;
|
height: 60rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list .item .centertxt {
|
.list .item .centertxt {
|
||||||
@ -469,7 +565,7 @@
|
|||||||
font-family: "PingFang SC";
|
font-family: "PingFang SC";
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 50rpx;
|
line-height: 36rpx;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,14 +574,14 @@
|
|||||||
font-family: "PingFang SC";
|
font-family: "PingFang SC";
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 30rpx;
|
line-height: 36rpx;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.list .item .rightIco .img {
|
.list .item .rightIco .img {
|
||||||
width: 50rpx;
|
width: 45rpx;
|
||||||
height: 50rpx;
|
height: 45rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.openBlue {
|
.openBlue {
|
||||||
|
|||||||
@ -139,8 +139,10 @@
|
|||||||
},
|
},
|
||||||
// 跳转到详情页面
|
// 跳转到详情页面
|
||||||
handleFile(item) {
|
handleFile(item) {
|
||||||
|
let url = item.detailPageUrl;
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/6170/deviceControl/index",
|
// url: "/pages/6170/deviceControl/index",
|
||||||
|
url:url,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
// 页面跳转成功后的回调函数
|
// 页面跳转成功后的回调函数
|
||||||
res.eventChannel.emit('detailData', {
|
res.eventChannel.emit('detailData', {
|
||||||
431
pages/common/forgotPassword/index.vue
Normal file
431
pages/common/forgotPassword/index.vue
Normal file
@ -0,0 +1,431 @@
|
|||||||
|
<template>
|
||||||
|
<view class="pageContent">
|
||||||
|
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||||
|
<view class="content_con">
|
||||||
|
找回密码
|
||||||
|
</view>
|
||||||
|
<view class="content">
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||||
|
</view>
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||||
|
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||||
|
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||||
|
</view>
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="password" v-model="password" placeholder="请设置新密码(6—20个数字或字母)" class="input" />
|
||||||
|
</view>
|
||||||
|
<!-- 登录按钮 -->
|
||||||
|
<button class="login-btn" @click="handleLogin">
|
||||||
|
确定
|
||||||
|
</button>
|
||||||
|
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||||
|
<!-- 协议勾选 -->
|
||||||
|
<view class="agreement">
|
||||||
|
<view class="custom-checkbox" @click="toggleCheck">
|
||||||
|
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||||
|
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||||
|
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||||
|
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 弹框 -->
|
||||||
|
<view class="agreement-mask" v-if="showAgreement">
|
||||||
|
<!-- 协议弹窗 -->
|
||||||
|
<view class="agreement-popup" @click.stop>
|
||||||
|
<!-- 标题 -->
|
||||||
|
<view class="popup-title">服务协议及隐私政策</view>
|
||||||
|
<!-- 协议内容 -->
|
||||||
|
<view class="popup-content">
|
||||||
|
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||||
|
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||||
|
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||||
|
</view>
|
||||||
|
<!-- 按钮组 -->
|
||||||
|
<view class="popup-buttons">
|
||||||
|
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||||
|
<button class="btn agree" @click="handleAgree">同意</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
|
import {
|
||||||
|
forgetPassword,
|
||||||
|
forgetPasswordSmsCode
|
||||||
|
} from '@/api/common/login.js';
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showView: false,
|
||||||
|
phone: '', //手机号码
|
||||||
|
code: "", //验证码
|
||||||
|
password: '', //密码
|
||||||
|
agreed: false,
|
||||||
|
isCounting: false,
|
||||||
|
countdown: 0,
|
||||||
|
isChecked: true,
|
||||||
|
showAgreement: false, // 控制弹窗显示
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad() {},
|
||||||
|
methods: {
|
||||||
|
// 获取验证码
|
||||||
|
async getPhoneCode() {
|
||||||
|
const phoneNumber = this.phone
|
||||||
|
const myreg = /^1[3456789]\d{9}$/;
|
||||||
|
if (!phoneNumber) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '手机号不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else if (!myreg.test(phoneNumber)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入正确的手机号',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await forgetPasswordSmsCode({
|
||||||
|
phonenumber: this.phone
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
// 更新倒计时状态
|
||||||
|
this.isCounting = true;
|
||||||
|
this.showView = true;
|
||||||
|
this.countdown = 60
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
this.countdown--
|
||||||
|
if (this.countdown <= 0) {
|
||||||
|
clearInterval(timer)
|
||||||
|
this.isCounting = false;
|
||||||
|
this.showView = false;
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
uni.showToast({
|
||||||
|
title: '验证码已发送',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {}
|
||||||
|
},
|
||||||
|
// 勾选同意
|
||||||
|
toggleCheck() {
|
||||||
|
this.isChecked = !this.isChecked
|
||||||
|
},
|
||||||
|
// 登录
|
||||||
|
goLogin() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/login/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 登录
|
||||||
|
async handleLogin() {
|
||||||
|
if (this.phone == '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '手机号不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
} else if (this.code == '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '验证码不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!this.password) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请设置新密码',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!this.isChecked) {
|
||||||
|
this.showAgreement = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中...'
|
||||||
|
})
|
||||||
|
// 调用忘记密码接口
|
||||||
|
const res = await forgetPassword({
|
||||||
|
phonenumber: this.phone,
|
||||||
|
smsCode: this.code,
|
||||||
|
tenantId: '894078', //租户ID
|
||||||
|
password: md5(this.password)
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '密码修改成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/login/index'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('捕获错误:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: error.msg || '登录失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 跳转到协议页面
|
||||||
|
goToPage(type) {
|
||||||
|
const url = type === 'agreement' ?
|
||||||
|
'/pages/common/userAgreement/index' // 服务协议
|
||||||
|
:
|
||||||
|
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||||
|
uni.navigateTo({
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 不同意
|
||||||
|
handleDisagree() {
|
||||||
|
this.showAgreement = false
|
||||||
|
},
|
||||||
|
// 同意
|
||||||
|
handleAgree() {
|
||||||
|
this.isChecked = !this.isChecked
|
||||||
|
this.showAgreement = false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pageContent {
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-bg {
|
||||||
|
background-size: 100% 100%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
height: 70%;
|
||||||
|
width: 100%;
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
border-radius: 60px 60px 0px 0px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content_con {
|
||||||
|
position: absolute;
|
||||||
|
top: 220rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
left: 30rpx;
|
||||||
|
font-size: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
height: 80rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
margin-top: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ver_item {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.get_phone_number {
|
||||||
|
position: absolute;
|
||||||
|
right: 0px;
|
||||||
|
color: #999;
|
||||||
|
top: 1rpx;
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
border: none;
|
||||||
|
text-align: right;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-family: PingFangSC-Medium, PingFang SC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grad {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agreement {
|
||||||
|
margin: 50rpx 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8rpx
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-btn {
|
||||||
|
margin-top: 90rpx;
|
||||||
|
background-color: rgb(187, 230, 0);
|
||||||
|
color: rgb(35, 35, 35);
|
||||||
|
border-radius: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-btn[disabled] {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-title {
|
||||||
|
text-align: center;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
padding-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gologin {
|
||||||
|
color: rgba(187, 230, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-icon {
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||||
|
border-radius: 50rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-icon.checked {
|
||||||
|
background-color: #07C160;
|
||||||
|
border-color: #07C160;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agreeT {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 遮罩层 */
|
||||||
|
.agreement-mask {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 弹窗主体 */
|
||||||
|
.agreement-popup {
|
||||||
|
width: 80%;
|
||||||
|
background-color: rgba(42, 42, 42);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 40rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 标题 */
|
||||||
|
.popup-title {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 内容文本 */
|
||||||
|
.popup-content {
|
||||||
|
font-size: 30rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 协议链接 */
|
||||||
|
.protocol-link {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
margin: 0 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 按钮容器 */
|
||||||
|
.popup-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 通用按钮样式 */
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
margin: 0 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 不同意按钮 */
|
||||||
|
.disagree {
|
||||||
|
background-color: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
border: 1px solid rgb(255, 255, 255);
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 同意按钮 */
|
||||||
|
.agree {
|
||||||
|
background-color: rgb(187, 230, 0);
|
||||||
|
color: #232323;
|
||||||
|
border: none;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -144,6 +144,8 @@
|
|||||||
deviceUnbind, //删除设备
|
deviceUnbind, //删除设备
|
||||||
deviceReName
|
deviceReName
|
||||||
} from '@/api/common/index.js'
|
} from '@/api/common/index.js'
|
||||||
|
import BleHelper from '@/utils/BleHelper.js';
|
||||||
|
var ble=null;
|
||||||
export default {
|
export default {
|
||||||
onPullDownRefresh() {
|
onPullDownRefresh() {
|
||||||
// 执行下拉刷新时的操作,比如重新获取数据
|
// 执行下拉刷新时的操作,比如重新获取数据
|
||||||
@ -225,7 +227,7 @@
|
|||||||
break;
|
break;
|
||||||
case 'share':
|
case 'share':
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/6170/allShare/index"
|
url: "/pages/common/allShare/index"
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -389,6 +391,8 @@
|
|||||||
this.deleteShow = false
|
this.deleteShow = false
|
||||||
// 关闭所有滑动项
|
// 关闭所有滑动项
|
||||||
this.$refs.swipeAction.closeAll();
|
this.$refs.swipeAction.closeAll();
|
||||||
|
|
||||||
|
ble && ble.DropDevice(data.id);
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
@ -486,6 +490,10 @@
|
|||||||
// 列表跳转
|
// 列表跳转
|
||||||
handleFile(item) {
|
handleFile(item) {
|
||||||
let url = item.detailPageUrl;
|
let url = item.detailPageUrl;
|
||||||
|
// console.log("url=",url);
|
||||||
|
// if(!url){
|
||||||
|
//url="/pages/670/HBY670"
|
||||||
|
// }
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: url,
|
url: url,
|
||||||
events: {
|
events: {
|
||||||
@ -498,6 +506,8 @@
|
|||||||
deviceType: this.tabs[this.activeTab].id || '',
|
deviceType: this.tabs[this.activeTab].id || '',
|
||||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||||
});
|
});
|
||||||
|
},fail(ex) {
|
||||||
|
console.log("ex=",ex);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -549,6 +559,7 @@
|
|||||||
console.log('列表收到消息了么');
|
console.log('列表收到消息了么');
|
||||||
this.onIntall()
|
this.onIntall()
|
||||||
});
|
});
|
||||||
|
ble=BleHelper.getBleTool();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
// 组件销毁前移除监听器
|
// 组件销毁前移除监听器
|
||||||
|
|||||||
@ -8,11 +8,26 @@
|
|||||||
<view class='ver_item'>
|
<view class='ver_item'>
|
||||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||||
</view>
|
</view>
|
||||||
<view class='ver_item'>
|
<view class='ver_item' v-if="isCodeLogin">
|
||||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||||
</view>
|
</view>
|
||||||
|
<view class='ver_item' v-else>
|
||||||
|
<input type="password" v-model="password" placeholder="请输入密码" class="input" />
|
||||||
|
</view>
|
||||||
|
<view class="switch-flex">
|
||||||
|
<view class="switch-login" @click="switchLogin">
|
||||||
|
{{ isCodeLogin ? '密码登录' : '验证码登录' }}
|
||||||
|
</view>
|
||||||
|
<view v-if="!isCodeLogin" @click="forgotPassword">忘记密码</view>
|
||||||
|
</view>
|
||||||
|
<!-- 登录按钮 -->
|
||||||
|
<button class="login-btn" @click="handleLogin">
|
||||||
|
登录
|
||||||
|
</button>
|
||||||
|
<view class="login-title">没有账号?<text class="gologin" @click="goLogin">去注册</text></view>
|
||||||
|
|
||||||
<!-- 协议勾选 -->
|
<!-- 协议勾选 -->
|
||||||
<view class="agreement">
|
<view class="agreement">
|
||||||
<view class="custom-checkbox" @click="toggleCheck">
|
<view class="custom-checkbox" @click="toggleCheck">
|
||||||
@ -24,10 +39,6 @@
|
|||||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 登录按钮 -->
|
|
||||||
<button class="login-btn" @click="handleLogin">
|
|
||||||
登录
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
<!-- 弹框 -->
|
<!-- 弹框 -->
|
||||||
<view class="agreement-mask" v-if="showAgreement">
|
<view class="agreement-mask" v-if="showAgreement">
|
||||||
@ -52,6 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
import {
|
import {
|
||||||
login,
|
login,
|
||||||
resourceSmsCode
|
resourceSmsCode
|
||||||
@ -60,18 +72,19 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showView: false,
|
showView: false,
|
||||||
phone: '17671332251', //手机号码
|
phone: '13800138002', //手机号码
|
||||||
code: "123456", //验证码
|
code: "123456", //验证码
|
||||||
|
password: "",
|
||||||
agreed: false,
|
agreed: false,
|
||||||
isCounting: false,
|
isCounting: false,
|
||||||
countdown: 0,
|
countdown: 0,
|
||||||
isChecked: true,
|
isChecked: true,
|
||||||
showAgreement: false, // 控制弹窗显示
|
showAgreement: false, // 控制弹窗显示
|
||||||
|
isCodeLogin: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
||||||
|
|
||||||
let time = uni.getStorageSync("tokenTime");
|
let time = uni.getStorageSync("tokenTime");
|
||||||
if (!time) {
|
if (!time) {
|
||||||
time = 0;
|
time = 0;
|
||||||
@ -93,6 +106,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 验证码密码切换
|
||||||
|
switchLogin() {
|
||||||
|
this.isCodeLogin = !this.isCodeLogin;
|
||||||
|
// 切换时重置相关输入和状态
|
||||||
|
this.code = "";
|
||||||
|
this.password = "";
|
||||||
|
this.isCounting = false;
|
||||||
|
this.countdown = 0;
|
||||||
|
this.showView = false;
|
||||||
|
},
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
async getPhoneCode() {
|
async getPhoneCode() {
|
||||||
const phoneNumber = this.phone
|
const phoneNumber = this.phone
|
||||||
@ -146,6 +169,18 @@
|
|||||||
toggleCheck() {
|
toggleCheck() {
|
||||||
this.isChecked = !this.isChecked
|
this.isChecked = !this.isChecked
|
||||||
},
|
},
|
||||||
|
// 去登录
|
||||||
|
goLogin() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/register/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 忘记密码
|
||||||
|
forgotPassword() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/forgotPassword/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
// 登录
|
// 登录
|
||||||
async handleLogin() {
|
async handleLogin() {
|
||||||
if (this.phone == '') {
|
if (this.phone == '') {
|
||||||
@ -155,7 +190,9 @@
|
|||||||
duration: 1000
|
duration: 1000
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
} else if (this.code == '') {
|
}
|
||||||
|
if (this.isCodeLogin) {
|
||||||
|
if (this.code == '') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '验证码不能为空',
|
title: '验证码不能为空',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
@ -163,29 +200,42 @@
|
|||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (this.password == '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '密码不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!this.isChecked) {
|
if (!this.isChecked) {
|
||||||
this.showAgreement = true
|
this.showAgreement = true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
console.log('44444');
|
|
||||||
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '登录中...'
|
title: '登录中...'
|
||||||
})
|
})
|
||||||
// 调用登录接口
|
let loginParams = {
|
||||||
const res = await login({
|
|
||||||
phonenumber: this.phone,
|
phonenumber: this.phone,
|
||||||
smsCode: this.code,
|
|
||||||
tenantId: '894078' // 租户ID
|
tenantId: '894078' // 租户ID
|
||||||
})
|
};
|
||||||
|
if (this.isCodeLogin) {
|
||||||
|
loginParams.smsCode = this.code;
|
||||||
|
//登录方式 1:手机验证码登录 2:密码登录
|
||||||
|
loginParams.loginType=1
|
||||||
|
} else {
|
||||||
|
loginParams.loginPassword = md5(this.password);
|
||||||
|
loginParams.loginType=2
|
||||||
|
}
|
||||||
|
// 调用登录接口
|
||||||
|
const res = await login(loginParams)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
console.log(res, 'ressss');
|
uni.hideLoading()
|
||||||
uni.hideLoading();
|
uni.setStorageSync('token', res.data.access_token) // 缓存token
|
||||||
uni.setStorageSync('token', res.data.access_token); // 缓存token
|
uni.setStorageSync('clientID', res.data.client_id) // 缓存token
|
||||||
uni.setStorageSync('clientID', res.data.client_id); // 缓存token
|
|
||||||
uni.setStorageSync('tokenTime', new Date().getTime() + 86400000); //过期时间
|
uni.setStorageSync('tokenTime', new Date().getTime() + 86400000); //过期时间
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '登录成功',
|
title: '登录成功',
|
||||||
@ -193,26 +243,21 @@
|
|||||||
})
|
})
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: '/pages/common/index/index'
|
url: '/pages/common/index/index'
|
||||||
});
|
})
|
||||||
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url:"/pages/BlueTooth/ModeSetting/index"
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg || '服务器异常,请稍后重试',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.hideLoading()
|
console.log('捕获错误:', error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.msg,
|
title: error.msg || '登录失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 跳转到协议页面
|
// 跳转到协议页面
|
||||||
goToPage(type) {
|
goToPage(type) {
|
||||||
@ -281,6 +326,20 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.switch-flex {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-login {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.get_phone_number {
|
.get_phone_number {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
@ -307,10 +366,12 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8rpx
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-btn {
|
.login-btn {
|
||||||
margin-top: 150rpx;
|
margin-top: 90rpx;
|
||||||
background-color: rgb(187, 230, 0);
|
background-color: rgb(187, 230, 0);
|
||||||
color: rgb(35, 35, 35);
|
color: rgb(35, 35, 35);
|
||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
@ -320,6 +381,16 @@
|
|||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.login-title {
|
||||||
|
text-align: center;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
padding-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gologin {
|
||||||
|
color: rgba(187, 230, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
.custom-checkbox {
|
.custom-checkbox {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -90,6 +90,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// 处理返回键
|
||||||
|
onBackPress() {
|
||||||
|
// 如果绑定成功了,返回时也要刷新首页
|
||||||
|
if (this.isSuccess) {
|
||||||
|
uni.$emit('refreshDeviceList');
|
||||||
|
}
|
||||||
|
return false; // 允许正常返回
|
||||||
|
},
|
||||||
|
// 页面卸载时处理
|
||||||
|
onUnload() {
|
||||||
|
// 如果绑定成功了,卸载时也要刷新首页
|
||||||
|
if (this.isSuccess) {
|
||||||
|
uni.$emit('refreshDeviceList');
|
||||||
|
}
|
||||||
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
if (options.deviceId) {
|
if (options.deviceId) {
|
||||||
this.deviceId = decodeURIComponent(options.deviceId);
|
this.deviceId = decodeURIComponent(options.deviceId);
|
||||||
|
|||||||
433
pages/common/register/index.vue
Normal file
433
pages/common/register/index.vue
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
<template>
|
||||||
|
<view class="pageContent">
|
||||||
|
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||||
|
<view class="content_con">
|
||||||
|
欢迎注册
|
||||||
|
</view>
|
||||||
|
<view class="content">
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||||
|
</view>
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||||
|
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||||
|
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||||
|
</view>
|
||||||
|
<view class='ver_item'>
|
||||||
|
<input type="password" v-model="password" placeholder="请设置密码(6—20个数字或字母)" class="input" />
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 登录按钮 -->
|
||||||
|
<button class="login-btn" @click="handleLogin">
|
||||||
|
注册
|
||||||
|
</button>
|
||||||
|
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||||
|
<!-- 协议勾选 -->
|
||||||
|
<view class="agreement">
|
||||||
|
<view class="custom-checkbox" @click="toggleCheck">
|
||||||
|
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||||
|
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||||
|
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||||
|
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 弹框 -->
|
||||||
|
<view class="agreement-mask" v-if="showAgreement">
|
||||||
|
<!-- 协议弹窗 -->
|
||||||
|
<view class="agreement-popup" @click.stop>
|
||||||
|
<!-- 标题 -->
|
||||||
|
<view class="popup-title">服务协议及隐私政策</view>
|
||||||
|
<!-- 协议内容 -->
|
||||||
|
<view class="popup-content">
|
||||||
|
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||||
|
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||||
|
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||||
|
</view>
|
||||||
|
<!-- 按钮组 -->
|
||||||
|
<view class="popup-buttons">
|
||||||
|
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||||
|
<button class="btn agree" @click="handleAgree">同意</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import md5 from 'blueimp-md5'
|
||||||
|
import {
|
||||||
|
register,
|
||||||
|
registerSmsCode
|
||||||
|
} from '@/api/common/login.js';
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showView: false,
|
||||||
|
phone: '', //手机号码
|
||||||
|
code: "", //验证码
|
||||||
|
password: '', //密码
|
||||||
|
agreed: false,
|
||||||
|
isCounting: false,
|
||||||
|
countdown: 0,
|
||||||
|
isChecked: true,
|
||||||
|
showAgreement: false, // 控制弹窗显示
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad() {},
|
||||||
|
methods: {
|
||||||
|
// 获取验证码
|
||||||
|
async getPhoneCode() {
|
||||||
|
const phoneNumber = this.phone
|
||||||
|
const myreg = /^1[3456789]\d{9}$/;
|
||||||
|
if (!phoneNumber) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '手机号不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else if (!myreg.test(phoneNumber)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入正确的手机号',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await registerSmsCode({
|
||||||
|
phonenumber: this.phone
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
// 更新倒计时状态
|
||||||
|
this.isCounting = true;
|
||||||
|
this.showView = true;
|
||||||
|
this.countdown = 60
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
this.countdown--
|
||||||
|
if (this.countdown <= 0) {
|
||||||
|
clearInterval(timer)
|
||||||
|
this.isCounting = false;
|
||||||
|
this.showView = false;
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
uni.showToast({
|
||||||
|
title: '验证码已发送',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {}
|
||||||
|
},
|
||||||
|
// 勾选同意
|
||||||
|
toggleCheck() {
|
||||||
|
this.isChecked = !this.isChecked
|
||||||
|
},
|
||||||
|
// 登录
|
||||||
|
goLogin() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/login/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 登录
|
||||||
|
async handleLogin() {
|
||||||
|
if (this.phone == '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '手机号不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
} else if (this.code == '') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '验证码不能为空',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
} else if (!this.password) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请设置密码',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!this.isChecked) {
|
||||||
|
this.showAgreement = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '注册中...'
|
||||||
|
})
|
||||||
|
// 调用登录接口
|
||||||
|
const res = await register({
|
||||||
|
phonenumber: this.phone,
|
||||||
|
smsCode: this.code,
|
||||||
|
tenantId: '894078', //租户ID
|
||||||
|
password: md5(this.password)
|
||||||
|
})
|
||||||
|
if (res.code == 200) {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '注册成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/login/index'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg || '服务器异常,请稍后重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('捕获错误:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: error.msg || '登录失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 跳转到协议页面
|
||||||
|
goToPage(type) {
|
||||||
|
const url = type === 'agreement' ?
|
||||||
|
'/pages/common/userAgreement/index' // 服务协议
|
||||||
|
:
|
||||||
|
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||||
|
uni.navigateTo({
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 不同意
|
||||||
|
handleDisagree() {
|
||||||
|
this.showAgreement = false
|
||||||
|
},
|
||||||
|
// 同意
|
||||||
|
handleAgree() {
|
||||||
|
this.isChecked = !this.isChecked
|
||||||
|
this.showAgreement = false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pageContent {
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-bg {
|
||||||
|
background-size: 100% 100%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
height: 70%;
|
||||||
|
width: 100%;
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
border-radius: 60px 60px 0px 0px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content_con {
|
||||||
|
position: absolute;
|
||||||
|
top: 220rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
left: 30rpx;
|
||||||
|
font-size: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
height: 80rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
margin-top: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ver_item {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.get_phone_number {
|
||||||
|
position: absolute;
|
||||||
|
right: 0px;
|
||||||
|
color: #999;
|
||||||
|
top: 1rpx;
|
||||||
|
background: rgb(26, 26, 26);
|
||||||
|
border: none;
|
||||||
|
text-align: right;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-family: PingFangSC-Medium, PingFang SC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grad {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agreement {
|
||||||
|
margin: 50rpx 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8rpx
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-btn {
|
||||||
|
margin-top: 90rpx;
|
||||||
|
background-color: rgb(187, 230, 0);
|
||||||
|
color: rgb(35, 35, 35);
|
||||||
|
border-radius: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-btn[disabled] {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-title {
|
||||||
|
text-align: center;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
padding-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gologin {
|
||||||
|
color: rgba(187, 230, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-icon {
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||||
|
border-radius: 50rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-icon.checked {
|
||||||
|
background-color: #07C160;
|
||||||
|
border-color: #07C160;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agreeT {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 遮罩层 */
|
||||||
|
.agreement-mask {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 弹窗主体 */
|
||||||
|
.agreement-popup {
|
||||||
|
width: 80%;
|
||||||
|
background-color: rgba(42, 42, 42);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 40rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 标题 */
|
||||||
|
.popup-title {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 内容文本 */
|
||||||
|
.popup-content {
|
||||||
|
font-size: 30rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 协议链接 */
|
||||||
|
.protocol-link {
|
||||||
|
color: rgb(187, 230, 0);
|
||||||
|
margin: 0 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 按钮容器 */
|
||||||
|
.popup-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 通用按钮样式 */
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
margin: 0 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 不同意按钮 */
|
||||||
|
.disagree {
|
||||||
|
background-color: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
border: 1px solid rgb(255, 255, 255);
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 同意按钮 */
|
||||||
|
.agree {
|
||||||
|
background-color: rgb(187, 230, 0);
|
||||||
|
color: #232323;
|
||||||
|
border: none;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -157,7 +157,7 @@ export default {
|
|||||||
const statusRes = await getdeviceSTatus({
|
const statusRes = await getdeviceSTatus({
|
||||||
functionMode: 2,
|
functionMode: 2,
|
||||||
batchId,
|
batchId,
|
||||||
typeName,
|
typeName:'FunctionAccessBatchStatusRule',
|
||||||
deviceImei,
|
deviceImei,
|
||||||
interval: 500
|
interval: 500
|
||||||
},
|
},
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
// 分享设备
|
// 分享设备
|
||||||
shareDevice(){
|
shareDevice(){
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/6170/shareDevices/index',
|
url: '/pages/common/shareDevices/index',
|
||||||
events: {
|
events: {
|
||||||
ack: function(data) {}
|
ack: function(data) {}
|
||||||
},
|
},
|
||||||
@ -39,7 +39,7 @@
|
|||||||
// 分享管理
|
// 分享管理
|
||||||
shareManagement(){
|
shareManagement(){
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/6170/shareManagement/index',
|
url: '/pages/common/shareManagement/index',
|
||||||
events: {
|
events: {
|
||||||
ack: function(data) {}
|
ack: function(data) {}
|
||||||
},
|
},
|
||||||
@ -69,6 +69,7 @@
|
|||||||
deviceShareCode,
|
deviceShareCode,
|
||||||
deviceShareAdd
|
deviceShareAdd
|
||||||
} from '@/api/6170/share.js'
|
} from '@/api/6170/share.js'
|
||||||
|
import Common from '@/utils/Common.js'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -205,6 +206,7 @@
|
|||||||
deviceId: this.itemInfo.id,
|
deviceId: this.itemInfo.id,
|
||||||
permission: selectedPermissions.join(',')
|
permission: selectedPermissions.join(',')
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.shareShow = true
|
this.shareShow = true
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
@ -227,7 +229,7 @@
|
|||||||
handleBtn() {
|
handleBtn() {
|
||||||
this.shareShow = false
|
this.shareShow = false
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/6170/allShare/index'
|
url: '/pages/common/allShare/index'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -237,6 +239,7 @@
|
|||||||
eventChannel.on('shareDevice', (data) => {
|
eventChannel.on('shareDevice', (data) => {
|
||||||
console.log(data, 'data1t111');
|
console.log(data, 'data1t111');
|
||||||
this.itemInfo = data.data;
|
this.itemInfo = data.data;
|
||||||
|
this.permissions=Common.getPermissions(this.itemInfo.persissonType);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -96,8 +96,10 @@
|
|||||||
},
|
},
|
||||||
// 跳转分享详情
|
// 跳转分享详情
|
||||||
handleFile(item) {
|
handleFile(item) {
|
||||||
|
let url = item.detailPageUrl;
|
||||||
|
console.log(item,'item');
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/6170/deviceControl/index",
|
url: url,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
// 页面跳转成功后的回调函数
|
// 页面跳转成功后的回调函数
|
||||||
res.eventChannel.emit('detailData', {
|
res.eventChannel.emit('detailData', {
|
||||||
@ -6,7 +6,7 @@
|
|||||||
<image src="/static/images/common/logo.png" class="logo"></image>
|
<image src="/static/images/common/logo.png" class="logo"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-right">
|
<view class="user-right">
|
||||||
<view class="user-title">武汉研创</view>
|
<view class="user-title">武汉星汉</view>
|
||||||
<view class="ID">ID:123456</view>
|
<view class="ID">ID:123456</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -27,6 +27,11 @@
|
|||||||
<text class="title">关于我们</text>
|
<text class="title">关于我们</text>
|
||||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="menu-item" @click="account">
|
||||||
|
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||||
|
<text class="title">账号安全</text>
|
||||||
|
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||||
|
</view>
|
||||||
<view class="btn_footer">
|
<view class="btn_footer">
|
||||||
<button class="logout" @click="logout">退出登录</button>
|
<button class="logout" @click="logout">退出登录</button>
|
||||||
</view>
|
</view>
|
||||||
@ -110,6 +115,12 @@
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/common/aboutUs/index'
|
url: '/pages/common/aboutUs/index'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
// 账户安全
|
||||||
|
account(){
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/common/account/index'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
static/fonts/PingFangBold.ttf
Normal file
BIN
static/fonts/PingFangBold.ttf
Normal file
Binary file not shown.
BIN
static/images/common/msg.png
Normal file
BIN
static/images/common/msg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
var isReady=false;var onReadyCallbacks=[];
|
var isReady=false;var onReadyCallbacks=[];
|
||||||
var isServiceReady=false;var onServiceReadyCallbacks=[];
|
var isServiceReady=false;var onServiceReadyCallbacks=[];
|
||||||
var __uniConfig = {"pages":["pages/650/HBY650","pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"JingQuan","compilerVersion":"4.75","entryPagePath":"pages/650/HBY650","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
|
var __uniConfig = {"pages":["pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877","pages/7305/BJQ7305"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"星汉物联","compilerVersion":"4.75","entryPagePath":"pages/common/login/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
|
||||||
var __uniRoutes = [{"path":"/pages/650/HBY650","meta":{"isQuit":true},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/common/login/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息"}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"添加设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}}];
|
var __uniRoutes = [{"path":"/pages/common/login/index","meta":{"isQuit":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"扫描设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"绑定设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/index","meta":{},"window":{"navigationBarTitleText":"设备类型"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}},{"path":"/pages/7305/BJQ7305","meta":{},"window":{"navigationBarTitleText":"BJQ7305"}}];
|
||||||
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||||
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||||
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}});
|
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}});
|
||||||
|
|||||||
33734
unpackage/dist/dev/app-plus/app-service.js
vendored
33734
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
30804
unpackage/dist/dev/app-plus/app-view.js
vendored
30804
unpackage/dist/dev/app-plus/app-view.js
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/manifest.json
vendored
2
unpackage/dist/dev/app-plus/manifest.json
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +1,19 @@
|
|||||||
import receivTool from "@/utils/BleReceive.js"
|
import receivTool from "@/utils/BleReceive.js"
|
||||||
var recei = null;
|
var recei = null;
|
||||||
|
const serviceDic = [ //合作供应商的蓝牙主服务
|
||||||
|
{
|
||||||
|
"serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB",
|
||||||
|
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
|
||||||
|
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"serviceId": "0000AE30-0000-1000-8000-00805F9B34FB",
|
||||||
|
"writeId": "0000AE03-0000-1000-8000-00805F9B34FB",
|
||||||
|
"notifyId": "0000AE02-0000-1000-8000-00805F9B34FB"
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
class BleHelper {
|
class BleHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.StorageKey = "linkedDevices";
|
this.StorageKey = "linkedDevices";
|
||||||
@ -26,7 +40,10 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.OpenBlue().then(()=>{
|
||||||
this.linkAllDevices();
|
this.linkAllDevices();
|
||||||
|
});
|
||||||
|
|
||||||
}, 10);
|
}, 10);
|
||||||
this.data = {
|
this.data = {
|
||||||
isOpenBlue: false, //蓝牙模块是否开启
|
isOpenBlue: false, //蓝牙模块是否开启
|
||||||
@ -40,9 +57,9 @@ class BleHelper {
|
|||||||
onDeviceFound: [], //发现新设备的事件
|
onDeviceFound: [], //发现新设备的事件
|
||||||
receivDataCallback: [] //接收到数据的事件
|
receivDataCallback: [] //接收到数据的事件
|
||||||
}
|
}
|
||||||
this.addReceiveCallback((a,b,c)=>{
|
// this.addReceiveCallback((a, b, c) => {
|
||||||
recei.ReceiveData(a,b,c);
|
// recei.ReceiveData(a, b, c);
|
||||||
}, "BleReceiveData");
|
// }, "BleReceiveData");
|
||||||
this.dic = {
|
this.dic = {
|
||||||
errRemarks: [{
|
errRemarks: [{
|
||||||
key: '10000',
|
key: '10000',
|
||||||
@ -104,18 +121,51 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DropDevice(bleId, deviceId) {
|
||||||
|
let flag = false;
|
||||||
|
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||||
|
let item = this.data.LinkedList[i];
|
||||||
|
if (bleId) {
|
||||||
|
if (item.deviceId == bleId) {
|
||||||
|
this.data.LinkedList.splice(i, 1);
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (item.device && item.device.id) {
|
||||||
|
this.data.LinkedList.splice(i, 1);
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
this.updateCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCache() {
|
||||||
|
// console.log("this.StorageKey=", this.StorageKey)
|
||||||
|
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
||||||
|
}
|
||||||
|
|
||||||
linkAllDevices() {
|
linkAllDevices() {
|
||||||
console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
||||||
|
|
||||||
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
||||||
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||||
let device = this.data.LinkedList[i];
|
let device = this.data.LinkedList[i];
|
||||||
console.log("自动连接:" + device.deviceId);
|
// console.log("自动连接绑定过的设备:" + device.deviceId);
|
||||||
|
if (device.macAddress && device.device && device.device.id) {
|
||||||
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
||||||
.notifyCharactId);
|
.notifyCharactId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("无设备连接");
|
// console.log("无设备连接");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +178,7 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const currentPage = pages[pages.length - 1];
|
const currentPage = pages[pages.length - 1];
|
||||||
console.log("currentPage=", currentPage.route);
|
// console.log("currentPage=", currentPage.route);
|
||||||
return currentPage.route;
|
return currentPage.route;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +189,7 @@ class BleHelper {
|
|||||||
key = new Date().getTime();
|
key = new Date().getTime();
|
||||||
}
|
}
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log("key=" + key);
|
// console.log("key=" + key);
|
||||||
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
||||||
return v.key == key;
|
return v.key == key;
|
||||||
});
|
});
|
||||||
@ -159,7 +209,7 @@ class BleHelper {
|
|||||||
let key = currKey ? currKey : this.getCurrentPagePath();
|
let key = currKey ? currKey : this.getCurrentPagePath();
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log("key=" + key);
|
// console.log("key=" + key);
|
||||||
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
||||||
return v.key == key;
|
return v.key == key;
|
||||||
});
|
});
|
||||||
@ -181,7 +231,7 @@ class BleHelper {
|
|||||||
key = new Date().getTime();
|
key = new Date().getTime();
|
||||||
}
|
}
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log("订阅消息回调,key=" + key);
|
// console.log("订阅消息回调,key=" + key);
|
||||||
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
||||||
return v.key == key;
|
return v.key == key;
|
||||||
});
|
});
|
||||||
@ -202,7 +252,7 @@ class BleHelper {
|
|||||||
removeReceiveCallback(currKey) {
|
removeReceiveCallback(currKey) {
|
||||||
let key = currKey ? currKey : this.getCurrentPagePath();
|
let key = currKey ? currKey : this.getCurrentPagePath();
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log("移除消息回调:" + key);
|
// console.log("移除消息回调:" + key);
|
||||||
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
||||||
return v.key == key;
|
return v.key == key;
|
||||||
});
|
});
|
||||||
@ -320,6 +370,7 @@ class BleHelper {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.data.available) {
|
if (this.data.available) {
|
||||||
|
console.log("蓝牙模块是可用状态");
|
||||||
resolve({
|
resolve({
|
||||||
available: this.data.available,
|
available: this.data.available,
|
||||||
discovering: this.data.discovering
|
discovering: this.data.discovering
|
||||||
@ -327,6 +378,7 @@ class BleHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.data.isOpenBlue) {
|
if (!this.data.isOpenBlue) {
|
||||||
|
console.log("蓝牙模块未打开");
|
||||||
resolve({
|
resolve({
|
||||||
available: false,
|
available: false,
|
||||||
discovering: false
|
discovering: false
|
||||||
@ -335,12 +387,13 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
uni.getBluetoothAdapterState({
|
uni.getBluetoothAdapterState({
|
||||||
success: (info) => {
|
success: (info) => {
|
||||||
|
console.log("蓝牙状态获取成功,",info)
|
||||||
this.data.available = info.available;
|
this.data.available = info.available;
|
||||||
this.data.discovering = info.discovering;
|
this.data.discovering = info.discovering;
|
||||||
resolve(info);
|
resolve(info);
|
||||||
},
|
},
|
||||||
fail: (ex1) => {
|
fail: (ex1) => {
|
||||||
////console.log("ex1", ex1);
|
console.log("蓝牙状态获取失败", ex1);
|
||||||
let res1 = {
|
let res1 = {
|
||||||
available: false,
|
available: false,
|
||||||
discovering: false
|
discovering: false
|
||||||
@ -363,7 +416,7 @@ class BleHelper {
|
|||||||
|
|
||||||
uni.openBluetoothAdapter({
|
uni.openBluetoothAdapter({
|
||||||
success: (args) => {
|
success: (args) => {
|
||||||
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
// console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||||
this.data.isOpenBlue = true;
|
this.data.isOpenBlue = true;
|
||||||
this.data.available = true;
|
this.data.available = true;
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@ -371,7 +424,7 @@ class BleHelper {
|
|||||||
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("开始订阅各类变化消息");
|
// console.log("开始订阅各类变化消息");
|
||||||
this.data.isSubscribe = true;
|
this.data.isSubscribe = true;
|
||||||
|
|
||||||
|
|
||||||
@ -381,14 +434,17 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uni.onBluetoothAdapterStateChange((state) => {
|
uni.onBluetoothAdapterStateChange((state) => {
|
||||||
console.log('蓝牙状态发生变化:' + JSON.stringify(state));
|
// console.log('蓝牙状态发生变化:' + JSON.stringify(state));
|
||||||
|
if (this.data.available !== state.available) {
|
||||||
this.data.available = state.available;
|
this.data.available = state.available;
|
||||||
this.data.discovering = state.discovering;
|
this.data.discovering = state.discovering;
|
||||||
if (this.data.available && this.data
|
if (this.data.available && this.data
|
||||||
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
|
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
|
||||||
|
this.linkAllDevices();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!state.available) { //蓝牙状态不可用了,将所有设备标记为断开连接
|
if (!state.available) { //蓝牙状态不可用了,将所有设备标记为断开连接
|
||||||
this.data.LinkedList.filter((v) => {
|
this.data.LinkedList.filter((v) => {
|
||||||
@ -396,8 +452,8 @@ class BleHelper {
|
|||||||
v.notifyState = false;
|
v.notifyState = false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey, this.data
|
|
||||||
.LinkedList);
|
this.updateCache();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -406,7 +462,7 @@ class BleHelper {
|
|||||||
if (!res.connected) {
|
if (!res.connected) {
|
||||||
|
|
||||||
console.log("蓝牙连接已断开", res);
|
console.log("蓝牙连接已断开", res);
|
||||||
this.data.LinkedList.find((v) => {
|
let f=this.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == res.deviceId) {
|
if (v.deviceId == res.deviceId) {
|
||||||
v.Linked = false;
|
v.Linked = false;
|
||||||
v.notifyState = false;
|
v.notifyState = false;
|
||||||
@ -414,15 +470,16 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey, this.data
|
this.updateCache();
|
||||||
.LinkedList);
|
console.log("尝试5次恢复连接");
|
||||||
|
this.LinkBlue(res.deviceId,f.writeServiceId,f.wirteCharactId,f.notifyCharactId,5)
|
||||||
} else {
|
} else {
|
||||||
console.log("蓝牙连接已恢复,", res);
|
console.log("蓝牙连接已恢复,", res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.onBluetoothDeviceFound((devices) => {
|
uni.onBluetoothDeviceFound((devices) => {
|
||||||
// ////console.log("发现新设备:" + JSON.stringify(devices));
|
console.log("发现新设备:" + JSON.stringify(devices));
|
||||||
this.data.searchList = this.data.searchList.concat(
|
this.data.searchList = this.data.searchList.concat(
|
||||||
devices);
|
devices);
|
||||||
if (this.cfg.onDeviceFound) {
|
if (this.cfg.onDeviceFound) {
|
||||||
@ -458,24 +515,49 @@ class BleHelper {
|
|||||||
// 将每个字节转换为对应的字符
|
// 将每个字节转换为对应的字符
|
||||||
str += String.fromCharCode(uint8Array[i]);
|
str += String.fromCharCode(uint8Array[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let header = "mac address:";
|
let header = "mac address:";
|
||||||
if (str.indexOf(header) == 0) { //650以文本传输mac
|
if (str.indexOf(header) == 0) { //650以文本传输mac
|
||||||
|
console.log("str=", str);
|
||||||
|
this.data.LinkedList.find((v) => {
|
||||||
|
if (v.deviceId == receive
|
||||||
|
.deviceId) {
|
||||||
|
let macStr = str.replace(
|
||||||
|
header, "");
|
||||||
|
if (macStr.includes(':')) {
|
||||||
|
v.macAddress = macStr;
|
||||||
|
} else {
|
||||||
|
v.macAddress = macStr
|
||||||
|
.replace(
|
||||||
|
/(.{2})/g, '$1:')
|
||||||
|
.slice(0, -1)
|
||||||
|
}
|
||||||
|
str = header + v.macAddress;
|
||||||
|
console.log("收到mac地址:", v
|
||||||
|
.macAddress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.updateCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str.indexOf('imei:') == 0) {
|
||||||
|
let imei = str.split(':')[1];
|
||||||
|
|
||||||
|
|
||||||
this.data.LinkedList.find((v) => {
|
this.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == receive
|
if (v.deviceId == receive
|
||||||
.deviceId) {
|
.deviceId) {
|
||||||
v.macAddress = str.replace(
|
v.imei=imei;
|
||||||
header, "");
|
|
||||||
// console.log("收到mac地址:", str)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey, this.data
|
this.updateCache();
|
||||||
.LinkedList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
|
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
|
||||||
// console.log("收到mac地址:", bytes)
|
console.log("收到mac地址:", bytes)
|
||||||
if (bytes.length >= 7) {
|
if (bytes.length >= 7) {
|
||||||
|
console.log("hexs=", hexs);
|
||||||
let mac = hexs.slice(1, 7).join(":")
|
let mac = hexs.slice(1, 7).join(":")
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
this.data.LinkedList.find((v) => {
|
this.data.LinkedList.find((v) => {
|
||||||
@ -485,12 +567,12 @@ class BleHelper {
|
|||||||
// console.log("收到mac地址:", str)
|
// console.log("收到mac地址:", str)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey, this
|
this.updateCache();
|
||||||
.data.LinkedList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("str=", str);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
////console.log("将数据转文本失败", ex);
|
console.log("将数据转文本失败", ex);
|
||||||
}
|
}
|
||||||
let recData = {
|
let recData = {
|
||||||
deviceId: receive.deviceId,
|
deviceId: receive.deviceId,
|
||||||
@ -500,23 +582,40 @@ class BleHelper {
|
|||||||
str: str,
|
str: str,
|
||||||
hexs: hexs
|
hexs: hexs
|
||||||
};
|
};
|
||||||
console.log("监听到特征值:" + JSON.stringify(recData));
|
// console.log("监听到特征值:" + JSON.stringify(recData));
|
||||||
|
try {
|
||||||
if (this.cfg.receivDataCallback) {
|
if (this.cfg.receivDataCallback) {
|
||||||
|
|
||||||
if (this.cfg.receivDataCallback.length > 0) {
|
if (this.cfg.receivDataCallback.length > 0) {
|
||||||
|
|
||||||
let path = this.getCurrentPagePath();
|
let path = this.getCurrentPagePath();
|
||||||
|
console.log("有人订阅消息")
|
||||||
this.cfg.receivDataCallback.forEach((rec) => {
|
this.cfg.receivDataCallback.forEach((
|
||||||
|
rec) => {
|
||||||
|
console.log("有人订阅消息111", )
|
||||||
if (rec.callback) {
|
if (rec.callback) {
|
||||||
rec.callback(recData, f, path);
|
try {
|
||||||
|
rec.callback(recData, f,
|
||||||
|
path, this.cfg
|
||||||
|
.receivDataCallback
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("订阅消息出现异常",
|
||||||
|
err);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
console.log("无人订阅消息");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("无人订阅receivDataCallback,不处理数据");
|
console.log("无人订阅receivDataCallback,不处理数据");
|
||||||
}
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
console.log("ex=", ex);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -582,10 +681,16 @@ class BleHelper {
|
|||||||
var these = this;
|
var these = this;
|
||||||
//开始搜索
|
//开始搜索
|
||||||
var Search = () => {
|
var Search = () => {
|
||||||
console.log("Search........");
|
//只搜索合作供应商的服务id
|
||||||
|
let serviceIds = serviceDic.map(v => {
|
||||||
|
return v.serviceId
|
||||||
|
});
|
||||||
|
|
||||||
|
//搜索一个服务id的设备,循环调用
|
||||||
|
let RunSearch = (serviceId) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.startBluetoothDevicesDiscovery({
|
uni.startBluetoothDevicesDiscovery({
|
||||||
services: [],
|
services:serviceId? [serviceId]:[],
|
||||||
allowDuplicatesKey: true,
|
allowDuplicatesKey: true,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
//console.log('开始搜索蓝牙设备成功');
|
//console.log('开始搜索蓝牙设备成功');
|
||||||
@ -600,19 +705,36 @@ class BleHelper {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let promises = [];
|
||||||
|
// for (let i = 0; i < serviceIds.length; i++) {
|
||||||
|
|
||||||
|
// promises.push(RunSearch(serviceIds[i]));
|
||||||
|
|
||||||
|
// }
|
||||||
|
promises.push(RunSearch());
|
||||||
|
Promise.all(promises).then(resolve).catch(reject);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return this.OpenBlue().then((res) => {
|
return this.OpenBlue().then((res) => {
|
||||||
console.log("蓝牙适配器状态", res)
|
// console.log("蓝牙适配器状态", res)
|
||||||
|
|
||||||
return Search();
|
return Search();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//停止搜索
|
//停止搜索
|
||||||
StopSearch() {
|
StopSearch() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -656,21 +778,26 @@ class BleHelper {
|
|||||||
|
|
||||||
//订阅消息
|
//订阅消息
|
||||||
subScribe(deviceId, state) {
|
subScribe(deviceId, state) {
|
||||||
|
console.log("开始订阅消息");
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
let c = this.data.LinkedList.find((v) => {
|
let c = this.data.LinkedList.find((v) => {
|
||||||
return v.deviceId == deviceId;
|
return v.deviceId == deviceId;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
if (c.notifyState) {
|
if (c.notifyState) {
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("c=", c);
|
|
||||||
let startSubScribe = (id, serviceId, characteristicId) => {
|
|
||||||
|
|
||||||
return new Promise((succ, err) => {
|
let startSubScribe = (id, serviceId, characteristicId) => {
|
||||||
|
console.log("serviceId=", serviceId);
|
||||||
|
console.log("characteristicId=", characteristicId);
|
||||||
|
let p1 = new Promise((succ, err) => {
|
||||||
|
|
||||||
uni.notifyBLECharacteristicValueChange({
|
uni.notifyBLECharacteristicValueChange({
|
||||||
deviceId: id,
|
deviceId: id,
|
||||||
serviceId: serviceId,
|
serviceId: serviceId,
|
||||||
@ -688,7 +815,10 @@ class BleHelper {
|
|||||||
v.notifyState = state;
|
v.notifyState = state;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
succ();
|
// console.log("success SubScribe");
|
||||||
|
succ(
|
||||||
|
res
|
||||||
|
); //见了鬼了,有时候执行了succ但promise永远pending了
|
||||||
},
|
},
|
||||||
fail: (ex) => {
|
fail: (ex) => {
|
||||||
|
|
||||||
@ -696,8 +826,27 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let p2 = new Promise((succ, err) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
err({
|
||||||
|
code: -1
|
||||||
|
});
|
||||||
|
}, 50);
|
||||||
|
});
|
||||||
|
return new Promise((succ, err) => {
|
||||||
|
Promise.race([p1, p2]).then(succ).catch(ex => {
|
||||||
|
if (ex.code == -1) {
|
||||||
|
succ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
err(ex);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
let promies = new Array();
|
let promies = new Array();
|
||||||
|
if (c.Characteristics && c.Characteristics.length) {
|
||||||
for (var i = 0; i < c.Characteristics.length; i++) {
|
for (var i = 0; i < c.Characteristics.length; i++) {
|
||||||
let item = c.Characteristics[i];
|
let item = c.Characteristics[i];
|
||||||
let serviceId = item.serviceId;
|
let serviceId = item.serviceId;
|
||||||
@ -705,9 +854,16 @@ class BleHelper {
|
|||||||
|
|
||||||
if (item.properties.notify) {
|
if (item.properties.notify) {
|
||||||
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
|
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
promies.push(startSubScribe(c.deviceId, c.notifyServiceid, c.notifyCharactId));
|
||||||
|
}
|
||||||
|
|
||||||
if (promies.length > 0) {
|
if (promies.length > 0) {
|
||||||
|
|
||||||
|
|
||||||
Promise.allSettled(promies).then((results) => {
|
Promise.allSettled(promies).then((results) => {
|
||||||
|
|
||||||
results.forEach((result, index) => {
|
results.forEach((result, index) => {
|
||||||
@ -718,18 +874,22 @@ class BleHelper {
|
|||||||
// .message);
|
// .message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// console.log("订阅消息成功");
|
||||||
resolve();
|
resolve();
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
console.log("ex=",ex);
|
||||||
reject(ex);
|
reject(ex);
|
||||||
|
}).finally(() => {
|
||||||
|
// console.log("finally")
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log("没有特征需要订阅");
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, 20);
|
}, 800);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -755,17 +915,44 @@ class BleHelper {
|
|||||||
v.services = res.services;
|
v.services = res.services;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey,
|
//this.updateCache();
|
||||||
this.data.LinkedList);
|
|
||||||
|
|
||||||
var promises = [];
|
var promises = [];
|
||||||
|
let s = null;
|
||||||
let se = res.services.find((v) => {
|
let se = res.services.find((v) => {
|
||||||
return v.uuid.indexOf(targetServiceId) > -1;
|
|
||||||
|
s = serviceDic.find(k => {
|
||||||
|
|
||||||
|
return k.serviceId == v.uuid;
|
||||||
|
})
|
||||||
|
if (s) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
// return v.uuid.indexOf(targetServiceId) > -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (se) {
|
if (se) {
|
||||||
promises.push(this.getFeatrus(id, se.uuid, writeCharId,
|
console.log("合作供应商的",s)
|
||||||
notifyCharId));
|
this.data.LinkedList.find((v) => {
|
||||||
|
if (v.deviceId == id) {
|
||||||
|
v.writeServiceId = s.serviceId;
|
||||||
|
v.wirteCharactId = s.writeId;
|
||||||
|
v.notifyServiceid = s.serviceId;
|
||||||
|
v.notifyCharactId = s.notifyId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.updateCache();
|
||||||
|
|
||||||
|
//合作供应商的设备,直接订阅消息,不走发现特征了
|
||||||
|
promises.push(this.subScribe(id, true));
|
||||||
|
|
||||||
|
// promises.push(this.getFeatrus(id, se.uuid, writeCharId,
|
||||||
|
// notifyCharId));
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
console.log("预设的蓝牙服务和特征中找不到");
|
||||||
for (var i = 0; i < res.services.length; i++) {
|
for (var i = 0; i < res.services.length; i++) {
|
||||||
let service = res.services[i];
|
let service = res.services[i];
|
||||||
promises.push(this.getFeatrus(id, service.uuid,
|
promises.push(this.getFeatrus(id, service.uuid,
|
||||||
@ -784,13 +971,19 @@ class BleHelper {
|
|||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
|
if (!s) {
|
||||||
|
//非指定供应商的设备,走订阅消息
|
||||||
return this.subScribe(id, true);
|
return this.subScribe(id, true);
|
||||||
|
} else {
|
||||||
|
//指定供应商的设备已经订阅过了
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('设备连接成功,初始化完成', res);
|
console.log('设备连接成功,初始化完成', this.data
|
||||||
console.log("LinkedList=", this.data
|
|
||||||
.LinkedList);
|
.LinkedList);
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -836,28 +1029,47 @@ class BleHelper {
|
|||||||
deviceId: id,
|
deviceId: id,
|
||||||
serviceId: serviceId,
|
serviceId: serviceId,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
|
||||||
console.log("获取到特征:" + JSON.stringify(res));
|
console.log("获取到特征:" + JSON.stringify(res));
|
||||||
res.characteristics.forEach((v) => {
|
// res.characteristics.forEach((v) => {
|
||||||
v.serviceId = serviceId;
|
// v.serviceId = serviceId;
|
||||||
});
|
// });
|
||||||
|
|
||||||
//写特征
|
//写特征
|
||||||
let writeChar = res.characteristics.find(char => {
|
let writeChar = res.characteristics.find(char => {
|
||||||
return char.uuid.indexOf(writeCharId) > -1
|
let fe = serviceDic.find(v => {
|
||||||
});
|
return v.serviceId == serviceId && v.writeId == char
|
||||||
if (!writeChar) {
|
.uuid;
|
||||||
writeChar = res.characteristics.find(char => {
|
})
|
||||||
return char.properties.write;
|
// return char.uuid.indexOf(writeCharId) > -1
|
||||||
});
|
if (fe) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
// if (!writeChar) {
|
||||||
|
// writeChar = res.characteristics.find(char => {
|
||||||
|
// return char.properties.write;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
//通知特征
|
//通知特征
|
||||||
let notiChar = res.characteristics.find(char => {
|
let notiChar = res.characteristics.find(char => {
|
||||||
return char.uuid.indexOf(notifyCharId) > -1;
|
let fe = serviceDic.find(v => {
|
||||||
});
|
return v.serviceId == serviceId && v.notifyId ==
|
||||||
if (!notiChar) {
|
char.uuid;
|
||||||
notiChar = res.characteristics.find(char => {
|
})
|
||||||
return char.properties.notify;
|
// return char.uuid.indexOf(writeCharId) > -1
|
||||||
});
|
if (fe) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
// return char.uuid.indexOf(notifyCharId) > -1;
|
||||||
|
});
|
||||||
|
// if (!notiChar) {
|
||||||
|
// notiChar = res.characteristics.find(char => {
|
||||||
|
// return char.properties.notify;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
this.data.LinkedList.find(function(v) {
|
this.data.LinkedList.find(function(v) {
|
||||||
if (v.deviceId == id) {
|
if (v.deviceId == id) {
|
||||||
if (!v.Characteristics) {
|
if (!v.Characteristics) {
|
||||||
@ -896,7 +1108,7 @@ class BleHelper {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
this.updateCache();
|
||||||
resolve(res);
|
resolve(res);
|
||||||
},
|
},
|
||||||
fail: (ex) => {
|
fail: (ex) => {
|
||||||
@ -909,9 +1121,11 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//连接某个设备
|
//连接某个设备
|
||||||
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId) {
|
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) {
|
||||||
|
|
||||||
|
|
||||||
|
if (maxRetries === undefined) {
|
||||||
|
maxRetries = 0; // 最大重试次数
|
||||||
|
}
|
||||||
if (!writeCharId) {
|
if (!writeCharId) {
|
||||||
writeCharId = "xxxx"; // "FFE1";
|
writeCharId = "xxxx"; // "FFE1";
|
||||||
}
|
}
|
||||||
@ -936,23 +1150,30 @@ class BleHelper {
|
|||||||
|
|
||||||
//连接设备
|
//连接设备
|
||||||
var linkDevice = () => {
|
var linkDevice = () => {
|
||||||
return new Promise((resolve, reject) => {
|
// 添加重试次数限制
|
||||||
|
let retryCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
const connect = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
if (fIndex > -1 && f?.Linked) {
|
if (fIndex > -1 && f?.Linked) {
|
||||||
console.log("当前已连接,跳过其他步骤")
|
// console.log("当前已连接,跳过其他步骤");
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.data.available) {
|
if (!this.data.available) {
|
||||||
reject(this.getError({code:10001}));
|
reject(this.getError({
|
||||||
|
code: 10001
|
||||||
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("正在连接" + deviceId);
|
console.log("正在连接" + deviceId);
|
||||||
uni.createBLEConnection({
|
uni.createBLEConnection({
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
timeout: 3000,
|
timeout: 30000,
|
||||||
success: (info) => {
|
success: (info) => {
|
||||||
|
|
||||||
console.log("新连接成功", this.data.LinkedList);
|
console.log("新连接成功", this.data.LinkedList);
|
||||||
this.getLinkBlue().then((arr) => {
|
this.getLinkBlue().then((arr) => {
|
||||||
let cr = arr.devices.find(c => {
|
let cr = arr.devices.find(c => {
|
||||||
@ -961,49 +1182,63 @@ class BleHelper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fIndex > -1) {
|
if (fIndex > -1) {
|
||||||
this.data.LinkedList[fIndex].Linked = true;
|
this.data.LinkedList[fIndex].Linked = true;
|
||||||
} else {
|
} else {
|
||||||
this.data.LinkedList.push(cr);
|
this.data.LinkedList.push(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.setStorageSync(this.StorageKey, this.data
|
this.updateCache();
|
||||||
|
console.log("LinkedList=", this.data
|
||||||
.LinkedList);
|
.LinkedList);
|
||||||
|
|
||||||
let os = plus.os.name;
|
// 处理 MTU 设置
|
||||||
if (os == 'android') {
|
if (plus.os.name === 'Android') {
|
||||||
uni.setBLEMTU({
|
uni.setBLEMTU({
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
mtu: 512,
|
mtu: 512,
|
||||||
success: (mtu) => {
|
success: (mtu) => {
|
||||||
|
|
||||||
////console.log("mtu设置成功");
|
resolve(true);
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
////console.log("mtu设置失败")
|
console.log("mtu设置失败");
|
||||||
|
resolve(
|
||||||
|
true
|
||||||
|
); // MTU设置失败不影响连接成功
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
|
}
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
|
||||||
reject(this.getError(ex));
|
reject(this.getError(ex));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
fail: (ex) => {
|
fail: (ex) => {
|
||||||
ex = this.getError(ex)
|
ex = this.getError(ex);
|
||||||
console.log("蓝牙连接失败" + JSON.stringify(ex));
|
console.log("蓝牙" + deviceId + "连接失败" + JSON.stringify(ex));
|
||||||
|
|
||||||
|
// 连接超时后自动重试
|
||||||
|
if (ex.code === 10012 && retryCount < maxRetries) {
|
||||||
|
retryCount++;
|
||||||
|
console.log(`重试连接 (${retryCount}/${maxRetries})`);
|
||||||
|
// 使用 setTimeout 避免递归调用栈溢出
|
||||||
|
setTimeout(() => {
|
||||||
|
connect().then(resolve).catch(reject);
|
||||||
|
}, 1000); // 延迟1秒后重试
|
||||||
|
} else {
|
||||||
reject(ex);
|
reject(ex);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1013,19 +1248,32 @@ class BleHelper {
|
|||||||
////console.log("2222222");
|
////console.log("2222222");
|
||||||
return linkDevice(deviceId);
|
return linkDevice(deviceId);
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
////console.log("11111111");
|
|
||||||
if (res) { //新连接
|
if (res) { //新连接
|
||||||
|
// console.log("11111111");
|
||||||
if (fIndex == -1) {
|
if (fIndex == -1) {
|
||||||
console.log("开始获取服务", targetServiceId)
|
// console.log("开始获取服务", targetServiceId)
|
||||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||||
notifyCharId); //获取服务
|
notifyCharId); //获取服务
|
||||||
} else {
|
} else {
|
||||||
|
if (f.wirteCharactId && f.notifyCharactId) {
|
||||||
if (!f.notifyState) {
|
if (!f.notifyState) {
|
||||||
|
// console.log("开始订阅特征");
|
||||||
this.subScribe(deviceId, true);
|
this.subScribe(deviceId, true);
|
||||||
|
} else {
|
||||||
|
console.log("不订阅消息");
|
||||||
}
|
}
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
|
} else {
|
||||||
|
console.log("开始获取服务", targetServiceId)
|
||||||
|
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||||
|
notifyCharId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else { //已连接过,直接订阅消息
|
} else { //已连接过,直接订阅消息
|
||||||
|
// console.log("11111111");
|
||||||
if (fIndex > -1 && f && !f.notifyState) {
|
if (fIndex > -1 && f && !f.notifyState) {
|
||||||
|
|
||||||
this.subScribe(deviceId, true);
|
this.subScribe(deviceId, true);
|
||||||
@ -1034,13 +1282,13 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
// console.log("then.....");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve();
|
resolve();
|
||||||
}, 500);
|
}, 500);
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
////console.log("出现异常", ex);
|
console.log("出现异常", ex);
|
||||||
reject(ex);
|
reject(ex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1156,7 +1404,7 @@ class BleHelper {
|
|||||||
characteristicId: device.wirteCharactId,
|
characteristicId: device.wirteCharactId,
|
||||||
value: buffer,
|
value: buffer,
|
||||||
success: () => {
|
success: () => {
|
||||||
console.log("发送数据成功");
|
// console.log("发送数据成功");
|
||||||
succ();
|
succ();
|
||||||
},
|
},
|
||||||
fail: (ex) => {
|
fail: (ex) => {
|
||||||
@ -1181,7 +1429,7 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => {
|
Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => {
|
||||||
console.log("ex=", ex);
|
// console.log("ex=", ex);
|
||||||
if (ex.code == -1) {
|
if (ex.code == -1) {
|
||||||
resolve(ex);
|
resolve(ex);
|
||||||
} else {
|
} else {
|
||||||
@ -1244,7 +1492,7 @@ class BleHelper {
|
|||||||
let a = pixels[i + 3];
|
let a = pixels[i + 3];
|
||||||
|
|
||||||
if (type == 'bgr') {
|
if (type == 'bgr') {
|
||||||
result[index++] = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
|
result[index++] = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
|
||||||
} else {
|
} else {
|
||||||
result[index++] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
result[index++] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||||
}
|
}
|
||||||
@ -1254,9 +1502,7 @@ class BleHelper {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBleData() {
|
|
||||||
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|||||||
@ -44,30 +44,33 @@ class BleReceive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReceiveData(receive,f,path) {
|
ReceiveData(receive,f,path,recArr) {
|
||||||
if(f && f.macAddress && f.id){
|
if(f && f.macAddress && f.device && f.device.id){
|
||||||
let data={};
|
let data={};
|
||||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
if(f.device.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||||
console.log("该设备是6155");
|
// console.log("该设备是6155");
|
||||||
data= this.Receive_6155(receive,f,path);
|
data= this.Receive_6155(receive,f,path,recArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
if(f.device.detailPageUrl=='/pages/650/HBY650'){
|
||||||
console.log("该设备是650");
|
// console.log("该设备是650");
|
||||||
data= this.Receive_650(receive,f,path);
|
data= this.Receive_650(receive,f,path,recArr);
|
||||||
}
|
}
|
||||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
if(f.device.detailPageUrl=='/pages/670/HBY670'){
|
||||||
console.log("该设备是670");
|
// console.log("该设备是670");
|
||||||
data= this.Receive_670(receive,f,path);
|
data= this.Receive_670(receive,f,path,recArr);
|
||||||
}
|
}
|
||||||
console.log("收到数据并处理完毕,",data);
|
// console.log("收到数据并处理完毕,",data);
|
||||||
return data;
|
return data;
|
||||||
|
}else{
|
||||||
|
console.log("已收到该消息,但无法处理",receive);
|
||||||
}
|
}
|
||||||
console.log("已收到该消息,但无法处理",f);
|
|
||||||
|
return receive;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_650(receive,f,path) {
|
Receive_650(receive,f,path,recArr) {
|
||||||
console.log("通用程序正在处理650的数据",receive);
|
console.log("通用程序正在处理650的数据",receive);
|
||||||
|
|
||||||
var parseData = () => {
|
var parseData = () => {
|
||||||
@ -93,7 +96,7 @@ class BleReceive {
|
|||||||
staticLevelText = '低档';
|
staticLevelText = '低档';
|
||||||
modeCurr = "low";
|
modeCurr = "low";
|
||||||
break;
|
break;
|
||||||
case 0x68:
|
case 0x64:
|
||||||
staticLevelText = '关闭';
|
staticLevelText = '关闭';
|
||||||
modeCurr = "close";
|
modeCurr = "close";
|
||||||
break;
|
break;
|
||||||
@ -250,14 +253,14 @@ class BleReceive {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_670(receive,f,path){
|
Receive_670(receive,f,path,recArr){
|
||||||
|
console.log("pagh=",path);
|
||||||
var todo = (bytes) =>{
|
var todo = (bytes) =>{
|
||||||
console.log("todo");
|
// console.log("todo",receive);
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
if (bytes[0] == 0x55) {
|
if (bytes[0] == 0x55) {
|
||||||
try {
|
try {
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||||
let staticLevelByte = bytes[1];
|
let staticLevelByte = bytes[1];
|
||||||
let staticLevelText = '';
|
let staticLevelText = '';
|
||||||
@ -271,11 +274,11 @@ class BleReceive {
|
|||||||
case 0x67:
|
case 0x67:
|
||||||
staticLevelText = 'low';
|
staticLevelText = 'low';
|
||||||
break
|
break
|
||||||
case 0x68:
|
case 0x64:
|
||||||
staticLevelText = 'close';
|
staticLevelText = 'close';
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
// 解析照明档位
|
// 解析照明档位
|
||||||
let lightingLevelByte = bytes[2];
|
let lightingLevelByte = bytes[2];
|
||||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
||||||
@ -287,7 +290,7 @@ class BleReceive {
|
|||||||
let batteryLevelByte = bytes[5];
|
let batteryLevelByte = bytes[5];
|
||||||
|
|
||||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
let warn = bytes[6];
|
let warn = bytes[6];
|
||||||
if (warn == 0x00) {
|
if (warn == 0x00) {
|
||||||
warn = 'none';
|
warn = 'none';
|
||||||
@ -304,7 +307,7 @@ class BleReceive {
|
|||||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
let staticWarn = bytes[7] == 0x01;//静止报警
|
||||||
let fourGStrenth = bytes[8]; //4g信号强度
|
let fourGStrenth = bytes[8]; //4g信号强度
|
||||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = lightingTime ;
|
receiveData.xuhang = lightingTime ;
|
||||||
@ -313,10 +316,25 @@ class BleReceive {
|
|||||||
receiveData.staticWarn = staticWarn;
|
receiveData.staticWarn = staticWarn;
|
||||||
receiveData.fourGStrenth = fourGStrenth;
|
receiveData.fourGStrenth = fourGStrenth;
|
||||||
receiveData.SOS=sosTxt;
|
receiveData.SOS=sosTxt;
|
||||||
|
|
||||||
|
this.setBleFormData(receiveData,f);
|
||||||
|
console.log("recArr=",recArr);
|
||||||
|
let recCnt=recArr.find(v=>{
|
||||||
|
return v.key == f.device.detailPageUrl;
|
||||||
|
});
|
||||||
|
if(!recCnt){
|
||||||
|
if (this.formData.staticWarn) { //有静止报警
|
||||||
|
uni.showModal({
|
||||||
|
title:"警告",
|
||||||
|
content:"设备静止报警中",
|
||||||
|
showCancel:false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
}
|
}
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
let uint8Array = new Uint8Array(receive.value);
|
let uint8Array = new Uint8Array(receive.value);
|
||||||
@ -340,6 +358,7 @@ class BleReceive {
|
|||||||
console.log('收到纬度:', +this.receiveData.macAddress);
|
console.log('收到纬度:', +this.receiveData.macAddress);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
// console.log("str=",str);
|
||||||
let json=JSON.parse(str);
|
let json=JSON.parse(str);
|
||||||
if("staBlue_picture" in json){
|
if("staBlue_picture" in json){
|
||||||
//重发图片
|
//重发图片
|
||||||
@ -372,7 +391,7 @@ class BleReceive {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData={};
|
||||||
console.log("文本解析失败")
|
// console.log("文本解析失败",error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
@ -380,7 +399,7 @@ class BleReceive {
|
|||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("todo",receiveData);
|
// console.log("todo",receiveData);
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData,f);
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
@ -390,8 +409,81 @@ class BleReceive {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
Receive_6155() {
|
Receive_6155(receive,f,path,recArr) {
|
||||||
console.log("通用程序正在处理6155的数据");
|
let bytes=receive.bytes;
|
||||||
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
let staticLevelByte = bytes[2];
|
||||||
|
let getName = function(type) {
|
||||||
|
let name = "";
|
||||||
|
switch (type) {
|
||||||
|
case 0x02:
|
||||||
|
name = '弱光';
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
name = '工作光';
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
name = '强光';
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
name = '爆闪';
|
||||||
|
break;
|
||||||
|
case 0x00:
|
||||||
|
name = '关闭';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
let staticLevelText = getName(staticLevelByte);
|
||||||
|
|
||||||
|
// 解析照明档位
|
||||||
|
let lightingLevelByte = bytes[3];
|
||||||
|
let lightingLevelText = getName(lightingLevelByte);
|
||||||
|
|
||||||
|
|
||||||
|
// 解析剩余电量
|
||||||
|
let batteryLevelByte = bytes[4];
|
||||||
|
// 电量百分比范围检查
|
||||||
|
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//充电状态
|
||||||
|
let warn = bytes[5];
|
||||||
|
if (warn == 0x00) {
|
||||||
|
warn = '未充电';
|
||||||
|
} else if (warn == 0x01) {
|
||||||
|
warn = '充电中';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||||
|
let lightingTime = "";
|
||||||
|
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||||
|
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||||
|
lightingTime = HH + "小时" + mm + "分钟";
|
||||||
|
let formData={};
|
||||||
|
formData.mode = staticLevelText;
|
||||||
|
formData.fuMode = lightingLevelText;
|
||||||
|
formData.battary = batteryLevel;
|
||||||
|
formData.statu = warn;
|
||||||
|
formData.xuhang = lightingTime;
|
||||||
|
|
||||||
|
if (batteryLevel <= 20) {
|
||||||
|
uni.showModal({
|
||||||
|
content:"设备电量低",
|
||||||
|
title:"提示"
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
this.setBleFormData(formData,f);
|
||||||
|
return formData;
|
||||||
|
} catch (error) {
|
||||||
|
console.log('数据解析错误:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
102
utils/Common.js
102
utils/Common.js
@ -1,11 +1,6 @@
|
|||||||
var cfg={
|
import request from "@/utils/request.js";
|
||||||
Version:'Uat',//Dev:开发环境,Uat:Uat环境,Relese正式环境
|
|
||||||
DevApi:'http://192.168.110.54:8000/',//开发环境
|
|
||||||
UatApi:'http://114.55.111.217/',//UAT环境
|
|
||||||
ReleseApi:'http://relese:3169/api/'//Relese环境
|
|
||||||
}
|
|
||||||
export default {
|
export default {
|
||||||
baseURL : cfg.Version=='Dev'?cfg.DevApi:(cfg.Version=='Uat'?cfg.UatApi:cfg.ReleseApi),
|
|
||||||
guid: function generateUUID() {
|
guid: function generateUUID() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
const r = Math.random() * 16 | 0;
|
const r = Math.random() * 16 | 0;
|
||||||
@ -76,11 +71,9 @@ export default {
|
|||||||
let ServerPath = these.DevApi;
|
let ServerPath = these.DevApi;
|
||||||
if (these.Version === 'Dev') {
|
if (these.Version === 'Dev') {
|
||||||
ServerPath = these.DevApi;
|
ServerPath = these.DevApi;
|
||||||
}
|
} else if (these.Version === 'Uat') {
|
||||||
else if(these.Version==='Uat'){
|
|
||||||
ServerPath = these.UatApi;
|
ServerPath = these.UatApi;
|
||||||
}
|
} else if (these.Version === 'Relese') {
|
||||||
else if(these.Version==='Relese'){
|
|
||||||
ServerPath = these.ReleseApi;
|
ServerPath = these.ReleseApi;
|
||||||
} else {
|
} else {
|
||||||
these.DevApi
|
these.DevApi
|
||||||
@ -136,7 +129,8 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,function(){
|
,
|
||||||
|
function() {
|
||||||
these.showToast('无网络连接');
|
these.showToast('无网络连接');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -208,11 +202,83 @@ export default {
|
|||||||
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
||||||
return formatMap[match];
|
return formatMap[match];
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
getdeviceShareId(id) {//获取设备分享信息
|
||||||
|
return request({
|
||||||
|
url: `/app/deviceShare/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getPermissions(type) {
|
||||||
|
if (!type) {
|
||||||
|
type='6170';
|
||||||
|
}
|
||||||
|
let array = [{
|
||||||
|
value: "1",
|
||||||
|
label: "灯光模式",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170', '670']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "2",
|
||||||
|
label: "激光模式",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "3",
|
||||||
|
label: "开机画面",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170', '670']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "4",
|
||||||
|
label: "人员信息登记",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170', '670']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "5",
|
||||||
|
label: "发送信息",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170', '670']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "6",
|
||||||
|
label: "产品信息",
|
||||||
|
checked: false,
|
||||||
|
type: ['210', '6170', '670']
|
||||||
|
}, {
|
||||||
|
value: "41",
|
||||||
|
label: "静电探测",
|
||||||
|
checked: false,
|
||||||
|
type: ['670']
|
||||||
|
}, {
|
||||||
|
value: "42",
|
||||||
|
label: "SOS",
|
||||||
|
checked: false,
|
||||||
|
type: ['670']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let arr=[];
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
let item = array[i];
|
||||||
|
if(!item){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!item.type){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let typeContais=item.type.find(v=>{
|
||||||
|
return v.includes(type);
|
||||||
|
});
|
||||||
|
if(typeContais){
|
||||||
|
let json={};
|
||||||
|
Object.assign(json,item);
|
||||||
|
arr.push(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -5,19 +5,17 @@ export const showLoading = (ev,options) => {
|
|||||||
if(!ev){
|
if(!ev){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let defaultTxt="请稍候...";
|
||||||
if(!options){
|
if(!options){
|
||||||
options={a:1};
|
options={text:defaultTxt};
|
||||||
}
|
}
|
||||||
if(!options.text && options.title){
|
if(!options.text && options.title){
|
||||||
options.text=options.title;
|
options.text=options.title;
|
||||||
}
|
}
|
||||||
if(!options.text){
|
if(!options.text){
|
||||||
options.text="请稍候...";
|
options.text=defaultTxt;
|
||||||
}
|
}
|
||||||
ev.$refs.loading.show(options);
|
ev.$refs.loading.show(options);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 隐藏loading
|
// 隐藏loading
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
// 兼容性补丁:为 Paho MQTT 提供 uni-app 环境下的 WebSocket 实现
|
// 兼容性补丁:为 Paho MQTT 提供 uni-app 环境下的 WebSocket 实现
|
||||||
(function(root) {
|
(function(root) {
|
||||||
// 如果未能找到全局对象,则无法应用补丁。
|
// 如果未能找到全局对象,则无法应用补丁。
|
||||||
console.log("root=",root);
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
console.error("MQTT Polyfill: 未能找到全局对象 (global/window/self 均未定义)。");
|
console.error("MQTT Polyfill: 未能找到全局对象 (global/window/self 均未定义)。");
|
||||||
return;
|
return;
|
||||||
@ -118,20 +117,20 @@
|
|||||||
*/
|
*/
|
||||||
import Paho from 'paho-mqtt';
|
import Paho from 'paho-mqtt';
|
||||||
import allConfigs from '../config/index.js';
|
import allConfigs from '../config/index.js';
|
||||||
|
|
||||||
// 根据环境选择正确的配置
|
// 根据环境选择正确的配置
|
||||||
const env = 'production'; //production //开发of线上 改这里就行
|
const env = 'production'; //production development
|
||||||
const config = allConfigs[env];
|
const envConfig = allConfigs[env];
|
||||||
|
const mqttProtocol = env === 'production' ? 'wss' : 'ws';
|
||||||
|
const useSSL = env === 'production';
|
||||||
class MqttClient {
|
class MqttClient {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.client = null;
|
this.client = null;
|
||||||
this.options = {
|
this.options = {
|
||||||
host: config.MQTT_HOST,
|
host: envConfig.MQTT_HOST,
|
||||||
port: config.MQTT_PORT,
|
port: envConfig.MQTT_PORT,
|
||||||
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
|
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
|
||||||
username: config.MQTT_USERNAME,
|
username: envConfig.MQTT_USERNAME,
|
||||||
password: config.MQTT_PASSWORD,
|
password: envConfig.MQTT_PASSWORD,
|
||||||
};
|
};
|
||||||
this.onConnectCallback = null;
|
this.onConnectCallback = null;
|
||||||
this.messageCallbacks = new Map();
|
this.messageCallbacks = new Map();
|
||||||
@ -167,7 +166,7 @@ class MqttClient {
|
|||||||
this.client.onMessageArrived = (message) => {
|
this.client.onMessageArrived = (message) => {
|
||||||
const topic = message.destinationName;
|
const topic = message.destinationName;
|
||||||
const payload = message.payloadString;
|
const payload = message.payloadString;
|
||||||
// console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
||||||
const potentialJsons = payload.replace(/}\s*{/g, '}|{').split('|');
|
const potentialJsons = payload.replace(/}\s*{/g, '}|{').split('|');
|
||||||
potentialJsons.forEach(jsonString => {
|
potentialJsons.forEach(jsonString => {
|
||||||
if (jsonString.trim() === '') return;
|
if (jsonString.trim() === '') return;
|
||||||
@ -178,6 +177,10 @@ class MqttClient {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isConnected() {
|
||||||
|
return this.client && this.client.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
connect(onConnectCallback) {
|
connect(onConnectCallback) {
|
||||||
if (this.client && this.client.isConnected()) {
|
if (this.client && this.client.isConnected()) {
|
||||||
console.log('MQTT客户端已连接。');
|
console.log('MQTT客户端已连接。');
|
||||||
@ -187,16 +190,18 @@ class MqttClient {
|
|||||||
|
|
||||||
this.manualDisconnect = false;
|
this.manualDisconnect = false;
|
||||||
this.onConnectCallback = onConnectCallback;
|
this.onConnectCallback = onConnectCallback;
|
||||||
|
console.log(`环境识别,http https:${env}`, {
|
||||||
console.log(`正在连接MQTT: ${this.options.host}:${this.options.port}/mqtt`);
|
connectUrl: `${mqttProtocol}://${this.options.host}:${this.options.port}/mqtt`,
|
||||||
|
useSSL: useSSL,
|
||||||
|
clientId: this.options.clientId
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const connectOptions = {
|
const connectOptions = {
|
||||||
timeout: 10, // 增加连接超时时间,应对网络波动
|
timeout: 10, // 增加连接超时时间,应对网络波动
|
||||||
keepAliveInterval: 30, // 明确设置心跳间隔为30秒
|
keepAliveInterval: 30, // 明确设置心跳间隔为30秒
|
||||||
userName: this.options.username,
|
userName: this.options.username,
|
||||||
password: this.options.password,
|
password: this.options.password,
|
||||||
useSSL: false,
|
useSSL: useSSL, //http ws https wss开启
|
||||||
cleanSession: true,
|
cleanSession: true,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
console.log('MQTT连接成功');
|
console.log('MQTT连接成功');
|
||||||
|
|||||||
@ -1,17 +1,11 @@
|
|||||||
import config from '../config/index.js';
|
import config from '../config/index.js';
|
||||||
const env = 'production'; //production development //开发of线上 改这里就行
|
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)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 处理GET请求参数
|
// 处理GET请求参数
|
||||||
let url =options.url;
|
let url = BASE.BASE_URL + options.url;
|
||||||
if(url.indexOf('http://')===0 || url.indexOf('https://')===0){
|
|
||||||
url=url;
|
|
||||||
}else{
|
|
||||||
url=BASE.BASE_URL + url;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("url"+url)
|
console.log("url"+url)
|
||||||
if (options.method === 'GET' && options.data) {
|
if (options.method === 'GET' && options.data) {
|
||||||
// 使用qs序列化参数
|
// 使用qs序列化参数
|
||||||
@ -28,11 +22,11 @@ const request = (options) => {
|
|||||||
header: options.header || {},
|
header: options.header || {},
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("请求成功",res);
|
// console.log("res=",res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.log("请求失败",err);
|
console.log("ex=",err);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
125
utils/update.js
125
utils/update.js
@ -1,3 +1,7 @@
|
|||||||
|
import request, {
|
||||||
|
baseURL
|
||||||
|
} from '@/utils/request.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查并执行wgt热更新
|
* 检查并执行wgt热更新
|
||||||
* @param {String} updateUrl - 检查更新的接口地址
|
* @param {String} updateUrl - 检查更新的接口地址
|
||||||
@ -8,22 +12,20 @@ function checkAndUpdateWgt(updateUrl) {
|
|||||||
}
|
}
|
||||||
// 显示加载提示
|
// 显示加载提示
|
||||||
|
|
||||||
|
let urls = ['http://114.55.111.217/app/CheckUpdate', 'https://t3v3e2xsjv.by.takin.cc/app/CheckUpdate'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 1. 获取当前应用版本信息
|
// 1. 获取当前应用版本信息
|
||||||
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
||||||
const currentVersion = widgetInfo.version;
|
const currentVersion = widgetInfo.version;
|
||||||
console.log("当前版本:" + currentVersion);
|
console.log("当前版本:" + currentVersion);
|
||||||
// 2. 调用后端接口检查是否有更新
|
|
||||||
uni.request({
|
|
||||||
url: updateUrl,
|
let callbck = (res) => {
|
||||||
method: 'GET',
|
|
||||||
data: {
|
|
||||||
currentVersion: currentVersion,
|
|
||||||
platform: uni.getSystemInfoSync().platform
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
console.log("res=", res)
|
// console.log("检查更新成功=", res)
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
|
|
||||||
const updateInfo = res.data.data;
|
const updateInfo = res.data.data;
|
||||||
@ -49,18 +51,107 @@ function checkAndUpdateWgt(updateUrl) {
|
|||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let Update = (url) => {
|
||||||
|
console.log("url=",url);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: url,
|
||||||
|
method: 'GET',
|
||||||
|
data: {
|
||||||
|
currentVersion: currentVersion,
|
||||||
|
platform: uni.getSystemInfoSync().platform,
|
||||||
|
appId:"xhyc"
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
// console.log("res=>",res)
|
||||||
|
res.type='1';
|
||||||
|
resolve(res);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
uni.hideLoading();
|
console.log("err=",err);
|
||||||
uni.showToast({
|
reject(err);
|
||||||
title: '检查更新失败',
|
},
|
||||||
icon: 'none',
|
complete:()=>{
|
||||||
duration: 2000
|
console.log("complete");
|
||||||
});
|
|
||||||
console.error('检查更新失败:', err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let Callback1 = (res) => {
|
||||||
|
console.log("检查版本更新:", res);
|
||||||
|
let os = plus.os.name.toLowerCase();
|
||||||
|
if (res.code != 200) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let f = res.data.find(v => {
|
||||||
|
if (v.dictLabel.toLowerCase() == os) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (f) {
|
||||||
|
if (f.dictValue == currentVersion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '检测到更新',
|
||||||
|
content: '当前版本“' + currentVersion + '”,发现新版本“' + f.dictValue + '”,是否立即更新?',
|
||||||
|
confirmText: '立即更新',
|
||||||
|
cancelText: '稍后更新',
|
||||||
|
success: (modalRes) => {
|
||||||
|
if (modalRes.confirm) {
|
||||||
|
downloadAndInstallWgt(f.remark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let Update1 = () => {
|
||||||
|
return request({
|
||||||
|
url: '/app/auth/version',
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let promises = [];
|
||||||
|
for (var i = 0; i < urls.length; i++) {
|
||||||
|
promises.push(Update(urls[i]));
|
||||||
|
}
|
||||||
|
promises.push(Update1());
|
||||||
|
|
||||||
|
Promise.allSettled(promises).then(results => {
|
||||||
|
let length = results.length;
|
||||||
|
let flag=false;
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
console.log('results['+i+']=',results[i]);
|
||||||
|
if (results[i].status == 'fulfilled' && results[i].value.type==='1' && !flag ) {
|
||||||
|
flag=true;
|
||||||
|
callbck(results[i].value)
|
||||||
|
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(results[i].status == 'fulfilled' && results[i].value.type!=='1' && !flag){
|
||||||
|
flag=true;
|
||||||
|
Callback1(results[i].value);
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!flag){
|
||||||
|
console.log("检查更新失败了");
|
||||||
|
}else{
|
||||||
|
console.log("检查更新成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,6 +16,11 @@ axios@^1.9.0:
|
|||||||
form-data "^4.0.0"
|
form-data "^4.0.0"
|
||||||
proxy-from-env "^1.1.0"
|
proxy-from-env "^1.1.0"
|
||||||
|
|
||||||
|
blueimp-md5@^2.19.0:
|
||||||
|
version "2.19.0"
|
||||||
|
resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz"
|
||||||
|
integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==
|
||||||
|
|
||||||
call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2:
|
call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz"
|
resolved "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz"
|
||||||
|
|||||||
Reference in New Issue
Block a user