Commit 6ecb22a4 authored by GuanHua's avatar GuanHua

🦄refactor: 修改代码规范

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