Commit 6ecb22a4 authored by GuanHua's avatar GuanHua

🦄refactor: 修改代码规范

parent d92698cd
......@@ -26,7 +26,7 @@ interface ChannelPreviewPropsType {
}
}
let TemplateList = ['science']
const TemplateList = ['science']
const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
const { query: { id, template } } = props.location
......@@ -45,11 +45,11 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
const findFirstAdvertsByType = () => {
return new Promise((resolve) => {
let params = {
const params: any = {
templateId: id,
type: 1
}
//@ts-ignore
PublicApi.getTemplateChannelFindAdvertsByType(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
......@@ -62,11 +62,11 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
const findSecondAdvertsByType = () => {
return new Promise((resolve) => {
let params = {
const params: any = {
templateId: id,
type: 2
}
//@ts-ignore
PublicApi.getTemplateChannelFindAdvertsByType(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
......@@ -95,12 +95,11 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
*/
const fetchCategoryById = (categoryId) => {
return new Promise((resolve) => {
let param = {
const param: any = {
templateId: id,
categoryId
}
// @ts-ignore
PublicApi.getTemplateChannelFindFirstCategoryDetail(param).then(res => {
resolve(res.data)
})
......@@ -126,13 +125,15 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
*/
const fetchLeadNews = () => {
return new Promise((resolve) => {
//@ts-ignore
PublicApi.getManageContentInformationFindAllByRecommendLabel({ recommendLabel: 1 }).then(res => {
const param: any = {
recommendLabel: 1
}
PublicApi.getManageContentInformationFindAllByRecommendLabel(param).then(res => {
if (res.code === 1000) {
let leadNewsList: any = res.data || []
const leadNewsList: any = res.data || []
if (leadNewsList.length >= 2) {
let leftList = leadNewsList.slice(0, Math.round(leadNewsList.length / 2))
let rightList = leadNewsList.slice(Math.round(leadNewsList.length / 2), leadNewsList.length)
const leftList = leadNewsList.slice(0, Math.round(leadNewsList.length / 2))
const rightList = leadNewsList.slice(Math.round(leadNewsList.length / 2), leadNewsList.length)
resolve({
leadLeftNews: leftList,
leadRightNews: rightList
......@@ -157,10 +158,10 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
PublicApi.getManageContentColumnAll().then(res => {
if (res.code === 1000) {
let result = ""
let allColumn = res.data
const allColumn = res.data
if (allColumn && allColumn.length > 0) {
let labelList = allColumn.map((item: any) => item.name)
let showCount = 4
const showCount = 4
if (labelList.length <= showCount) {
result = labelList.join(' | ')
} else {
......@@ -185,8 +186,8 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
// 二号位广告
serviceAdvertConfig[serviceAdvertConfig.key].props.advertList = await findSecondAdvertsByType()
//店铺信息
//店铺信息
const channelInfo: any = await fetchShopInfo()
AboutUsConfig[AboutUsConfig.key].props.shopInfo = channelInfo
......@@ -199,17 +200,17 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
let initIndex = 100
let floorLineConfig: any = {}
let floorLineKeys: any = []
const floorLineKeys: any = []
let firstCategory: any = await fetchFirstCategory()
const firstCategory: any = await fetchFirstCategory()
for (let item of firstCategory) {
let categoryDetail: any = await fetchCategoryById(item.id)
for (const item of firstCategory) {
const categoryDetail: any = await fetchCategoryById(item.id)
let floorLineConfigItem = {}
floorLineKeys.push(String(initIndex + 1))
let FloorLine = {
const FloorLine = {
[String(initIndex + 1)]: {
"componentName": "ShopFloorLine",
"props": {
......@@ -219,7 +220,7 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
}
}
let Category = {
const Category = {
[String(initIndex + 2)]: {
"componentName": "ShopFloorLine.Category",
"props": {
......@@ -231,7 +232,7 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
},
}
let Goods = {
const Goods = {
[String(initIndex + 3)]: {
"componentName": "ShopFloorLine.Goods",
"props": {
......@@ -249,7 +250,7 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, serviceAdvertConfig.key, CommonTitle2Config.key, AboutUsConfig.key, InformationConfig.key, FooterConfig.key]
let config = {
const config = {
...mallLayoutConfig,
...topBarConfig,
...topAdvertConfig,
......@@ -284,4 +285,4 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
) : <Loading />
}
export default ChannelPreview
\ No newline at end of file
export default ChannelPreview
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