Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jwhx
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
jwhx
Commits
525a5348
Commit
525a5348
authored
Jan 13, 2025
by
wuxiaoli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://rungit.jxdsy.cn:10000/sugar/jwhx
into dev
parents
f7f80289
8f1f1351
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
2 deletions
+65
-2
resources/admin/src/api/module/cashier.js
resources/admin/src/api/module/cashier.js
+7
-0
resources/admin/src/pages/cashierhome/cashierhome.vue
resources/admin/src/pages/cashierhome/cashierhome.vue
+58
-2
No files found.
resources/admin/src/api/module/cashier.js
View file @
525a5348
...
...
@@ -31,5 +31,12 @@ export default {
return
await
http
.
post
(
this
.
url
,
params
);
}
},
simple
:{
url
:
`
${
config
.
API_URL
}
order/cashier/simple`
,
name
:
"
购物车结算
"
,
post
:
async
function
(
params
){
return
await
http
.
post
(
this
.
url
,
params
);
}
}
}
}
\ No newline at end of file
resources/admin/src/pages/cashierhome/cashierhome.vue
View file @
525a5348
...
...
@@ -76,6 +76,9 @@
</div>
<div
class=
"pos_btn"
>
<!--
<el-button
size=
"large"
type=
"primary"
@
click=
"chooseSerial"
>
连接扫码枪
</el-button>
-->
<el-button
size=
"large"
type=
"primary"
@
click=
"focusfun"
>
监听扫码枪识别
</el-button>
<el-button
size=
"large"
type=
"danger"
@
click=
"delAllGoods()"
>
清空购物单
</el-button>
<el-button
size=
"large"
type=
"success"
@
click=
"checkOut()"
>
结算
</el-button>
...
...
@@ -191,6 +194,7 @@ export default {
typingTimeout
:
null
,
// 用于判断输入间隔的定时器
port
:
null
,
// 原始数据 购物车
odata
:
[],
...
...
@@ -560,7 +564,7 @@ export default {
console
.
log
(
'
input.value:
'
,
input
.
value
);
if
(
input
.
value
){
if
(
input
.
value
&&
input
.
value
.
length
>
5
){
this
.
childgoods
.
goods_sn
=
input
.
value
;
this
.
childgoods
.
store_id
=
0
;
this
.
addCart
(
"
single
"
,
""
,
1
);
...
...
@@ -579,7 +583,7 @@ export default {
this
.
scannedCode
=
input
.
value
;
console
.
log
(
'
Scanned code:
'
,
this
.
scannedCode
);
if
(
input
.
value
){
if
(
input
.
value
&&
input
.
value
.
length
>
5
){
this
.
childgoods
.
goods_sn
=
input
.
value
;
this
.
childgoods
.
store_id
=
0
;
this
.
addCart
(
"
single
"
,
""
,
1
);
...
...
@@ -686,6 +690,58 @@ export default {
selectionChange
(
selection
){
this
.
selection
=
selection
;
},
//----2.0 扫码枪监听-------------------------------------------------------------------------------
async
chooseSerial
(){
if
(
'
serial
'
in
navigator
)
{
try
{
this
.
port
=
(
await
navigator
.
serial
.
requestPort
())
||
null
;
console
.
log
(
'
选择串口成功
'
);
this
.
port
&&
this
.
openSerial
();
}
catch
(
e
)
{
console
.
log
(
'
选择串口失败
'
);
}
}
else
{
console
.
log
(
'
浏览器不支持serial API
'
);
}
},
//打开串口读取数据
async
openSerial
()
{
console
.
info
(
"
6666
"
);
await
this
.
port
.
open
({
baudRate
:
9600
});
try
{
const
textDecoder
=
new
TextDecoderStream
();
this
.
port
.
readable
.
pipeTo
(
textDecoder
.
writable
);
const
reader
=
textDecoder
.
readable
.
getReader
();
let
data
=
''
;
//扫码数据
while
(
true
)
{
const
{
value
,
done
}
=
await
reader
.
read
();
if
(
done
)
{
reader
.
releaseLock
();
break
;
}
data
=
`
${
data
}${
value
}
`
if
(
value
.
includes
(
'
\r
'
)){
//读取结束
let
codeData
=
data
;
data
=
""
;
//清空下次读取不会叠加
console
.
log
(
`二维码数据:
${
codeData
}
`
)
//处理拿到数据逻辑
}
}
}
catch
(
error
)
{
console
.
error
(
error
);
this
.
port
=
null
;
}
finally
{
try
{
reader
.
releaseLock
();
//关闭串口
await
this
.
port
.
close
();
}
catch
(
e
)
{}
}
this
.
port
=
null
;
}
//----2.0 扫码枪监听-------------------------------------------------------------------------------
},
};
</
script
>
...
...
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