Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-app-hairDryer
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-app-hairDryer
Commits
78b903da
Commit
78b903da
authored
Jun 10, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'test'
添加解绑键盘设备功能 See merge request
!5
parents
499cf5f3
657e93c5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
172 additions
and
4 deletions
+172
-4
index.js
src/api/index.js
+11
-0
EquipmentTest.js
src/containers/Equipment/EquipmentTest.js
+70
-0
index.js
src/containers/Equipment/index.js
+81
-2
style.scss
src/containers/Equipment/style.scss
+10
-2
No files found.
src/api/index.js
View file @
78b903da
...
...
@@ -79,3 +79,14 @@ export const getWxConfig = entity =>
url
:
'/richScan'
,
params
:
entity
,
});
export
const
unbindKeyboard
=
entity
=>
fetch
({
url
:
`/devices/
${
entity
.
deviceCode
}
/keyboard/unbinding`
,
method
:
'post'
,
data
:
entity
,
});
export
const
getUnbindKeyboardResult
=
entity
=>
fetch
({
url
:
`/devices/
${
entity
.
deviceCode
}
/keyboard/unbinding`
,
params
:
entity
,
});
src/containers/Equipment/EquipmentTest.js
View file @
78b903da
...
...
@@ -5,11 +5,15 @@ import eqIcon from '../../images/Equipment/equip_number_icon@2x.png';
import
testIcon
from
'../../images/Equipment/test_water_icon@2x.png'
;
import
scanImg
from
'../../images/Equipment/scan.png'
;
import
WxWrap
from
'../../HOC/wx'
;
import
{
unbindKeyboard
,
getUnbindKeyboardResult
}
from
'../../api'
;
import
rateIcon
from
'../../images/Equipment/rate_active_icon@2x.png'
;
let
DeviceCode
=
''
;
class
EquipmentTest
extends
Component
{
state
=
{
deviceCode
:
DeviceCode
,
getTime
:
0
,
timer
:
null
,
};
componentWillMount
()
{
...
...
@@ -72,6 +76,66 @@ class EquipmentTest extends Component {
},
});
};
clickHandle
=
()
=>
{
const
{
deviceCode
}
=
this
.
state
;
if
(
!
deviceCode
)
{
Toast
.
fail
(
'请输入设备编号或扫设备二维码'
);
return
;
}
Toast
.
loading
(
''
,
99
);
return
unbindKeyboard
({
deviceCode
:
deviceCode
,
})
.
then
(()
=>
{
this
.
loopUntilGetResult
();
})
.
catch
(
err
=>
{
Toast
.
fail
(
err
.
msg
||
'请求解除键盘失败'
);
});
};
loopUntilGetResult
=
()
=>
{
let
timer
=
setInterval
(()
=>
{
this
.
getResult
();
},
1000
);
this
.
setState
({
timer
});
};
getResult
=
()
=>
{
const
{
deviceCode
}
=
this
.
state
;
const
{
getTime
}
=
this
.
state
;
if
(
getTime
===
10
)
{
return
;
}
this
.
setState
(({
getTime
})
=>
({
getTime
:
getTime
+
1
,
}));
return
getUnbindKeyboardResult
({
deviceCode
:
deviceCode
,
})
.
then
(()
=>
{
const
{
timer
}
=
this
.
state
;
clearInterval
(
timer
);
Toast
.
success
(
'解除键盘设备'
);
this
.
setState
({
timer
:
null
,
getTime
:
0
,
});
})
.
catch
(
err
=>
{
const
{
getTime
,
timer
}
=
this
.
state
;
if
(
getTime
===
10
)
{
clearInterval
(
timer
);
Toast
.
fail
(
err
.
msg
||
'解除键盘设备失败'
);
this
.
setState
({
timer
:
null
,
getTime
:
0
,
});
}
console
.
error
(
err
);
});
};
render
()
{
const
{
deviceCode
}
=
this
.
state
;
return
(
...
...
@@ -108,6 +172,12 @@ class EquipmentTest extends Component {
<
span
>
测试吹风
<
/span
>
<
/div
>
<
/div
>
<
div
className
=
'linkItem'
onClick
=
{
this
.
clickHandle
}
>
<
i
className
=
'linkIcon'
>
<
img
src
=
{
rateIcon
}
alt
=
''
/>
<
/i
>
<
span
>
解绑键盘设备
<
/span
>
<
/div
>
<
/div
>
);
}
...
...
src/containers/Equipment/index.js
View file @
78b903da
...
...
@@ -7,16 +7,89 @@ import bindIcon from '../../images/Equipment/link_position_icon@2x.png';
import
testIcon
from
'../../images/Equipment/test_water_icon@2x.png'
;
import
rateIcon
from
'../../images/Equipment/rate_active_icon@2x.png'
;
import
UserInfoContext
from
'../../context/userinfo-context'
;
import
{
unbindKeyboard
,
getUnbindKeyboardResult
}
from
'../../api'
;
import
{
Toast
}
from
'antd-mobile'
;
export
class
Index
extends
React
.
Component
{
static
propTypes
=
{
name
:
PropTypes
.
string
,
};
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
getTime
:
0
,
timer
:
null
,
};
}
componentWillMount
()
{
const
{
setTitle
}
=
this
.
props
;
setTitle
(
'功能页'
);
}
componentWillUnmount
()
{
const
{
timer
}
=
this
.
state
;
if
(
timer
)
{
clearInterval
(
timer
);
}
}
clickHandle
=
()
=>
{
Toast
.
loading
(
''
,
99
);
const
{
deviceCode
}
=
this
.
props
.
match
.
params
;
return
unbindKeyboard
({
deviceCode
:
deviceCode
,
})
.
then
(()
=>
{
this
.
loopUntilGetResult
();
})
.
catch
(
err
=>
{
Toast
.
fail
(
err
.
msg
||
'请求解除键盘失败'
);
});
};
loopUntilGetResult
=
()
=>
{
let
timer
=
setInterval
(()
=>
{
this
.
getResult
();
},
1000
);
this
.
setState
({
timer
});
};
getResult
=
()
=>
{
const
{
deviceCode
}
=
this
.
props
.
match
.
params
;
const
{
getTime
}
=
this
.
state
;
if
(
getTime
===
10
)
{
return
;
}
this
.
setState
(({
getTime
})
=>
({
getTime
:
getTime
+
1
,
}));
return
getUnbindKeyboardResult
({
deviceCode
:
deviceCode
,
})
.
then
(()
=>
{
const
{
timer
}
=
this
.
state
;
clearInterval
(
timer
);
Toast
.
success
(
'解除键盘设备'
);
this
.
setState
({
timer
:
null
,
getTime
:
0
,
});
})
.
catch
(
err
=>
{
const
{
getTime
,
timer
}
=
this
.
state
;
if
(
getTime
===
10
)
{
clearInterval
(
timer
);
Toast
.
fail
(
err
.
msg
||
'解除键盘设备失败'
);
this
.
setState
({
timer
:
null
,
getTime
:
0
,
});
}
console
.
error
(
err
);
});
};
render
()
{
const
{
deviceCode
}
=
this
.
props
.
match
.
params
;
...
...
@@ -32,8 +105,8 @@ export class Index extends React.Component {
<
/span
>
<
/div
>
<
div
className
=
'br8 btnBox'
>
<
div
className
=
'boxB boxBs'
/>
<
div
className
=
'boxBv'
/>
{
/*
<div className='boxB boxBs' />
<div className='boxBv' />
*/
}
<
Link
className
=
'linkItem'
to
=
{
'/Equipment/'
+
deviceCode
+
'/SelectEquipment'
}
>
...
...
@@ -58,6 +131,12 @@ export class Index extends React.Component {
<
/i
>
<
span
>
费率激活
<
/span
>
<
/Link
>
<
div
className
=
'linkItem'
onClick
=
{
this
.
clickHandle
}
>
<
i
className
=
'linkIcon'
>
<
img
src
=
{
rateIcon
}
alt
=
''
/>
<
/i
>
<
span
>
解绑键盘设备
<
/span
>
<
/div
>
<
/div
>
<
/div
>
);
...
...
src/containers/Equipment/style.scss
View file @
78b903da
...
...
@@ -3,7 +3,7 @@
background
:
#ebebeb
url('../../images/Login/login_bg@2x.png')
no-repeat
;
background-size
:
contain
;
background-position-y
:
-624px
;
overflow-y
:
auto
;
.inputBox
{
display
:
flex
;
width
:
500px
;
...
...
@@ -28,7 +28,6 @@
}
.btnBox
{
width
:
500px
;
height
:
500px
;
margin
:
86px
auto
0
;
background-color
:
#fff
;
box-shadow
:
0
0
5px
rgba
(
43
,
43
,
43
,
0
.3
);
...
...
@@ -63,6 +62,7 @@
top
:
249px
;
}
.linkItem
{
box-sizing
:
border-box
;
width
:
250px
;
height
:
250px
;
display
:
flex
;
...
...
@@ -73,6 +73,14 @@
font-size
:
26px
;
position
:
relative
;
}
.linkItem
:nth-child
(
odd
),
.linkItem
:nth-child
(
even
)
{
border-bottom
:
1px
solid
#ebebeb
;
}
.linkItem
:nth-child
(
odd
)
{
border-right
:
1px
solid
#ebebeb
;
}
.linkIcon
{
width
:
60px
;
height
:
60px
;
...
...
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