Commit fadff86f authored by GuanHua's avatar GuanHua

fix: 修复模板装修相关bug

parent 95bacda4
......@@ -11,7 +11,7 @@ import { ArrowUpOutlined, DeleteOutlined, PlusOutlined, ArrowDownOutlined, Caret
import { addTempalteIdToList } from '../../../../utils'
import styles from './index.less'
interface advertItemType {
interface AdvertItemType {
/**
* ID
*/
......@@ -54,7 +54,7 @@ interface advertItemType {
interface AdvertSettingPropsType {
advertList: advertItemType[];
advertList: AdvertItemType[];
onChange: Function;
type: 'top' | 'banner' | 'interact' | 'category';
templateid: number;
......@@ -64,7 +64,7 @@ interface AdvertSettingPropsType {
const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref) => {
const { advertList = [], templateid, type, categoryid, templateType } = props
const [list, setList] = useState<advertItemType[]>(advertList)
const [list, setList] = useState<AdvertItemType[]>(advertList)
const [confirmLoading, setConfirmLoading] = useState<boolean>(false)
const [newProps, setNewProps] = useState(props)
......@@ -87,10 +87,10 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
setNewProps(newProps)
}
const sortUp = (index: number, item: advertItemType) => {
let newList = JSON.parse(JSON.stringify(list))
let tempItem = JSON.parse(JSON.stringify(item))
let temp = newList[index - 1]
const sortUp = (index: number, item: AdvertItemType) => {
const newList = JSON.parse(JSON.stringify(list))
const tempItem = JSON.parse(JSON.stringify(item))
const temp = newList[index - 1]
newList[index - 1] = item
newList[index - 1].sort = temp.sort
newList[index] = temp
......@@ -99,10 +99,10 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
changeNewProps('advertList', newList)
}
const sortDown = (index: number, item: advertItemType) => {
let newList = JSON.parse(JSON.stringify(list))
let temp = newList[index + 1]
let tempItem = JSON.parse(JSON.stringify(item))
const sortDown = (index: number, item: AdvertItemType) => {
const newList = JSON.parse(JSON.stringify(list))
const temp = newList[index + 1]
const tempItem = JSON.parse(JSON.stringify(item))
newList[index + 1] = item
newList[index + 1].sort = temp.sort
newList[index] = temp
......@@ -112,7 +112,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
}
const addSliderItem = () => {
let newList = JSON.parse(JSON.stringify(list))
const newList = JSON.parse(JSON.stringify(list))
let sort = 0
if (newList.length <= 0) {
sort = 1
......@@ -120,7 +120,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
sort = newList[newList.length - 1].sort + 1
}
let tempItem: any = {
const tempItem: any = {
templateId: Number(templateid),
type: getAdvertType(type),
name: '',
......@@ -140,7 +140,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
}
const handleDeleteItem = (index: number) => {
let newList = JSON.parse(JSON.stringify(list))
const newList = JSON.parse(JSON.stringify(list))
newList.splice(index, 1)
let sort = 1
newList.map(item => {
......@@ -152,7 +152,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
}
const handleExpand = (sort: number, state: boolean) => {
let newList = JSON.parse(JSON.stringify(list))
const newList = JSON.parse(JSON.stringify(list))
newList.map(item => {
if (item.sort === sort) {
item.expand = state
......@@ -162,7 +162,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
}
const handleKeyChange = (value: string, sort: number, key: string) => {
let newList = JSON.parse(JSON.stringify(list))
const newList = JSON.parse(JSON.stringify(list))
newList.map(item => {
if (item.sort === sort) {
item[key] = value
......@@ -193,9 +193,10 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
return
}
setConfirmLoading(true)
let newParam: any = JSON.parse(JSON.stringify(newProps))
const newParam: any = JSON.parse(JSON.stringify(newProps))
newParam.advertList = newParam.advertList.map((item) => {
if (!item.link && !item.link.startsWith('http://') && !item.link.startsWith('https://')) {
console.log(item.link, "item.link")
if (item.link && !item.link.startsWith('http://') && !item.link.startsWith('https://')) {
item.link = `http://${item.link}`
}
return item
......@@ -247,7 +248,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
reject()
return
}
let param: any = {
const param: any = {
templateId: templateid,
type: getAdvertType(type),
adverts: addTempalteIdToList(advertList, templateid)
......@@ -293,7 +294,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
<div className={styles.advert_setting_line_name} onClick={() => handleExpand(item.sort, !item.expand)}>
<span>{item.name}</span>
{
!!item.expand ? <CaretUpOutlined className={styles.icon} /> : <CaretDownOutlined className={styles.icon} />
item.expand ? <CaretUpOutlined className={styles.icon} /> : <CaretDownOutlined className={styles.icon} />
}
</div>
{
......@@ -319,10 +320,10 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
<div className={styles.advert_setting_line_addItem_line}>
<div className={styles.advert_setting_line_addItem_line_label}>链接</div>
<div className={styles.advert_setting_line_addItem_line_brief}>
<Input
className={styles.advert_setting_line_addItem_input}
value={item.link}
onChange={(e) => handleKeyChange(e.target.value, item.sort, 'link')}
<Input
className={styles.advert_setting_line_addItem_input}
value={item.link}
onChange={(e) => handleKeyChange(e.target.value, item.sort, 'link')}
/>
</div>
</div>
......@@ -344,4 +345,6 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
)
})
export default AdvertSetting
\ No newline at end of file
AdvertSetting.displayName = "AdvertSetting"
export default AdvertSetting
import React, { useState, useEffect, useCallback } from 'react'
import React, { useState, useEffect } from 'react'
import { clearSelectedStatus, changeProps } from 'lingxi-editor-core'
import { Row, Col, Button, Input, Pagination, Select, Form, message, Modal } from 'antd'
import SettingList from '../../../../components/SettingList'
......@@ -207,6 +207,7 @@ const GoodsSetting: React.FC<GoodsSettingPropsType> = (props) => {
changeProps({
props: {
linkdisable: true,
templateid,
categoryid,
goodsList: newList
......
......@@ -127,7 +127,7 @@ const ShopEdit: React.FC<ShopEditPropsType> = (props) => {
const fetchShopInfo = () => {
return new Promise((resolve) => {
const param: any = {
memberId,
memberId,
roleId: memberRoleId
}
PublicApi.getTemplateShopFindShop(param).then(res => {
......
This diff is collapsed.
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