Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
max_android_panel
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhang Xin
max_android_panel
Commits
0917214c
Commit
0917214c
authored
Jul 19, 2018
by
yaxiLiuu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of git.mjitech.com:zhangxin/max_android_panel into dev
parents
7b2c4ebd
b0614921
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
26 deletions
+118
-26
client/actions/getStore.js
+2
-2
client/config/index.js
+3
-2
client/config/socketType.js
+8
-0
client/containers/PageContainer/PageContainer.jsx
+52
-10
client/index.js
+2
-0
client/util/event.js
+32
-0
client/util/socket.js
+19
-12
No files found.
client/actions/getStore.js
View file @
0917214c
...
@@ -16,7 +16,7 @@ let json = {
...
@@ -16,7 +16,7 @@ let json = {
"address"
:
"华贸商业街(新光天地与利兹卡尔顿酒店之间广场)"
"address"
:
"华贸商业街(新光天地与利兹卡尔顿酒店之间广场)"
}
}
}
}
}
}
;
const
saveStoreInfo
=
(
data
)
=>
{
const
saveStoreInfo
=
(
data
)
=>
{
return
{
return
{
...
@@ -25,7 +25,7 @@ const saveStoreInfo = (data)=>{
...
@@ -25,7 +25,7 @@ const saveStoreInfo = (data)=>{
}
}
};
};
const
getStoreInfo
=
()
=>
{
const
getStoreInfo
=
(
storeId
)
=>
{
return
(
dispatch
)
=>
{
return
(
dispatch
)
=>
{
// fetch(domain + '/web/pad_warehouse/getMachineData.action',{
// fetch(domain + '/web/pad_warehouse/getMachineData.action',{
// credentials : 'include',
// credentials : 'include',
...
...
client/config/index.js
View file @
0917214c
import
swiperContainers
from
'./swiperContainer'
import
swiperContainers
from
'./swiperContainer'
import
showPage
from
'./showPage'
import
showPage
from
'./showPage'
import
socketType
from
'./socketType'
module
.
exports
=
{
swiperContainers
,...
showPage
}
module
.
exports
=
{
swiperContainers
,...
showPage
,
socketType
}
\ No newline at end of file
\ No newline at end of file
client/config/socketType.js
0 → 100644
View file @
0917214c
const
socketType
=
{
GETSTOREINFO
:
'GETSTOREINFO'
,
GETSOCKETMSG
:
'GETSOCKETMSG'
}
module
.
exports
=
socketType
;
\ No newline at end of file
client/containers/PageContainer/PageContainer.jsx
View file @
0917214c
...
@@ -18,7 +18,9 @@ import HomeContainer from '../HomeContainer/HomeContainer'
...
@@ -18,7 +18,9 @@ import HomeContainer from '../HomeContainer/HomeContainer'
import
FinishAskContainer
from
'../FinishAskContainer/FinishAskContainer'
import
FinishAskContainer
from
'../FinishAskContainer/FinishAskContainer'
import
ChooseTaskContainer
from
'../ChooseTaskContainer/ChooseTaskContainer'
import
ChooseTaskContainer
from
'../ChooseTaskContainer/ChooseTaskContainer'
import
Button
from
'../../components/CommonComponent/ButtonComponent/ButtonComponent'
;
import
Button
from
'../../components/CommonComponent/ButtonComponent/ButtonComponent'
;
import
Clock
from
'../../components/CommonComponent/ClockComponent/ClockComponent'
import
Clock
from
'../../components/CommonComponent/ClockComponent/ClockComponent'
;
import
{
on
,
remove
}
from
'../../util/event'
;
require
(
'./index.css'
);
require
(
'./index.css'
);
...
@@ -38,7 +40,6 @@ const defaultPopupInfo = {
...
@@ -38,7 +40,6 @@ const defaultPopupInfo = {
class
PageContainer
extends
React
.
Component
{
class
PageContainer
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
// UTILPATH.socket.getIp();
this
.
state
=
{
this
.
state
=
{
showPage
:
showPage
[
2
],
showPage
:
showPage
[
2
],
lastPage
:
''
,
lastPage
:
''
,
...
@@ -46,7 +47,8 @@ class PageContainer extends React.Component {
...
@@ -46,7 +47,8 @@ class PageContainer extends React.Component {
popupInfo
:
defaultPopupInfo
,
popupInfo
:
defaultPopupInfo
,
pageStyle
:
{},
pageStyle
:
{},
lastPageStyle
:{},
lastPageStyle
:{},
showClock
:
false
//关门页面显示倒计时
showClock
:
false
,
//关门页面显示倒计时
headerInfo
:
{}
};
};
this
.
getPages
=
this
.
getPages
.
bind
(
this
);
this
.
getPages
=
this
.
getPages
.
bind
(
this
);
this
.
showPopup
=
this
.
showPopup
.
bind
(
this
);
this
.
showPopup
=
this
.
showPopup
.
bind
(
this
);
...
@@ -63,6 +65,8 @@ class PageContainer extends React.Component {
...
@@ -63,6 +65,8 @@ class PageContainer extends React.Component {
this
.
overTimeSolve
=
this
.
overTimeSolve
.
bind
(
this
);
this
.
overTimeSolve
=
this
.
overTimeSolve
.
bind
(
this
);
this
.
failCloseDoor
=
this
.
failCloseDoor
.
bind
(
this
);
this
.
failCloseDoor
=
this
.
failCloseDoor
.
bind
(
this
);
this
.
judgeDoorStatus
=
this
.
judgeDoorStatus
.
bind
(
this
);
this
.
judgeDoorStatus
=
this
.
judgeDoorStatus
.
bind
(
this
);
this
.
getSocketMsg
=
this
.
getSocketMsg
.
bind
(
this
);
this
.
changePages
=
this
.
changePages
.
bind
(
this
);
this
.
maxCountBackTime
=
300
;
this
.
maxCountBackTime
=
300
;
this
.
count
=
1000
;
this
.
count
=
1000
;
...
@@ -70,15 +74,48 @@ class PageContainer extends React.Component {
...
@@ -70,15 +74,48 @@ class PageContainer extends React.Component {
this
.
countBackTime
=
-
1
;
this
.
countBackTime
=
-
1
;
}
}
componentWillMount
()
{
let
{
dispatch
}
=
this
.
props
;
dispatch
(
getStoreInfo
());
let
pages
=
this
.
getPages
();
connectOk
(){
this
.
setState
({
console
.
log
(
"connectOk"
)
page
:
pages
}
componentWillMount
()
{
let
that
=
this
;
on
(
CONFIG
.
socketType
.
GETSTOREINFO
,
this
,
function
(
data
)
{
console
.
log
(
"==GETSTOREINFO==="
)
console
.
log
(
data
)
dispatch
(
getStoreInfo
(
data
.
storeId
));
})
on
(
CONFIG
.
socketType
.
GETSOCKETMSG
,
this
,
function
(
data
)
{
console
.
log
(
"==GETSTOREINFO==="
)
console
.
log
(
data
)
console
.
log
(
this
);
that
.
getSocketMsg
(
data
)
})
})
}
getSocketMsg
(
data
){
switch
(
data
.
type
){
case
'SUCCESS_OPENDOOR'
:
//执行开门
this
.
setState
({
showPage
:
showPage
[
1
]
},()
=>
{
this
.
beginCountBack
();
});
break
;
case
'SUCCESS_CLOSEDOOR'
:
//关门成功
this
.
setState
({
showPage
:
showPage
[
7
],
showClock
:
false
,
popupInfo
:
defaultPopupInfo
});
break
;
}
}
}
componentDidMount
(){
componentDidMount
(){
// this.beginCountBack()
// this.beginCountBack()
}
}
...
@@ -89,7 +126,12 @@ class PageContainer extends React.Component {
...
@@ -89,7 +126,12 @@ class PageContainer extends React.Component {
componentWillUnmount
(){
componentWillUnmount
(){
}
}
changePages
(
page
){
this
.
setState
({
showPage
:
page
,
popupInfo
:
defaultPopupInfo
})
}
//开始倒计时,看有没有操作,只是在整个开门过程中才监听
//开始倒计时,看有没有操作,只是在整个开门过程中才监听
...
...
client/index.js
View file @
0917214c
...
@@ -29,5 +29,6 @@ function renderPage(store) {
...
@@ -29,5 +29,6 @@ function renderPage(store) {
let
store
=
activateVendor
();
let
store
=
activateVendor
();
UTILPATH
.
socket
.
getIp
();
renderPage
(
store
);
renderPage
(
store
);
\ No newline at end of file
client/util/event.js
0 → 100644
View file @
0917214c
let
events
=
{};
const
on
=
(
name
,
self
,
callback
)
=>
{
let
tuple
=
[
self
,
callback
];
let
cb
=
events
[
name
];
if
(
Array
.
isArray
(
cb
)){
cb
.
push
(
tuple
);
}
else
{
events
[
name
]
=
[
tuple
];
}
};
const
emit
=
(
name
,
data
)
=>
{
let
callbacks
=
events
[
name
];
if
(
Array
.
isArray
(
callbacks
)){
callbacks
.
map
((
tuple
)
=>
{
let
self
=
tuple
[
0
];
let
callback
=
tuple
[
1
];
callback
.
call
(
self
,
data
);
})
}
};
const
remove
=
(
name
,
self
)
=>
{
let
callbacks
=
events
[
name
];
if
(
Array
.
isArray
(
callbacks
)){
events
[
name
]
=
callbacks
.
filter
(
turple
=>
turple
[
0
]
!==
self
)
}
};
module
.
exports
=
{
on
,
emit
,
remove
};
\ No newline at end of file
client/util/socket.js
View file @
0917214c
import
fetch
from
'isomorphic-fetch'
import
fetch
from
'isomorphic-fetch'
;
import
{
emit
}
from
'./event'
let
domainIp
=
'192.168.10.'
;
let
domainIp
=
'192.168.199.'
;
let
initIndex
=
1
;
let
initIndex
=
1
;
let
totalIndex
=
255
/
5
;
let
totalIndex
=
255
/
5
;
...
@@ -28,10 +30,11 @@ const parseJson = (response)=>{
...
@@ -28,10 +30,11 @@ const parseJson = (response)=>{
return
response
.
json
();
return
response
.
json
();
};
};
const
getIp
=
(
cb
)
=>
{
const
getIp
=
()
=>
{
console
.
log
(
"getIp : "
,
initIndex
)
console
.
log
(
"getIp : "
,
initIndex
)
for
(
let
i
=
initIndex
;
i
<
(
totalIndex
+
initIndex
)
;
i
++
){
for
(
let
i
=
initIndex
;
i
<
(
totalIndex
+
initIndex
)
;
i
++
){
let
url
=
'http://'
+
domainIp
+
i
+
':9999/getmyid'
;
let
url
=
'http://'
+
domainIp
+
i
+
':9999/getmyid'
;
console
.
log
(
url
)
fetch
(
url
,{
fetch
(
url
,{
// credentials : 'include',
// credentials : 'include',
method
:
'GET'
,
method
:
'GET'
,
...
@@ -44,7 +47,7 @@ const getIp = (cb)=>{
...
@@ -44,7 +47,7 @@ const getIp = (cb)=>{
if
(
data
.
storeId
){
if
(
data
.
storeId
){
let
wsUrl
=
'ws://'
+
domainIp
+
i
+
':7788/notify?from=plant&storeId='
+
data
.
storeId
;
let
wsUrl
=
'ws://'
+
domainIp
+
i
+
':7788/notify?from=plant&storeId='
+
data
.
storeId
;
currentIpIndex
=
i
;
currentIpIndex
=
i
;
init
(
wsUrl
,
cb
);
init
(
i
,
data
.
storeId
);
}
}
})
})
...
@@ -87,9 +90,10 @@ const testIp = (ip) => {
...
@@ -87,9 +90,10 @@ const testIp = (ip) => {
if
(
data
.
storeId
){
if
(
data
.
storeId
){
window
.
storeId
=
data
.
storeId
;
window
.
storeId
=
data
.
storeId
;
window
.
localIp
=
domainIp
+
i
;
window
.
localIp
=
domainIp
+
i
;
let
wsUrl
=
'ws://'
+
domainIp
+
i
+
':7788/notify?from=plant&storeId='
+
data
.
storeId
;
let
wsUrl
=
'ws://'
+
domainIp
+
i
+
':7788/notify?from=plant&storeId='
+
data
.
storeId
;
currentIpIndex
=
i
;
currentIpIndex
=
i
;
init
(
wsUrl
,
cb
);
init
(
i
,
data
.
storeId
);
}
}
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
...
@@ -104,10 +108,12 @@ const testIp = (ip) => {
...
@@ -104,10 +108,12 @@ const testIp = (ip) => {
}
}
const
init
=
(
url
,
cb
)
=>
{
const
init
=
(
ip
,
storeid
)
=>
{
console
.
log
(
"init :"
,
url
);
if
(
"WebSocket"
in
window
&&
!
ws
&&
url
){
let
wsUrl
=
'ws://'
+
domainIp
+
ip
+
':7788/notify?from=plant&storeId='
+
storeid
;
ws
=
new
WebSocket
(
url
);
console
.
log
(
"init :"
,
wsUrl
);
if
(
"WebSocket"
in
window
&&
!
ws
&&
ip
&&
storeid
){
ws
=
new
WebSocket
(
wsUrl
);
ws
.
onopen
=
function
()
ws
.
onopen
=
function
()
{
{
...
@@ -119,16 +125,17 @@ const init = (url,cb)=>{
...
@@ -119,16 +125,17 @@ const init = (url,cb)=>{
inteval
=
null
;
inteval
=
null
;
initIndex
=
1
;
initIndex
=
1
;
failTotal
=
1
;
failTotal
=
1
;
cb
();
console
.
log
(
"open"
);
console
.
log
(
"open"
);
isFalse
=
false
;
isFalse
=
false
;
emit
(
CONFIG
.
socketType
.
GETSTOREINFO
,{
ip
:
domainIp
+
ip
,
storeId
:
storeid
})
};
};
ws
.
onmessage
=
function
(
evt
)
ws
.
onmessage
=
function
(
evt
)
{
{
var
received_msg
=
evt
.
data
;
var
received_msg
=
JSON
.
parse
(
evt
.
data
);
//String
console
.
log
(
"数据已接收..."
);
console
.
log
(
"数据已接收..."
);
emit
(
CONFIG
.
socketType
.
GETSOCKETMSG
,
received_msg
);
};
};
ws
.
onclose
=
function
(
err
)
ws
.
onclose
=
function
(
err
)
...
...
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