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 (