liaolx
2026-03-03 ad32682d6a6d84d128f74521a62a4f9c92ba43c0
feat: 补回退出登录入口
3个文件已添加
1个文件已修改
164 ■■■■■ 已修改文件
src/app.config.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/otherPage/pages/set/index.config.ts 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/otherPage/pages/set/index.less 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/otherPage/pages/set/index.tsx 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/app.config.ts
@@ -35,7 +35,13 @@
        'pages/pricing-rules/index',
        'pages/ride-guide/index',
      ],
    }
    },
    {
      root: 'otherPage',
      pages: [
        'pages/set/index',
      ],
    },
  ];
  tabBar = {
src/otherPage/pages/set/index.config.ts
New file
@@ -0,0 +1,6 @@
export default {
  navigationBarTitleText: '设置',
  backgroundColor: "#ffffff",
  backgroundColorTop: "#ffffff",
  backgroundColorBottom: "#ffffff",
};
src/otherPage/pages/set/index.less
New file
@@ -0,0 +1,55 @@
.set-page-box {
  .set-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 750px;
    height: 124px;
    padding: 0 64px;
  }
  .set-text {
    font-size: 28px;
    color: #000000;
    text-align: left;
    font-weight: 500;
    font-family: PingFang SC;
    font-style: normal;
    line-height: 44px;
  }
  .arrow {
    width: 32px;
    height: 32px;
  }
  .logout-cont {
    position: fixed;
    bottom: 112px;
    left: 100px;
    text-align: center;
    .btn-logout {
      display: block;
      width: 550px;
      height: 96px;
      margin: 0 auto;
      font-size: 28px;
      line-height: 96px;
      color: #FFFFFF;
      background: #1A1A1A;
      border-radius: 4px;
      border: none;
      font-family: PingFang SC;
      font-style: normal;
      font-weight: 600;
    }
    .btn-switch {
      width: 544px;
      height: 96px;
      margin-top: 16px;
      font-size: 28px;
      color: #0f1520;
      line-height: 96px;
      background: transparent;
    }
  }
}
src/otherPage/pages/set/index.tsx
New file
@@ -0,0 +1,95 @@
import Taro from '@tarojs/taro';
import { Component } from 'react';
import { View, Button } from '@tarojs/components';
import { connect } from 'react-redux';
import { dispatch } from '../../../utils/redux';
import { _UID } from '../../../constants/api';
import { dispatchLoginStatusUpdate } from '../../../actions/user';
import { dispatchLogout } from '../../../actions/user_weapp';
import { jumpTo } from '../../../utils/jump';
import { getStorage } from '../../../utils/tools';
import { loginStatus as loginStatusConst } from '../../../constants/user';
import gioReport from '../../../utils/gio';
import './index.less'
import { createPage } from '../../../utils/page';
type Props = {
  dispatch: any
  dispatchLogout: any
  dispatchLoginStatusUpdate: any
};
type State = {
  loginStatus: number
};
// @ts-ignore
@connect(() => ({}), {
  dispatch,
  dispatchLogout,
  dispatchLoginStatusUpdate
})
// @ts-ignore
@createPage()
export default class Set extends Component<Props, State> {
  $app: any = Taro.getApp().$app;
  state = {
    loginStatus: loginStatusConst.NOT_LOGIN,
  }
  async componentDidShow() {
    this.$app.xpReportShow();
    const otp = await getStorage('otp');
    if (!otp) {
      this.setState({ loginStatus: loginStatusConst.NOT_LOGIN });
    } else {
      this.setState({ loginStatus: loginStatusConst.LOGIN });
    }
  }
  componentDidHide() {
    this.$app.xpReportHide();
  }
  handleLogout = () => {
    this.$app.xpReportSend({ pageId: 'P10037', buttonId: 'B026' });
    Taro.showModal({
      title: '确定要退出登录吗',
      content: '',
      confirmColor: '#7BAE3F',
      cancelColor: '#808080',
    })
      .then(res => {
        if (res.confirm) {
          this.props.dispatch({ type: 'loginOut' });
          this.$app.xpReportSend({ pageId: 'P10037', buttonId: 'B006' });
          this.props.dispatchLogout({})
            .then(() => {
              gioReport.logoutClearReport();
              Taro.setStorage({ key: _UID, data: '-1' });
              Taro.setStorage({ key: 'otp', data: '', complete: () => {
                  jumpTo({ type: 'back' });
                }
              });
            });
        }
      })
    // 通知webview刷新code
    this.props.dispatchLoginStatusUpdate({ userUpdate: true });
  }
  render() {
    const { loginStatus } = this.state
    return (
      <View className='set-page-box'>
        {loginStatus === loginStatusConst.LOGIN && (
          <View className='logout-cont'>
            <Button className='btn-logout' onClick={this.handleLogout}>退出登录</Button>
          </View>
        )}
      </View>
    );
  }
}