Commit ec6f8b6b authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

Merge branch 'dev-srm' of http://10.0.0.22:3000/lingxi/lingxi-business-system into dev-srm

parents 87050f23 f544eff1
......@@ -43,6 +43,7 @@ export const ORDER_TYPE = ['',
]
export enum TEMPLATE_TYPE {
platform = 0,
mall = 1,
shop = 2,
goods = 3,
......
export const mallLayoutConfig = {
key: "0",
"0": {
"componentName": "MallLayout",
"props": {
"style": {
"width": "100%",
"minHeight": "100%"
}
},
"childNodes": ["1", "3", "4", "21"]
},
}
export const topBarConfig = {
key: "1",
"1": {
"componentName": "TopBar",
"props": {
linkdisable: true
},
}
}
export const topAdvertConfig = {
key: "2",
"2": {
"componentName": "Advert",
"props": {
"type": "top",
"linkdisable": true,
"advertList": []
},
},
}
export const headerConfig = {
key: "3",
"3": {
"componentName": "Header",
"props": {
"logoUrl": ""
},
},
}
export const mainNavConfig = {
key: "4",
"4": {
"componentName": "MallMainNav",
"props": {},
},
}
// < div className = { styles.horizontalWrap } >
// <Category categoryList={ categoryList } />
// < div className = { styles.bannerWrap } >
// {
// useMemo(() => <Advert type="banner" advertList = { firstAdvertList } />, [firstAdvertList])
// }
// {
// useMemo(() => <Advert type="interact" advertList = { secondAdvertList } />, [secondAdvertList])
// }
// </div>
// < div className = { styles.quickNavWrap } >
// <QuickNav
// userInfo={ userInfo }
// userRoles = { userRoles }
// name = { mallInfo?.name }
// advertList = { secondAdvertList }
// />
// </div>
// < /div>
export const bannerContainer = {
key: "21",
"21": {
"componentName": "div",
"props": {
"style": {
position: "relative",
display: "flex",
paddingTop: "16px",
width: "1200px",
margin: "0 auto",
}
},
"childNodes": ["22", "23", "24"]
}
}
export const categoryConfig = {
key: "22",
"22": {
"componentName": "Category",
"props": {
categoryList: [],
canHide: false,
}
}
}
export const bannerWrap = {
key: "23",
"23": {
"componentName": "div",
"props": {
"style": {
margin: "0 16px",
flex: 1,
width: 0,
}
},
"childNodes": ["5", "6"]
}
}
export const quickNavConfigWrap = {
key: "24",
"24": {
"componentName": "div",
"props": {},
"childNodes": ["25", "26"]
}
}
export const quickNavConfig = {
key: "25",
"25": {
"componentName": "QuickNav",
"props": {},
}
}
export const navAdvertConfig = {
key: "26",
"26": {
"componentName": "Advert",
"props": {
"type": "nav",
"linkdisable": true,
"advertList": []
},
},
}
export const bannerAdvertConfig = {
key: "5",
"5": {
"componentName": "Advert",
"props": {
"type": "banner",
"hasQuickNav": false,
"linkdisable": true,
"advertList": []
}
},
}
export const interactAdvertConfig = {
key: "6",
"6": {
"componentName": "Advert",
"props": {
"type": "interact",
"linkdisable": true,
"advertList": []
},
},
}
export const FindMoreConfig = {
key: "18",
"18": {
"componentName": "FindMore",
"props": {},
},
}
export const InformationConfig = {
key: '19',
"19": {
"componentName": "Information",
"props": {},
},
}
export const FooterConfig = {
key: '20',
"20": {
"componentName": "Footer",
"props": {},
},
}
import { GlobalConfig } from '@/global/config'
const siteUrl = GlobalConfig.site.siteInfo.siteUrl
/**
* 请求头
*/
export const REQUEST_HEADER = 'http://'
export const getTopDomainByHost = (url: string): string => {
if (!url) return ''
return url.split('.').slice(-2).join('.')
}
export const TOP_DOMAIN = getTopDomainByHost(siteUrl)
export const getMenuData = (shopId: number) => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { id: number}) => item.id === shopId)
if (webMallList.length > 0) {
const SUB_DOMAIN = webMallList[0].url
return [
{
"id": 0,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}`,
"name": "商城首页",
"status": true,
"key": "shopHome",
},
{
"id": 1,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/commodity`,
"name": "现货商品",
"status": true,
"key": "shopCommodity",
},
{
"id": 2,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/inquiry`,
"name": "询价商品",
"status": true,
"key": "purchaseOnline",
},
{
"id": 3,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/stores`,
"name": "优选店铺",
"status": true,
"key": "shopPointsMall",
},
{
"id": 4,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/integral`,
"name": "积分商城",
"key": "shops",
"status": true,
},
{
"id": 5,
"link": `${REQUEST_HEADER}info.${TOP_DOMAIN}`,
"name": "行情资讯",
"status": true,
"key": "shopInfomation",
},
]
}
return []
}
@content-height: calc(100vh - 120px);
.wrapper {
background: white;
display: flex;
flex-direction: column;
box-shadow: 2px 0 4px 0 rgba(174, 174, 174, 0.50);
transition: all .3s;
}
.content {
display: flex;
flex: 1;
flex-direction: row;
}
.canvas-container {
display: flex;
flex: 1;
justify-content: center;
background-color: #F4F5F7;
height: calc(@content-height + 50px);
overflow: hidden;
}
\ No newline at end of file
import React, { useEffect, useState } from 'react'
import { LegoProvider } from 'lingxi-editor-core'
import ToolBar from '../components/toolBar'
import DesignPanel from '../components/DesignPanel'
import SettingPanel from '../settingsPanel'
import config from '../configs'
import { Prompt } from 'umi'
import { GlobalConfig } from '@/global/config'
import { topBarConfig, topAdvertConfig, headerConfig, mainNavConfig, bannerContainer, quickNavConfigWrap, categoryConfig, bannerWrap, quickNavConfig, bannerAdvertConfig, interactAdvertConfig, navAdvertConfig, mallLayoutConfig, InformationConfig, FooterConfig } from './defaultData'
import Loading from '../components/Loading'
import { LAYOUT_TYPE } from '@/constants'
import { getMenuData } from './defaultMenu'
import { PublicApi } from '@/services/api'
import styles from './index.less'
import { isEmpty } from 'lodash'
interface MallEditPropsType {
location: {
query: {
/**
* 模板id
*/
id: number;
/**
* 模板名称
*/
template: string;
shopId: number;
}
}
}
const TemplateList = ['science']
const MallEdit: React.FC<MallEditPropsType> = (props) => {
const { query: { id, template, shopId } } = props.location
const [loading, setLoading] = useState<boolean>(true)
const [theme, setTheme] = useState<string>('theme-mall-science')
const [componentConfigs, setComponentConfigs] = useState({})
useEffect(() => {
if (!TemplateList.includes(template)) {
setTheme(`theme-mall-${TemplateList[0]}`)
} else {
setTheme(`theme-mall-${template}`)
}
getComponentsConfig()
}, [])
const findAdvertsByType = (type: number) => {
return new Promise((resolve) => {
const params: any = {
templateId: id,
type
}
PublicApi.getTemplateAdornWebEnterpriseFindAdvertsByType(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
} else {
resolve([])
}
})
})
}
/**
* 获取所有一级品类信息
*/
const fetchFirstCategory = () => {
return new Promise((resolve) => {
PublicApi.getTemplateWebCategoryWebFindAllFirstCategory().then(res => {
if (res.code === 1000) {
resolve(res.data)
} else {
resolve([])
}
})
})
}
/**
* 获取一级品类详细信息
*/
const fetchCategoryById = (categoryId) => {
return new Promise((resolve) => {
const param: any = {
templateId: id,
categoryId
}
PublicApi.getTemplateAdornWebEnterpriseCategoryAdorn(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const fetchNewByLabel = (label: string) => {
// 1-头条文章 2-轮播新闻 3-图片新闻 4-推荐阅读
return new Promise((resolve, reject) => {
PublicApi.getManageContentInformationFindAllByRecommendLabel({ recommendLabel: label }).then((res: { code: number; data: unknown }) => {
if (res.code === 1000) {
resolve(res.data)
} else {
reject()
}
}).catch(() => {
reject()
})
})
}
/**
* 获取商品品类树
*/
const getCategoryTree = () => {
return new Promise((resolve) => {
const param: any = {
templateId: id
}
PublicApi.getTemplateWebCategoryWebFindEnterpriseCategoryTree(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
/**
* 获取导航栏菜单数据
*/
const getMallNavData = () => {
return new Promise((resolve) => {
const param: any = {
templateId: id
}
PublicApi.getTemplateAdornWebEnterpriseFindColumn(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const getComponentsConfig = async () => {
// 导航栏
const navData = await getMallNavData()
if(!isEmpty(navData)) {
mainNavConfig[mainNavConfig.key].props.menuData = navData
} else {
mainNavConfig[mainNavConfig.key].props.menuData = getMenuData(Number(shopId))
}
// mainNavConfig[mainNavConfig.key].props.type = LAYOUT_TYPE.mall
// mainNavConfig[mainNavConfig.key].props.categoryList = []
categoryConfig[categoryConfig.key].props.categoryList = await getCategoryTree()
// 一号位广告
bannerAdvertConfig[bannerAdvertConfig.key].props.advertList = await findAdvertsByType(1)
// 二号位广告
interactAdvertConfig[interactAdvertConfig.key].props.advertList = await findAdvertsByType(2)
// 三号位广告
navAdvertConfig[navAdvertConfig.key].props.advertList = await findAdvertsByType(4)
const shopList = GlobalConfig.web.shopInfo
const webMallInfo = shopList.filter(item => item.environment === 1 && item.type === 1)[0]
headerConfig[headerConfig.key].props.logoUrl = webMallInfo.logoUrl
topBarConfig[topBarConfig.key].props.shopname = webMallInfo.name
// 行情资讯
InformationConfig[InformationConfig.key].props.newsList = await fetchNewByLabel('4')
let initIndex = 100
let floorLineConfig: any = {}
const floorLineKeys: any = []
const firstCategory: any = await fetchFirstCategory()
for (const item of firstCategory) {
const categoryDetail: any = await fetchCategoryById(item.categoryId)
let floorLineConfigItem = {}
floorLineKeys.push(String(initIndex + 1))
const FloorLine = {
[String(initIndex + 1)]: {
"componentName": "FloorLine",
"props": {
title: item.name
},
"childNodes": [String(initIndex + 2), String(initIndex + 3)]
}
}
const Horizontal1 = {
[String(initIndex + 2)]: {
"componentName": "FloorLine.Horizontal",
"props": {},
"childNodes": [String(initIndex + 4), String(initIndex + 5)]
},
}
const Brand = {
[String(initIndex + 3)]: {
"componentName": "FloorLine.Brand",
"props": {
linkdisable: true,
categoryid: item.id,
brandList: categoryDetail.brandBOList
},
},
}
const Category = {
[String(initIndex + 4)]: {
"componentName": "FloorLine.Category",
"props": {
linkdisable: true,
categoryid: item.id,
categoryAdvertPicUrl: categoryDetail.categoryAdvertPicUrl,
secondCategoryList: categoryDetail.categoryBOList,
},
},
}
const Vertical1 = {
[String(initIndex + 5)]: {
"componentName": "FloorLine.Vertical",
"props": {},
"childNodes": [String(initIndex + 6), String(initIndex + 8)]
},
}
const FloorHeader = {
[String(initIndex + 6)]: {
"componentName": "FloorLine.FloorHeader",
"props": {
linkdisable: true,
shopNum: categoryDetail.shopNum,
goodsNum: categoryDetail.goodsNum
},
"childNodes": [String(initIndex + 7)]
},
}
const Banner = {
[String(initIndex + 7)]: {
"componentName": "FloorLine.Banner",
"props": {
"type": "category",
linkdisable: true,
categoryid: item.id,
advertList: categoryDetail.thirdAdvertList
},
},
}
const Horizontal2 = {
[String(initIndex + 8)]: {
"componentName": "FloorLine.Horizontal",
"props": {},
"childNodes": [String(initIndex + 9), String(initIndex + 10)]
},
}
const Goods = {
[String(initIndex + 9)]: {
"componentName": "FloorLine.Goods",
"props": {
linkdisable: true,
goodsList: categoryDetail.goodsBOList,
categoryid: item.id,
},
},
}
const Shops = {
[String(initIndex + 10)]: {
"componentName": "FloorLine.Shops",
"props": {
linkdisable: true,
shopsList: categoryDetail.shopBOList,
categoryid: item.id,
},
},
}
floorLineConfigItem = { ...FloorLine, ...Horizontal1, ...Brand, ...Category, ...Vertical1, ...FloorHeader, ...Banner, ...Horizontal2, ...Goods, ...Shops }
floorLineConfig = { ...floorLineConfig, ...floorLineConfigItem }
initIndex += 100
}
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, InformationConfig.key, FooterConfig.key]
const config = {
...mallLayoutConfig,
...topBarConfig,
...topAdvertConfig,
...headerConfig,
...mainNavConfig,
...bannerContainer,
...categoryConfig,
...bannerWrap,
...quickNavConfigWrap,
...quickNavConfig,
...bannerAdvertConfig,
...interactAdvertConfig,
...navAdvertConfig,
...floorLineConfig,
...InformationConfig,
...FooterConfig
}
setComponentConfigs(config)
setLoading(false)
}
return !loading ? (
<LegoProvider initState={{ componentConfigs: componentConfigs }} config={config}>
<Prompt message="你确定要离开么?" />
<div className={styles['wrapper']}>
<ToolBar />
<div className={styles['content']}>
<div className={styles['canvas-container']}>
<DesignPanel theme={theme} />
</div>
</div>
</div>
<SettingPanel templateId={id} />
</LegoProvider>
) : <Loading />
}
export default MallEdit
export const mallLayoutConfig = {
key: "0",
"0": {
"componentName": "MallLayout",
"props": {
"style": {
"width": "100%",
"minHeight": "100%"
}
},
"childNodes": ["1", "3", "4", "21"]
},
}
export const topBarConfig = {
key: "1",
"1": {
"componentName": "TopBar",
"props": {
linkdisable: true
},
}
}
export const topAdvertConfig = {
key: "2",
"2": {
"componentName": "Advert",
"props": {
"type": "top",
"linkdisable": true,
"advertList": []
},
},
}
export const headerConfig = {
key: "3",
"3": {
"componentName": "Header",
"props": {
"logoUrl": ""
},
},
}
export const mainNavConfig = {
key: "4",
"4": {
"componentName": "MallMainNav",
"props": {},
},
}
// < div className = { styles.horizontalWrap } >
// <Category categoryList={ categoryList } />
// < div className = { styles.bannerWrap } >
// {
// useMemo(() => <Advert type="banner" advertList = { firstAdvertList } />, [firstAdvertList])
// }
// {
// useMemo(() => <Advert type="interact" advertList = { secondAdvertList } />, [secondAdvertList])
// }
// </div>
// < div className = { styles.quickNavWrap } >
// <QuickNav
// userInfo={ userInfo }
// userRoles = { userRoles }
// name = { mallInfo?.name }
// advertList = { secondAdvertList }
// />
// </div>
// < /div>
export const bannerContainer = {
key: "21",
"21": {
"componentName": "div",
"props": {
"style": {
position: "relative",
display: "flex",
paddingTop: "16px",
width: "1200px",
margin: "0 auto",
}
},
"childNodes": ["22", "23", "24"]
}
}
export const categoryConfig = {
key: "22",
"22": {
"componentName": "Category",
"props": {
categoryList: [],
canHide: false,
}
}
}
export const bannerWrap = {
key: "23",
"23": {
"componentName": "div",
"props": {
"style": {
margin: "0 16px",
flex: 1,
width: 0,
}
},
"childNodes": ["5", "6"]
}
}
export const quickNavConfigWrap = {
key: "24",
"24": {
"componentName": "div",
"props": {},
"childNodes": ["25", "26"]
}
}
export const quickNavConfig = {
key: "25",
"25": {
"componentName": "QuickNav",
"props": {},
}
}
export const navAdvertConfig = {
key: "26",
"26": {
"componentName": "Advert",
"props": {
"type": "nav",
"linkdisable": true,
"advertList": []
},
},
}
export const bannerAdvertConfig = {
key: "5",
"5": {
"componentName": "Advert",
"props": {
"type": "banner",
"hasQuickNav": false,
"linkdisable": true,
"advertList": []
}
},
}
export const interactAdvertConfig = {
key: "6",
"6": {
"componentName": "Advert",
"props": {
"type": "interact",
"linkdisable": true,
"advertList": []
},
},
}
export const FindMoreConfig = {
key: "18",
"18": {
"componentName": "FindMore",
"props": {},
},
}
export const InformationConfig = {
key: '19',
"19": {
"componentName": "Information",
"props": {},
},
}
export const FooterConfig = {
key: '20',
"20": {
"componentName": "Footer",
"props": {},
},
}
import { GlobalConfig } from '@/global/config'
const siteUrl = GlobalConfig.site.siteInfo.siteUrl
/**
* 请求头
*/
export const REQUEST_HEADER = 'http://'
export const getTopDomainByHost = (url: string): string => {
if (!url) return ''
return url.split('.').slice(-2).join('.')
}
export const TOP_DOMAIN = getTopDomainByHost(siteUrl)
export const getMenuData = (shopId: number) => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { id: number}) => item.id === shopId)
if (webMallList.length > 0) {
const SUB_DOMAIN = webMallList[0].url
return [
{
"id": 0,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}`,
"name": "商城首页",
"status": true,
"key": "shopHome",
},
{
"id": 1,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/commodity`,
"name": "现货商品",
"status": true,
"key": "shopCommodity",
},
{
"id": 2,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/inquiry`,
"name": "询价商品",
"status": true,
"key": "purchaseOnline",
},
{
"id": 3,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/stores`,
"name": "优选店铺",
"status": true,
"key": "shopPointsMall",
},
{
"id": 4,
"link": `${REQUEST_HEADER}${SUB_DOMAIN}.${TOP_DOMAIN}/integral`,
"name": "积分商城",
"key": "shops",
"status": true,
},
{
"id": 5,
"link": `${REQUEST_HEADER}info.${TOP_DOMAIN}`,
"name": "行情资讯",
"status": true,
"key": "shopInfomation",
},
]
}
return []
}
@content-height: calc(100vh - 120px);
.wrapper {
background: white;
display: flex;
flex-direction: column;
box-shadow: 2px 0 4px 0 rgba(174, 174, 174, 0.50);
transition: all .3s;
}
.content {
display: flex;
flex: 1;
flex-direction: row;
}
.canvas-container {
display: flex;
flex: 1;
justify-content: center;
background-color: #F4F5F7;
height: calc(@content-height + 50px);
overflow: hidden;
}
\ No newline at end of file
import React, { useEffect, useState } from 'react'
import { LegoProvider } from 'lingxi-editor-core'
import ToolBar from '../components/toolBar'
import DesignPanel from '../components/DesignPanel'
import SettingPanel from '../settingsPanel'
import config from '../configs'
import { Prompt } from 'umi'
import { GlobalConfig } from '@/global/config'
import { topBarConfig, topAdvertConfig, headerConfig, mainNavConfig, bannerContainer, quickNavConfigWrap, categoryConfig, bannerWrap, quickNavConfig, bannerAdvertConfig, interactAdvertConfig, navAdvertConfig, mallLayoutConfig, InformationConfig, FooterConfig } from './defaultData'
import Loading from '../components/Loading'
import { LAYOUT_TYPE } from '@/constants'
import { getMenuData } from './defaultMenu'
import { PublicApi } from '@/services/api'
import styles from './index.less'
import { isEmpty } from 'lodash'
interface MallEditPropsType {
location: {
query: {
/**
* 模板id
*/
id: number;
/**
* 模板名称
*/
template: string;
shopId: number;
}
}
}
const TemplateList = ['science']
const MallEdit: React.FC<MallEditPropsType> = (props) => {
const { query: { id, template, shopId } } = props.location
const [loading, setLoading] = useState<boolean>(true)
const [theme, setTheme] = useState<string>('theme-mall-science')
const [componentConfigs, setComponentConfigs] = useState({})
useEffect(() => {
if (!TemplateList.includes(template)) {
setTheme(`theme-mall-${TemplateList[0]}`)
} else {
setTheme(`theme-mall-${template}`)
}
getComponentsConfig()
}, [])
const findAdvertsByType = (type: number) => {
return new Promise((resolve) => {
const params: any = {
templateId: id,
type
}
PublicApi.getTemplateAdornWebEnterpriseFindAdvertsByType(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
} else {
resolve([])
}
})
})
}
/**
* 获取所有一级品类信息
*/
const fetchFirstCategory = () => {
return new Promise((resolve) => {
PublicApi.getTemplateWebCategoryWebFindAllFirstCategory().then(res => {
if (res.code === 1000) {
resolve(res.data)
} else {
resolve([])
}
})
})
}
/**
* 获取一级品类详细信息
*/
const fetchCategoryById = (categoryId) => {
return new Promise((resolve) => {
const param: any = {
templateId: id,
categoryId
}
PublicApi.getTemplateAdornWebEnterpriseCategoryAdorn(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const fetchNewByLabel = (label: string) => {
// 1-头条文章 2-轮播新闻 3-图片新闻 4-推荐阅读
return new Promise((resolve, reject) => {
PublicApi.getManageContentInformationFindAllByRecommendLabel({ recommendLabel: label }).then((res: { code: number; data: unknown }) => {
if (res.code === 1000) {
resolve(res.data)
} else {
reject()
}
}).catch(() => {
reject()
})
})
}
/**
* 获取商品品类树
*/
const getCategoryTree = () => {
return new Promise((resolve) => {
const param: any = {
templateId: id
}
PublicApi.getTemplateWebCategoryWebFindEnterpriseCategoryTree(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
/**
* 获取导航栏菜单数据
*/
const getMallNavData = () => {
return new Promise((resolve) => {
const param: any = {
templateId: id
}
PublicApi.getTemplateAdornWebEnterpriseFindColumn(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const getComponentsConfig = async () => {
// 导航栏
const navData = await getMallNavData()
if(!isEmpty(navData)) {
mainNavConfig[mainNavConfig.key].props.menuData = navData
} else {
mainNavConfig[mainNavConfig.key].props.menuData = getMenuData(Number(shopId))
}
// mainNavConfig[mainNavConfig.key].props.type = LAYOUT_TYPE.mall
// mainNavConfig[mainNavConfig.key].props.categoryList = []
categoryConfig[categoryConfig.key].props.categoryList = await getCategoryTree()
// 一号位广告
bannerAdvertConfig[bannerAdvertConfig.key].props.advertList = await findAdvertsByType(1)
// 二号位广告
interactAdvertConfig[interactAdvertConfig.key].props.advertList = await findAdvertsByType(2)
// 三号位广告
navAdvertConfig[navAdvertConfig.key].props.advertList = await findAdvertsByType(4)
const shopList = GlobalConfig.web.shopInfo
const webMallInfo = shopList.filter(item => item.environment === 1 && item.type === 1)[0]
headerConfig[headerConfig.key].props.logoUrl = webMallInfo.logoUrl
topBarConfig[topBarConfig.key].props.shopname = webMallInfo.name
// 行情资讯
InformationConfig[InformationConfig.key].props.newsList = await fetchNewByLabel('4')
let initIndex = 100
let floorLineConfig: any = {}
const floorLineKeys: any = []
const firstCategory: any = await fetchFirstCategory()
for (const item of firstCategory) {
const categoryDetail: any = await fetchCategoryById(item.categoryId)
let floorLineConfigItem = {}
floorLineKeys.push(String(initIndex + 1))
const FloorLine = {
[String(initIndex + 1)]: {
"componentName": "FloorLine",
"props": {
title: item.name
},
"childNodes": [String(initIndex + 2), String(initIndex + 3)]
}
}
const Horizontal1 = {
[String(initIndex + 2)]: {
"componentName": "FloorLine.Horizontal",
"props": {},
"childNodes": [String(initIndex + 4), String(initIndex + 5)]
},
}
const Brand = {
[String(initIndex + 3)]: {
"componentName": "FloorLine.Brand",
"props": {
linkdisable: true,
categoryid: item.id,
brandList: categoryDetail.brandBOList
},
},
}
const Category = {
[String(initIndex + 4)]: {
"componentName": "FloorLine.Category",
"props": {
linkdisable: true,
categoryid: item.id,
categoryAdvertPicUrl: categoryDetail.categoryAdvertPicUrl,
secondCategoryList: categoryDetail.categoryBOList,
},
},
}
const Vertical1 = {
[String(initIndex + 5)]: {
"componentName": "FloorLine.Vertical",
"props": {},
"childNodes": [String(initIndex + 6), String(initIndex + 8)]
},
}
const FloorHeader = {
[String(initIndex + 6)]: {
"componentName": "FloorLine.FloorHeader",
"props": {
linkdisable: true,
shopNum: categoryDetail.shopNum,
goodsNum: categoryDetail.goodsNum
},
"childNodes": [String(initIndex + 7)]
},
}
const Banner = {
[String(initIndex + 7)]: {
"componentName": "FloorLine.Banner",
"props": {
"type": "category",
linkdisable: true,
categoryid: item.id,
advertList: categoryDetail.thirdAdvertList
},
},
}
const Horizontal2 = {
[String(initIndex + 8)]: {
"componentName": "FloorLine.Horizontal",
"props": {},
"childNodes": [String(initIndex + 9), String(initIndex + 10)]
},
}
const Goods = {
[String(initIndex + 9)]: {
"componentName": "FloorLine.Goods",
"props": {
linkdisable: true,
goodsList: categoryDetail.goodsBOList,
categoryid: item.id,
},
},
}
const Shops = {
[String(initIndex + 10)]: {
"componentName": "FloorLine.Shops",
"props": {
linkdisable: true,
shopsList: categoryDetail.shopBOList,
categoryid: item.id,
},
},
}
floorLineConfigItem = { ...FloorLine, ...Horizontal1, ...Brand, ...Category, ...Vertical1, ...FloorHeader, ...Banner, ...Horizontal2, ...Goods, ...Shops }
floorLineConfig = { ...floorLineConfig, ...floorLineConfigItem }
initIndex += 100
}
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, InformationConfig.key, FooterConfig.key]
const config = {
...mallLayoutConfig,
...topBarConfig,
...topAdvertConfig,
...headerConfig,
...mainNavConfig,
...bannerContainer,
...categoryConfig,
...bannerWrap,
...quickNavConfigWrap,
...quickNavConfig,
...bannerAdvertConfig,
...interactAdvertConfig,
...navAdvertConfig,
...floorLineConfig,
...InformationConfig,
...FooterConfig
}
setComponentConfigs(config)
setLoading(false)
}
return !loading ? (
<LegoProvider initState={{ componentConfigs: componentConfigs }} config={config}>
<Prompt message="你确定要离开么?" />
<div className={styles['wrapper']}>
<ToolBar />
<div className={styles['content']}>
<div className={styles['canvas-container']}>
<DesignPanel theme={theme} />
</div>
</div>
</div>
<SettingPanel templateId={id} />
</LegoProvider>
) : <Loading />
}
export default MallEdit
.shop_center_template {
.add_card {
display: flex;
height: 100%;
border-radius: 2px;
border: 1px dashed rgba(223, 225, 230, 1);
background: rgba(250, 251, 252, 1);
align-items: center;
justify-content: center;
cursor: pointer;
flex-direction: column;
&:hover {
border: 1px dashed rgba(200, 200, 230, 1);
}
.add_card_btn {
display: flex;
justify-content: center;
align-items: center;
width: 48px;
height: 48px;
background: rgba(235, 236, 240, 1);
border-radius: 50%;
margin-bottom: 24px;
font-size: 22px;
color: #C0C4CC;
}
&>p {
color: #909399;
}
}
}
\ No newline at end of file
import React, { useState, useEffect } from 'react'
import { Row, Col } from 'antd'
import TemplateItem from '../components/templateItem'
import { inject } from 'mobx-react'
import { PublicApi } from '@/services/api'
import { TEMPLATE_TYPE } from '@/constants'
import { GetTemplateWebPageTemplateWebFindAllTemplateByTypeResponse } from '@/services/TemplateApi'
import styles from './index.less'
interface ShopCenterTemplatePropsType {
SiteStore: any
}
const ShopCenterTemplate: React.FC<ShopCenterTemplatePropsType> = (props) => {
const { SiteStore: { siteId } } = props
const [templateList, setTemplateList] = useState<GetTemplateWebPageTemplateWebFindAllTemplateByTypeResponse>([])
useEffect(() => {
const prarm: any = {
type: TEMPLATE_TYPE.platform,
siteId
}
PublicApi.getTemplateWebPageTemplateWebFindAllTemplateByType(prarm).then(res => {
if (res.code === 1000) {
setTemplateList(res.data)
}
})
}, [])
return (
<div className={styles.shop_center_template}>
<Row gutter={24} className={styles.template_list}>
{
templateList.map(item => (
<Col xxl={6} xl={8} lg={12} key={item.id}>
<TemplateItem templateInfo={item} type="mall" />
</Col>
))
}
</Row>
</div>
)
}
export default inject('SiteStore')(ShopCenterTemplate)
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