Commit b2a29158eb0978059ba80342f8eba03d6c96dfde

Authored by zhangzzzz
1 parent 7b1d4f4b

修改移动端;

Showing 1 changed file with 17 additions and 19 deletions
src/routes/mobile/IndexMobile.js
1 import React from "react"; 1 import React from "react";
2 import "antd-mobile-v2/dist/antd-mobile.css"; 2 import "antd-mobile-v2/dist/antd-mobile.css";
3 import { Icon, NavBar, TabBar, Modal } from "antd-mobile-v2"; 3 import { Icon, NavBar, TabBar, Modal } from "antd-mobile-v2";
4 -// import { history } from 'dva/router'; 4 +// import { routerRedux } from 'dva/router';
5 import { connect, history } from "umi"; 5 import { connect, history } from "umi";
6 6
7 import * as commonUtils from "@/utils/utils"; 7 import * as commonUtils from "@/utils/utils";
@@ -46,26 +46,24 @@ class IndexMobile extends React.Component { @@ -46,26 +46,24 @@ class IndexMobile extends React.Component {
46 }; 46 };
47 } 47 }
48 componentWillMount() { 48 componentWillMount() {
49 - console.log(this.props,'indexMobile');  
50 -  
51 - // this.props.dispatch(history.push("/indexMobile")); // 刷新时更新路由,避免底部按钮和返回按钮错乱显示  
52 - // if (this.props.routing && this.props.routing) {  
53 - // const { state } = this.props.routing;  
54 - // if (state) {  
55 - // const { sId } = state;  
56 - // if (sId === "myself") {  
57 - // this.setState({ selectedTab: "myself" });  
58 - // // this.renderContent('contacts');  
59 - // }  
60 - // }  
61 - // } 49 + history.push("/indexMobile"); // 刷新时更新路由,避免底部按钮和返回按钮错乱显示
  50 + if (this.props.routing && this.props.routing) {
  51 + const { state } = this.props.routing;
  52 + if (state) {
  53 + const { sId } = state;
  54 + if (sId === "myself") {
  55 + this.setState({ selectedTab: "myself" });
  56 + // this.renderContent('contacts');
  57 + }
  58 + }
  59 + }
62 60
63 // AppUtil.addDrag(); 61 // AppUtil.addDrag();
64 } 62 }
65 63
66 componentDidUpdate(prevProps) { 64 componentDidUpdate(prevProps) {
67 /* eslint-disable */ 65 /* eslint-disable */
68 - if (prevProps?.location.state !== this.props.location.state) { 66 + if (this.props.location && prevProps?.location.state !== this.props.location.state) {
69 const originTitle = { 67 const originTitle = {
70 message: "消息", 68 message: "消息",
71 scene: "现场", 69 scene: "现场",
@@ -285,7 +283,7 @@ class IndexMobile extends React.Component { @@ -285,7 +283,7 @@ class IndexMobile extends React.Component {
285 selectedTab: "message", 283 selectedTab: "message",
286 title: "消息", 284 title: "消息",
287 }); 285 });
288 - this.props.dispatch(history.push("/indexMobile")); 286 + history.push("/indexMobile");
289 }} 287 }}
290 data-seed="logId" 288 data-seed="logId"
291 > 289 >
@@ -322,7 +320,7 @@ class IndexMobile extends React.Component { @@ -322,7 +320,7 @@ class IndexMobile extends React.Component {
322 selectedTab: "scene", 320 selectedTab: "scene",
323 title: "现场", 321 title: "现场",
324 }); 322 });
325 - this.props.dispatch(history.push("/indexMobile")); 323 + history.push("/indexMobile");
326 }} 324 }}
327 data-seed="logId1" 325 data-seed="logId1"
328 > 326 >
@@ -359,7 +357,7 @@ class IndexMobile extends React.Component { @@ -359,7 +357,7 @@ class IndexMobile extends React.Component {
359 selectedTab: "workbench", 357 selectedTab: "workbench",
360 title: "工作台", 358 title: "工作台",
361 }); 359 });
362 - this.props.dispatch(history.push("/indexMobile")); 360 + routerRedux.push("/indexMobile");
363 }} 361 }}
364 > 362 >
365 {this.state.selectedTab === "workbench" ? this.renderContent(this.state.selectedTab) : ""} 363 {this.state.selectedTab === "workbench" ? this.renderContent(this.state.selectedTab) : ""}
@@ -395,7 +393,7 @@ class IndexMobile extends React.Component { @@ -395,7 +393,7 @@ class IndexMobile extends React.Component {
395 selectedTab: "myself", 393 selectedTab: "myself",
396 title: "我的", 394 title: "我的",
397 }); 395 });
398 - this.props.dispatch(history.push("/indexMobile")); 396 + history.push("/indexMobile");
399 }} 397 }}
400 > 398 >
401 {this.state.selectedTab === "myself" ? this.renderContent(this.state.selectedTab) : ""} 399 {this.state.selectedTab === "myself" ? this.renderContent(this.state.selectedTab) : ""}