From c877a44579952e2923bf00e3313d1a41f2a90481 Mon Sep 17 00:00:00 2001 From: Apple <> Date: Wed, 21 Sep 2022 17:34:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E5=9F=BA=E7=A1=80=E9=85=8D=E7=BD=AE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couponCard/goodsPage/config/bottomBar.js | 2 +- .../couponCard/goodsPage/config/main.js | 155 ++---- .../couponCard/goodsPage/config/picture.js | 2 +- .../couponCard/goodsPage/config/title.js | 2 +- .../edittemplate/exchange/goodsPage.js | 161 ++---- src/pages/exchangepage/edittemplate/main.js | 88 +--- .../edittemplate/whiteList/whitegoods.js | 484 ++++++++---------- 7 files changed, 346 insertions(+), 548 deletions(-) diff --git a/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/bottomBar.js b/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/bottomBar.js index d1dd4dfc..85786d87 100644 --- a/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/bottomBar.js +++ b/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/bottomBar.js @@ -204,7 +204,7 @@ export default class edittemplate extends React.Component {

显示

- +
0 && files[0].status == "success") { - let model = this.state.model; - model.top_image = files[0].src; - this.setState({ model: model }) - this.props.setbanner(files[0].src); - } else { - let model = this.state.model; - model.top_image = ''; - this.setState({ model: model }) - this.props.setbanner(""); - } - }; - + //顶部banner + onUploadChange(files) { + let model = this.state.model; + model.top_image = ''; + this.props.setGoodConfig({attr:'top_image',value:''}); + if (files.length > 0 && files[0].status == "success") { + model.top_image = files[0].src; + this.props.setGoodConfig({attr:'top_image',value:files[0].src}); + } + this.setState({ model: model }) +}; //悬浮富文本 getsusEditext(c) { let model1 = this.state.model; model1.describe.content = c; this.setState({ model: model1 }); - this.props.seteditorHtml(c); - } - //富文本 - getEditext(c) { - let model1 = this.state.model; - model1.describe.content = c; - this.setState({ model: model1 }); - this.props.seteditorHtml(c); + this.props.setexplainConfig({attr:'content',value:c}); } //底部描述图 onUploadChange2(files) { - if (files.length > 0 && files[0].status == "success") { - let model1 = this.state.model; + let model1 = this.state.model; + model1.describe.bg_image = ''; + this.props.setexplainConfig({attr:'bg_image',value:''}); + if (files.length > 0 && files[0].status == "success") { model1.describe.bg_image = files[0].src; - this.setState({ model: model1 }) - this.props.setbottomImg(files[0].src); - } else { - let model1 = this.state.model; - model1.describe.bg_image = ''; - this.setState({ model: model1 }) - this.props.setbottomImg(""); - } + this.props.setexplainConfig({attr:'bg_image',value:files[0].src}); + } + this.setState({ model: model1 }) }; - - onUploadError = (type, data) => { if (type === 'overMaxAmount') { Notify.error(`最多可上传 ${data.maxAmount} 张图片`); @@ -107,41 +86,16 @@ export default class couponGoodConfig extends React.Component { Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); } }; - handleChange = (color) => { + controlColor = (attr,color) => { let model1 = this.state.model; - model1.font_color = color; + model1[attr] = color; this.setState({ model: model1 }); - this.props.setButtonbgcolor(color); - - } - handleChange1 = (color) => { - let model1 = this.state.model; - model1.button_color = color; - this.setState({ - model: model1 - }); - this.props.setButtoncolor(color); - } - - // 字体颜色 - fontcolor(cor) { - let models = this.state.model; - models.button_color = cor; - this.setState({ model: models }); - this.props.setButtoncolor(cor); - } - // 背景颜色 - bgcolor(cor) { - let models = this.state.model; - models.font_color = cor; - this.setState({ model: models }); - this.props.setButtonbgcolor(cor); + this.props.setGoodConfig({attr,value:color}); } onUpload = (file, report) => { let self = this; - console.log('上传头像', file); return new Promise((resolve, reject) => { let path = "" let formdata = new FormData(); @@ -187,16 +141,9 @@ export default class couponGoodConfig extends React.Component { }; componentWillUnmount() { let oldobj = JSON.parse(sessionStorage.getItem('editorConfig')); - if (oldobj && oldobj.coupon) { - let coupon = oldobj.coupon - coupon.product_list = this.state.model; - oldobj.coupon = coupon; - } else { - oldobj = {} - let coupon = {} - coupon.product_list = this.state.model; - oldobj.coupon = coupon; - } + let coupon = oldobj.coupon + coupon.product_list = this.state.model; + oldobj.coupon = coupon; sessionStorage.setItem('editorConfig', JSON.stringify(oldobj)); } render() { @@ -212,8 +159,8 @@ export default class couponGoodConfig extends React.Component {
样式
- - { this.onListChange(e) }} value={this.state.model.list}> + + { this.configChange('list',e) }} value={this.state.model.list}> 轮播 列表 矩阵 @@ -221,31 +168,31 @@ export default class couponGoodConfig extends React.Component {
{ - this.state.model.list == 2 ? + this.state.model.list == 2 ?
- { this.bgcolor('#ffffff') }}> - { this.bgcolor('#000000') }}> + { this.controlColor('font_color','#ffffff') }}> + { this.controlColor('font_color','#000000') }}>
-
+ this.controlColor('font_color',c)} />
: null } { - this.state.model.list == 2 ? + this.state.model.list == 2 ?
- { this.fontcolor('#ffffff') }}> - { this.fontcolor('#04C160') }}> - { this.fontcolor('#AE99D3') }}> - { this.fontcolor('#FACD6A') }}> - { this.fontcolor('#FE7962') }}> + { this.controlColor('button_color','#ffffff') }}> + { this.controlColor('button_color','#04C160') }}> + { this.controlColor('button_color','#AE99D3') }}> + { this.controlColor('button_color','#FACD6A') }}> + { this.controlColor('button_color','#FE7962') }}>
- + this.controlColor('button_color',c)} />
: null }
基础图层
- +
- - { this.onactivityChange(e) }} value={this.state.model.describe.type}> + + { this.explainChange('type',e) }} value={this.state.model.describe.type}> this.hasItemFn(1)} value={"1"}>图片 this.hasItemFn(2)} value={"2"}>悬浮 this.hasItemFn(3)} value={"3"}>富文本 @@ -274,7 +221,7 @@ export default class couponGoodConfig extends React.Component {
{ - this.state.model.describe.type == 1 ? + this.state.model.describe.type == 1 ? - : this.state.model.describe.type == 2 ? this.getsusEditext(c)} /> : this.state.model.describe.type == 3 ? this.getEditext(c)} /> : null + : this.state.model.describe.type == 2 ? this.getsusEditext(c)} /> : this.state.model.describe.type == 3 ? this.getsusEditext(c)} /> : null } diff --git a/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/picture.js b/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/picture.js index a234575e..25b6fc7a 100644 --- a/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/picture.js +++ b/src/pages/exchangepage/edittemplate/couponCard/goodsPage/config/picture.js @@ -106,7 +106,7 @@ export default class edittemplate extends React.Component {
- + A+ -
: + : 0 && files[0].status == "success") { - let model = this.state.model; - model.top_image = files[0].src; - this.setState({ model: model }) - this.props.setbanner(files[0].src); - } else { - let model = this.state.model; - model.top_image = ''; - this.setState({ model: model }) - this.props.setbanner(""); - } - }; - //悬浮富文本 getsusEditext(c) { let model1 = this.state.model; model1.describe.content = c; this.setState({ model: model1 }); - this.props.seteditorHtml(c); + this.props.setexplainConfig({attr:'content',value:c}); } - //富文本 - getEditext(c) { + hasItemFn(c) { let model1 = this.state.model; - model1.describe.content = c; - this.setState({ model: model1 }); - this.props.seteditorHtml(c); + if (c == model1.describe.type) { + model1.describe.type = ''; + this.setState({ model: model1 }); + this.props.setexplainConfig({attr:'type',value:''}); + } } - //底部描述图 - onUploadChange2(files) { - if (files.length > 0 && files[0].status == "success") { - let model1 = this.state.model; - model1.describe.bg_image = files[0].src; - this.setState({ model: model1 }) - this.props.setbottomImg(files[0].src); - } else { - let model1 = this.state.model; - model1.describe.bg_image = ''; - this.setState({ model: model1 }) - this.props.setbottomImg(""); + //顶部banner + onUploadChange(files) { + let model = this.state.model; + model.top_image = ''; + this.props.setGoodConfig({attr:'top_image',value:''}); + if (files.length > 0 && files[0].status == "success") { + model.top_image = files[0].src; + this.props.setGoodConfig({attr:'top_image',value:files[0].src}); } + this.setState({ model: model }) }; - + + //底部描述图 + onUploadChange2(files) { + let model1 = this.state.model; + model1.describe.bg_image = ''; + this.props.setexplainConfig({attr:'bg_image',value:''}); + if (files.length > 0 && files[0].status == "success") { + model1.describe.bg_image = files[0].src; + this.props.setexplainConfig({attr:'bg_image',value:files[0].src}); + } + this.setState({ model: model1 }) + }; onUploadError = (type, data) => { if (type === 'overMaxAmount') { @@ -103,41 +84,17 @@ export default class edittemplate extends React.Component { Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); } }; - handleChange = (color) => { + controlColor = (attr,color) => { let model1 = this.state.model; - model1.font_color = color; + model1[attr] = color; this.setState({ model: model1 }); - this.props.setButtonbgcolor(color); - - } - handleChange1 = (color) => { - let model1 = this.state.model; - model1.button_color = color; - this.setState({ - model: model1 - }); - this.props.setButtoncolor(color); + this.props.setGoodConfig({attr,value:color}); } - // 字体颜色 - fontcolor(cor) { - let models = this.state.model; - models.button_color = cor; - this.setState({ model: models }); - this.props.setButtoncolor(cor); - } - // 背景颜色 - bgcolor(cor) { - let models = this.state.model; - models.font_color = cor; - this.setState({ model: models }); - this.props.setButtonbgcolor(cor); - } onUpload = (file, report) => { let self = this; - console.log('上传头像', file); return new Promise((resolve, reject) => { let path = "" let formdata = new FormData(); @@ -151,18 +108,14 @@ export default class edittemplate extends React.Component { reject(); }) }); - let count = 0; const update = () => { if (path) { - resolve( path ); - } else { - if (count < 100) { count += 2; report(count); @@ -174,8 +127,6 @@ export default class edittemplate extends React.Component { reject(); } } - - }; setTimeout(update, 500); }); @@ -201,8 +152,8 @@ export default class edittemplate extends React.Component {
样式
- - { this.onListChange(e) }} value={this.state.model.list}> + + { this.configChange('list',e) }} value={this.state.model.list}> 轮播 列表 矩阵 @@ -210,31 +161,31 @@ export default class edittemplate extends React.Component {
{ - this.state.model.list == 2 ? + this.state.model.list == 2 ?
- { this.bgcolor('#ffffff') }}> - { this.bgcolor('#000000') }}> + { this.controlColor('font_color','#ffffff') }}> + { this.controlColor('font_color','#000000') }}>
-
+ this.controlColor('font_color',c)} />
: null } { - this.state.model.list == 2 ? + this.state.model.list == 2 ?
- { this.fontcolor('#ffffff') }}> - { this.fontcolor('#04C160') }}> - { this.fontcolor('#AE99D3') }}> - { this.fontcolor('#FACD6A') }}> - { this.fontcolor('#FE7962') }}> + { this.controlColor('button_color','#ffffff') }}> + { this.controlColor('button_color','#04C160') }}> + { this.controlColor('button_color','#AE99D3') }}> + { this.controlColor('button_color','#FACD6A') }}> + { this.controlColor('button_color','#FE7962') }}>
- + this.controlColor('button_color',c)} />
: null }
基础图层
- +
- - { this.onactivityChange(e) }} value={this.state.model.describe.type}> + + { this.explainChange('type',e) }} value={this.state.model.describe.type}> this.hasItemFn(1)} value={"1"}>图片 this.hasItemFn(2)} value={"2"}>悬浮 this.hasItemFn(3)} value={"3"}>富文本 @@ -263,7 +214,7 @@ export default class edittemplate extends React.Component {
{ - this.state.model.describe.type == 1 ? + this.state.model.describe.type == 1 ? - : this.state.model.describe.type == 2 ? this.getsusEditext(c)} /> : this.state.model.describe.type == 3 ? this.getEditext(c)} /> : null + : this.state.model.describe.type == 2 ? this.getsusEditext(c)} /> : this.state.model.describe.type == 3 ? this.getsusEditext(c)} /> : null } diff --git a/src/pages/exchangepage/edittemplate/main.js b/src/pages/exchangepage/edittemplate/main.js index 22900ef0..d44b479b 100644 --- a/src/pages/exchangepage/edittemplate/main.js +++ b/src/pages/exchangepage/edittemplate/main.js @@ -589,36 +589,25 @@ export default class edittemplate extends React.Component { landConfig[c.attr]=c.value; this.setState({ model: landConfig }) } - - //获取商品列表页数据 - getGoodsbanner(c) { + //商品列表页基础配置 + getGoodConfig(c){ let goodsConfig = this.state.product_list - goodsConfig.top_image = c + goodsConfig[c.attr] = c.value; this.setState({ product_list: goodsConfig }) } + //商品列表页说明配置 + getexplainConfig(c){ + let goodsConfig = this.state.product_list + goodsConfig.describe[c.attr] = c.value + this.setState({ product_list: goodsConfig }) + } + getgoodsbottomimgFn(c) { let goodsConfig = this.state.product_list goodsConfig.describe.bg_image = c this.setState({ product_list: goodsConfig }) } - //获取商品排列方式 - getarrayType(c) { - let goodsConfig = this.state.product_list - goodsConfig.list = c - this.setState({ product_list: goodsConfig }) - } - //获取背景颜色 - getButtonbgcolor(c) { - let goodsConfig = this.state.product_list - goodsConfig.font_color = c - this.setState({ product_list: goodsConfig }) - } - //富文本 - getEditorHtmlFn(c) { - let goodsConfig = this.state.product_list - goodsConfig.describe.content = c - this.setState({ product_list: goodsConfig }) - } + //详情页 getdetailEditorHtmlFn(c) { let detailpage = this.state.product_detail @@ -631,18 +620,8 @@ export default class edittemplate extends React.Component { this.setState({ product_detail: detailpage }) } - //活动说明类型 - getactiveTypeFn(c) { - let goodsConfig = this.state.product_list - goodsConfig.describe.type = c - this.setState({ product_list: goodsConfig }) - } - //字体颜色 - getButtoncolor(c) { - let goodsConfig = this.state.product_list - goodsConfig.button_color = c - this.setState({ product_list: goodsConfig }) - } + + onmodelChange(e) { let editorData = _.cloneDeep(JSON.parse(sessionStorage.getItem('editorConfig'))) let holdData; @@ -1170,17 +1149,8 @@ export default class edittemplate extends React.Component { /> ) : this.state.activeNavStatus == 2 ? ( this.getactiveTypeFn(c)} - seteditorHtml={(c) => this.getEditorHtmlFn(c)} - setButtonbgcolor={(c) => { - this.getButtonbgcolor(c) - }} - setButtoncolor={(c) => { - this.getButtoncolor(c) - }} - setbottomImg={(c) => this.getgoodsbottomimgFn(c)} - setbanner={(c) => this.getGoodsbanner(c)} - setarrayType={(c) => this.getarrayType(c)} + setexplainConfig={(c) => this.getexplainConfig(c)} + setGoodConfig={(c) => this.getGoodConfig(c)} /> ) : this.state.detailType == 1 ? ( { this.getdetailbgcolor(c) }} - setbottomImg={(c) => this.getbottomimgFn(c)} setdetailftc={(c) => this.getdetailfont_color(c)} /> ) : @@ -1202,17 +1171,8 @@ export default class edittemplate extends React.Component { /> ) : this.state.activeNavStatus == 2 ? ( this.getactiveTypeFn(c)} - seteditorHtml={(c) => this.getEditorHtmlFn(c)} - setButtonbgcolor={(c) => { - this.getButtonbgcolor(c) - }} - setButtoncolor={(c) => { - this.getButtoncolor(c) - }} - setbottomImg={(c) => this.getgoodsbottomimgFn(c)} - setbanner={(c) => this.getGoodsbanner(c)} - setarrayType={(c) => this.getarrayType(c)} + setexplainConfig={(c) => this.getexplainConfig(c)} + setGoodConfig={(c) => this.getGoodConfig(c)} /> ) : this.state.detailType == 1 ? ( { this.getdetailbgcolor(c) }} - setbottomImg={(c) => this.getbottomimgFn(c)} setdetailftc={(c) => this.getdetailfont_color(c)} /> ) : : this.state.activeNavStatus == 1 ? (//优惠券 @@ -1232,18 +1191,9 @@ export default class edittemplate extends React.Component { /> ) : this.state.activeNavStatus == 2 ? ( this.getactiveTypeFn(c)} - seteditorHtml={(c) => this.getEditorHtmlFn(c)} - setButtonbgcolor={(c) => { - this.getButtonbgcolor(c) - }} - setButtoncolor={(c) => { - this.getButtoncolor(c) - }} componentName={this.state.componentOfconfig} - setbottomImg={(c) => this.getgoodsbottomimgFn(c)} - setbanner={(c) => this.getGoodsbanner(c)} - setarrayType={(c) => this.getarrayType(c)} + setexplainConfig={(c) => this.getexplainConfig(c)} + setGoodConfig={(c) => this.getGoodConfig(c)} /> ) : this.state.detailType == 1 ? ( this.state.activeNavStatus == 1 ? diff --git a/src/pages/exchangepage/edittemplate/whiteList/whitegoods.js b/src/pages/exchangepage/edittemplate/whiteList/whitegoods.js index ad984095..2f1215d6 100644 --- a/src/pages/exchangepage/edittemplate/whiteList/whitegoods.js +++ b/src/pages/exchangepage/edittemplate/whiteList/whitegoods.js @@ -1,302 +1,252 @@ import React from 'react'; -import { ColorPicker,ImageUpload,Tooltip,Notify ,RadioGroup,RadioButton,Icon} from 'zent'; -import "../main.less" +import { ColorPicker, ImageUpload, Tooltip, Notify, RadioGroup, RadioButton, Icon } from 'zent'; +import "../main.less" import "@/assets/comm.css" import Form from "@/components/form/main" import FormItem from "@/components/form-item/main" -import {uploadImg,handelResponse} from "@/assets/api.js" +import { uploadImg, handelResponse } from "@/assets/api.js" import Wangeditor from './whitewangeditor.js' -export default class edittemplate extends React.Component{ - constructor(props){ +export default class edittemplate extends React.Component { + constructor(props) { super(props) - this.state={ - model:{ - top_image: "", - list: "2", - font_color:"#ffffff", - button_color: "#FACD6A", - describe: {type : "", content : "",bg_image:''} - } - } - } - - componentWillMount(e){ - let config=JSON.parse(sessionStorage.getItem('editorConfig')); - if(config&&config.whiteList&&config.whiteList.product_list){ - this.setState({model:config.whiteList.product_list}); - } - } - - onListChange(e){ - let model = this.state.model; - model.list = e.target.value; - this.setState({model:model}) - this.props.setarrayType(e.target.value); - } - - //活动说明 - onactivityChange(e){ - let model1=this.state.model; - model1.describe.type=e.target.value; - this.setState({model:model1}) - this.props.setactiveType(e.target.value); - } - - hasItemFn(c){ - let model1=this.state.model; - if(c==model1.describe.type){ - model1.describe.type=''; - this.setState({model:model1}); - this.props.setactiveType(''); + this.state = { + model: { + top_image: "", + list: "2", + font_color: "#ffffff", + button_color: "#FACD6A", + describe: { type: "", content: "", bg_image: '' } + } } } + componentWillMount(e) { + let config = JSON.parse(sessionStorage.getItem('editorConfig')); + if (config && config.whiteList && config.whiteList.product_list) { + this.setState({ model: config.whiteList.product_list }); + } + } + configChange(attr, e) { + let model = this.state.model; + model[attr] = e.target.value; + this.setState({ model: model }) + this.props.setGoodConfig({ attr, value: e.target.value }); + } + //活动说明 + explainChange(attr, e) { + let model1 = this.state.model; + model1.describe[attr] = e.target.value; + this.setState({ model: model1 }) + this.props.setexplainConfig({ attr, value: e.target.value }); + } + hasItemFn(c) { + let model1 = this.state.model; + if (c == model1.describe.type) { + model1.describe.type = ''; + this.setState({ model: model1 }); + this.props.setexplainConfig({ attr: 'type', value: '' }); + } + } //顶部banner - onUploadChange(files){ - if(files.length > 0 && files[0].status == "success") - { - let model = this.state.model; - model.top_image= files[0].src; - this.setState({model:model}) - this.props.setbanner(files[0].src); - }else{ - let model = this.state.model; - model.top_image=''; - this.setState({model:model}) - this.props.setbanner(""); + onUploadChange(files) { + let model = this.state.model; + model.top_image = ''; + this.props.setGoodConfig({ attr: 'top_image', value: '' }); + if (files.length > 0 && files[0].status == "success") { + model.top_image = files[0].src; + this.props.setGoodConfig({ attr: 'top_image', value: files[0].src }); + } + this.setState({ model: model }) + }; + + //悬浮富文本 + getsusEditext(c) { + let model1 = this.state.model; + model1.describe.content = c; + this.setState({ model: model1 }); + this.props.setexplainConfig({attr:'content',value:c}); + } + //底部描述图 + onUploadChange2(files) { + let model1 = this.state.model; + model1.describe.bg_image = ''; + this.props.setexplainConfig({ attr: 'bg_image', value: '' }); + if (files.length > 0 && files[0].status == "success") { + model1.describe.bg_image = files[0].src; + this.props.setexplainConfig({ attr: 'bg_image', value: files[0].src }); + } + this.setState({ model: model1 }) + }; + + + onUploadError = (type, data) => { + if (type === 'overMaxAmount') { + Notify.error(`最多可上传 ${data.maxAmount} 张图片`); + } else if (type === 'overMaxSize') { + Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); } }; - - //悬浮富文本 - getsusEditext(c){ - let model1=this.state.model; - model1.describe.content=c; - this.setState({model:model1}); - this.props.seteditorHtml(c); - } - //富文本 - getEditext(c){ - let model1=this.state.model; - model1.describe.content=c; - this.setState({model:model1}); - this.props.seteditorHtml(c); - } - - //底部描述图 - onUploadChange2(files){ - if(files.length > 0 && files[0].status == "success") - { - let model1 = this.state.model; - model1.describe.bg_image= files[0].src; - this.setState({model:model1}) - this.props.setbottomImg(files[0].src); - }else{ - let model1 = this.state.model; - model1.describe.bg_image=''; - this.setState({model:model1}) - this.props.setbottomImg(""); - } - }; - - - - onUploadError = (type, data) => { - if (type === 'overMaxAmount') { - Notify.error(`最多可上传 ${data.maxAmount} 张图片`); - } else if (type === 'overMaxSize') { - Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); - } - }; - handleChange = (color) => { - let model1=this.state.model; - model1.font_color=color; - this.setState({ - model:model1 + onUpload = (file, report) => { + let self = this; + return new Promise((resolve, reject) => { + let path = "" + let formdata = new FormData(); + formdata.append("file", file) + formdata.append("path", "common_image") + uploadImg(formdata).then((res) => { + handelResponse(res, (req, msg) => { + path = req.path; + + }, (err) => { + reject(); + }) }); - this.props.setButtonbgcolor(color); - - } - handleChange1 = (color) => { - let model1=this.state.model; - model1.button_color=color; - this.setState({ - model:model1 + + let count = 0; + const update = () => { + if (path) { + + resolve( + path + ); + + } + else { + + if (count < 100) { + count += 2; + report(count); + setTimeout(update, 500); + console.log("上传中") + } + else { + + reject(); + } + } + + + }; + setTimeout(update, 500); }); - this.props.setButtoncolor(color); + + }; + controlColor = (attr, color) => { + let model1 = this.state.model; + model1[attr] = color; + this.setState({ + model: model1 + }); + this.props.setGoodConfig({ attr, value: color }); } - // 字体颜色 - fontcolor(cor){ - let models=this.state.model; - models.button_color=cor; - this.setState({model:models}); - this.props.setButtoncolor(cor); - } - // 背景颜色 - bgcolor(cor){ - let models=this.state.model; - models.font_color=cor; - this.setState({model:models}); - this.props.setButtonbgcolor(cor); - } - onUpload = (file, report) => { - let self=this; - console.log('上传头像',file); - return new Promise((resolve, reject) => { - let path = "" - let formdata= new FormData(); - formdata.append("file",file) - formdata.append("path","common_image") - uploadImg(formdata).then((res)=>{ - handelResponse(res,(req,msg)=>{ - path = req.path; - - },(err)=>{ - reject(); - }) - }); - - let count = 0; - const update = () => { - if(path) - { - - resolve( - path - ); - - } - else{ - - if (count < 100) { - count += 2; - report(count); - setTimeout(update, 500); - console.log("上传中") - } - else{ - - reject(); - } - } - - - }; - setTimeout(update, 500); - }); - - }; - - - - componentWillUnmount(){ - let oldobj=JSON.parse(sessionStorage.getItem('editorConfig')); - if(oldobj&&oldobj.whiteList){ - let whiteList=oldobj.whiteList; - whiteList.product_list=this.state.model; - oldobj.whiteList=whiteList; - }else{ - let whiteList={} - whiteList.product_list=this.state.model; - oldobj.whiteList=whiteList; - } - sessionStorage.setItem('editorConfig',JSON.stringify(oldobj)); + + componentWillUnmount() { + let oldobj = JSON.parse(sessionStorage.getItem('editorConfig')); + if (oldobj && oldobj.whiteList) { + let whiteList = oldobj.whiteList; + whiteList.product_list = this.state.model; + oldobj.whiteList = whiteList; + } else { + let whiteList = {} + whiteList.product_list = this.state.model; + oldobj.whiteList = whiteList; } + sessionStorage.setItem('editorConfig', JSON.stringify(oldobj)); + } - render(){ - return( -
-
-
样式
- -
- - {this.onListChange(e)} } value={this.state.model.list}> - 轮播 - 列表 - 矩阵 - - -
- { - this.state.model.list==2? -
- {this.bgcolor('#ffffff')}}> - {this.bgcolor('#000000')}}> -
-
-
-
:null - } - { - this.state.model.list==2? -
- {this.fontcolor('#ffffff')}}> - {this.fontcolor('#04C160')}}> - {this.fontcolor('#AE99D3')}}> - {this.fontcolor('#FACD6A')}}> - {this.fontcolor('#FE7962')}}> -
- + render() { + return ( +
+ +
样式
+ +
+ + { this.configChange('list', e) }} value={this.state.model.list}> + 轮播 + 列表 + 矩阵 + +
+ { + this.state.model.list == 2 ? +
+ { this.controlColor('font_color', '#ffffff') }}> + { this.controlColor('font_color', '#000000') }}> +
+ this.controlColor('font_color', c)} />
+
+
: null + } + { + this.state.model.list == 2 ? +
+ { this.controlColor('button_color', '#ffffff') }}> + { this.controlColor('button_color', '#04C160') }}> + { this.controlColor('button_color', '#AE99D3') }}> + { this.controlColor('button_color', '#FACD6A') }}> + { this.controlColor('button_color', '#FE7962') }}> +
+ this.controlColor('button_color', c)} /> +
+
+ +
: null + } + + +
基础图层
+ + { this.onUploadChange(e) }} + onUpload={this.onUpload} + defaultFileList={this.state.model.top_image ? [{ 'src': this.state.model.top_image }] : null} + onError={this.onUploadError} + /> + + +
+ + { this.explainChange('type', e) }} value={this.state.model.describe.type}> + this.hasItemFn(1)} value={"1"}>图片 + this.hasItemFn(2)} value={"2"}>悬浮 + this.hasItemFn(3)} value={"3"}>富文本 + + + + + +
- - :null - } - - -
基础图层
- - + {this.onUploadChange(e)} } - onError={this.onUploadError} - onUpload={this.onUpload} - defaultFileList={ this.state.model.top_image ? [{'src':this.state.model.top_image}] : null } - onError={this.onUploadError} - - /> - - -
- - {this.onactivityChange(e)} } value={this.state.model.describe.type}> - this.hasItemFn(1)} value={"1"}>图片 - this.hasItemFn(2)} value={"2"}>悬浮 - this.hasItemFn(3)} value={"3"}>富文本 - - - - - - -
- { - this.state.model.describe.type==1? - {this.onUploadChange2(e)} } + onChange={(e) => { this.onUploadChange2(e) }} onUpload={this.onUpload} onError={this.onUploadError} - defaultFileList={this.state.model.describe.bg_image ? [{'src':this.state.model.describe.bg_image}] : null} + defaultFileList={this.state.model.describe.bg_image ? [{ 'src': this.state.model.describe.bg_image }] : null} /> - :this.state.model.describe.type==2?this.getsusEditext(c)} />:this.state.model.describe.type==3?this.getEditext(c)}/>:null - } + : this.state.model.describe.type == 2 ? this.getsusEditext(c)} /> : this.state.model.describe.type == 3 ? this.getsusEditext(c)} /> : null + } + - - +
) }