diff --git a/src/routes/mobile/IndexMobile.js b/src/routes/mobile/IndexMobile.js
index fb6423e..b683d36 100644
--- a/src/routes/mobile/IndexMobile.js
+++ b/src/routes/mobile/IndexMobile.js
@@ -78,7 +78,7 @@ class IndexMobile extends React.Component {
const mine = commonFunc.showLocalMessage(this.props, 'mine', '我的');
scene
const originTitle = {
- message: message ,
+ message: message,
scene: scene,
workbench: workbench,
device: device,
@@ -94,7 +94,24 @@ class IndexMobile extends React.Component {
}
}
}
-
+ componentDidMount() {
+ // 监听系统返回键
+ const { plus } = window;
+ plus?.key?.addEventListener('backbutton', () => {
+ if (location.pathname === '/indexMobile') {
+ // 首页双击返回
+ if (this.backPressedOnce) {
+ plus.runtime.quit();
+ } else {
+ this.backPressedOnce = true;
+ plus.nativeUI.toast('再按一次退出应用');
+ setTimeout(() => { this.backPressedOnce = false; }, 2000);
+ }
+ } else {
+ window.history.back(-1);
+ }
+ });
+ }
handleTouchStart = e => {
this.setState({
touchStartPageX: e.changedTouches[0].pageX,
@@ -115,7 +132,7 @@ class IndexMobile extends React.Component {
const { plus } = window;
if (location.pathname === "/indexMobile") {
alert("确定退出吗?", "", [
- { text: "取消", onPress: () => {} },
+ { text: "取消", onPress: () => { } },
{ text: "是", onPress: () => plus.runtime.quit() }, // 关闭app
]);
} else {
@@ -227,7 +244,7 @@ class IndexMobile extends React.Component {
if (location.pathname === "/indexMobile/quotationDetail") {
return (
-
+
)
} else {
return (
@@ -277,12 +294,12 @@ class IndexMobile extends React.Component {
style={
this.state.fullScreen
? {
- position: "fixed",
- width: "100%",
- top: "40px",
- bottom: 0,
- background: "#fff",
- }
+ position: "fixed",
+ width: "100%",
+ top: "40px",
+ bottom: 0,
+ background: "#fff",
+ }
: { height: 400 }
}
onTouchStart={this.handleTouchStart.bind(this)}
@@ -362,7 +379,7 @@ class IndexMobile extends React.Component {
commonBusiness.clearSocketData({ token, value: {}, sModelsId: 100 });
this.setState({
selectedTab: "scene",
- title:scene,
+ title: scene,
});
history.push("/indexMobile");
}}