Commit 01426f58 authored by GuanHua's avatar GuanHua

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

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