Commit ad24f3ca by 姜雷

完善页面

parent 5366f0d2
...@@ -15,6 +15,7 @@ module.exports = override( ...@@ -15,6 +15,7 @@ module.exports = override(
modifyVars: { modifyVars: {
'@brand-primary': '#ff900d', '@brand-primary': '#ff900d',
'@brand-primary-tap': '#fac17d', '@brand-primary-tap': '#fac17d',
'@button-height': '60 * @hd',
}, },
}), }),
addPostcssPlugins([ addPostcssPlugins([
......
{ {
"name": "wx-school-home", "name": "wx-hair-dryer",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"homepage": "/schoolHome", "homepage": "/hairDryer",
"dependencies": { "dependencies": {
"antd-mobile": "^2.2.8", "antd-mobile": "^2.2.8",
"axios": "^0.18.0", "axios": "^0.18.0",
"jsbarcode": "^3.11.0",
"react": "^16.8.2", "react": "^16.8.2",
"react-dom": "^16.8.2", "react-dom": "^16.8.2",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
......
import { Component } from 'react';
import { getWxConfig } from '../api/index';
import { APP_ID } from '../config/index';
class WxWrap extends Component {
constructor(props, context) {
super(props, context);
this.state = {
wxDone: false,
};
this.wxConfigHandle();
}
wxConfigHandle = () => {
const wx = window.wx;
return new Promise((resolve, reject) => {
let url = window.location.href.split('#')[0];
const u = navigator.userAgent;
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
url = window.location.origin + '/';
}
getWxConfig({
url: encodeURIComponent(url),
})
.then(res => {
const data = res.data;
wx.config({
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: APP_ID, // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名
jsApiList: ['scanQRCode'], // 必填,需要使用的JS接口列表
});
})
.catch(err => {
console.log(err);
reject(err);
});
wx.ready(() => this.wxReadyHandle(resolve));
wx.error(reject);
});
};
wxReadyHandle = done => {
this.setState({
wxDone: true,
});
done();
};
render() {
const { render } = this.props;
return render({ ...this.state, wxConfigHandle: this.wxConfigHandle });
}
}
export default WxWrap;
import { useState, useEffect } from 'react';
import { getWxConfig } from '../api/index';
import { APP_ID } from '../config/index';
function useWxConfig() {
const [wxDone, setWxDone] = useState(false);
function wxConfigHandle() {
const wx = window.wx;
return new Promise((resolve, reject) => {
let url = window.location.href.split('#')[0];
const u = navigator.userAgent;
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
url = window.location.origin + '/';
}
getWxConfig({
url: encodeURIComponent(url),
})
.then(res => {
const data = res.data;
wx.config({
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: APP_ID, // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名
jsApiList: ['scanQRCode'], // 必填,需要使用的JS接口列表
});
})
.catch(err => {
console.log(err);
reject(err);
});
wx.ready(() => {
setWxDone(true);
resolve();
});
wx.error(reject);
});
}
useEffect(() => {
wxConfigHandle();
return () => {
setWxDone(false);
};
}, []);
return [wxDone, wxConfigHandle];
}
export default useWxConfig;
...@@ -3,7 +3,7 @@ import config from '../config/index'; ...@@ -3,7 +3,7 @@ import config from '../config/index';
import errorHandle from './errorHandle'; import errorHandle from './errorHandle';
import store from '../store/index'; import store from '../store/index';
const path = config.SERVER_URL + '/dcxy/api/gx/construction'; const path = config.SERVER_URL + '/dcxy/api/blower/manager/construction';
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: path, // api的base_url baseURL: path, // api的base_url
...@@ -14,18 +14,24 @@ service.interceptors.request.use( ...@@ -14,18 +14,24 @@ service.interceptors.request.use(
conf => { conf => {
let token = store.getToken(); let token = store.getToken();
conf.headers = { conf.headers = token
...conf.headers, ? {
reqSource: 'wx', ...conf.headers,
token: token ? token : '', reqSource: 'wx',
}; token: token,
}
: {
...conf.headers,
reqSource: 'wx',
token: 'SHOWER-001-867477ecfd6f684b2df2d2b96b2544ca1550546762647',
};
return conf; return conf;
}, },
error => { error => {
// Do something with request error // Do something with request error
console.log(error); // for debug console.log(error); // for debug
Promise.reject(error); Promise.reject(error);
} },
); );
// respone拦截器 // respone拦截器
......
export const APP_ID = 'wxf5912b79bba23663';
export const SERVER_URL = 'http://ex-dev-blower-manager.168cad.top';
export default {
APP_ID,
SERVER_URL,
};
...@@ -18,7 +18,11 @@ function App() { ...@@ -18,7 +18,11 @@ function App() {
<UserInfoContext.Provider <UserInfoContext.Provider
value={{ value={{
userinfo: userinfo, userinfo: userinfo,
updateUserInfo: setUserinfo, updateUserInfo: val =>
setUserinfo({
...userinfo,
...val,
}),
}}> }}>
<Route render={props => <NavBar {...props} title={title} />} /> <Route render={props => <NavBar {...props} title={title} />} />
<Switch> <Switch>
......
...@@ -4,7 +4,7 @@ import { Button, Toast } from 'antd-mobile'; ...@@ -4,7 +4,7 @@ import { Button, Toast } from 'antd-mobile';
import './style.scss'; import './style.scss';
import { getPositions } from '../../api/index'; import { getPositions } from '../../api/index';
import UserInfoContext from '../../context/userinfo-context'; import UserInfoContext from '../../context/userinfo-context';
// import WxWrap from '../../HOC/wx'; import WxWrap from '../../HOC/wx';
import scanImg from '../../images/Equipment/scan.png'; import scanImg from '../../images/Equipment/scan.png';
import { filterEmoji } from '../../utils/index'; import { filterEmoji } from '../../utils/index';
...@@ -23,7 +23,6 @@ export class Bindequipment extends React.Component { ...@@ -23,7 +23,6 @@ export class Bindequipment extends React.Component {
componentWillMount() { componentWillMount() {
const { setTitle } = this.props; const { setTitle } = this.props;
setTitle('输入设备编号'); setTitle('输入设备编号');
console.log(this.props);
} }
changeHandle = e => { changeHandle = e => {
let value = e.target.value.trim(); let value = e.target.value.trim();
...@@ -43,7 +42,6 @@ export class Bindequipment extends React.Component { ...@@ -43,7 +42,6 @@ export class Bindequipment extends React.Component {
bindEquipment = () => { bindEquipment = () => {
if (this.validate()) { if (this.validate()) {
Toast.loading('', 20); Toast.loading('', 20);
console.log(this.props);
const { history, userinfo, updateUserInfo } = this.props; const { history, userinfo, updateUserInfo } = this.props;
const { deviceCode } = this.state; const { deviceCode } = this.state;
getPositions({ getPositions({
...@@ -52,7 +50,7 @@ export class Bindequipment extends React.Component { ...@@ -52,7 +50,7 @@ export class Bindequipment extends React.Component {
}) })
.then(res => { .then(res => {
Toast.hide(); Toast.hide();
console.log(res); // console.log(res);
const { barcode, ...data } = res.data; const { barcode, ...data } = res.data;
if (data.id) { if (data.id) {
updateUserInfo({ barcode, position: { ...data, isBind: true } }); updateUserInfo({ barcode, position: { ...data, isBind: true } });
...@@ -138,13 +136,18 @@ export class Bindequipment extends React.Component { ...@@ -138,13 +136,18 @@ export class Bindequipment extends React.Component {
} }
export default props => ( export default props => (
<UserInfoContext.Consumer> <WxWrap
{({ updateUserInfo, userinfo }) => ( render={state => (
<Bindequipment <UserInfoContext.Consumer>
{...props} {({ updateUserInfo, userinfo }) => (
updateUserInfo={updateUserInfo} <Bindequipment
userinfo={userinfo} {...props}
/> {...state}
updateUserInfo={updateUserInfo}
userinfo={userinfo}
/>
)}
</UserInfoContext.Consumer>
)} )}
</UserInfoContext.Consumer> />
); );
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
background-position-y: -624px; background-position-y: -624px;
background-color: #fff; background-color: #fff;
.inputBox { .inputBox {
display: block;
width: 500px; width: 500px;
height: 200px; height: 200px;
margin: 127px auto 0; margin: 127px auto 0;
......
...@@ -3,9 +3,8 @@ import { Toast, Button } from 'antd-mobile'; ...@@ -3,9 +3,8 @@ import { Toast, Button } from 'antd-mobile';
import './style.scss'; import './style.scss';
import eqIcon from '../../images/Equipment/equip_number_icon@2x.png'; 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 checkIcon from '../../images/Equipment/check_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';
let DeviceCode = ''; let DeviceCode = '';
class EquipmentTest extends Component { class EquipmentTest extends Component {
...@@ -16,7 +15,6 @@ class EquipmentTest extends Component { ...@@ -16,7 +15,6 @@ class EquipmentTest extends Component {
componentWillMount() { componentWillMount() {
const { setTitle } = this.props; const { setTitle } = this.props;
setTitle('功能页'); setTitle('功能页');
console.log(this.props);
} }
changeHandle = e => { changeHandle = e => {
this.setState({ this.setState({
...@@ -95,10 +93,7 @@ class EquipmentTest extends Component { ...@@ -95,10 +93,7 @@ class EquipmentTest extends Component {
/> />
</span> </span>
</div> </div>
<Button <Button type='primary' className='scan' onClick={this.scanEquipment}>
type='primary'
className='scan'
onClick={this.scanEquipment}>
<div className='scanicon'> <div className='scanicon'>
<img src={scanImg} alt='' /> <img src={scanImg} alt='' />
</div> </div>
...@@ -106,27 +101,18 @@ class EquipmentTest extends Component { ...@@ -106,27 +101,18 @@ class EquipmentTest extends Component {
</div> </div>
<div className='br8 btnBox testBtnBox'> <div className='br8 btnBox testBtnBox'>
<div className='boxBs testBoxBs' /> <div className='linkItem' onClick={() => this.goPage('/TestWater')}>
<div
className='linkItem'
onClick={() => this.goPage('/TestWater')}>
<i className='linkIcon'> <i className='linkIcon'>
<img src={testIcon} alt='' /> <img src={testIcon} alt='' />
</i> </i>
<span>测试放水</span> <span>测试放水</span>
</div> </div>
<div
className='linkItem'
onClick={() => this.goPage('/CheckWater')}>
<i className='linkIcon'>
<img src={checkIcon} alt='' />
</i>
<span>校准流量</span>
</div>
</div> </div>
</div> </div>
); );
} }
} }
export default EquipmentTest; export default props => (
<WxWrap render={state => <EquipmentTest {...props} {...state} />} />
);
...@@ -5,7 +5,6 @@ import './style.scss'; ...@@ -5,7 +5,6 @@ import './style.scss';
import eqIcon from '../../images/Equipment/equip_number_icon@2x.png'; import eqIcon from '../../images/Equipment/equip_number_icon@2x.png';
import bindIcon from '../../images/Equipment/link_position_icon@2x.png'; 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 checkIcon from '../../images/Equipment/check_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';
...@@ -17,7 +16,6 @@ export class Index extends React.Component { ...@@ -17,7 +16,6 @@ export class Index extends React.Component {
componentWillMount() { componentWillMount() {
const { setTitle } = this.props; const { setTitle } = this.props;
setTitle('功能页'); setTitle('功能页');
console.log(this.props);
} }
render() { render() {
const { deviceCode } = this.props.match.params; const { deviceCode } = this.props.match.params;
...@@ -54,14 +52,6 @@ export class Index extends React.Component { ...@@ -54,14 +52,6 @@ export class Index extends React.Component {
</Link> </Link>
<Link <Link
className='linkItem' className='linkItem'
to={'/Equipment/' + deviceCode + '/CheckWater'}>
<i className='linkIcon'>
<img src={checkIcon} alt='' />
</i>
<span>校准流量</span>
</Link>
<Link
className='linkItem'
to={'/Equipment/' + deviceCode + '/RateActivity'}> to={'/Equipment/' + deviceCode + '/RateActivity'}>
<i className='linkIcon'> <i className='linkIcon'>
<img src={rateIcon} alt='' /> <img src={rateIcon} alt='' />
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
} }
.testBtnBox { .testBtnBox {
height: 250px; height: 250px;
justify-content: center;
} }
.boxB, .boxB,
.boxBv, .boxBv,
......
...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; ...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Switch, Route } from 'react-router-dom'; import { Switch, Route } from 'react-router-dom';
import Equipment from '../Equipment/index'; import Equipment from '../Equipment/index';
import SelectEquipment from '../SelectEquipment'; import SelectEquipment from '../SelectEquipment';
// import TestWater from '../TestWater'; import TestWater from '../TestWater';
// import CheckWater from '../CheckWater'; // import CheckWater from '../CheckWater';
import RateActivity from '../RateActivity'; import RateActivity from '../RateActivity';
import Location from '../Location'; import Location from '../Location';
...@@ -12,9 +12,6 @@ class EquipmentContetn extends React.Component { ...@@ -12,9 +12,6 @@ class EquipmentContetn extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string, name: PropTypes.string,
}; };
constructor(props) {
super(props);
}
render() { render() {
const { setTitle } = this.props; const { setTitle } = this.props;
...@@ -22,33 +19,24 @@ class EquipmentContetn extends React.Component { ...@@ -22,33 +19,24 @@ class EquipmentContetn extends React.Component {
return ( return (
<Switch> <Switch>
<Route <Route
path="/Equipment/:deviceCode" path='/Equipment/:deviceCode'
exact exact
render={props => <Equipment {...props} setTitle={setTitle} />} render={props => <Equipment {...props} setTitle={setTitle} />}
/> />
<Route <Route
path="/Equipment/:deviceCode/SelectEquipment" path='/Equipment/:deviceCode/SelectEquipment'
render={props => ( render={props => <SelectEquipment {...props} setTitle={setTitle} />}
<SelectEquipment
{...props}
setTitle={setTitle}
/>
)}
/> />
{/* <Route <Route
path="/Equipment/:deviceCode/TestWater" path='/Equipment/:deviceCode/TestWater'
render={props => <TestWater {...props} setTitle={setTitle} />} render={props => <TestWater {...props} setTitle={setTitle} />}
/> */} />
{/* <Route
path="/Equipment/:deviceCode/CheckWater"
render={props => <CheckWater {...props} setTitle={setTitle} />}
/> */}
<Route <Route
path="/Equipment/:deviceCode/RateActivity" path='/Equipment/:deviceCode/RateActivity'
render={props => <RateActivity {...props} setTitle={setTitle} />} render={props => <RateActivity {...props} setTitle={setTitle} />}
/> />
<Route <Route
path="/Equipment/:deviceCode/Location" path='/Equipment/:deviceCode/Location'
render={props => <Location {...props} setTitle={setTitle} />} render={props => <Location {...props} setTitle={setTitle} />}
/> />
</Switch> </Switch>
......
...@@ -15,6 +15,8 @@ function Index(props) { ...@@ -15,6 +15,8 @@ function Index(props) {
history.replace('/login'); history.replace('/login');
} else { } else {
console.log('跳转微信授权接口'); console.log('跳转微信授权接口');
const { history } = props;
history.replace('/login');
// const { APP_ID } = config; // const { APP_ID } = config;
// console.log(APP_ID); // console.log(APP_ID);
// let rUrl = encodeURIComponent(window.location.href.split('#')[0]); // let rUrl = encodeURIComponent(window.location.href.split('#')[0]);
......
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import styles from './style.css'; import './style.scss';
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import searchIcon from '../../images/Search/default_search_icon@2x.png'; import searchIcon from '../../images/Search/default_search_icon@2x.png';
import { getPositionsList } from '../../api/index'; import { getPositionsList } from '../../api/index';
...@@ -91,55 +91,47 @@ export class Location extends React.Component { ...@@ -91,55 +91,47 @@ export class Location extends React.Component {
render() { render() {
const { showToast, localText, localList } = this.state; const { showToast, localText, localList } = this.state;
return ( return (
<div className={'appContent ' + styles.Location}> <div className='appContent Location'>
<div className={styles.searchBox}> <div className='searchBox'>
<input <input
className={'br8 ' + styles.searchInput} className='br8 searchInput'
type='text' type='text'
onChange={this.changeHandle} onChange={this.changeHandle}
placeholder='请输入位置关键词' placeholder='请输入位置关键词'
/> />
<span className={styles.searchBtn} onClick={this.searchList}> <span className='searchBtn' onClick={this.searchList}>
<i className={styles.searchIcon}> <i className='searchIcon'>
<img src={searchIcon} alt='' /> <img src={searchIcon} alt='' />
</i> </i>
搜索 搜索
</span> </span>
</div> </div>
<div className={styles.infoBar}> <div className='infoBar'>
{localList.map(item => ( {localList.map(item => (
<div <div
key={item.firstLetter} key={item.firstLetter}
className={styles.infoItem} className='infoItem'
onClick={() => this.showToast(item.firstLetter)} onClick={() => this.showToast(item.firstLetter)}>
>
{item.firstLetter} {item.firstLetter}
</div> </div>
))} ))}
</div> </div>
<div <div className={showToast ? 'show br8 infoToast' : 'br8 infoToast'}>
className={
showToast
? styles.show + ' br8 ' + styles.infoToast
: 'br8 ' + styles.infoToast
}
>
{localText} {localText}
</div> </div>
<div className={styles.locationList}> <div className='locationList'>
{localList.map(area => ( {localList.map(area => (
<div key={area.firstLetter} className={styles.locationArea}> <div key={area.firstLetter} className='locationArea'>
<div id={area.firstLetter} className={styles.locationTitle}> <div id={area.firstLetter} className='locationTitle'>
{area.firstLetter} {area.firstLetter}
</div> </div>
{area.positions.map((location, index) => ( {area.positions.map((location, index) => (
<div <div
key={index} key={index}
className={styles.locationItem} className='locationItem'
onClick={() => onClick={() =>
this.bindEquipment(location.id, location.position) this.bindEquipment(location.id, location.position)
} }>
>
{location.position} {location.position}
</div> </div>
))} ))}
......
...@@ -2,79 +2,79 @@ ...@@ -2,79 +2,79 @@
background-color: #fff; background-color: #fff;
overflow-y: scroll; overflow-y: scroll;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} .searchBox {
.searchBox { height: 90px;
height: 90px; }
} .searchInput {
.searchInput { /* composes: input from '../BindEquipment/style.css'; */
/* composes: input from '../BindEquipment/style.css'; */ margin-top: 18px;
margin-top: 18px; margin-left: 40px;
margin-left: 40px; width: 440px;
width: 440px; height: 56px;
height: 56px; border-color: #ff900d;
border-color: #ff900d; }
} .searchBtn {
.searchBtn { display: inline-block;
display: inline-block; height: 90px;
height: 90px; line-height: 90px;
line-height: 90px; margin-left: 24px;
margin-left: 24px; font-size: 30px;
font-size: 30px; color: #ff900d;
color: #ff900d; }
} .searchIcon {
.searchIcon { display: inline-block;
display: inline-block; width: 30px;
width: 30px; height: 30px;
height: 30px; margin-right: 10px;
margin-right: 10px; vertical-align: middle;
vertical-align: middle; }
} .infoBar {
.infoBar { position: fixed;
position: fixed; top: 262px;
top: 262px; right: 30px;
right: 30px; width: 40px;
width: 40px; text-align: center;
text-align: center; font-size: 26px;
font-size: 26px; color: #666;
color: #666; }
} .infoItem {
.infoItem { height: 50px;
height: 50px; line-height: 50px;
line-height: 50px; }
} .infoToast {
.infoToast { position: fixed;
position: fixed; width: 180px;
width: 180px; height: 180px;
height: 180px; line-height: 180px;
line-height: 180px; background-color: rgba(254, 148, 10, 0.4);
background-color: rgba(254, 148, 10, 0.4); left: 9999px;
left: 9999px; top: 480px;
top: 480px; margin-left: -90px;
margin-left: -90px; text-align: center;
text-align: center; font-size: 116px;
font-size: 116px; color: #fff;
color: #fff; opacity: 0;
opacity: 0; transition: opacity 500ms;
transition: opacity 500ms; }
} .show {
.show { opacity: 1;
opacity: 1; left: 50%;
left: 50%; }
} .locationTitle {
.locationTitle { padding: 0 40px;
padding: 0 40px; height: 70px;
height: 70px; line-height: 70px;
line-height: 70px; background-color: #ebebeb;
background-color: #ebebeb; font-size: 26px;
font-size: 26px; color: #999;
color: #999; }
} .locationItem {
.locationItem { width: 530px;
width: 530px; line-height: 80px;
line-height: 80px; margin: 0 auto;
margin: 0 auto; font-size: 30px;
font-size: 30px; color: #444;
color: #444; border-bottom: 2px solid #ebebeb;
border-bottom: 2px solid #ebebeb; word-break: break-all;
word-break: break-all; }
} }
...@@ -83,7 +83,7 @@ export class Index extends React.Component { ...@@ -83,7 +83,7 @@ export class Index extends React.Component {
login(entity) login(entity)
.then(res => { .then(res => {
Toast.hide(); Toast.hide();
console.log(res); // console.log(res);
const data = res.data; const data = res.data;
const { accountCategory } = data; const { accountCategory } = data;
const { history } = this.props; const { history } = this.props;
......
import React from 'react'; import React from 'react';
class Index extends React.Component { function NoMatch() {
render() { return <div>404 NoMatch</div>;
return <div>404 NoMatch</div>;
}
} }
export default Index; export default NoMatch;
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Toast } from 'antd-mobile'; import { Button, Toast } from 'antd-mobile';
import styles from './style.scss'; import './style.scss';
import eqIcon from '../../images/Equipment/equip_number_icon@2x.png'; import eqIcon from '../../images/Equipment/equip_number_icon@2x.png';
import rateIcon from '../../images/Rate/rate_detail_icon@2x.png'; import rateIcon from '../../images/Rate/rate_detail_icon@2x.png';
import { fetchRate, activateRate } from '../../api/index'; import { fetchRate, activateRate } from '../../api/index';
...@@ -15,12 +15,10 @@ export class Index extends React.Component { ...@@ -15,12 +15,10 @@ export class Index extends React.Component {
this.state = { this.state = {
mode: null, mode: null,
type: 1, type: 1,
coldMeasure: '0', measure: '0',
coldMoney: '0.00', money: '0.00',
hotMeasure: '0', startingDuration: '0',
hotMoney: '0.00', startingMoney: '0.00',
warmMeasure: '0',
warmMoney: '0.00',
}; };
} }
...@@ -32,22 +30,18 @@ export class Index extends React.Component { ...@@ -32,22 +30,18 @@ export class Index extends React.Component {
.then(res => { .then(res => {
console.log(res); console.log(res);
const { const {
coldMeasure, measure,
coldMoney, money,
hotMeasure, startingDuration,
hotMoney, startingMoney,
mode, mode,
warmMeasure,
warmMoney,
type, type,
} = res.data; } = res.data;
this.setState({ this.setState({
coldMeasure, measure,
coldMoney: (coldMoney / 100).toFixed(2), money: (money / 100).toFixed(2),
hotMeasure, startingDuration,
hotMoney: (hotMoney / 100).toFixed(2), startingMoney: (startingMoney / 100).toFixed(2),
warmMeasure,
warmMoney: (warmMoney / 100).toFixed(2),
mode, mode,
type, type,
}); });
...@@ -70,119 +64,50 @@ export class Index extends React.Component { ...@@ -70,119 +64,50 @@ export class Index extends React.Component {
}; };
render() { render() {
const { deviceCode } = this.props.match.params; const { deviceCode } = this.props.match.params;
const { const { measure, money, startingDuration, startingMoney } = this.state;
coldMeasure,
coldMoney,
hotMeasure,
hotMoney,
warmMeasure,
warmMoney,
mode,
type,
} = this.state;
let rateTypeText = 'ML|S';
if (mode === 1) {
rateTypeText = 'ML';
}
if (mode === 2) {
rateTypeText = 'S';
}
return ( return (
<div className={'appContent ' + styles.RateActivity}> <div className='appContent RateActivity'>
<div className={styles.inputBox}> <div className='inputBox'>
<i className={styles.inputIcon}> <i className='inputIcon'>
<img src={eqIcon} alt='' /> <img src={eqIcon} alt='' />
</i> </i>
<span className={'ellipsis ' + styles.inputText}> <span className='ellipsis inputText'>
设备编号: 设备编号:
{deviceCode} {deviceCode}
</span> </span>
</div> </div>
<div className={styles.inputBox}> <div className='inputBox'>
<i className={styles.inputIcon}> <i className='inputIcon'>
<img src={rateIcon} alt='' /> <img src={rateIcon} alt='' />
</i> </i>
<span className={'ellipsis ' + styles.inputText}>费率详情:</span> <span className='ellipsis inputText'>费率详情:</span>
</div> </div>
<div className={styles.rateBox}> <div className='rateBox'>
{type === 2 <div className='rateArea'>
? [ <div className='rateTitle'>
<div className={styles.rateArea}> <span className='rateItem'>费率价格()</span>
<div className={styles.rateTitle}> <span className='rateItem'>费率单位(s)</span>
<span className={styles.rateItem}>一路费率价格()</span> </div>
<span className={styles.rateItem}> <div className='line' />
费率单位({rateTypeText}) <div className='ratePrice'>
</span> <span className='rateItem'>{money}</span>
</div> <span className='rateItem'>{measure}</span>
<div className={styles.line} /> </div>
<div className={styles.ratePrice}> </div>
<span className={styles.rateItem}>{coldMoney}</span> <div className='rateArea'>
<span className={styles.rateItem}>{coldMeasure}</span> <div className='rateTitle'>
</div> <span className='rateItem'>起步费率价格()</span>
</div>, <span className='rateItem'>起步费率单位(s)</span>
<div className={styles.rateArea}> </div>
<div className={styles.rateTitle}> <div className='line' />
<span className={styles.rateItem}>二路费率价格()</span> <div className='ratePrice'>
<span className={styles.rateItem}> <span className='rateItem'>{startingMoney}</span>
费率单位({rateTypeText}) <span className='rateItem'>{startingDuration}</span>
</span> </div>
</div> </div>
<div className={styles.line} />
<div className={styles.ratePrice}>
<span className={styles.rateItem}>{hotMoney}</span>
<span className={styles.rateItem}>{hotMeasure}</span>
</div>
</div>,
<div className={styles.rateArea}>
<div className={styles.rateTitle}>
<span className={styles.rateItem}>三路费率价格()</span>
<span className={styles.rateItem}>
费率单位({rateTypeText})
</span>
</div>
<div className={styles.line} />
<div className={styles.ratePrice}>
<span className={styles.rateItem}>{warmMoney}</span>
<span className={styles.rateItem}>{warmMeasure}</span>
</div>
</div>,
]
: [
<div className={styles.rateArea}>
<div className={styles.rateTitle}>
<span className={styles.rateItem}>冷水费率价格()</span>
<span className={styles.rateItem}>
冷水费率单位({rateTypeText})
</span>
</div>
<div className={styles.line} />
<div className={styles.ratePrice}>
<span className={styles.rateItem}>{coldMoney}</span>
<span className={styles.rateItem}>{coldMeasure}</span>
</div>
</div>,
<div className={styles.rateArea}>
<div className={styles.rateTitle}>
<span className={styles.rateItem}>热水费率价格()</span>
<span className={styles.rateItem}>
热水费率单位({rateTypeText})
</span>
</div>
<div className={styles.line} />
<div className={styles.ratePrice}>
<span className={styles.rateItem}>{hotMoney}</span>
<span className={styles.rateItem}>{hotMeasure}</span>
</div>
</div>,
]}
</div> </div>
<Button <Button type='primary' className='btn' onClick={this.clickHandle}>
type='primary'
className={styles.btn}
onClick={this.clickHandle}
>
激活费率 激活费率
</Button> </Button>
</div> </div>
......
.RateActivity { .RateActivity {
background-color: #fff; background-color: #fff;
.inputBox { .inputBox {
/* composes: inputBox from '../Equipment/style.css'; */
margin-top: 62px; margin-top: 62px;
margin-bottom: 62px; margin-bottom: 62px;
} }
...@@ -9,12 +8,8 @@ ...@@ -9,12 +8,8 @@
margin-bottom: 4px; margin-bottom: 4px;
} }
.inputIcon { .inputIcon {
/* composes: inputIcon from '../Equipment/style.css'; */
margin-left: 0; margin-left: 0;
} }
.inputText {
/* composes: inputText from '../Equipment/style.css'; */
}
.rateBox { .rateBox {
margin: 0 auto; margin: 0 auto;
width: 460px; width: 460px;
...@@ -50,7 +45,6 @@ ...@@ -50,7 +45,6 @@
margin-bottom: 0; margin-bottom: 0;
} }
.btn { .btn {
/* composes: btn from '../BindEquipment/style.css'; */
width: 500px; width: 500px;
margin: 90px auto; margin: 90px auto;
font-size: 30px; font-size: 30px;
......
...@@ -15,7 +15,6 @@ export class SelectEquipment extends React.Component { ...@@ -15,7 +15,6 @@ export class SelectEquipment extends React.Component {
componentWillMount() { componentWillMount() {
const { setTitle } = this.props; const { setTitle } = this.props;
setTitle('绑定解绑设备'); setTitle('绑定解绑设备');
console.log(this.props);
} }
goLocation = () => { goLocation = () => {
const { history } = this.props; const { history } = this.props;
...@@ -82,8 +81,8 @@ export class SelectEquipment extends React.Component { ...@@ -82,8 +81,8 @@ export class SelectEquipment extends React.Component {
return ( return (
<div className='appContent SelectEquipment'> <div className='appContent SelectEquipment'>
<div className='List'> <div className='List'>
<label className='listItem'> <label className='SE-listItem'>
<div className='inputBox'> <div className='SE-inputBox'>
<i className='inputIcon'> <i className='inputIcon'>
<img src={eqIcon} alt='' /> <img src={eqIcon} alt='' />
</i> </i>
...@@ -91,15 +90,15 @@ export class SelectEquipment extends React.Component { ...@@ -91,15 +90,15 @@ export class SelectEquipment extends React.Component {
</div> </div>
<div className='br8 input nobor'>{deviceCode}</div> <div className='br8 input nobor'>{deviceCode}</div>
</label> </label>
<label className='listItem'> <label className='SE-listItem'>
<div className='inputBox'> <div className='SE-inputBox'>
<i className='inputIcon'> <i className='inputIcon'>
<img src={locationIcon} alt='' /> <img src={locationIcon} alt='' />
</i> </i>
<span className='ellipsis inputText'>选择安装位置:</span> <span className='ellipsis inputText'>选择安装位置:</span>
</div> </div>
{position.isBind ? ( {position.isBind ? (
<div className={'br8 input'}>{position.position}</div> <div className='br8 input'>{position.position}</div>
) : ( ) : (
<div className='br8 input autoH' onClick={this.goLocation}> <div className='br8 input autoH' onClick={this.goLocation}>
{position.id ? position.position : '点击选择设备安装位置'} {position.id ? position.position : '点击选择设备安装位置'}
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
width: 500px; width: 500px;
margin: 126px auto 0; margin: 126px auto 0;
} }
.listItem { .SE-listItem {
display: block; display: block;
} }
.listItem:nth-child(1) { .SE-listItem:nth-child(1) {
margin-bottom: 38px; margin-bottom: 38px;
} }
.inputBox { .SE-inputBox {
display: flex; display: flex;
font-size: 26px; font-size: 26px;
height: 28px; height: 28px;
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
.inputIcon { .inputIcon {
width: 24px; width: 24px;
height: 28px; height: 28px;
margin: 0;
margin-right: 10px; margin-right: 10px;
} }
.inputText{
line-height: 28px;
}
.input { .input {
/* composes: input from '../BindEquipment/style.css'; */ /* composes: input from '../BindEquipment/style.css'; */
text-indent: 20px; text-indent: 20px;
......
import React from 'react';
import PropTypes from 'prop-types';
import './style.scss';
import eqIcon from '../../images/Equipment/equip_number_icon@2x.png';
import UserInfoContext from '../../context/userinfo-context';
import JsBarcode from 'jsbarcode';
export class Index extends React.Component {
static propTypes = {
name: PropTypes.string,
rateType: PropTypes.number,
barcode: PropTypes.string,
};
constructor(props) {
super(props);
this.state = {
showBig: false,
};
}
componentWillMount() {
const { setTitle } = this.props;
setTitle('测试放水');
}
componentDidMount() {
this.createBarcode();
}
createBarcode = () => {
const { barcode } = this.props;
let barStr = `${barcode}1`;
let dom = document.getElementById('BarCode');
JsBarcode(dom, barStr, {
margin: 0,
height: 300,
});
};
toggleBigBarCode = () => {
const { showBig } = this.state;
this.setState({
showBig: !showBig,
});
};
render() {
const { deviceCode } = this.props.match.params;
const { showBig } = this.state;
return (
<div className='appContent TestWater'>
<div className={showBig ? 'BarCodeBox BarCodeBoxBig' : 'BarCodeBox'}>
<div className={showBig ? 'BarCodeImg BarCodeImgBig' : 'BarCodeImg'}>
<img id='BarCode' alt='' />
</div>
<div className='toggleBtn' onClick={this.toggleBigBarCode}>
{showBig ? '缩小' : '放大'}
</div>
</div>
<div className='inputBox'>
<i className='inputIcon'>
<img src={eqIcon} alt='' />
</i>
<span className='ellipsis inputText'>
设备编号:
{deviceCode}
</span>
</div>
</div>
);
}
}
export default props => (
<UserInfoContext.Consumer>
{({ userinfo }) => (
<Index
{...props}
rateType={userinfo.position.mode}
barcode={userinfo.barcode}
/>
)}
</UserInfoContext.Consumer>
);
.TestWater {
background-color: #fff;
.inputBox {
margin-top: 62px;
margin-bottom: 62px;
}
.inputIcon {
margin-left: 0;
}
.inputWrap {
width: 500px;
margin: 0 auto;
display: flex;
align-items: center;
}
.input {
border: none;
font-size: 26px;
padding-left: 20px;
flex: 1;
}
.line {
width: 2px;
height: 60px;
background-color: #ebebeb;
}
.waterText {
width: 100px;
font-size: 30px;
color: #444;
}
.btn {
// composes: btn from '../BindEquipment/style.css';
width: 500px;
margin: 30px auto;
}
.BarCodeBox {
position: relative;
width: 100%;
height: 221px;
background-image: url('../../images/Equipment/tiaoxingma-1.png');
background-size: cover;
overflow: hidden;
transition: all 0.28s;
}
.BarCodeBoxBig {
height: 372.3px;
background-image: url('../../images/Equipment/tiaoxingma-2.png');
}
.BarCodeImg {
margin: 22.1px 44.2px 0;
width: 551.2px;
height: 160.4px;
background-color: #fff;
overflow: hidden;
transition: all 0.28s;
}
.BarCodeImgBig {
margin: 22.1px 22.1px 0;
width: 593.3px;
height: 309.4px;
}
.toggleBtn {
position: absolute;
right: 0;
bottom: 2px;
width: 69.7px;
height: 34px;
line-height: 34px;
text-indent: 15px;
font-size: 18px;
color: #fff;
background-image: url('../../images//Equipment/矩形-1941---Assistor.png');
background-size: cover;
}
}
...@@ -2,12 +2,12 @@ class Store { ...@@ -2,12 +2,12 @@ class Store {
constructor() { constructor() {
this.token = ''; this.token = '';
} }
static getToken = () => { static getToken() {
return this.token; return this.token;
}; }
static updateToken = token => { static updateToken(token) {
this.token = token; this.token = token;
}; }
} }
export default Store; export default Store;
...@@ -108,6 +108,7 @@ img { ...@@ -108,6 +108,7 @@ img {
.br8 { .br8 {
border-radius: 8px; border-radius: 8px;
} }
.listItem { .listItem {
display: flex; display: flex;
width: 100%; width: 100%;
...@@ -120,4 +121,29 @@ img { ...@@ -120,4 +121,29 @@ img {
.listInput { .listInput {
flex: 1; flex: 1;
border: none; border: none;
} }
\ No newline at end of file .inputBox {
display: flex;
width: 500px;
margin: 84px auto 0;
}
.input {
box-sizing: border-box;
flex: 1;
height: 80px;
line-height: 80px;
text-indent: 20px;
border: 2px solid #ff900d;
word-break: break-all;
}
.inputIcon {
width: 24px;
height: 28px;
margin: 26px 10px 0 20px;
}
.inputText {
font-size: 26px;
color: #444;
flex: 1;
line-height: 80px;
}
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