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 (