Commit 9068080a authored by GuanHua's avatar GuanHua

fix: 修复从渠道商城进入会员中心后,返回商城时,返回到企业商城的问题

parent afda6263
...@@ -8,7 +8,7 @@ import us from '../../../mockStatic/us.png' ...@@ -8,7 +8,7 @@ import us from '../../../mockStatic/us.png'
import { CaretDownOutlined } from '@ant-design/icons' import { CaretDownOutlined } from '@ant-design/icons'
import { GlobalConfig } from '@/global/config' import { GlobalConfig } from '@/global/config'
interface countryItem { interface CountryItem {
name: string, name: string,
key: string, key: string,
icon: string icon: string
...@@ -16,7 +16,7 @@ interface countryItem { ...@@ -16,7 +16,7 @@ interface countryItem {
const HeaderDropdown: React.FC = () => { const HeaderDropdown: React.FC = () => {
// 此处暂时无接口, 对接接口后需用枚举类型做补充 // 此处暂时无接口, 对接接口后需用枚举类型做补充
const [select, setSelect] = useState<countryItem>({ const [select, setSelect] = useState<CountryItem>({
key: 'cn', key: 'cn',
name: '简体中文-ZH', name: '简体中文-ZH',
icon: ChinaImg icon: ChinaImg
...@@ -46,4 +46,4 @@ const HeaderDropdown: React.FC = () => { ...@@ -46,4 +46,4 @@ const HeaderDropdown: React.FC = () => {
) )
} }
export default HeaderDropdown export default HeaderDropdown
\ No newline at end of file
...@@ -4,11 +4,12 @@ import React, { useCallback, useRef, useLayoutEffect, useState } from 'react'; ...@@ -4,11 +4,12 @@ import React, { useCallback, useRef, useLayoutEffect, useState } from 'react';
import Avatar from './AvatarDropdown'; import Avatar from './AvatarDropdown';
import SelectLang from './SelectLang'; import SelectLang from './SelectLang';
import Location from './Location'; import Location from './Location';
import { history } from 'umi'
import Roles from './Roles'; import Roles from './Roles';
import { inject, observer } from 'mobx-react'
import styles from '../styles/RightContent.less'; import styles from '../styles/RightContent.less';
import { Link } from 'umi';
import { getAuth } from '@/utils/auth'; import { getAuth } from '@/utils/auth';
import { SOCKET_URL } from '@/constants'; import { SOCKET_URL, LAYOUT_TYPE } from '@/constants';
// export type SiderTheme = 'light' | 'dark'; // export type SiderTheme = 'light' | 'dark';
// export interface GlobalHeaderRightProps extends Partial<ConnectProps> { // export interface GlobalHeaderRightProps extends Partial<ConnectProps> {
...@@ -17,10 +18,10 @@ import { SOCKET_URL } from '@/constants'; ...@@ -17,10 +18,10 @@ import { SOCKET_URL } from '@/constants';
// } // }
const NOT_READ_MESSAGE = 1; const NOT_READ_MESSAGE = 1;
const GlobalHeaderRight: React.FC<{}> = (props) => { const GlobalHeaderRight: React.FC<{SiteStore?: any}> = (props) => {
// const { theme, layout } = props; const { SiteStore: { currentLayoutInfo } } = props;
const [message, setMessage] = useState<number>(0); const [message, setMessage] = useState<number>(0);
let className = styles.right; const className = styles.right;
// if (theme === 'dark' && layout === 'topmenu') { // if (theme === 'dark' && layout === 'topmenu') {
// className = `${styles.right} ${styles.dark}`; // className = `${styles.right} ${styles.dark}`;
...@@ -33,7 +34,7 @@ const GlobalHeaderRight: React.FC<{}> = (props) => { ...@@ -33,7 +34,7 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) { if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
const url = `${SOCKET_URL}/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`; const url = `${SOCKET_URL}/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
ws.current = new WebSocket(url); ws.current = new WebSocket(url);
ws.current.onopen = (e) => {} // ws.current.onopen = (e) => {}
ws.current.onmessage = (e) => { ws.current.onmessage = (e) => {
const data = JSON.parse(e.data); const data = JSON.parse(e.data);
if(data.type === NOT_READ_MESSAGE) { if(data.type === NOT_READ_MESSAGE) {
...@@ -56,9 +57,13 @@ const GlobalHeaderRight: React.FC<{}> = (props) => { ...@@ -56,9 +57,13 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
}; };
}, [ws, webSocketInit]); }, [ws, webSocketInit]);
const handleBackMall = () => {
history.push(currentLayoutInfo.mallLink)
}
return ( return (
<div className={className}> <div className={className}>
<Link to='/' style={{color: 'rgba(0, 0, 0, 0.85)'}}>返回商城</Link> <span style={{color: 'rgba(0, 0, 0, 0.85)', cursor: "pointer"}} onClick={handleBackMall}>返回商城</span>
<Roles /> <Roles />
<Location /> <Location />
<SelectLang /> <SelectLang />
...@@ -87,7 +92,7 @@ const GlobalHeaderRight: React.FC<{}> = (props) => { ...@@ -87,7 +92,7 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
); );
}; };
export default GlobalHeaderRight export default inject("SiteStore")(observer(GlobalHeaderRight))
// export default connect(({ settings }: ConnectState) => ({ // export default connect(({ settings }: ConnectState) => ({
// theme: settings.navTheme, // theme: settings.navTheme,
......
...@@ -9,6 +9,7 @@ import { LAYOUT_TYPE } from "@/constants" ...@@ -9,6 +9,7 @@ import { LAYOUT_TYPE } from "@/constants"
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import TopBar from '../components/TopBar' import TopBar from '../components/TopBar'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { GlobalConfig } from '@/global/config'
import { GetTemplateWebMemberChannelWebMemberChannelMainResponse } from '@/services/TemplateApi' import { GetTemplateWebMemberChannelWebMemberChannelMainResponse } from '@/services/TemplateApi'
import SearchShopResult from '../components/SearchShopResult' import SearchShopResult from '../components/SearchShopResult'
import ChannelHeader from '../components/ChannelHeader' import ChannelHeader from '../components/ChannelHeader'
...@@ -27,7 +28,7 @@ interface LXChannelLayoutPropsType { ...@@ -27,7 +28,7 @@ interface LXChannelLayoutPropsType {
} }
const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => { const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => {
const { children, location } = props const { children, location, SiteStore } = props
const [templateName] = useState<string>('theme-channel-science') const [templateName] = useState<string>('theme-channel-science')
const { channelId } = location.query const { channelId } = location.query
const [shopInfo, setShopInfo] = useState<GetTemplateWebMemberChannelWebMemberChannelMainResponse>() const [shopInfo, setShopInfo] = useState<GetTemplateWebMemberChannelWebMemberChannelMainResponse>()
...@@ -52,6 +53,10 @@ const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => { ...@@ -52,6 +53,10 @@ const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => {
} catch (error) { } catch (error) {
setLoading(false) setLoading(false)
} }
SiteStore.saveCurrentLayout({
layoutType: LAYOUT_TYPE.channel,
mallLink: `${GlobalConfig.channelRootRoute}?channelId=${channelId}`
})
}, []) }, [])
useEffect(() => { useEffect(() => {
......
...@@ -9,6 +9,7 @@ import { LAYOUT_TYPE } from "@/constants" ...@@ -9,6 +9,7 @@ import { LAYOUT_TYPE } from "@/constants"
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import TopBar from '../components/TopBar' import TopBar from '../components/TopBar'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { GlobalConfig } from '@/global/config'
import { GetTemplateWebMemberChannelWebMemberChannelMainResponse } from '@/services/TemplateApi' import { GetTemplateWebMemberChannelWebMemberChannelMainResponse } from '@/services/TemplateApi'
import SearchShopResult from '../components/SearchShopResult' import SearchShopResult from '../components/SearchShopResult'
import ChannelHeader from '../components/ChannelHeader' import ChannelHeader from '../components/ChannelHeader'
...@@ -27,7 +28,7 @@ interface LXIChannelLayoutPropsType { ...@@ -27,7 +28,7 @@ interface LXIChannelLayoutPropsType {
} }
const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => { const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => {
const { children, location } = props const { children, location, SiteStore } = props
const [templateName] = useState<string>('theme-channel-science') const [templateName] = useState<string>('theme-channel-science')
const { channelId } = location.query const { channelId } = location.query
const [shopInfo, setShopInfo] = useState<GetTemplateWebMemberChannelWebMemberChannelMainResponse>() const [shopInfo, setShopInfo] = useState<GetTemplateWebMemberChannelWebMemberChannelMainResponse>()
...@@ -51,7 +52,10 @@ const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => { ...@@ -51,7 +52,10 @@ const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => {
} catch (error) { } catch (error) {
setLoading(false) setLoading(false)
} }
SiteStore.saveCurrentLayout({
layoutType: LAYOUT_TYPE.ichannel,
mallLink: `${GlobalConfig.ichannelRootRoute}?channelId=${channelId}`
})
}, []) }, [])
useEffect(() => { useEffect(() => {
......
...@@ -28,7 +28,7 @@ interface LXMallLayoutPropsType { ...@@ -28,7 +28,7 @@ interface LXMallLayoutPropsType {
const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => { const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const { children, location } = props const { children, location } = props
const [templateName] = useState<string>('theme-mall-science') const [templateName] = useState<string>('theme-mall-science')
const { siteId, mallTemplateInfo, findUseMallTemplate } = props.SiteStore const { saveCurrentLayout, mallTemplateInfo, findUseMallTemplate } = props.SiteStore
const [mallInfo, setMallInfo] = useState<any>({}) const [mallInfo, setMallInfo] = useState<any>({})
const getMenuRouter = (routes: any, pathname: any) => { const getMenuRouter = (routes: any, pathname: any) => {
...@@ -46,6 +46,10 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -46,6 +46,10 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
findUseMallTemplate() findUseMallTemplate()
} }
getWebMallInfo() getWebMallInfo()
saveCurrentLayout({
layoutType: LAYOUT_TYPE.mall,
mallLink: "/",
})
}, []) }, [])
const getWebMallInfo = () => { const getWebMallInfo = () => {
......
...@@ -28,7 +28,7 @@ interface LXMallLayoutPropsType { ...@@ -28,7 +28,7 @@ interface LXMallLayoutPropsType {
const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const { children, location } = props const { children, location, SiteStore } = props
const [templateName] = useState<string>('theme-shop-science') const [templateName] = useState<string>('theme-shop-science')
const { shopId } = location.query const { shopId } = location.query
const [shopInfo, setShopInfo] = useState<any>() const [shopInfo, setShopInfo] = useState<any>()
...@@ -45,6 +45,10 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -45,6 +45,10 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
console.log(error) console.log(error)
setLoading(false) setLoading(false)
} }
SiteStore.saveCurrentLayout({
layoutType: LAYOUT_TYPE.mall,
mallLink: "/",
})
getWebMallInfo() getWebMallInfo()
}, []) }, [])
......
import { action, computed, observable, runInAction } from 'mobx' import { action, computed, observable, runInAction } from 'mobx'
import { ISiteModule } from '@/module/siteModule' import { ISiteModule } from '@/module/siteModule'
import { GlobalConfig } from '@/global/config' import { GlobalConfig } from '@/global/config'
import { LAYOUT_TYPE } from '@/constants'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
type CurrentLayoutType = {
layoutType: string,
mallLink: string,
}
const sessionCurrentLayout: string = sessionStorage.getItem("currentLayout")
class SiteStore implements ISiteModule { class SiteStore implements ISiteModule {
// 可在根目录下的demo.js修改数据 // 可在根目录下的demo.js修改数据
@observable public siteId: number = GlobalConfig.global.siteInfo.id; // 站点id @observable public siteId: number = GlobalConfig.global.siteInfo.id; // 站点id
...@@ -12,6 +21,7 @@ class SiteStore implements ISiteModule { ...@@ -12,6 +21,7 @@ class SiteStore implements ISiteModule {
@observable public shopTemplateId: number = null; // 店铺模板id @observable public shopTemplateId: number = null; // 店铺模板id
@observable public channelTemplateId: number = null; // 渠道模板id @observable public channelTemplateId: number = null; // 渠道模板id
@observable public commodityTemplateInfo: any = {} @observable public commodityTemplateInfo: any = {}
@observable public currentLayoutInfo: CurrentLayoutType = sessionCurrentLayout ? JSON.parse(sessionCurrentLayout) : { layoutType: LAYOUT_TYPE.mall, mallLink: "/" }
/** /**
* 根据站点查询正在使用的商城模板 * 根据站点查询正在使用的商城模板
...@@ -37,6 +47,14 @@ class SiteStore implements ISiteModule { ...@@ -37,6 +47,14 @@ class SiteStore implements ISiteModule {
} }
/** /**
* 保存当前商城类型
*/
public saveCurrentLayout = (layoutInfo: CurrentLayoutType) => {
this.currentLayoutInfo = layoutInfo
sessionStorage.setItem("currentLayout", JSON.stringify(this.currentLayoutInfo))
}
/**
* 根据站点查询正在使用的商品描述模板 * 根据站点查询正在使用的商品描述模板
*/ */
@action.bound @action.bound
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment