Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
梁建民
/
wmsMin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51d671d5
authored
Apr 09, 2022
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js
parent
5f81aba0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
27 deletions
pages/tag/deviceList.vue
util/api.js
pages/tag/deviceList.vue
View file @
51d671d5
...
...
@@ -103,10 +103,11 @@ export default {
fail
:
res
=>
{
uni
.
hideLoading
();
console
.
log
(
'查找设备失败!'
);
uni
.
showToast
({
icon
:
'error'
,
title
:
'查找设备失败!'
,
duration
:
3000
uni
.
showModal
({
title
:
'提示'
,
content
:
'查找设备失败'
,
showCancel
:
false
,
confirmText
:
'关闭'
});
}
});
...
...
@@ -182,10 +183,11 @@ export default {
uni
.
setStorageSync
(
'device'
,
{
name
:
this
.
deviceName
,
deviceId
:
this
.
deviceId
});
},
fail
:
error
=>
{
uni
.
showToast
({
icon
:
'error'
,
title
:
'连接设备失败!'
,
duration
:
3000
uni
.
showModal
({
title
:
'提示'
,
content
:
'连接设备失败'
,
showCancel
:
false
,
confirmText
:
'关闭'
});
}
});
...
...
@@ -197,27 +199,55 @@ export default {
uni
.
showLoading
({
title
:
'连接设备中'
});
//先断开现有蓝牙连接
uni
.
closeBLEConnection
({
deviceId
:
this
.
deviceId
,
success
:
res
=>
{
console
.
log
(
'断开蓝牙连接:'
,
JSON
.
stringify
(
res
.
errMsg
));
this
.
deviceName
=
name
;
//设备名称
this
.
deviceId
=
deviceId
;
//设备id
this
.
current
=
index
;
this
.
stopBluetoothDevicesDiscovery
();
//先停止蓝牙搜索
//判断设备当前是否有连接
if
(
this
.
deviceId
)
{
//先断开现有蓝牙连接
uni
.
closeBLEConnection
({
deviceId
:
deviceId
,
success
:
res
=>
{
console
.
log
(
'断开蓝牙连接:'
,
JSON
.
stringify
(
res
.
errMsg
));
this
.
deviceName
=
name
;
//设备名称
this
.
deviceId
=
deviceId
;
//设备id
this
.
current
=
index
;
//恢复蓝牙连接状态的初始值
if
(
this
.
textArr
.
length
>
0
)
{
var
tempArr
=
[];
for
(
let
i
=
0
;
i
<
this
.
textArr
.
length
;
i
++
)
{
tempArr
.
push
(
'连接'
);
this
.
stopBluetoothDevicesDiscovery
();
//先停止蓝牙搜索
//恢复蓝牙连接状态的初始值
if
(
this
.
textArr
.
length
>
0
)
{
var
tempArr
=
[];
for
(
let
i
=
0
;
i
<
this
.
textArr
.
length
;
i
++
)
{
tempArr
.
push
(
'连接'
);
}
this
.
textArr
=
tempArr
;
}
this
.
textArr
=
tempArr
;
},
fail
:
error
=>
{
uni
.
hideLoading
();
uni
.
showModal
({
title
:
'提示'
,
content
:
'断开设备失败'
,
showCancel
:
false
,
confirmText
:
'关闭'
});
}
});
}
else
{
this
.
deviceName
=
name
;
//设备名称
this
.
deviceId
=
deviceId
;
//设备id
this
.
current
=
index
;
this
.
stopBluetoothDevicesDiscovery
();
//先停止蓝牙搜索
//恢复蓝牙连接状态的初始值
if
(
this
.
textArr
.
length
>
0
)
{
var
tempArr
=
[];
for
(
let
i
=
0
;
i
<
this
.
textArr
.
length
;
i
++
)
{
tempArr
.
push
(
'连接'
);
}
this
.
textArr
=
tempArr
;
}
}
);
}
},
/**
* 刷新蓝牙列表
...
...
@@ -228,7 +258,7 @@ export default {
console
.
log
(
'停止搜索'
,
JSON
.
stringify
(
res
.
errMsg
));
this
.
list
=
[];
this
.
startBluetoothDeviceDiscovery
();
//刷新图标交互
this
.
refreshTransition
=
true
;
setTimeout
(()
=>
{
...
...
util/api.js
View file @
51d671d5
//
const API_BASE = 'https://api.ichunt.com';
const
API_BASE
=
'http://api.liexin.com'
const
API_BASE
=
'https://api.ichunt.com'
;
//
const API_BASE = 'http://api.liexin.com'
const
API
=
{
/**
* 上传数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment