Commit 46c60caa authored by GuanHua's avatar GuanHua

feat:动态获取商城的模板id和修复些样式问题

parent e9fec2f9
...@@ -82,7 +82,7 @@ async function batchAxiosHttps() { ...@@ -82,7 +82,7 @@ async function batchAxiosHttps() {
const serverErrorQueue = [] const serverErrorQueue = []
console.log('\n') console.log('\n')
for (const item in serviceConfig) { for (const item in serviceConfig) {
if(JSON.stringify(item) !== '{}'){ if (JSON.stringify(item) !== '{}') {
for (const subItem in serviceConfig[item]) { for (const subItem in serviceConfig[item]) {
try { try {
const data = await axios(serviceConfig[item][subItem]) const data = await axios(serviceConfig[item][subItem])
...@@ -90,12 +90,12 @@ async function batchAxiosHttps() { ...@@ -90,12 +90,12 @@ async function batchAxiosHttps() {
if (data.data.code === 1000) { if (data.data.code === 1000) {
asyncHttpQueue[item][subItem] = data.data.data asyncHttpQueue[item][subItem] = data.data.data
} else { } else {
serverErrorQueue.push({ ...asyncHttpQueue[item][subItem], ...data.data}) serverErrorQueue.push({ ...asyncHttpQueue[item][subItem], ...data.data })
// 默认置为null // 默认置为null
asyncHttpQueue[item][subItem] = null asyncHttpQueue[item][subItem] = null
} }
} catch(err) { } catch (err) {
httpErrorQueue.push({...serviceConfig[item][subItem], ...err.response.data}) httpErrorQueue.push({ ...serviceConfig[item][subItem], ...err.response.data })
} }
} }
} }
......
...@@ -12,6 +12,7 @@ import { MALL_TYPE } from '@/constants' ...@@ -12,6 +12,7 @@ import { MALL_TYPE } from '@/constants'
import copy from 'copy-to-clipboard' import copy from 'copy-to-clipboard'
import cx from 'classnames' import cx from 'classnames'
import styles from './index.less' import styles from './index.less'
import { GetTemplateChannelFindChannelResponse } from '@/services/TemplateApi'
import { isEmpty } from '@formily/antd/esm/shared' import { isEmpty } from '@formily/antd/esm/shared'
interface ShopInfoPropsType { interface ShopInfoPropsType {
...@@ -34,6 +35,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -34,6 +35,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片 const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片
const [honorPics, setHonorPics] = useState([]) // 资质荣誉 const [honorPics, setHonorPics] = useState([]) // 资质荣誉
const [logo, setLogo] = useState<string>("") const [logo, setLogo] = useState<string>("")
const [shopInfo, setShopInfo] = useState<GetTemplateChannelFindChannelResponse>()
const [shopId, setShopId] = useState<number>() const [shopId, setShopId] = useState<number>()
useEffect(() => { useEffect(() => {
...@@ -58,6 +60,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -58,6 +60,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
PublicApi.getTemplateChannelFindChannel().then(res => { PublicApi.getTemplateChannelFindChannel().then(res => {
const data = res.data const data = res.data
if (res.code === 1000) { if (res.code === 1000) {
setShopInfo(data)
setSelectCityData(initMemberShopArea(data.memberChannelAreas)) setSelectCityData(initMemberShopArea(data.memberChannelAreas))
setLogo(data.logo) setLogo(data.logo)
setShopId(data.shopId) setShopId(data.shopId)
...@@ -209,11 +212,11 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -209,11 +212,11 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
let selectItem = allMallList.filter(item => item.id === mallId) let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId) setShopId(mallId)
if (mallId) { if (mallId) {
setStoreUrl(`${siteUrl}/${selectItem[0].url}?id=${1}`) setStoreUrl(`${siteUrl}/channelMall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`)
// setStoreUrl(`${siteUrl}/${selectItem[0].url}?id=${1}`)
} else { } else {
setStoreUrl(null) setStoreUrl(null)
} }
} }
const handleFormValueChange = () => { const handleFormValueChange = () => {
...@@ -333,7 +336,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -333,7 +336,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}> <Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
{ {
allMallList.map(item => ( allMallList.map(item => (
<Select.Option key={item.id} value={item.id}>{MALL_TYPE[item.type]}</Select.Option> <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
)) ))
} }
</Select> </Select>
...@@ -346,7 +349,6 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -346,7 +349,6 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
</div> </div>
) )
} }
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
......
...@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => { ...@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => {
<Row gutter={24} className={styles.template_list}> <Row gutter={24} className={styles.template_list}>
{ {
templateList.map(item => ( templateList.map(item => (
<Col span={6} key={item.id}> <Col xxl={6} xl={8} lg={12} key={item.id}>
<TemplateItem templateInfo={item} type="shop" /> <TemplateItem templateInfo={item} type="shop" />
</Col> </Col>
)) ))
......
import React from 'react' import React, { useEffect } from 'react'
import { ScienceTemplate } from './template' import { ScienceTemplate } from './template'
import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchApi' import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchApi'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import isEmpty from 'lodash/isEmpty'
import styles from './index.less' import styles from './index.less'
interface IntroductionPropsType { interface IntroductionPropsType {
...@@ -9,88 +12,20 @@ interface IntroductionPropsType { ...@@ -9,88 +12,20 @@ interface IntroductionPropsType {
const Introduction: React.FC<IntroductionPropsType> = (props) => { const Introduction: React.FC<IntroductionPropsType> = (props) => {
const { commodityDetail } = props const { commodityDetail } = props
const SiteStore = useLocalStore(() => store.SiteStore)
const { commodityTemplateInfo, findUseGoodsTemplate } = SiteStore
const data = [ useEffect(() => {
{ if (isEmpty(commodityTemplateInfo)) {
label: '主要用途', findUseGoodsTemplate()
value: '皮鞋、皮带、箱包、其他用途' }
}, }, [])
{
label: '皮层', useEffect(() => {
value: '二层' }, [commodityTemplateInfo])
},
{
label: '风格',
value: '荔枝纹'
},
{
label: '张幅皮形',
value: '自然张'
},
{
label: '颜色',
value: '黑色、红色、黄色、橙色、咖啡色'
},
{
label: '厚度',
value: '1.0mm ~ 1.5mm'
},
{
label: '产地',
value: '无'
},
{
label: '尺码保障',
value: '83%'
},
{
label: '取样',
value: '无'
},
{
label: '等级',
value: '统级'
},
{
label: '保税',
value: '是'
},
{
label: '备注',
value: '统级'
},
{
label: '编号',
value: '无'
},
{
label: '材质',
value: '无'
},
{
label: '国际色卡',
value: '无'
},
{
label: '手感',
value: '无'
},
{
label: '七天无理由退换货',
value: '无'
},
{
label: '交货地',
value: '无'
},
{
label: '商品状态',
value: '无'
},
]
const renderIntroduction = () => { const renderIntroduction = () => {
let templateName = 'science' let templateName = commodityTemplateInfo.fileName || 'science'
switch (templateName) { switch (templateName) {
case 'science': case 'science':
return <ScienceTemplate /> return <ScienceTemplate />
...@@ -116,4 +51,4 @@ const Introduction: React.FC<IntroductionPropsType> = (props) => { ...@@ -116,4 +51,4 @@ const Introduction: React.FC<IntroductionPropsType> = (props) => {
) )
} }
export default Introduction export default observer(Introduction)
...@@ -9,6 +9,8 @@ import Exhibition from './components/Exhibition' ...@@ -9,6 +9,8 @@ import Exhibition from './components/Exhibition'
import BrowseRecords from './components/BrowseRecords' import BrowseRecords from './components/BrowseRecords'
import Interested from './components/Interested' import Interested from './components/Interested'
import ShopInfo from './components/ShopInfo' import ShopInfo from './components/ShopInfo'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import ProductDescription from './components/ProductDescription' import ProductDescription from './components/ProductDescription'
import InputNumber from '@/components/InputNumber' import InputNumber from '@/components/InputNumber'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
...@@ -71,11 +73,23 @@ const CommodityDetail = (props) => { ...@@ -71,11 +73,23 @@ const CommodityDetail = (props) => {
if (res.code === 1000) { if (res.code === 1000) {
setCommodityDetail(res.data) setCommodityDetail(res.data)
initAttributeAndValueList(res.data?.unitPriceAndPicList) initAttributeAndValueList(res.data?.unitPriceAndPicList)
getPayWayListByMemberId(res.data?.memberId)
res.data?.isMemberPrice && getMemberCredit(res.data?.memberId, res.data?.memberRoleId) res.data?.isMemberPrice && getMemberCredit(res.data?.memberId, res.data?.memberRoleId)
} }
}) })
} }
const getPayWayListByMemberId = (memberId: number) => {
if (!memberId) {
return
}
//@ts-ignore
PublicApi.getPayPayWayList({ memberId }).then(res => {
})
}
const getMemberCredit = (memberId, memberRoleId) => { const getMemberCredit = (memberId, memberRoleId) => {
let param = { let param = {
parentMemberId: memberId, parentMemberId: memberId,
...@@ -158,7 +172,12 @@ const CommodityDetail = (props) => { ...@@ -158,7 +172,12 @@ const CommodityDetail = (props) => {
message.info("请选择商品属性") message.info("请选择商品属性")
return return
} }
history.push(`/order`) PublicApi.postOrderIsWorkFlow({ productIds: [selectCommodityId] }).then(res => {
if (res.code === 1000) {
message.destroy()
history.push(`/order?commodityId=${selectCommodityId}&scence=buy`)
}
})
} }
const renderBtn = () => { const renderBtn = () => {
...@@ -486,4 +505,4 @@ const CommodityDetail = (props) => { ...@@ -486,4 +505,4 @@ const CommodityDetail = (props) => {
) )
} }
export default CommodityDetail export default observer(CommodityDetail)
...@@ -23,14 +23,15 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -23,14 +23,15 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const { fetchCategoryList, categoryList } = props.CategoryStore const { fetchCategoryList, categoryList } = props.CategoryStore
useEffect(() => { useEffect(() => {
console.log(type, "type")
let getCategoryFn let getCategoryFn
let params: any = {} let params: any = {}
switch (type) { switch (type) {
case LAYOUT_TYPE.mall: case LAYOUT_TYPE.mall:
if (mallTemplateId) {
params.templateId = mallTemplateId params.templateId = mallTemplateId
getCategoryFn = PublicApi.getTemplatePlatformFindAllCategoryTree getCategoryFn = PublicApi.getTemplatePlatformFindAllCategoryTree
fetchCategoryList(getCategoryFn, params, type) fetchCategoryList(getCategoryFn, params, type)
}
break break
case LAYOUT_TYPE.shop: case LAYOUT_TYPE.shop:
if (shopId) { if (shopId) {
...@@ -46,7 +47,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -46,7 +47,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
break break
} }
}, [props]) }, [props, mallTemplateId])
return ( return (
<div className={styles.category}> <div className={styles.category}>
......
...@@ -16,6 +16,17 @@ interface MainNavPropsType { ...@@ -16,6 +16,17 @@ interface MainNavPropsType {
const MainNav: React.FC<MainNavPropsType> = (props) => { const MainNav: React.FC<MainNavPropsType> = (props) => {
const { menuData, pathname, type, shopId, shopUrlParam } = props const { menuData, pathname, type, shopId, shopUrlParam } = props
const getNavLink = (item) => {
switch (type) {
case LAYOUT_TYPE.shop:
return `${item.path}?shopId=${shopUrlParam}`
case LAYOUT_TYPE.channel:
return `${item.path}?id=${shopUrlParam}`
default:
return item.path
}
}
return ( return (
<div className={cx(styles.main_nav, type === LAYOUT_TYPE.shop ? styles.shop : "")}> <div className={cx(styles.main_nav, type === LAYOUT_TYPE.shop ? styles.shop : "")}>
<div className={styles.main_nav_container}> <div className={styles.main_nav_container}>
...@@ -24,7 +35,7 @@ const MainNav: React.FC<MainNavPropsType> = (props) => { ...@@ -24,7 +35,7 @@ const MainNav: React.FC<MainNavPropsType> = (props) => {
{ {
menuData && menuData.map(item => !item.hide && ( menuData && menuData.map(item => !item.hide && (
<li className={cx(styles.nav_item, item.path === pathname ? styles.active : '')} key={item.key}> <li className={cx(styles.nav_item, item.path === pathname ? styles.active : '')} key={item.key}>
<Link to={type === LAYOUT_TYPE.shop ? `${item.path}?shopId=${shopUrlParam}` : item.path}>{item.name}</Link> <Link to={getNavLink(item)}>{item.name}</Link>
</li> </li>
)) ))
} }
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
flex: 1; flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 8px;
&>span { &>span {
font-size: 14px; font-size: 14px;
......
...@@ -80,7 +80,9 @@ const MallIndex: React.FC<MallIndexPropsType> = (props) => { ...@@ -80,7 +80,9 @@ const MallIndex: React.FC<MallIndexPropsType> = (props) => {
// @ts-ignore // @ts-ignore
PublicApi.getTemplatePlatformFindFirstCategoryDetail(param).then(res => { PublicApi.getTemplatePlatformFindFirstCategoryDetail(param).then(res => {
if (res.code === 1000) {
resolve(res.data) resolve(res.data)
}
}) })
}) })
} }
......
...@@ -5,8 +5,11 @@ import { ...@@ -5,8 +5,11 @@ import {
} from '@ant-design/pro-layout' } from '@ant-design/pro-layout'
import SelectLang from '@/layouts/components/SelectLang' import SelectLang from '@/layouts/components/SelectLang'
import { useIntl } from 'umi' import { useIntl } from 'umi'
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 { GetTemplateChannelFindChannelResponse } from '@/services/TemplateApi'
import ChannelHeader from '../components/ChannelHeader' import ChannelHeader from '../components/ChannelHeader'
import MainNav from '../components/MainNav' import MainNav from '../components/MainNav'
import SideNav from '../components/SideNav' import SideNav from '../components/SideNav'
...@@ -25,6 +28,9 @@ interface LXMallLayoutPropsType { ...@@ -25,6 +28,9 @@ interface LXMallLayoutPropsType {
const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => { const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const { children, location } = props const { children, location } = props
const [templateName] = useState<string>('theme-channel-science') const [templateName] = useState<string>('theme-channel-science')
const { id } = location.query
const [shopInfo, setShopInfo] = useState<GetTemplateChannelFindChannelResponse>()
const [query, setQuery] = useState<any>({})
const getMenuRouter = (routes: any, pathname: any) => { const getMenuRouter = (routes: any, pathname: any) => {
let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1) let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
...@@ -36,10 +42,34 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -36,10 +42,34 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const menuRouter = getMenuRouter(menuData, location.pathname) const menuRouter = getMenuRouter(menuData, location.pathname)
useEffect(() => { useEffect(() => {
let body = document.getElementsByTagName('body')[0] let queryParam = id ? atob(id) : undefined
body.className = templateName queryParam = queryParam ? JSON.parse(queryParam) : {}
setQuery(queryParam)
}, []) }, [])
useEffect(() => {
if (query.memberId) {
fetchShopInfo(query.memberId)
}
}, [query])
const fetchShopInfo = (memberId) => {
//@ts-ignore
PublicApi.getTemplateChannelFindChannel({ memberId }).then(res => {
if (res.code === 1000) {
setShopInfo(res.data)
}
})
}
useEffect(() => {
if (shopInfo) {
let body = document.getElementsByTagName('body')[0];
body.className = shopInfo.fileName ? `theme-shop-${shopInfo.fileName}` : templateName;
}
}, [shopInfo])
return ( return (
<div className={styles.lxmall_page}> <div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} /> <TopBar langComponent={<SelectLang />} />
...@@ -48,7 +78,7 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -48,7 +78,7 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
!menuRouter?.hideHeader && ( !menuRouter?.hideHeader && (
<> <>
<ChannelHeader /> <ChannelHeader />
<MainNav menuData={menuData} pathname={location.pathname} type="channel" /> <MainNav menuData={menuData} pathname={location.pathname} type={LAYOUT_TYPE.channel} shopId={query.shopId} shopUrlParam={id} />
</> </>
) )
} }
...@@ -56,7 +86,11 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -56,7 +86,11 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
children && React.Children.map(children, (child: any) => { children && React.Children.map(children, (child: any) => {
return React.cloneElement(child, return React.cloneElement(child,
{ {
layoutType: 'channel' layoutType: 'channel',
shopId: query.shopId,
memberId: query.memberId,
shopUrlParam: id,
shopInfo
}, },
); );
}) })
......
...@@ -6,11 +6,13 @@ import { ...@@ -6,11 +6,13 @@ import {
import SelectLang from '@/layouts/components/SelectLang' import SelectLang from '@/layouts/components/SelectLang'
import { useIntl } from 'umi' import { useIntl } from 'umi'
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import { LAYOUT_TYPE } from '@/constants'
import TopBar from '../components/TopBar' import TopBar from '../components/TopBar'
import Header from '../components/Header' import Header from '../components/Header'
import MainNav from '../components/MainNav' import MainNav from '../components/MainNav'
import SideNav from '../components/SideNav' import SideNav from '../components/SideNav'
import Footer from '../components/Footer' import Footer from '../components/Footer'
import isEmpty from 'lodash/isEmpty'
import styles from './index.less' import styles from './index.less'
interface LXMallLayoutPropsType { interface LXMallLayoutPropsType {
...@@ -25,7 +27,9 @@ interface LXMallLayoutPropsType { ...@@ -25,7 +27,9 @@ 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 } = props.SiteStore const { siteId, mallTemplateInfo, findUseMallTemplate } = props.SiteStore
const getMenuRouter = (routes: any, pathname: any) => { const getMenuRouter = (routes: any, pathname: any) => {
let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1) let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
...@@ -37,10 +41,18 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -37,10 +41,18 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const menuRouter = getMenuRouter(menuData, location.pathname) const menuRouter = getMenuRouter(menuData, location.pathname)
useEffect(() => { useEffect(() => {
let body = document.getElementsByTagName('body')[0]; if (isEmpty(mallTemplateInfo)) {
body.className = templateName; findUseMallTemplate()
}
}, []) }, [])
useEffect(() => {
if (!isEmpty(mallTemplateInfo)) {
let body = document.getElementsByTagName('body')[0];
body.className = mallTemplateInfo.fileName ? `theme-mall-${mallTemplateInfo.fileName}` : templateName;
}
}, [mallTemplateInfo])
return ( return (
<div className={styles.lxmall_page}> <div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} /> <TopBar langComponent={<SelectLang />} />
...@@ -49,7 +61,7 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -49,7 +61,7 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
!menuRouter?.hideHeader && ( !menuRouter?.hideHeader && (
<> <>
<Header /> <Header />
<MainNav menuData={menuData} pathname={location.pathname} type="mall" /> <MainNav menuData={menuData} pathname={location.pathname} type={LAYOUT_TYPE.mall} />
</> </>
) )
} }
...@@ -57,7 +69,7 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -57,7 +69,7 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
children && React.Children.map(children, (child: any) => { children && React.Children.map(children, (child: any) => {
return React.cloneElement(child, return React.cloneElement(child,
{ {
layoutType: 'mall' layoutType: 'mall',
}, },
); );
}) })
......
...@@ -41,16 +41,12 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -41,16 +41,12 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
let queryParam = shopId ? atob(shopId) : undefined let queryParam = shopId ? atob(shopId) : undefined
queryParam = queryParam ? JSON.parse(queryParam) : {} queryParam = queryParam ? JSON.parse(queryParam) : {}
setQuery(queryParam) setQuery(queryParam)
let body = document.getElementsByTagName('body')[0];
body.className = templateName;
}, []) }, [])
useEffect(() => { useEffect(() => {
if (query.memberId) { if (query.memberId) {
console.log()
fetchShopInfo(query.memberId) fetchShopInfo(query.memberId)
} }
}, [query]) }, [query])
const fetchShopInfo = (memberId) => { const fetchShopInfo = (memberId) => {
...@@ -62,6 +58,13 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -62,6 +58,13 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
}) })
} }
useEffect(() => {
if (shopInfo) {
let body = document.getElementsByTagName('body')[0];
body.className = shopInfo.fileName ? `theme-shop-${shopInfo.fileName}` : templateName;
}
}, [shopInfo])
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const basicInfo = getMenuData(props.route.routes, { locale: true }, formatMessage) const basicInfo = getMenuData(props.route.routes, { locale: true }, formatMessage)
const menuData = basicInfo.menuData ? basicInfo.menuData.filter(item => !item.redirect) : [] const menuData = basicInfo.menuData ? basicInfo.menuData.filter(item => !item.redirect) : []
......
...@@ -8,7 +8,7 @@ import CitySelect from '@/components/CitySelect' ...@@ -8,7 +8,7 @@ import CitySelect from '@/components/CitySelect'
import RequireItem from '@/components/RequireItem' import RequireItem from '@/components/RequireItem'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import UploadImage from '@/components/UploadImage' import UploadImage from '@/components/UploadImage'
import { MALL_TYPE } from '@/constants' import { GetTemplateShopFindShopResponse } from '@/services/TemplateApi'
import copy from 'copy-to-clipboard' import copy from 'copy-to-clipboard'
import cx from 'classnames' import cx from 'classnames'
import styles from './index.less' import styles from './index.less'
...@@ -33,6 +33,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -33,6 +33,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片 const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片
const [honorPics, setHonorPics] = useState([]) // 资质荣誉 const [honorPics, setHonorPics] = useState([]) // 资质荣誉
const [logo, setLogo] = useState<string>("") const [logo, setLogo] = useState<string>("")
const [shopInfo, setShopInfo] = useState<GetTemplateShopFindShopResponse>()
const [shopId, setShopId] = useState<number>() const [shopId, setShopId] = useState<number>()
useEffect(() => { useEffect(() => {
...@@ -61,6 +62,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -61,6 +62,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
PublicApi.getTemplateShopFindShop().then(res => { PublicApi.getTemplateShopFindShop().then(res => {
const data = res.data const data = res.data
if (res.code === 1000) { if (res.code === 1000) {
setShopInfo(data)
setSelectCityData(initMemberShopArea(data.memberShopAreas)) setSelectCityData(initMemberShopArea(data.memberShopAreas))
setLogo(data.logo) setLogo(data.logo)
setShopId(data.shopId) setShopId(data.shopId)
...@@ -210,11 +212,10 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -210,11 +212,10 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
let selectItem = allMallList.filter(item => item.id === mallId) let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId) setShopId(mallId)
if (mallId) { if (mallId) {
setStoreUrl(`${siteUrl}/${selectItem[0].url}?id=${1}`) setStoreUrl(`${siteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`)
} else { } else {
setStoreUrl(null) setStoreUrl(null)
} }
} }
const handleFormValueChange = () => { const handleFormValueChange = () => {
...@@ -334,7 +335,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -334,7 +335,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}> <Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
{ {
allMallList.map(item => ( allMallList.map(item => (
<Select.Option key={item.id} value={item.id}>{MALL_TYPE[item.type]}</Select.Option> <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
)) ))
} }
</Select> </Select>
......
...@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => { ...@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => {
<Row gutter={24} className={styles.template_list}> <Row gutter={24} className={styles.template_list}>
{ {
templateList.map(item => ( templateList.map(item => (
<Col span={6} key={item.id}> <Col xxl={6} xl={8} lg={12} key={item.id}>
<TemplateItem templateInfo={item} type="shop" /> <TemplateItem templateInfo={item} type="shop" />
</Col> </Col>
)) ))
......
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 { PublicApi } from '@/services/api'
class SiteStore implements ISiteModule { class SiteStore implements ISiteModule {
// 可在根目录下的demo.js修改数据 // 可在根目录下的demo.js修改数据
@observable public siteId: number = GlobalConfig.global.siteId; // 站点id @observable public siteId: number = GlobalConfig.global.siteId; // 站点id
@observable public siteUrl: string = GlobalConfig.global.siteUrl; // 站点域名 @observable public siteUrl: string = GlobalConfig.global.siteUrl; // 站点域名
@observable public mallTemplateId: number = 852; // 企业商城模板id @observable public mallTemplateId: number = null; // 企业商城模板id
@observable public mallTemplateInfo: any = {}; // 企业商城模板id
@observable public shopTemplateId: number = 708; // 店铺模板id @observable public shopTemplateId: number = 708; // 店铺模板id
@observable public channelTemplateId: number = 903; // 渠道模板id @observable public channelTemplateId: number = 903; // 渠道模板id
@observable public commodityTemplateInfo: any = {}
/**
* 根据站点查询正在使用的商城模板
*/
@action.bound
public findUseMallTemplate = async () => {
const tempMallTemplateInfo = sessionStorage.getItem("mallTemplateInfo")
if (tempMallTemplateInfo) {
this.mallTemplateInfo = JSON.parse(tempMallTemplateInfo)
this.mallTemplateId = this.mallTemplateInfo.id
return
}
//@ts-ignore
const res = await PublicApi.getTemplatePlatformFindUseTemplateBySite({ siteId: this.siteId })
runInAction(() => {
this.mallTemplateInfo = res.data
this.mallTemplateId = this.mallTemplateInfo.id
sessionStorage.setItem("mallTemplateInfo", JSON.stringify(this.mallTemplateInfo))
})
}
/**
* 根据站点查询正在使用的商品描述模板
*/
@action.bound
public findUseGoodsTemplate = async () => {
const tempCommodityTemplateInfo = sessionStorage.getItem("commodityTemplateInfo")
if (tempCommodityTemplateInfo) {
this.commodityTemplateInfo = JSON.parse(tempCommodityTemplateInfo)
return
}
//@ts-ignore
const res = await PublicApi.getTemplateGoodsFindUseGoodsTemplate({ siteId: this.siteId })
runInAction(() => {
this.commodityTemplateInfo = res.data
sessionStorage.setItem("commodityTemplateInfo", JSON.stringify(this.commodityTemplateInfo))
})
}
} }
export default SiteStore export default SiteStore
...@@ -5,7 +5,7 @@ const tokenList = [ ...@@ -5,7 +5,7 @@ const tokenList = [
{ name: 'Member', token: 'c0e920f071595a73ba234b6fa6cfe42192d3d740d59f030caa2c7f0f08777d78' }, // 商户会员管理服务 { name: 'Member', token: 'c0e920f071595a73ba234b6fa6cfe42192d3d740d59f030caa2c7f0f08777d78' }, // 商户会员管理服务
{ name: 'Product', token: 'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4' }, // 商品服务 { name: 'Product', token: 'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4' }, // 商品服务
{ name: 'Template', token: '7ec923520215c7e2f771867cb4d29cafbf823daf0fb2d3d9fa70b57a523c8bfb' }, // 店铺模板服务 { name: 'Template', token: '7ec923520215c7e2f771867cb4d29cafbf823daf0fb2d3d9fa70b57a523c8bfb' }, // 店铺模板服务
{ name: 'Pay', token: 'c789e0e56ee8a8cc2fbd85f930eb2928c58fc1014583c6643acf29cff954da49' }, // 支付服务 { name: 'Pay', token: '34608cd33222b1650795459d73b8eb0b260eb92cf5e8d1e646f85a4875e36f05' }, // 支付服务
{ name: 'Search', token: 'ca19f532efba91f7773cbfbd526b798c6ac83df670071e97d72c50dca1d53a48' }, // 搜索服务 { name: 'Search', token: 'ca19f532efba91f7773cbfbd526b798c6ac83df670071e97d72c50dca1d53a48' }, // 搜索服务
{ name: 'Order', token: '5de0aaeaac12c8d911d86dada6cd128993e34cd6e13135fa79246aa5979a2bcd' }, //订单服务 { name: 'Order', token: '5de0aaeaac12c8d911d86dada6cd128993e34cd6e13135fa79246aa5979a2bcd' }, //订单服务
// { name: '', token: 'c0e920f071595a73ba234b6fa6cfe42192d3d740d59f030caa2c7f0f08777d78' } // 商户会员管理服务 // { name: '', token: 'c0e920f071595a73ba234b6fa6cfe42192d3d740d59f030caa2c7f0f08777d78' } // 商户会员管理服务
......
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