import React, { Component } from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; import Api from '@/api'; import { inject, observer } from 'mobx-react'; import { HTTP_STATUS, BASE_PATH } from '@/shared/common/constants'; import { getImgPath } from '@/shared/common/utils'; import { IUserStore } from '@/models/user'; import './index.scss'; type P = RouteComponentProps & { userStore?: IUserStore; }; type S = { isLogin; }; @inject('userStore') @observer class Home extends Component
{ componentDidMount() { this.isLogin(); } isLogin = async () => { const res = await Api.auth.checkLoginState(); //已登录 if (HTTP_STATUS.SUCCESSS === res.ret && res.login) { this.props.userStore.setIsLogin(true); this.getUserInfo(); } else { sessionStorage.clear(); this.props.userStore.clear(); } }; getUserInfo = async () => { const res = await Api.account.basicInfo(); if (HTTP_STATUS.SUCCESSS === res.code) { this.props.userStore.setUserInfo(res.data); } }; login = () => { const formUri = window.location.origin + BASE_PATH + '/index'; Api.auth.login(formUri); }; applyEntry = () => { //检测是否登录 if (this.props.userStore.isLogin) { this.props.history.push('/index'); } else { this.login(); } }; logout = async () => { const res = await Api.auth.logout(); if (HTTP_STATUS.SUCCESSS === res.ret) { sessionStorage.clear(); this.props.userStore.clear(); this.props.history.replace('/'); } }; renderDownMenu = () => { const config = [ { name: '退出', class: 'logout', link: '', onClick: this.logout, }, ]; const mItemList = config.map((item, index) => { return (
内容分销:分销喜马海量内容,轻松获取分销收益。
企业采购:在线采购实物商品,尽享超低折扣。
商品选购:快速下单,有效降低沟通成本。
订单管理:物流状态实时跟踪,避免人工订货漏单错单。
账户管理:线上账户自助结算,收支明细随时查看,确保资金安全,账目清晰。
多样产品:提供可满足多种线下场景的产品,如朗读亭、有声图书馆、小雅音箱等。
营销玩法:支持发放活动优惠券、会员体验券、打折促销等多种营销手段。