From 8f90a194b9e10492a00b4ba246f95d8f7bb1024c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E7=BA=A2=E6=A2=85?= <1924913374@qq.com> Date: Wed, 14 Sep 2022 13:39:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E7=99=BD=E5=90=8D=E5=8D=95=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couponTemplate/landingPage/config/main.js | 236 ++++++++++-------- src/pages/exchangepage/edittemplate/main.js | 28 ++- 2 files changed, 152 insertions(+), 112 deletions(-) diff --git a/src/pages/exchangepage/couponTemplate/landingPage/config/main.js b/src/pages/exchangepage/couponTemplate/landingPage/config/main.js index ee3660a2..96662aea 100644 --- a/src/pages/exchangepage/couponTemplate/landingPage/config/main.js +++ b/src/pages/exchangepage/couponTemplate/landingPage/config/main.js @@ -6,6 +6,7 @@ import { Notify, RadioGroup, RadioButton } from 'zent'; import Ipt from "@/components/input/main" import Form from "@/components/form/main" import FormItem from "@/components/form-item/main" +import Bus from '@/assets/eventBus.js' import { uploadImg, handelResponse, getThemeType } from "@/assets/api.js" import Wangeditor from '@/pages/exchangepage/edittemplate/wangeditorCom.js' export default class edittemplate extends React.Component { @@ -28,18 +29,34 @@ export default class edittemplate extends React.Component { } componentWillMount(e) { + console.log(6666,'组件初始化啦'); let self = this; let config = JSON.parse(sessionStorage.getItem('editorConfig')); let moudTyle = sessionStorage.getItem('mouldType'); if (moudTyle && moudTyle == 0) { this.setState({ isSystemModel: true }); } - if (config && config.couponList && config.couponList.land) { - let data = config.couponList.land; + if (this.props.templateType == 4) { + let data = config.couponWhiteList.land; this.setState({ model: data }); } else { - + let data = config.couponList.land; + this.setState({ model: data }); } + Bus.addListener('refreshcoupon', (prop) => { + console.log(46, config); + if (config && config.couponList && config.couponList.land) { + let data = config[prop].land; + this.setState({ model: data }); + } + console.log(52,prop); + if(prop=='couponList'){ + config.couponWhiteList.land = this.state.model; + }else{ + config.couponList.land = this.state.model; + } + sessionStorage.setItem('editorConfig', JSON.stringify(config)); + }) getThemeType().then(res => { handelResponse(res, (req, msg) => { let typeListSource = res.data.map(it => { @@ -224,119 +241,87 @@ export default class edittemplate extends React.Component { //组件将要销毁阶段 componentWillUnmount() { let oldobj = JSON.parse(sessionStorage.getItem('editorConfig')); - if (oldobj && oldobj.couponList) { - let couponList = oldobj.couponList + let couponList; + if (this.props.templateType == 4) { + couponList = oldobj.couponWhiteList couponList.land = this.state.model; - oldobj.couponList = couponList; + oldobj.couponWhiteList = couponList; } else { - oldobj = {} - let couponList = {} + couponList = oldobj.couponList couponList.land = this.state.model; oldobj.couponList = couponList; } sessionStorage.setItem('editorConfig', JSON.stringify(oldobj)); } - + componentWillReceiveProps(val) { + console.log(123, val); + } render() { + console.log(262,this.state); return (
-

落地页设置

+

落地页设置123

-
-
基础设置
+
+
基础设置
-
- - { - let model2 = this.state.model; - model2.title = e; - this.setState({ model: model2 }) - this.props.settitle(e) - }} - onClearItem={(e) => { + + + { let model2 = this.state.model; - model2.title = ""; + model2.title = e; this.setState({ model: model2 }) + this.props.settitle(e) }} - value={this.state.model.title} placeholder={"请输入"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'300px'} alignment={'left'} /> - - { - this.state.isSystemModel ? ( - - this.sortFn(c)} value={this.state.model.sort} placeholder="请输入数字" integer={true} max={999} /> - ) : null - } - { - this.state.isSystemModel ? ( - - { this.onmouldChange(e) }} placeholder="选择一项" width={300} value={this.state.model.type_id} /> + + ) : null + } +
样式
+ +
+ { this.bgcolor('#ffffff') }}> + { this.bgcolor('#EEEEEE') }}> + { this.bgcolor('#000000') }}> +
+ +
-
- - -
- { this.fontcolor('#ffffff') }}> - { this.fontcolor('#04C160') }}> - { this.fontcolor('#AE99D3') }}> - { this.fontcolor('#FACD6A') }}> - { this.fontcolor('#FE7962') }}> -
- + + +
+ { this.fontcolor('#ffffff') }}> + { this.fontcolor('#04C160') }}> + { this.fontcolor('#AE99D3') }}> + { this.fontcolor('#FACD6A') }}> + { this.fontcolor('#FE7962') }}> +
+ +
-
- -
基础图层
- - { this.onUploadChange(e) }} - onUpload={this.onUpload} - defaultFileList={this.state.model.top_image ? [{ 'src': this.state.model.top_image }] : null} - onError={this.onUploadError} - /> - - - { this.onUploadChange1(e) }} - defaultFileList={this.state.model.middle_image ? [{ 'src': this.state.model.middle_image }] : null} - onUpload={this.onUpload} - onError={this.onUploadError} - /> - - - { this.onactivityChange(e) }} value={this.state.model.describe.type}> - this.hasItemFn(1)}>图片 - this.hasItemFn(2)}>富文本 - - - { - this.state.model.describe.type == 1 ? + +
基础图层
+ { this.onUploadChange2(e) }} + onChange={(e) => { this.onUploadChange(e) }} onUpload={this.onUpload} + defaultFileList={this.state.model.top_image ? [{ 'src': this.state.model.top_image }] : null} onError={this.onUploadError} - defaultFileList={this.state.model.describe.bg_image ? [{ 'src': this.state.model.describe.bg_image }] : null} /> - : null - } - { - this.state.model.describe.type == 2 ? + + { this.onUploadChange2(e) }} + onChange={(e) => { this.onUploadChange1(e) }} + defaultFileList={this.state.model.middle_image ? [{ 'src': this.state.model.middle_image }] : null} onUpload={this.onUpload} onError={this.onUploadError} - defaultFileList={this.state.model.describe.bg_image ? [{ 'src': this.state.model.describe.bg_image }] : null} /> - : null - } - {this.state.model.describe.type == 2 ? this.getEditext(c)} /> : null} - -
+
+ + { this.onactivityChange(e) }} value={this.state.model.describe.type}> + this.hasItemFn(1)}>图片 + this.hasItemFn(2)}>富文本 + + + { + this.state.model.describe.type == 1 ? + { this.onUploadChange2(e) }} + onUpload={this.onUpload} + onError={this.onUploadError} + defaultFileList={this.state.model.describe.bg_image ? [{ 'src': this.state.model.describe.bg_image }] : null} + /> + : null + } + { + this.state.model.describe.type == 2 ? + { this.onUploadChange2(e) }} + onUpload={this.onUpload} + onError={this.onUploadError} + defaultFileList={this.state.model.describe.bg_image ? [{ 'src': this.state.model.describe.bg_image }] : null} + /> + : null + } + {this.state.model.describe.type == 2 ? this.getEditext(c)} /> : null} + +
) } diff --git a/src/pages/exchangepage/edittemplate/main.js b/src/pages/exchangepage/edittemplate/main.js index 38600118..8d9ca635 100644 --- a/src/pages/exchangepage/edittemplate/main.js +++ b/src/pages/exchangepage/edittemplate/main.js @@ -341,9 +341,20 @@ export default class edittemplate extends React.Component { } couponList['land'].title = newEditor.title couponList['land'].sort = newEditor.sort - newEditor.exchangeList = exchangeList - newEditor.whiteList = whiteList - newEditor.couponList = couponList; + //优惠券白名单 + let couponWhiteList = newEditor.couponWhiteList + if (!couponWhiteList) { + couponWhiteList = {} + couponWhiteList.land = model + couponWhiteList.product_list = couponProduct_list + couponWhiteList.product_detail = product_detail + } + couponWhiteList['land'].title = newEditor.title + couponWhiteList['land'].sort = newEditor.sort + newEditor.exchangeList = exchangeList + newEditor.whiteList = whiteList + newEditor.couponList = couponList; + newEditor.couponWhiteList = couponWhiteList; if (template == 1) { //1-白名单 2-兑换码 this.setState({ model: newEditor.whiteList.land, @@ -362,7 +373,7 @@ export default class edittemplate extends React.Component { this.setState({ pagedisable: true }) } } else {//新增数据 - let obj = {}, whiteList = {}, exchangeList = {}, couponList = {} + let obj = {}, whiteList = {}, exchangeList = {}, couponList = {},couponWhiteList={} let sourceObj = {//模板数据结构 land: model, product_list, @@ -376,9 +387,11 @@ export default class edittemplate extends React.Component { whiteList = _.cloneDeep(sourceObj); exchangeList = _.cloneDeep(sourceObj); couponList = _.cloneDeep(sourcecouponObj); + couponWhiteList = _.cloneDeep(sourcecouponObj); obj.exchangeList = exchangeList obj.whiteList = whiteList obj.couponList = couponList + obj.couponWhiteList = couponWhiteList sessionStorage.setItem('editorConfig', JSON.stringify(obj)) } } @@ -656,6 +669,12 @@ export default class edittemplate extends React.Component { let couponData = editorData.couponList let { land, product_list, product_detail } = couponData; this.setState({ model: land, product_list, product_detail }) + Bus.emit('refreshcoupon', 'couponList') + }else if (e.target.value == 4) { + let couponData = editorData.couponWhiteList + let { land, product_list, product_detail } = couponData; + this.setState({ model: land, product_list, product_detail }) + Bus.emit('refreshcoupon', 'couponWhiteList') } } onPreview() { @@ -1242,6 +1261,7 @@ export default class edittemplate extends React.Component { landbgcolor={(c) => this.getlandbgcolor(c)} landftcolor={(c) => this.getlandftcolor(c)} setbanner={(e) => this.getLandingdata(e)} + templateType={this.state.showType} /> ) : this.state.activeNavStatus == 2 ? (