Commit a35f5e01 by 姜雷

Merge branch 'test' into 'master'

Test See merge request !6
parents 17608af4 78b903da
...@@ -79,3 +79,14 @@ export const getWxConfig = entity => ...@@ -79,3 +79,14 @@ export const getWxConfig = entity =>
url: '/richScan', url: '/richScan',
params: entity, 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,
});
...@@ -5,11 +5,15 @@ import eqIcon from '../../images/Equipment/equip_number_icon@2x.png'; ...@@ -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 testIcon from '../../images/Equipment/test_water_icon@2x.png';
import scanImg from '../../images/Equipment/scan.png'; import scanImg from '../../images/Equipment/scan.png';
import WxWrap from '../../HOC/wx'; import WxWrap from '../../HOC/wx';
import { unbindKeyboard, getUnbindKeyboardResult } from '../../api';
import rateIcon from '../../images/Equipment/rate_active_icon@2x.png';
let DeviceCode = ''; let DeviceCode = '';
class EquipmentTest extends Component { class EquipmentTest extends Component {
state = { state = {
deviceCode: DeviceCode, deviceCode: DeviceCode,
getTime: 0,
timer: null,
}; };
componentWillMount() { componentWillMount() {
...@@ -72,6 +76,66 @@ class EquipmentTest extends Component { ...@@ -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() { render() {
const { deviceCode } = this.state; const { deviceCode } = this.state;
return ( return (
...@@ -108,6 +172,12 @@ class EquipmentTest extends Component { ...@@ -108,6 +172,12 @@ class EquipmentTest extends Component {
<span>测试吹风</span> <span>测试吹风</span>
</div> </div>
</div> </div>
<div className='linkItem' onClick={this.clickHandle}>
<i className='linkIcon'>
<img src={rateIcon} alt='' />
</i>
<span>解绑键盘设备</span>
</div>
</div> </div>
); );
} }
......
...@@ -7,16 +7,89 @@ import bindIcon from '../../images/Equipment/link_position_icon@2x.png'; ...@@ -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 testIcon from '../../images/Equipment/test_water_icon@2x.png';
import rateIcon from '../../images/Equipment/rate_active_icon@2x.png'; import rateIcon from '../../images/Equipment/rate_active_icon@2x.png';
import UserInfoContext from '../../context/userinfo-context'; import UserInfoContext from '../../context/userinfo-context';
import { unbindKeyboard, getUnbindKeyboardResult } from '../../api';
import { Toast } from 'antd-mobile';
export class Index extends React.Component { export class Index extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string, name: PropTypes.string,
}; };
constructor(props) {
super(props);
this.state = {
getTime: 0,
timer: null,
};
}
componentWillMount() { componentWillMount() {
const { setTitle } = this.props; const { setTitle } = this.props;
setTitle('功能页'); 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() { render() {
const { deviceCode } = this.props.match.params; const { deviceCode } = this.props.match.params;
...@@ -32,8 +105,8 @@ export class Index extends React.Component { ...@@ -32,8 +105,8 @@ export class Index extends React.Component {
</span> </span>
</div> </div>
<div className='br8 btnBox'> <div className='br8 btnBox'>
<div className='boxB boxBs' /> {/* <div className='boxB boxBs' />
<div className='boxBv' /> <div className='boxBv' /> */}
<Link <Link
className='linkItem' className='linkItem'
to={'/Equipment/' + deviceCode + '/SelectEquipment'}> to={'/Equipment/' + deviceCode + '/SelectEquipment'}>
...@@ -58,6 +131,12 @@ export class Index extends React.Component { ...@@ -58,6 +131,12 @@ export class Index extends React.Component {
</i> </i>
<span>费率激活</span> <span>费率激活</span>
</Link> </Link>
<div className='linkItem' onClick={this.clickHandle}>
<i className='linkIcon'>
<img src={rateIcon} alt='' />
</i>
<span>解绑键盘设备</span>
</div>
</div> </div>
</div> </div>
); );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
background: #ebebeb url('../../images/Login/login_bg@2x.png') no-repeat; background: #ebebeb url('../../images/Login/login_bg@2x.png') no-repeat;
background-size: contain; background-size: contain;
background-position-y: -624px; background-position-y: -624px;
overflow-y: auto;
.inputBox { .inputBox {
display: flex; display: flex;
width: 500px; width: 500px;
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
} }
.btnBox { .btnBox {
width: 500px; width: 500px;
height: 500px;
margin: 86px auto 0; margin: 86px auto 0;
background-color: #fff; background-color: #fff;
box-shadow: 0 0 5px rgba(43, 43, 43, 0.3); box-shadow: 0 0 5px rgba(43, 43, 43, 0.3);
...@@ -63,6 +62,7 @@ ...@@ -63,6 +62,7 @@
top: 249px; top: 249px;
} }
.linkItem { .linkItem {
box-sizing: border-box;
width: 250px; width: 250px;
height: 250px; height: 250px;
display: flex; display: flex;
...@@ -73,6 +73,14 @@ ...@@ -73,6 +73,14 @@
font-size: 26px; font-size: 26px;
position: relative; 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 { .linkIcon {
width: 60px; width: 60px;
height: 60px; height: 60px;
......
...@@ -16,6 +16,9 @@ img { ...@@ -16,6 +16,9 @@ img {
display: block; display: block;
width: 100%; width: 100%;
} }
input {
font-size: 28px;
}
[aspectratio] { [aspectratio] {
position: relative; position: relative;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment