IndexSrmMobile.js
6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* eslint-disable */
import React from 'react';
import 'antd-mobile-v2/dist/antd-mobile.css';
import { Icon, NavBar, TabBar, Modal } from 'antd-mobile-v2';
// import { history } from 'dva/router';
import { connect,history } from 'umi';
import styles from './IndexMobile.less';
import SceneSrmMobile from './common/SceneSrmMobile';
import MessageMobile from './common/MessageMobile';
import ContactsMobile from './common/ContactsMobile';
import WorkBenchMobile from './common/WorkBenchMobile';
import CommobileList from './commobileList/commobileList';
import ProcessReportMobile from './common/ProcessReportMobile';
import MyselfMobile from './common/MyselfMobile';
import ContactsInfoMobile from './common/ContactsInfoMobile';
import RevisePasswordMobile from './common/RevisePasswordMobile';
import CommobileBill from './common/commobileBill';
import CommobilePrintPdf from './common/commobilePrintPdf';
import Icon1 from '../../assets/mobile/1.png';
import Icon11 from '../../assets/mobile/11.png';
import Icon2 from '../../assets/mobile/2.png';
import Icon21 from '../../assets/mobile/21.png';
import Icon3 from '../../assets/mobile/3.png';
import Icon31 from '../../assets/mobile/31.png';
import Icon4 from '../../assets/mobile/4.png';
import Icon41 from '../../assets/mobile/41.png';
import Icon5 from '../../assets/mobile/5.png';
import Icon51 from '../../assets/mobile/51.png';
// import AppUtil from '../../utils/AppUtil';
import * as commonBusiness from '../../components/Common/commonBusiness';
// eslint-disable-next-line prefer-destructuring
const alert = Modal.alert;
class indexSrmMobile extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedTab: 'scene',
title: '现场',
hidden: false,
fullScreen: true,
touchStartPageX: 0, // 滑动开始的Y坐标
touchStartPageY: 0,
};
}
componentWillMount() {
this.props.dispatch(history.push('/indexSrmMobile')); // 刷新时更新路由,避免底部按钮和返回按钮错乱显示
if (this.props.routing && this.props.routing) {
const { state } = this.props.routing;
if (state) {
const { sId } = state;
if (sId === 'myself') {
this.setState({ selectedTab: 'myself' });
// this.renderContent('contacts');
}
}
}
// AppUtil.addDrag();
}
handleTouchStart = (e) => {
this.setState({
touchStartPageX: e.changedTouches[0].pageX,
touchStartPageY: e.changedTouches[0].pageY,
});
}
handleTouchEnd = (e) => {
const touchEndtPageX = e.changedTouches[0].pageX;
const touchEndtPageY = e.changedTouches[0].pageY;
const touchDireactionX = touchEndtPageX - this.state.touchStartPageX; // 滑动横向坐标
const touchDireactionY = touchEndtPageY - this.state.touchStartPageY; // 滑动横向坐标
if (touchDireactionX > 100 && touchDireactionY > -80) { // 滑动一定距离
const { plus } = window;
if (location.pathname === '/indexSrmMobile') {
alert('确定退出吗?', '', [
{ text: '取消', onPress: () => {} },
{ text: '是', onPress: () => plus.runtime.quit() }, // 关闭app
]);
} else {
window.history.back(-1);
}
}
}
renderContent(pageText) {
if (pageText === 'message') {
return (
<div className={styles.demoContainer}>
<MessageMobile sModelsId="15881420820002724305540568933000" />
</div>
);
} else if (pageText === 'scene') {
if (location.pathname === '/indexSrmMobile/commobileList') {
return (
<div className={styles.demoContainer}>
<CommobileList {...this.props} />
</div>
);
} else if (location.pathname === '/indexSrmMobile/printPdf') {
return (
<div className={styles.demoContainer}>
<CommobilePrintPdf {...this.props} />
</div>
);
} else if (location.pathname === '/indexSrmMobile/processReport') {
return (
<div className={styles.demoContainer}>
<ProcessReportMobile {...this.props} />
</div>
);
} else if (location.pathname === '/indexSrmMobile/commobileBill') {
return (
<div className={styles.demoContainer}>
<CommobileBill {...this.props} />
</div>
);
} else {
return (
<div className={styles.demoContainer}>
<SceneSrmMobile {...this.props} sModelType={pageText} sModelsId="101251240115015916850901130" />
{/* 15881422910005021526504105317000 */}
</div>
);
}
} else if (pageText === 'workbench') {
if (location.pathname === '/indexSrmMobile/commobileList') {
return (
<div className={styles.demoContainer}>
<CommobileList {...this.props} />
</div>
);
} else {
return (
<div className={styles.demoContainer}>
<WorkBenchMobile sModelsId="15881424880009660140992643529000" />
</div>
);
}
} else if (pageText === 'device') {
return (
<CommobileList {...this.props} sModelsId="101251240115015888433389260" />
);
} else if (pageText === 'myself') {
if (location.pathname === '/indexSrmMobile/contacts') {
return (
<div className={styles.demoContainer}>
<ContactsMobile {...this.props} sModelType={pageText} sModelsId="101251240115015888435981690" />
</div>
);
} else if (location.pathname === '/indexSrmMobile/revisePassword') {
return (
<div className={styles.demoContainer}>
<RevisePasswordMobile {...this.props} sModelsId="101251240115015888435981690" />
</div>
);
} else if (location.pathname === '/indexSrmMobile/contactsInfo') {
return (
<div className={styles.demoContainer}>
<ContactsInfoMobile {...this.props} sModelsId="101251240115015892479567200" />
</div>
);
} else {
return (
<div className={styles.demoContainer}>
<MyselfMobile {...this.props} sModelType={pageText} sModelsId="101251240115015888435981690" />
</div>
);
}
}
}
render() {
const { hidden } = this.state;
const TabBarHidden = location.pathname === '/indexCssMobile' ? hidden : true;
return (
<div id="tab-bar" className={styles.demo}>
{this.state.selectedTab === 'scene' ? this.renderContent(this.state.selectedTab) : ''}
</div>
);
}
}
export default connect(({ app, routing }) =>
({ app, routing }))(indexSrmMobile);