Commit 46c60caa authored by GuanHua's avatar GuanHua

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

parent e9fec2f9
......@@ -55,7 +55,7 @@ const serviceConfig = {
// // }
// }
}
}
// 批量组装接口
......@@ -82,7 +82,7 @@ async function batchAxiosHttps() {
const serverErrorQueue = []
console.log('\n')
for (const item in serviceConfig) {
if(JSON.stringify(item) !== '{}'){
if (JSON.stringify(item) !== '{}') {
for (const subItem in serviceConfig[item]) {
try {
const data = await axios(serviceConfig[item][subItem])
......@@ -90,12 +90,12 @@ async function batchAxiosHttps() {
if (data.data.code === 1000) {
asyncHttpQueue[item][subItem] = data.data.data
} else {
serverErrorQueue.push({ ...asyncHttpQueue[item][subItem], ...data.data})
serverErrorQueue.push({ ...asyncHttpQueue[item][subItem], ...data.data })
// 默认置为null
asyncHttpQueue[item][subItem] = null
}
} catch(err) {
httpErrorQueue.push({...serviceConfig[item][subItem], ...err.response.data})
} catch (err) {
httpErrorQueue.push({ ...serviceConfig[item][subItem], ...err.response.data })
}
}
}
......
......@@ -12,6 +12,7 @@ import { MALL_TYPE } from '@/constants'
import copy from 'copy-to-clipboard'
import cx from 'classnames'
import styles from './index.less'
import { GetTemplateChannelFindChannelResponse } from '@/services/TemplateApi'
import { isEmpty } from '@formily/antd/esm/shared'
interface ShopInfoPropsType {
......@@ -34,6 +35,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片
const [honorPics, setHonorPics] = useState([]) // 资质荣誉
const [logo, setLogo] = useState<string>("")
const [shopInfo, setShopInfo] = useState<GetTemplateChannelFindChannelResponse>()
const [shopId, setShopId] = useState<number>()
useEffect(() => {
......@@ -58,6 +60,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
PublicApi.getTemplateChannelFindChannel().then(res => {
const data = res.data
if (res.code === 1000) {
setShopInfo(data)
setSelectCityData(initMemberShopArea(data.memberChannelAreas))
setLogo(data.logo)
setShopId(data.shopId)
......@@ -209,11 +212,11 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(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 {
setStoreUrl(null)
}
}
const handleFormValueChange = () => {
......@@ -333,7 +336,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
{
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>
......@@ -346,7 +349,6 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
</div>
)
}
</Form.Item>
<Form.Item
labelAlign="left"
......
......@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => {
<Row gutter={24} className={styles.template_list}>
{
templateList.map(item => (
<Col span={6} key={item.id}>
<Col xxl={6} xl={8} lg={12} key={item.id}>
<TemplateItem templateInfo={item} type="shop" />
</Col>
))
......
import React from 'react'
import React, { useEffect } from 'react'
import { ScienceTemplate } from './template'
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'
interface IntroductionPropsType {
......@@ -9,88 +12,20 @@ interface IntroductionPropsType {
const Introduction: React.FC<IntroductionPropsType> = (props) => {
const { commodityDetail } = props
const SiteStore = useLocalStore(() => store.SiteStore)
const { commodityTemplateInfo, findUseGoodsTemplate } = SiteStore
const data = [
{
label: '主要用途',
value: '皮鞋、皮带、箱包、其他用途'
},
{
label: '皮层',
value: '二层'
},
{
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: '无'
},
]
useEffect(() => {
if (isEmpty(commodityTemplateInfo)) {
findUseGoodsTemplate()
}
}, [])
useEffect(() => {
}, [commodityTemplateInfo])
const renderIntroduction = () => {
let templateName = 'science'
let templateName = commodityTemplateInfo.fileName || 'science'
switch (templateName) {
case 'science':
return <ScienceTemplate />
......@@ -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'
import BrowseRecords from './components/BrowseRecords'
import Interested from './components/Interested'
import ShopInfo from './components/ShopInfo'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import ProductDescription from './components/ProductDescription'
import InputNumber from '@/components/InputNumber'
import { PublicApi } from '@/services/api'
......@@ -71,11 +73,23 @@ const CommodityDetail = (props) => {
if (res.code === 1000) {
setCommodityDetail(res.data)
initAttributeAndValueList(res.data?.unitPriceAndPicList)
getPayWayListByMemberId(res.data?.memberId)
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) => {
let param = {
parentMemberId: memberId,
......@@ -158,7 +172,12 @@ const CommodityDetail = (props) => {
message.info("请选择商品属性")
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 = () => {
......@@ -486,4 +505,4 @@ const CommodityDetail = (props) => {
)
}
export default CommodityDetail
export default observer(CommodityDetail)
......@@ -23,14 +23,15 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const { fetchCategoryList, categoryList } = props.CategoryStore
useEffect(() => {
console.log(type, "type")
let getCategoryFn
let params: any = {}
switch (type) {
case LAYOUT_TYPE.mall:
params.templateId = mallTemplateId
getCategoryFn = PublicApi.getTemplatePlatformFindAllCategoryTree
fetchCategoryList(getCategoryFn, params, type)
if (mallTemplateId) {
params.templateId = mallTemplateId
getCategoryFn = PublicApi.getTemplatePlatformFindAllCategoryTree
fetchCategoryList(getCategoryFn, params, type)
}
break
case LAYOUT_TYPE.shop:
if (shopId) {
......@@ -46,7 +47,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
break
}
}, [props])
}, [props, mallTemplateId])
return (
<div className={styles.category}>
......
......@@ -16,6 +16,17 @@ interface MainNavPropsType {
const MainNav: React.FC<MainNavPropsType> = (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 (
<div className={cx(styles.main_nav, type === LAYOUT_TYPE.shop ? styles.shop : "")}>
<div className={styles.main_nav_container}>
......@@ -24,7 +35,7 @@ const MainNav: React.FC<MainNavPropsType> = (props) => {
{
menuData && menuData.map(item => !item.hide && (
<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>
))
}
......
......@@ -71,6 +71,7 @@
flex: 1;
display: flex;
align-items: center;
margin-right: 8px;
&>span {
font-size: 14px;
......
......@@ -80,7 +80,9 @@ const MallIndex: React.FC<MallIndexPropsType> = (props) => {
// @ts-ignore
PublicApi.getTemplatePlatformFindFirstCategoryDetail(param).then(res => {
resolve(res.data)
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
......
......@@ -5,8 +5,11 @@ import {
} from '@ant-design/pro-layout'
import SelectLang from '@/layouts/components/SelectLang'
import { useIntl } from 'umi'
import { LAYOUT_TYPE } from "@/constants"
import { inject, observer } from 'mobx-react'
import TopBar from '../components/TopBar'
import { PublicApi } from '@/services/api'
import { GetTemplateChannelFindChannelResponse } from '@/services/TemplateApi'
import ChannelHeader from '../components/ChannelHeader'
import MainNav from '../components/MainNav'
import SideNav from '../components/SideNav'
......@@ -25,6 +28,9 @@ interface LXMallLayoutPropsType {
const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const { children, location } = props
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) => {
let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
......@@ -36,10 +42,34 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const menuRouter = getMenuRouter(menuData, location.pathname)
useEffect(() => {
let body = document.getElementsByTagName('body')[0]
body.className = templateName
let queryParam = id ? atob(id) : undefined
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 (
<div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} />
......@@ -48,7 +78,7 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
!menuRouter?.hideHeader && (
<>
<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) => {
children && React.Children.map(children, (child: any) => {
return React.cloneElement(child,
{
layoutType: 'channel'
layoutType: 'channel',
shopId: query.shopId,
memberId: query.memberId,
shopUrlParam: id,
shopInfo
},
);
})
......
......@@ -6,11 +6,13 @@ import {
import SelectLang from '@/layouts/components/SelectLang'
import { useIntl } from 'umi'
import { inject, observer } from 'mobx-react'
import { LAYOUT_TYPE } from '@/constants'
import TopBar from '../components/TopBar'
import Header from '../components/Header'
import MainNav from '../components/MainNav'
import SideNav from '../components/SideNav'
import Footer from '../components/Footer'
import isEmpty from 'lodash/isEmpty'
import styles from './index.less'
interface LXMallLayoutPropsType {
......@@ -25,7 +27,9 @@ interface LXMallLayoutPropsType {
const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const { children, location } = props
const [templateName] = useState<string>('theme-mall-science')
const { siteId } = props.SiteStore
const { siteId, mallTemplateInfo, findUseMallTemplate } = props.SiteStore
const getMenuRouter = (routes: any, pathname: any) => {
let list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
......@@ -37,10 +41,18 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const menuRouter = getMenuRouter(menuData, location.pathname)
useEffect(() => {
let body = document.getElementsByTagName('body')[0];
body.className = templateName;
if (isEmpty(mallTemplateInfo)) {
findUseMallTemplate()
}
}, [])
useEffect(() => {
if (!isEmpty(mallTemplateInfo)) {
let body = document.getElementsByTagName('body')[0];
body.className = mallTemplateInfo.fileName ? `theme-mall-${mallTemplateInfo.fileName}` : templateName;
}
}, [mallTemplateInfo])
return (
<div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} />
......@@ -49,7 +61,7 @@ const LXMallLayout: React.FC<LXMallLayoutPropsType> = (props) => {
!menuRouter?.hideHeader && (
<>
<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) => {
children && React.Children.map(children, (child: any) => {
return React.cloneElement(child,
{
layoutType: 'mall'
layoutType: 'mall',
},
);
})
......
......@@ -41,16 +41,12 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
let queryParam = shopId ? atob(shopId) : undefined
queryParam = queryParam ? JSON.parse(queryParam) : {}
setQuery(queryParam)
let body = document.getElementsByTagName('body')[0];
body.className = templateName;
}, [])
useEffect(() => {
if (query.memberId) {
console.log()
fetchShopInfo(query.memberId)
}
}, [query])
const fetchShopInfo = (memberId) => {
......@@ -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 basicInfo = getMenuData(props.route.routes, { locale: true }, formatMessage)
const menuData = basicInfo.menuData ? basicInfo.menuData.filter(item => !item.redirect) : []
......
......@@ -8,7 +8,7 @@ import CitySelect from '@/components/CitySelect'
import RequireItem from '@/components/RequireItem'
import { PublicApi } from '@/services/api'
import UploadImage from '@/components/UploadImage'
import { MALL_TYPE } from '@/constants'
import { GetTemplateShopFindShopResponse } from '@/services/TemplateApi'
import copy from 'copy-to-clipboard'
import cx from 'classnames'
import styles from './index.less'
......@@ -33,6 +33,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片
const [honorPics, setHonorPics] = useState([]) // 资质荣誉
const [logo, setLogo] = useState<string>("")
const [shopInfo, setShopInfo] = useState<GetTemplateShopFindShopResponse>()
const [shopId, setShopId] = useState<number>()
useEffect(() => {
......@@ -61,6 +62,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
PublicApi.getTemplateShopFindShop().then(res => {
const data = res.data
if (res.code === 1000) {
setShopInfo(data)
setSelectCityData(initMemberShopArea(data.memberShopAreas))
setLogo(data.logo)
setShopId(data.shopId)
......@@ -210,11 +212,10 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId)
if (mallId) {
setStoreUrl(`${siteUrl}/${selectItem[0].url}?id=${1}`)
setStoreUrl(`${siteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`)
} else {
setStoreUrl(null)
}
}
const handleFormValueChange = () => {
......@@ -334,7 +335,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
{
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>
......
......@@ -35,7 +35,7 @@ const ShopTemplate: React.FC = () => {
<Row gutter={24} className={styles.template_list}>
{
templateList.map(item => (
<Col span={6} key={item.id}>
<Col xxl={6} xl={8} lg={12} key={item.id}>
<TemplateItem templateInfo={item} type="shop" />
</Col>
))
......
import { action, computed, observable, runInAction } from 'mobx'
import { ISiteModule } from '@/module/siteModule';
import { GlobalConfig } from '@/global/config';
import { ISiteModule } from '@/module/siteModule'
import { GlobalConfig } from '@/global/config'
import { PublicApi } from '@/services/api'
class SiteStore implements ISiteModule {
// 可在根目录下的demo.js修改数据
@observable public siteId: number = GlobalConfig.global.siteId; // 站点id
@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 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
......@@ -5,7 +5,7 @@ const tokenList = [
{ name: 'Member', token: 'c0e920f071595a73ba234b6fa6cfe42192d3d740d59f030caa2c7f0f08777d78' }, // 商户会员管理服务
{ name: 'Product', token: 'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4' }, // 商品服务
{ name: 'Template', token: '7ec923520215c7e2f771867cb4d29cafbf823daf0fb2d3d9fa70b57a523c8bfb' }, // 店铺模板服务
{ name: 'Pay', token: 'c789e0e56ee8a8cc2fbd85f930eb2928c58fc1014583c6643acf29cff954da49' }, // 支付服务
{ name: 'Pay', token: '34608cd33222b1650795459d73b8eb0b260eb92cf5e8d1e646f85a4875e36f05' }, // 支付服务
{ name: 'Search', token: 'ca19f532efba91f7773cbfbd526b798c6ac83df670071e97d72c50dca1d53a48' }, // 搜索服务
{ name: 'Order', token: '5de0aaeaac12c8d911d86dada6cd128993e34cd6e13135fa79246aa5979a2bcd' }, //订单服务
// { 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