import React, { Component, Fragment } from 'react'; import { Form, Select, Radio, Input, Slider, Upload, Button, Icon, } from 'antd'; import global from '@/global.less'; import { sldTsvg, sldBeforeUpload, failTip, sldSvgIcon, getLocalStorageStingVal, quillEscapeToHtml, } from '@/utils/utils'; import SldSelGoodsSingleDiy from '@/components/spreader/SldSelGoodsSingleDiy'; import { m_diy_spreader_link_type, sld_m_diy_tpzh_style, sld_com_empty_arrar_2, sld_com_empty_arrar_3, sld_com_empty_arrar_4, sld_com_empty_arrar_5, sld_m_diy_svideo_style, sld_m_diy_live_style, sld_m_diy_activity_style, sld_m_diy_notice_style, } from '@/utils/util_data'; import { SketchPicker } from 'react-color'; import styles from './index.less'; import { connect } from 'dva'; import { apiUrl } from '@/utils/sldconfig.js'; import SldSelMoreLeftRightGoods from '@/components/spreader/SldSelMoreLeftRightGoods'; import SldReactQuill from '@/components/SldReactQuill'; import ALibbSvg from '@/components/ALibbSvg'; import defaultSettings from '@/defaultSettings'; const FormItem = Form.Item; const Option = Select.Option; const formItemLayoutModal = { labelCol: { span: 2, }, wrapperCol: { span: 18, }, }; //设置富文本可以有的内容 const toolbarOptions = [ ['bold', 'italic', 'underline', 'strike'], // toggled buttons [{'header': 1}, {'header': 2}], // custom button values [{'list': 'ordered'}, {'list': 'bullet'}], [{'script': 'sub'}, {'script': 'super'}], // superscript/subscript [{'indent': '-1'}, {'indent': '+1'}], // outdent/indent [{'direction': 'rtl'}], // text direction [{'size': ['small', false, 'large', 'huge']}], // custom dropdown [{'header': [1, 2, 3, 4, 5, 6, false]}], [{'color': ['#000','#e60000','#ff9900','#ffff00','#008a00','#0066cc','#9933ff','#fff','#facccc','#ffebcc','#ffffcc','#cce8cc','#cce0f5','#ebd6ff','#bbbbbb','#f06666','#ffc266','#ffff66','#66b966','#66a3e0','#c285ff','#888888','#a10000','#b26b00','#b2b200','#006100','#0047b2','#6b24b2','#444444','#5c0000','#663d00','#666600','#003700','#002966','#3d1466']}, {'background': []}], // dropdown with defaults from theme [{'font': []}], [{'align': []}], ['clean'] // remove formatting button ]; @connect(({ mdecorate, pc_home }) => ({ mdecorate, pc_home, })) @Form.create() export default class MDiyItem extends Component { state = { showColorPicker: false,//是否展示颜色选择器,默认不展示 showColorPicker2: false,//是否展示颜色选择器,默认不展示 link_type: '',//链接选择的类型,用于选择商品/分类/专题 modalSpuShow: false,//是否展示商品多选modal框,默认不显示 modalVisible: false,//是否展示短视频多选modal框,默认不显示 modalVisibleLive: false,//是否展示直播多选modal框,默认不显示 modalVisibleGoods: false,//是否展示商品多选modal框,默认不显示 modalVisibleActivityGoods: false,//是否展示促销商品多选modal框,默认不显示 activityType: '',//促销互动类型 sle_more_title: '',//多选组件title }; componentDidMount() { } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.isReset != undefined && nextProps.isReset) { this.props.form.resetFields(); } } sele_more_svideo = { info: [],//选择的短视频数组 ids: [],//选择的短视频id数组 min_num: 1,//最小数量,0为不限制 max_num: 30,//最多选择30个 }; sele_more_live = { info: [],//选择的直播数组 ids: [],//选择的直播id数组 min_num: 1,//最小数量,0为不限制 max_num: 30,//最多选择30个 }; sele_more_goods = { info: [],//选择的商品数组 ids: [],//选择的商品id数组 min_num: 3,//最小数量,0为不限制 max_num: 9,//最多选择30个 }; oprate_more_tab_index = 0;//TAB切换当前操作的数据index //是否显示取色器 showColorPicker = (type, flag) => { this.setState({ [type]: flag, }); }; //slodon_获取富文本返回的内容 handleGetContent = (val, type) => { this.onChange(val, type); }; //图片组合选择样式事件 handleTuPianZuHeStyle = (val) => { let { select_data } = this.props; //图片组合里面如果是选择了图片的展现形式,需要重新组装数据 let tmp_data = []; if (val == 0) { tmp_data = sld_com_empty_arrar_2; } else if (val == 1) { tmp_data = sld_com_empty_arrar_2; } else if (val == 2) { tmp_data = sld_com_empty_arrar_2; } else if (val == 3) { tmp_data = sld_com_empty_arrar_3; } else if (val == 4) { tmp_data = sld_com_empty_arrar_3; } else if (val == 5) { tmp_data = sld_com_empty_arrar_4; } else if (val == 6) { tmp_data = sld_com_empty_arrar_4; } else if (val == 7) { tmp_data = sld_com_empty_arrar_5; } else if (val == 8) { tmp_data = sld_com_empty_arrar_4; } select_data.data = []; if(val<8){ for (let i in tmp_data) { select_data.data.push({ img: '', img_path: '', title: '', url: '', url_type: '', info: '', width: '100%', height: 150, }); } }else{ for (let i in sld_com_empty_arrar_4) { let temp = [] for(let j in sld_com_empty_arrar_2){ temp.push({ img: '', img_path: '', name: '', url: '', url_type: '', info: '', }); } select_data.data.push({ main_title: '', sub_title: '', url: '', url_type: '', info: '', img:temp }); } } select_data.sele_style = val; this.props.handleCurSelData(select_data); }; //短视频展示风格选择事件 handleVideoStyle = (val) => { let { select_data } = this.props; select_data.show_style = val; //清空选择的商品 this.sele_more_svideo.ids = []; this.sele_more_svideo.info = []; select_data.data.ids = []; select_data.data.info = []; this.props.handleCurSelData(select_data); }; //公告展示风格选择事件 handleNoticeStyle = (val) => { let { select_data } = this.props; select_data.show_style = val; this.props.handleCurSelData(select_data); }; //直播展示风格选择事件 handleLiveStyle = (val) => { let { select_data } = this.props; select_data.show_style = val; //清空选择的商品 this.sele_more_live.ids = []; this.sele_more_live.info = []; select_data.data.ids = []; select_data.data.info = []; this.props.handleCurSelData(select_data); }; //活动组活动类型选择事件 handleActivityStyle = (val) => { let { select_data } = this.props; select_data.show_style = val; //清空选择的商品 this.sele_more_goods.ids = []; this.sele_more_goods.info = []; select_data.data.ids = []; select_data.data.info = []; select_data.border_radius = 8; select_data.bg_color = '#fff'; select_data.tag_bg_color = '#FF5C00'; select_data.title = ''; select_data.sub_title = ''; this.props.handleCurSelData(select_data); }; /* * 输入框内容更改事件 * val组件传回来的值, * type 修改值对应的键名 * index 多个数据的序号,主要用于轮播/导航/图片组合 * parent_index 父级的index。默认为-1 * */ onChange = (val, type, tar_index = 0,parent_index=-1) => { let { select_data } = this.props; if ((select_data.type == 'lunbo') || (select_data.type == 'nav' && (type != 'icon_set' && type != 'style_set' && type != 'slide')) || select_data.type == 'tupianzuhe' || (select_data.type == 'more_tab' && type != 'border_radius')||(select_data.type == 'top_cat_nav' && type != 'swiper_bg_style')) { if (select_data.type == 'more_tab') { if (type == 'data_type') { //TAB切换数据类型的时候需要清空商品信息 this.saveCurSelData([], 'info', tar_index, 'more'); this.saveCurSelData([], 'ids', tar_index, 'more'); } } this.saveCurSelData(val, type, tar_index, 'more',parent_index); return false; } if (select_data.type == 'fzx' || select_data.type == 'fzkb' || select_data.type == 'fuwenben' || select_data.type == 'dapei' || select_data.type == 'tuijianshangpin' || select_data.type == 'kefu' || select_data.type == 'gonggao' || (select_data.type == 'nav' && (type == 'icon_set' || type == 'style_set' || type == 'slide')) || (select_data.type == 'tupianzuhe' && type == 'sele_style') || select_data.type == 'svideo' || select_data.type == 'live' || (select_data.type == 'more_tab' && type == 'border_radius') || select_data.type == 'activity'||(select_data.type == 'top_cat_nav' && type == 'swiper_bg_style')) { //辅助线/辅助空白/客服/富文本/图片组合的展现样式 this.saveCurSelData(val, type, tar_index, 'single'); } }; //修改内容,数据根节点的操作,parent_index为父级的index saveCurSelData = (val, type, tar_index = 0, flag,parent_index=-1) => { let { select_data } = this.props; if (flag == 'single') { //辅助线/辅助空白/富文本/客服操作, 导航的根节点样式 this.props.handleCurSelData({ [type]: val }); } else if (flag == 'more') { //每个数组下面的操作 let tar_data = []; if(parent_index>-1){ if(select_data.type == 'tupianzuhe'&&select_data.sele_style == 8){ tar_data = select_data.data[parent_index].img.filter((item, index) => index == tar_index)[0]; } }else{ tar_data = select_data.data.filter((item, index) => index == tar_index)[0]; } tar_data[type] = val; this.props.handleCurSelData(select_data); } }; //链接选择器选择之后渲染页面 getDetailItem = (data, index = 0) => { let render_con = ''; if (data.url_type == '') { render_con = null; } else if (data.url_type == 'url') { render_con =
链接地址
this.onChange(e.target.value, 'url', index)}/>
; } else if (data.url_type == 'keyword') { render_con =
关键词
this.onChange(e.target.value, 'url', index)}/>
; } else if (data.url_type == 'goods') { render_con =
商品名称
; } else if (data.url_type == 'category') { render_con =
分类名称
; } return render_con; }; //链接选择器选择之后渲染页面不显示label,parent_index为父级的index getDetailItemHideLabel = (data, index = 0,parent_index=-1) => { let render_con = ''; const { select_data } = this.props; if (data.url_type == '') { render_con = null; } else if (data.url_type == 'url') { render_con = this.onChange(e.target.value, 'url', index,parent_index)}/>; } else if (data.url_type == 'keyword') { render_con = this.onChange(e.target.value, 'url', index,parent_index)}/>; } else if (data.url_type == 'goods') { render_con = ; } else if (data.url_type == 'category') { render_con = ; } return render_con; }; /* * 链接选择器选择事件 * tar_index为多条数据的角标,(用于轮播/导航/图片组合) * parent_index为父级的index * */ sldHandSeleLink = (val, tar_index = 0, parent_index=-1) => { let data = {}; let { select_data } = this.props; if (select_data.type == 'lunbo' || select_data.type == 'nav' || select_data.type == 'tupianzuhe' || select_data.type == 'top_cat_nav') { if(parent_index>-1){ if(select_data.type == 'tupianzuhe'&&select_data.sele_style == 8){ data = select_data.data[parent_index].img.filter((item, index) => index == tar_index)[0]; } }else{ data = select_data.data.filter((item, index) => index == tar_index)[0]; } } if (val == '') { //无操作 data.url = '';//公告链接 data.url_type = '';//公告链接类型 data.info = '';//用于存放额外信息 } else if (val == 'url') { //链接地址 data.url = '';//公告链接 data.url_type = 'url';//公告链接类型 data.info = '';//用于存放额外信息 } else if (val == 'keyword') { //关键词 data.url = '';//关键词 data.url_type = 'keyword';//关键词类型 data.info = '';//用于存放额外信息 } else if (val == 'goods') { //商品 data.url = '';//商品gid data.url_type = 'goods';//商品类型 data.info = '';//用于存放额外信息 } else if (val == 'category') { //分类 data.url = '';//分类id data.url_type = 'category';//分类类型 data.info = '';//用于存放额外信息 }else { //签到、店铺街、领券中心、推手系统、O2O、短视频、直播、积分商城、【促销】团购、【促销】限时折扣、【促销】拼团、【促销】预售、【促销】阶梯团 data.url = ''; data.url_type = val;//链接类型 data.info = '';//用于存放额外信息 } this.cur_index = tar_index;//当前操作数据的序号 this.parent_index = parent_index;//当前操作数据的父级的序号 this.setState({ link_type: val }); if (select_data.type == 'lunbo' || select_data.type == 'nav' || select_data.type == 'tupianzuhe' || select_data.type == 'top_cat_nav') { //轮播导航 this.props.handleCurSelData(select_data); } else { //目前用于搭配 this.props.handleCurSelData(data); } }; //商品或分类选中事件 seleSku = (val) => { const { select_data } = this.props; let data = {}; if (select_data.type == 'lunbo' || select_data.type == 'nav' || select_data.type == 'tupianzuhe' || select_data.type == 'top_cat_nav') { if(this.parent_index!=undefined&&this.parent_index>-1){ data = select_data.data[this.parent_index].img.filter((item, index) => index == this.cur_index)[0]; }else{ data = select_data.data.filter((item, index) => index == this.cur_index)[0]; } } else { data = { ...select_data }; } if (data.url_type == 'goods') { data.url = val.goodsId; data.info = val; } else if (data.url_type == 'category') { data.url = val.labelId; data.info = val; } if (select_data.type == 'lunbo' || select_data.type == 'nav') { this.props.handleCurSelData(select_data); } else { this.props.handleCurSelData(data); } this.setState({ link_type: '' }); }; //选择商品或者分类取消事件 sldHandleLinkCancle = () => { const { select_data } = this.props; let data = { ...select_data }; if (data.type == 'lunbo' || data.type == 'nav') { //轮播 let tar_data = data.data.filter((item, index) => index == this.cur_index)[0]; tar_data.url = ''; tar_data.url_type = ''; tar_data.info = ''; } else { data.url = '';//公告链接 data.url_type = '';//公告链接类型 data.info = '';//用于存放额外信息 } this.props.handleCurSelData(data); this.setState({ link_type: '' }); }; /* * 上传图片 * tar_index标示多个图片的时候图片下标((用于轮播/导航/图片组合) * */ setImg = (info, tar_index = 0,tar_parent_index=-1) => { const { select_data } = this.props; let data = { ...select_data }; let img_data = info.file.response; if (info.file.status === 'done') { if (select_data.type == 'lunbo' || select_data.type == 'nav' || select_data.type == 'tupianzuhe' || select_data.type == 'top_cat_nav') { //轮播 let target_data = []; if(tar_parent_index > -1){ if(select_data.type == 'tupianzuhe'&&select_data.sele_style == 8){ target_data = data.data[tar_parent_index].img.filter((item, index) => index == tar_index)[0]; } }else{ target_data = data.data.filter((item, index) => index == tar_index)[0]; } target_data.img = img_data.data.url; target_data.img_path = img_data.data.path; target_data.width = img_data.data.width; target_data.height = img_data.data.height; data.width = img_data.data.width; if (data.data.length == 1) { data.height = img_data.data.height; } else if (data.data.length > 1) { if (img_data.data.height > data.height) { data.height = img_data.data.height; } } } else { //搭配 data.dapei_img = img_data.data.url; data.img_path = img_data.data.path; data.width = img_data.data.width; data.height = img_data.data.height; } } this.props.handleCurSelData(data); }; //删除搭配图片 delImg = () => { const { select_data } = this.props; let data = { ...select_data }; data.dapei_img = ''; data.img_path = ''; this.props.handleCurSelData(data); }; //删除选中的短视频 delSvideo = (svideoId, tar_index = 0) => { const { select_data } = this.props; let data = { ...select_data }; if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == tar_index)[0]; tar_data.ids = tar_data.ids.filter(item => item != svideoId); tar_data.info = tar_data.info.filter(item => item.video_id != svideoId); } else { data.data.ids = data.data.ids.filter(item => item != svideoId); data.data.info = data.data.info.filter(item => item.video_id != svideoId); } this.props.handleCurSelData(data); }; //删除选中的直播 delLive = (liveId, tar_index = 0) => { const { select_data } = this.props; let data = { ...select_data }; if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == tar_index)[0]; tar_data.ids = tar_data.ids.filter(item => item != liveId); tar_data.info = tar_data.info.filter(item => item.live_id != liveId); } else { data.data.ids = data.data.ids.filter(item => item != liveId); data.data.info = data.data.info.filter(item => item.live_id != liveId); } this.props.handleCurSelData(data); }; //删除单个商品 delGoods = (goodsId, tar_index = 0) => { const { select_data } = this.props; let data = { ...select_data }; if (data.type == 'dapei' || data.type == 'tuijianshangpin'|| data.type == 'activity') { data.data.ids = data.data.ids.filter(item => item != goodsId); data.data.info = data.data.info.filter(item => item.goodsId != goodsId); } else if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == tar_index)[0]; tar_data.ids = tar_data.ids.filter(item => item != goodsId); tar_data.info = tar_data.info.filter(item => item.goodsId != goodsId); } this.props.handleCurSelData(data); }; //短视频多选-回调事件 seleSvideo = (selectedRows, selectedRowKeys) => { const { select_data } = this.props; let data = { ...select_data }; this.sele_more_svideo.ids = [...selectedRowKeys]; this.sele_more_svideo.info = JSON.parse(JSON.stringify(selectedRows)); if (data.type == 'svideo') { data.data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); data.data.info = JSON.parse(JSON.stringify(selectedRows)); } else if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == this.oprate_more_tab_index)[0]; tar_data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); tar_data.info = JSON.parse(JSON.stringify(selectedRows)); } this.props.handleCurSelData(data); this.sldHandleCancle(); }; //直播多选-回调事件 seleLive = (selectedRows, selectedRowKeys) => { const { select_data } = this.props; let data = { ...select_data }; this.sele_more_live.ids = [...selectedRowKeys]; this.sele_more_live.info = JSON.parse(JSON.stringify(selectedRows)); if (data.type == 'live') { data.data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); data.data.info = JSON.parse(JSON.stringify(selectedRows)); } else if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == this.oprate_more_tab_index)[0]; tar_data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); tar_data.info = JSON.parse(JSON.stringify(selectedRows)); } this.props.handleCurSelData(data); this.sldHandleCancle(); }; //商品多选-回调事件 seleGoods = (selectedRows, selectedRowKeys) => { const { select_data } = this.props; let data = { ...select_data }; this.sele_more_goods.ids = [...selectedRowKeys]; this.sele_more_goods.info = JSON.parse(JSON.stringify(selectedRows)); if (data.type == 'dapei' || data.type == 'activity' || data.type == 'tuijianshangpin') { data.data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); data.data.info = JSON.parse(JSON.stringify(selectedRows)); } else if (data.type == 'more_tab') { let tar_data = data.data.filter((item, index) => index == this.oprate_more_tab_index)[0]; tar_data.ids = JSON.parse(JSON.stringify(selectedRowKeys)); tar_data.info = JSON.parse(JSON.stringify(selectedRows)); } this.props.handleCurSelData(data); this.sldHandleCancle(); }; sldHandleCancle = () => { this.setState({ modalSpuShow: false, modalVisible: false, modalVisibleLive: false, modalVisibleGoods: false, modalVisibleActivityGoods: false, }); }; renderDaPeiGoods = (data) => { return
{data.data.info.map((item, index) => { return
this.delGoods(item.id)}> {sldTsvg('shanchu3', '#fff', 15, 15)}
; })}
; }; /* * 图片组合8图片模块 * upload_img_tip 上传图片的提示 * */ renderTPZH8Img = (item, index, upload_img_tip = '',parent_index=-1) => { let limintLength = 15;//限制内容长度 const { select_data } = this.props; //标题的label 标题的key 标题的placeholder let title_key = 'title'; let title_placeholder = '请输入图片标题'; let content =
this.setImg(info, index,parent_index)} headers={{ Authorization: 'Bearer ' + getLocalStorageStingVal('sld_token'), }} >
{item.img ? : sldSvgIcon(defaultSettings.primaryColor, 40, 40, 'ziyuan110') } 选择图片
{upload_img_tip}
this.onChange(e.target.value, title_key, index,parent_index)} value={item[title_key]}/> {this.getDetailItemHideLabel(item, index,parent_index)}
return content; }; /* * * upload_img_tip 上传图片的提示 * */ renderLunBo = (item, index, upload_img_tip = '',parent_index=-1) => { let limintLength = 15;//限制内容长度 const { select_data } = this.props; //标题的label 标题的key 标题的placeholder 显示删除图标show_del_icon let title_key, title_placeholder, show_color_picker = false, show_del_icon = true; if (select_data.type == 'lunbo') { //轮播 show_del_icon = true; } if (select_data.type == 'top_cat_nav') { //顶部分类导航 show_del_icon = true; show_color_picker = true;//显示颜色选择器 } else if (select_data.type == 'nav') { //导航 limintLength = 5; show_del_icon = true; title_key = 'name'; title_placeholder = '请输入导航名称'; } else if (select_data.type == 'tupianzuhe') { //图片组合 if (select_data.sele_style < 4) { show_del_icon = true; } else { show_del_icon = false; } title_key = 'title'; title_placeholder = '请输入图片标题'; } let content = ''; content =
this.setImg(info, index,parent_index)} headers={{ Authorization: 'Bearer ' + getLocalStorageStingVal('sld_token') }} >
{item.img ? :sldSvgIcon(defaultSettings.primaryColor,40,40,'ziyuan110') } 选择图片
{upload_img_tip}
{show_color_picker &&
选择背景色: {/**/} this.showTopCatNavColorPicker(true, index)}>
{item.show_color_picker && (
this.showTopCatNavColorPicker(false, index)}/> this.onChange('rgba(' + e.rgb.r + ',' + e.rgb.g + ',' + e.rgb.b + ',' + e.rgb.a + ')', 'bg_color', index)}/>
)} } {(select_data.type != 'top_cat_nav' && select_data.type != 'lunbo') && this.onChange(e.target.value, title_key, index)} value={item[title_key]}/> } {this.getDetailItemHideLabel(item, index)}
{show_del_icon &&
this.delSldComImg(index)}> {sldTsvg('qingchu', '#666', 16, 16)}
}
; return content; }; //删除图片item,针对于多条数据的处理(用于轮播/导航/图片组合) delSldComImg = (tar_index) => { let { select_data } = this.props; let data = select_data.data.filter((item, index) => index != tar_index); select_data.data = data; this.props.handleCurSelData(select_data); }; //添加轮播图片 addLunbo = (data) => { data.data.push({ img: '',//图片绝对地址 img_path: '',//图片相对地址 title: '',//图片标题 url: '', //链接值 url_type: '',//链接类型 info: '',//用于存放额外信息 width: '100%', height: 285.5, }); this.props.handleCurSelData(data); }; //添加顶部分类导航轮播 addTopCatNav = (data) => { if(data.data.length == 8){ failTip('最多支持8张轮播图'); return false; } data.data.push({ img: '',//图片绝对地址 img_path: '',//图片相对地址 title: '',//图片标题 url: '', //链接值 url_type: '',//链接类型 info: '',//用于存放额外信息 width: '355', height: 140, bg_color: '#FC1C1C',//轮播背景色 show_color_picker:false,//是否显示颜色选择器,默认不显示 swiper_bg_style:1,//轮播背景风格,1为纯色弧度,2为渐变 }); this.props.handleCurSelData(data); }; //顶部分类——颜色选择器的显示与否 showTopCatNavColorPicker = (flag,index) =>{ let { select_data } = this.props; select_data.data[index].show_color_picker = flag; this.props.handleCurSelData(select_data); } //添加导航item addNav = (data) => { if (data.type == 'nav' && data.data.length >= 5) { failTip('最多添加5个导航,否则页面展示效果不佳'); return false; } else if (data.type == 'tupianzuhe' && data.data.length >= 30) { failTip('最多添加30张图片'); return false; } else { data.data.push({ img: '',//图片绝对地址 img_path: '',//图片相对地址 name: '',//导航名称 url: '', //链接值 url_type: '',//链接类型 info: '',//用于存放额外信息 width: '100%', height: 150, }); this.props.handleCurSelData(data); } }; //添加TAB切换分类导航,最多15个 addMoreTabNav = (data) => { if (data.data.length >= 15) { failTip('最多添加15个tab导航'); return false; } else { if (data.data.length == 0) { data.nav_current = 0; } data.data.push({ title: '',//分类标题 sub_title: '',//子标题 data_type: 'goods',//商品类型 cart_icon_type: 5,//商品的话显示的购物车图标 ids: [],//数据id集合 info: [],//数据信息 }); this.props.handleCurSelData(data); } }; //短视频添加事件 selMoreSvideo = (data) => { let { sle_more_title } = this.state; this.sele_more_svideo.info = data.data.info; this.sele_more_svideo.ids = data.data.ids; if (data.show_style == 'four' || data.show_style == 'five') { this.sele_more_svideo = { info: this.sele_more_svideo.info,//选择的短视频数组 ids: this.sele_more_svideo.ids,//选择的短视频id数组 min_num: 3,//最小数量,0为不限制 max_num: 15,//最多选择15个 }; sle_more_title = '选择短视频(最少选择3个,最多选择15个)'; } else if (data.show_style == 'two') { this.sele_more_svideo = { info: this.sele_more_svideo.info,//选择的短视频数组 ids: this.sele_more_svideo.ids,//选择的短视频id数组 total_num: 3,//只能选择3个 }; sle_more_title = '选择短视频(只能选择3个)'; } else { this.sele_more_svideo = { info: this.sele_more_svideo.info,//选择的短视频数组 ids: this.sele_more_svideo.ids,//选择的短视频id数组 total_num: 2,//只能选择2个 }; sle_more_title = '选择短视频(只能选择2个)'; } this.setState({ modalVisible: true, sle_more_title, }); }; //选择商品事件-多选 selMoreGoods = (data) => { let { activityType, sle_more_title, modalVisibleGoods, modalVisibleActivityGoods } = this.state; if (data.type == 'dapei') { //搭配 this.sele_more_goods = { info: data.data.info, ids: data.data.ids, min_num: 3, max_num: 15, }; sle_more_title = '选择商品(最少选择3个,最多选择9个)'; modalVisibleGoods = true; } else if (data.type == 'tuijianshangpin') { //商品推荐 this.sele_more_goods = { info: data.data.info, ids: data.data.ids, min_num: 1, }; sle_more_title = '选择商品(最少选择1个)'; modalVisibleGoods = true; } else if (data.type == 'activity') { if (data.show_style == 'group_buy') { //团购 this.sele_more_goods = { info: data.data.info, ids: data.data.ids, total_num: 2,//只能选择2个 }; sle_more_title = '选择团购商品(只能选择2个)'; } else { //拼团、限时折扣 this.sele_more_goods = { info: data.data.info, ids: data.data.ids, min_num: 3, max_num: 15, }; sle_more_title = '选择' + (data.show_style == 'pin' ? '拼团' : '限时折扣') + '商品(最少选择3个,最多选择15个)'; } activityType = data.show_style; modalVisibleActivityGoods = true; } this.setState({ modalVisibleActivityGoods, modalVisibleGoods, activityType, sle_more_title, }); }; //TAB切换选择数据功能 selMoreTabData = (data, tar_index) => { let { modalVisibleLive, modalVisible, modalVisibleGoods } = this.state; let tar_data = data.data.filter((item, index) => index == tar_index)[0]; if (tar_data.data_type == 'goods') { this.sele_more_goods = { info: tar_data.info,//选择的商品数组 ids: tar_data.ids,//选择的商品id数组 min_num: 2,//最少选择2个 }; modalVisibleGoods = true; } else if (tar_data.data_type == 'live') { this.sele_more_live = { info: tar_data.info,//选择的直播数组 ids: tar_data.ids,//选择的直播id数组 min_num: 2,//最少选择2个 }; modalVisibleLive = true; } else if (tar_data.data_type == 'svideo') { this.sele_more_svideo = { info: tar_data.info,//选择的短视频数组 ids: tar_data.ids,//选择的短视频id数组 min_num: 2,//最少选择2个 }; modalVisible = true; } this.oprate_more_tab_index = tar_index;//TAB切换当前操作的数据index this.setState({ modalVisibleLive, modalVisible, modalVisibleGoods, }); }; //直播添加事件 selMoreLive = (data) => { let { sle_more_title } = this.state; this.sele_more_live.info = data.data.info; this.sele_more_live.ids = data.data.ids; if (data.show_style == 'one' || data.show_style == 'five') { this.sele_more_live = { info: this.sele_more_live.info,//选择的直播数组 ids: this.sele_more_live.ids,//选择的直播id数组 total_num: 2,//只能选择2个 }; sle_more_title = '选择直播(只能选择2个)'; } else if (data.show_style == 'two') { this.sele_more_live = { info: this.sele_more_live.info,//选择的直播数组 ids: this.sele_more_live.ids,//选择的直播id数组 min_num: 3,//最少选择3个 max_num: 15,//最多选择15个 }; sle_more_title = '选择直播(最少选择3个,最多选择15个)'; } this.setState({ modalVisibleLive: true, sle_more_title, }); }; renderMoreTabSeleData = (data, type, tar_index) => { let con = ''; if (type == 'goods') { con =
序号 商品信息 价格 操作
{data.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.goodsName}
{svideo_item.productPrice * 1}
this.delGoods(svideo_item.goodsId, tar_index)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
} else if (type == 'svideo') { con =
序号 短视频信息 播放量 操作
{data.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.video_name} {svideo_item.label_name}
{svideo_item.click_num}
this.delSvideo(svideo_item.video_id, tar_index)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
; } else if (type == 'live') { con =
序号 直播信息 播放量 操作
{data.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.live_name} {svideo_item.label_name}
{svideo_item.click_num}
this.delLive(svideo_item.live_id, tar_index)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
} return con; }; renderItem = (data) => { const { getFieldDecorator } = this.props.form; const { showColorPicker, showColorPicker2 } = this.state; let con = ''; this.props.form.resetFields(['activity_border_radius','tjsp_isshow_sales','tjsp_show_style','tjsp_border_radius','tjsp_border_style','live_border_radius']); if (data.type == 'top_cat_nav') { //轮播 con =
轮播背景设置
this.onChange(e.target.value, 'swiper_bg_style')}> 纯色弧度 渐变
轮播图片
{data.data.length > 0 && data.data.map((item, index) => { return this.renderLunBo(item, index, '宽710*高280'); })}
this.addTopCatNav(data)}> + 添加图片
}else if (data.type == 'lunbo') { //轮播 con =
轮播图片
{data.data.length > 0 && data.data.map((item, index) => { return this.renderLunBo(item, index, '宽710,高不限制'); })}
this.addLunbo(data)}> + 添加图片
} else if (data.type == 'nav') { //导航 con =
显示风格
this.onChange(e.target.value, 'style_set')}> 导航 分组
{data.style_set == 'nav' &&
显示图标
this.onChange(e.target.value, 'icon_set')}> 图标居上 图标居左 不显示图标
} {data.style_set == 'nav' &&
图标大小
this.onChange(e, 'slide')}/>
}
导航图片
{data.data.length > 0 && data.data.map((item, index) => { return this.renderLunBo(item, index); })}
this.addNav(data)}> + 添加导航
} else if (data.type == 'tupianzuhe') { //图片组合 con =
展示风格
{sld_m_diy_tpzh_style.map(item => { return
this.handleTuPianZuHeStyle(item.sele_style)}>
; })}
{data.sele_style == 8 && {data.data.length>0&&data.data.map((item, index) => { return
{index%2==0?'左':'右'}{index<2?1:2}模块数据
this.onChange(e.target.value,'main_title', index)} value={item.main_title}/> this.onChange(e.target.value, 'sub_title', index)} value={item.sub_title}/> {this.getDetailItem(item,index)}
{item.img.length > 0 && item.img.map((child, child_index) => { let upload_tip = '宽154*高188'; return this.renderTPZH8Img(child, child_index, upload_tip,index); })}
})}
} {data.sele_style != 8 &&
上传图片
{data.data.length > 0 && data.data.map((item, index) => { let upload_tip = ''; if (data.sele_style == 0 || data.sele_style == 1) { upload_tip = '宽750,高不限制'; } else if (data.sele_style == 2) { upload_tip = '宽300*高300'; } else if (data.sele_style == 3) { upload_tip = '宽200*高200'; } else if (data.sele_style == 4) { if (index == 0) { upload_tip = '宽300*高320'; } else { upload_tip = '宽300*高150'; } } else if (data.sele_style == 5) { if (index == 0 || index == 3) { upload_tip = '宽200*高200'; } else { upload_tip = '宽400*高200'; } } else if (data.sele_style == 6) { if (index == 0 || index == 3) { upload_tip = '宽300*高150'; } else { upload_tip = '宽300*高300'; } } else if (data.sele_style == 7) { if (index == 4) { upload_tip = '宽200*高420'; } else { upload_tip = '宽200*高200'; } } return this.renderLunBo(item, index, upload_tip); })}
{data.sele_style < 4 &&
this.addNav(data)}> + 添加图片
}
}
} else if (data.type == 'fzx') { //辅助线 con =
颜色
this.showColorPicker('showColorPicker', true)}>
{e.preventDefault(); this.onChange('#e3e5e9', 'color') }}>重置
{showColorPicker && (
this.showColorPicker('showColorPicker', false)}/> this.onChange('rgba(' + e.rgb.r + ',' + e.rgb.g + ',' + e.rgb.b + ',' + e.rgb.a + ')', 'color')}/>
)}
上下边距
this.onChange(e, 'tbmargin')}/>
左右边距
this.onChange(e, 'lrmargin')}/>
样式
{getFieldDecorator('fzx_border_type', { initialValue: data.val })( this.onChange(e.target.value, 'val')}> 实线 虚线 点线 , )}
} else if (data.type == 'fzkb') { //辅助线 con =
颜色
this.showColorPicker('showColorPicker', true)}>
{e.preventDefault(); this.onChange('#fff', 'color') }}>重置
{showColorPicker && (
this.showColorPicker('showColorPicker', false)}/> this.onChange(e.hex, 'color')}/>
)}
空白高度
this.onChange(e, 'text')}/>
} else if (data.type == 'fuwenben') { //富文本 con =
this.handleGetContent(con, 'text')} toolbarOptions = {toolbarOptions} />
} else if (data.type == 'kefu') { //客服 con =
客服文本
this.onChange(e.target.value, 'text')}/>
客服电话
this.onChange(e.target.value, 'tel')}/>
; } else if (data.type == 'gonggao') { //公告 con =
展示风格
{sld_m_diy_notice_style.map(item => { return
this.handleNoticeStyle(item.sele_style)}>
; })}
公告内容
this.onChange(e.target.value, 'text')} value={data.text}/>
公告链接
{this.getDetailItem(data)}
} else if (data.type == 'dapei') { //搭配 con =
搭配图片
{data.dapei_img != '' &&
this.delImg(data)}> {sldTsvg('shanchu4', '#fff', 15, 15)}
} this.setImg(info)} headers={{ Authorization: 'Bearer ' + getLocalStorageStingVal('sld_token'), }} > 此处建议上传宽度为750,高度不限制的图片;支持格式gif,jpg,png。
图片标题
this.onChange(e.target.value, 'dapei_title')} value={data.dapei_title}/>
图片描述
this.onChange(e.target.value, 'dapei_desc')} value={data.dapei_desc}/>
选择商品
* 商品添加: {e.preventDefault(); this.selMoreGoods(data) }}>+ 添加 最少添加3个,最多添加9个
{data.data.info.length > 0 &&
序号 商品信息 价格 操作
{data.data.info.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.goodsName}
{svideo_item.productPrice * 1}
this.delGoods(svideo_item.goodsId)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
}
; } else if (data.type == 'tuijianshangpin') { //推荐商品 con =
商品销量
{getFieldDecorator('tjsp_isshow_sales', { initialValue: data.isshow_sales })( this.onChange(e.target.value, 'isshow_sales')}> 展示 隐藏 , )}
展示类型
{getFieldDecorator('tjsp_show_style', { initialValue: data.show_style })( this.onChange(e.target.value, 'show_style')}> 大图 一行两个 列表 , )}
商品边角
{getFieldDecorator('tjsp_border_radius', { initialValue: data.border_radius })( this.onChange(e.target.value, 'border_radius')}> 圆角 直角 , )}
商品样式
{getFieldDecorator('tjsp_border_style', { initialValue: data.border_style })( this.onChange(e.target.value, 'border_style')}> 无边白底 卡片投影 描边白底 无边灰底 , )}
页面边距
this.onChange(e, 'page_margin')}/>
商品间距
this.onChange(e, 'goods_margin')}/>
选择商品
{data.data.info.length > 0 &&
序号 商品信息 价格 操作
{data.data.info.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.goodsName}
{svideo_item.productPrice * 1}
this.delGoods(svideo_item.goodsId)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
}
; } else if (data.type == 'svideo') { //短视频 con =
展示风格
{sld_m_diy_svideo_style.map(item => { return
this.handleVideoStyle(item.sele_style)}>
; })}
短视频卡片边角
{getFieldDecorator('svideo_border_radius', { initialValue: data.border_radius })( this.onChange(e.target.value, 'border_radius')}> 圆角 直角 , )}
设置标题
this.onChange(e.target.value, 'title')}/>
添加短视频
* 视频添加: {e.preventDefault(); this.selMoreSvideo(data) }}>+ 添加 {/*最多添加{this.sele_more_svideo.min_num}个*/}
{data.data.info.length > 0 &&
序号 短视频信息 播放量 操作
{data.data.info.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.video_name} {svideo_item.label_name}
{svideo_item.click_num}
this.delSvideo(svideo_item.video_id)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
}
; } else if (data.type == 'live') { //直播 con =
展示风格
{sld_m_diy_live_style.map(item => { return
this.handleLiveStyle(item.sele_style)}>
; })}
直播卡片边角
{getFieldDecorator('live_border_radius', { initialValue: data.border_radius })( this.onChange(e.target.value, 'border_radius')}> 圆角 直角 , )}
设置标题
this.onChange(e.target.value, 'title')}/>
添加直播
* 直播添加: {e.preventDefault(); this.selMoreLive(data) }}>+ 添加 {/*最多添加30个*/}
{data.data.info.length > 0 &&
序号 直播信息 播放量 操作
{data.data.info.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.live_name} {svideo_item.label_name}
{svideo_item.click_num}
this.delLive(svideo_item.live_id)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
}
; } else if (data.type == 'more_tab') { //TAB切换 con =
数据卡片边角
{getFieldDecorator('more_tab_border_radius', { initialValue: data.border_radius })( this.onChange(e.target.value, 'border_radius')}> 圆角 直角 , )}
{data.data.length > 0 && data.data.map((more_tab_item, more_tab_index) => { return
this.delSldComImg(more_tab_index)}> {sldTsvg('qingchu', '#666', 16, 16)}
* 分类标题: this.onChange(e.target.value, 'title', more_tab_index)} value={more_tab_item.title}/>
* 子标题: this.onChange(e.target.value, 'sub_title', more_tab_index)} value={more_tab_item.sub_title}/>
* 数据添加: {e.preventDefault(); this.selMoreTabData(data, more_tab_index) }}>+ 添加 需要选择偶数个,最少2个
{more_tab_item.info.length > 0 && this.renderMoreTabSeleData(more_tab_item.info, more_tab_item.data_type, more_tab_index)}
; })}
this.addMoreTabNav(data)}> + 添加分类导航
; } else if (data.type == 'activity') { //活动组 con =
活动类型
{sld_m_diy_activity_style.map(item => { return
this.handleActivityStyle(item.sele_style)}>
; })}
数据卡片边角
{getFieldDecorator('activity_border_radius', { initialValue: data.border_radius })( this.onChange(e.target.value, 'border_radius')}> 圆角 直角 , )}
活动标签背景颜色设置
this.showColorPicker('showColorPicker2', true)}>
{e.preventDefault(); this.onChange('', 'tag_bg_color') }}>默认
{showColorPicker2 && (
this.showColorPicker('showColorPicker2', false)}/> this.onChange('rgba(' + e.rgb.r + ',' + e.rgb.g + ',' + e.rgb.b + ',' + e.rgb.a + ')', 'tag_bg_color')}/>
)}
活动主标题
this.onChange(e.target.value, 'title')} value={data.title}/>
{data.show_style != 'pin' &&
活动子标题
this.onChange(e.target.value, 'sub_title')} value={data.sub_title}/>
}
选择商品
* 商品添加: {e.preventDefault(); this.selMoreGoods(data) }}>+ 添加 {/*最少添加3个,最多添加9个*/}
{data.data.info.length > 0 &&
序号 商品信息 价格 操作
{data.data.info.map((svideo_item, svideo_index) => { return
{svideo_index + 1}
{svideo_item.goodsName}
{svideo_item.goodsPrice * 1}
this.delGoods(svideo_item.goodsId)} className={`${styles.operate} ${global.flex_row_center_center}`}>
; })}
}
; } return con; }; render() { const { select_data } = this.props; const { link_type, modalVisibleGoods, sle_more_title } = this.state; return (
{this.renderItem(select_data)}
{/*商品多选的modal框-start*/} {/*商品多选的modal框-end*/}
); } }