Commit 01426f58 authored by GuanHua's avatar GuanHua

feat:渠道商城和渠道自有商城模板的区分

parent c3e407f1
......@@ -16,11 +16,12 @@ interface ChannelIndexPropsType {
memberId: number;
shopId: number;
shopUrlParam: string;
shopInfo: GetTemplateChannelFindChannelResponse
shopInfo: GetTemplateChannelFindChannelResponse;
layoutType: LAYOUT_TYPE
}
const ChannelIndex: React.FC<ChannelIndexPropsType> = (props) => {
const { memberId, shopUrlParam, shopInfo } = props
const { memberId, shopUrlParam, shopInfo, layoutType } = props
const [categoryList, setCategoryList] = useState<GetTemplatePlatformFindAllFirstCategoryResponse>([])
const [firstAdvertList, setFirstAdvertList] = useState([])
const [secondAdvertList, setSecondAdvertList] = useState([])
......@@ -28,17 +29,28 @@ const ChannelIndex: React.FC<ChannelIndexPropsType> = (props) => {
useEffect(() => {
if (shopInfo) {
if (shopInfo.templateId) {
getCategoryComponents()
findFirstAdvertsByType()
findSecondAdvertsByType()
let templateId
switch (layoutType) {
case LAYOUT_TYPE.channel:
templateId = shopInfo.channelShopTemplateId
break;
case LAYOUT_TYPE.ichannel:
templateId = shopInfo.channelOwnShopTemplateId
break
default:
break;
}
if (templateId) {
getCategoryComponents(templateId)
findFirstAdvertsByType(templateId)
findSecondAdvertsByType(templateId)
}
}
}, [shopInfo])
const findFirstAdvertsByType = () => {
const findFirstAdvertsByType = (templateId) => {
let params = {
templateId: shopInfo.templateId,
templateId,
type: 1,
memberId
}
......@@ -50,9 +62,9 @@ const ChannelIndex: React.FC<ChannelIndexPropsType> = (props) => {
})
}
const findSecondAdvertsByType = () => {
const findSecondAdvertsByType = (templateId) => {
let params = {
templateId: shopInfo.templateId,
templateId,
type: 2,
memberId
}
......@@ -83,10 +95,10 @@ const ChannelIndex: React.FC<ChannelIndexPropsType> = (props) => {
/**
* 获取一级品类详细信息
*/
const fetchCategoryById = (categoryId) => {
const fetchCategoryById = (categoryId, templateId) => {
return new Promise((resolve) => {
let param = {
templateId: shopInfo.templateId,
templateId: templateId,
categoryId,
memberId
}
......@@ -98,12 +110,12 @@ const ChannelIndex: React.FC<ChannelIndexPropsType> = (props) => {
})
}
const getCategoryComponents = async () => {
const getCategoryComponents = async (templateId) => {
let result = []
let firstCategory: any = await fetchFirstCategory()
for (let item of firstCategory) {
let categoryDetail: any = await fetchCategoryById(item.id)
let categoryDetail: any = await fetchCategoryById(item.id, templateId)
result.push(
<ShopFloorLine
linkUrl={`/channelmall/commodity?channelId=${shopUrlParam}&categoryId=${item.id}&categoryName=${btoa(encodeURIComponent(item.name))}`}
......
......@@ -66,7 +66,7 @@ const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => {
useEffect(() => {
let body = document.getElementsByTagName('body')[0];
if (shopInfo) {
body.className = shopInfo.fileName ? `theme-channel-${shopInfo.fileName}` : templateName;
body.className = shopInfo.channelShopTemplateFileName ? `theme-channel-${shopInfo.channelShopTemplateFileName}` : templateName;
} else {
body.className = templateName
}
......
......@@ -65,7 +65,7 @@ const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => {
useEffect(() => {
let body = document.getElementsByTagName('body')[0];
if (shopInfo) {
body.className = shopInfo.fileName ? `theme-channel-${shopInfo.fileName}` : templateName;
body.className = shopInfo.channelOwnShopTemplateFileName ? `theme-channel-${shopInfo.channelOwnShopTemplateFileName}` : templateName;
} else {
body.className = templateName
}
......
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