编辑器优惠券白名单数据处理

This commit is contained in:
许红梅 2022-09-14 13:39:42 +08:00
parent 1fa59939a8
commit 8f90a194b9
2 changed files with 152 additions and 112 deletions

View File

@ -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,26 +241,29 @@ 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 (
<div>
<div className='control page-title-control'>
<h1 style={{ fontSize: '16px' }}>落地页设置</h1>
<h1 style={{ fontSize: '16px' }}>落地页设置123</h1>
</div>
<div style={{ width: "92%", "margin": "0 auto 60px", "overflow": "auto", "maxHeight": "100%" }}>

View File

@ -341,9 +341,20 @@ export default class edittemplate extends React.Component {
}
couponList['land'].title = newEditor.title
couponList['land'].sort = newEditor.sort
//优惠券白名单
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 ? (
<CouponGoodsListForm