系统模板新增/编辑接口联调,数据处理

This commit is contained in:
许红梅 2022-09-16 16:44:50 +08:00
parent 72ee4b2b11
commit 7457efe98f
2 changed files with 38 additions and 49 deletions

View File

@ -12,17 +12,14 @@ export default class edittemplate extends React.Component {
constructor(props) {
super(props)
this.state = {
isSystemModel: false,
mouldWay: [],
model: {
title: "落地页标题12",
top_image: "",
middle_image: "",
white_image: "",
describe: { type: "", content: "", bg_image: '' },
bg_color: "#EEEEEE",
font_color: "#000000",
sort: 1,
type_id: { key: 1, text: '通用' }
},
}
}
@ -32,9 +29,6 @@ export default class edittemplate extends React.Component {
let self = this;
let config = JSON.parse(sessionStorage.getItem('editorConfig'));
let moudTyle = sessionStorage.getItem('mouldType');
if (moudTyle && moudTyle == 0) {
this.setState({ isSystemModel: true });
}
let data = config.coupon.land;
console.log(111,data);
this.setState({ model: data });
@ -47,17 +41,6 @@ export default class edittemplate extends React.Component {
// config.coupon.land = this.state.model;
// sessionStorage.setItem('editorConfig', JSON.stringify(config));
// })
getThemeType().then(res => {
handelResponse(res, (req, msg) => {
let typeListSource = res.data.map(it => {
return { key: it.id, text: it.name }
});
self.setState({ mouldWay: typeListSource });
}, (err) => {
})
}).catch(err => {
});
}
handleChange = (color) => {
let model1 = this.state.model;
@ -95,13 +78,6 @@ export default class edittemplate extends React.Component {
this.props.setbanner(this.state.model);
}
}
onmouldChange(c) {
let model1 = this.state.model;
model1.type_id = c;
this.setState({ model: model1 });
this.props.setbanner(model1);
}
//上传顶部banner
onUploadChange(files) {
if (files.length > 0 && files[0].status == "success") {
@ -118,15 +94,15 @@ export default class edittemplate extends React.Component {
};
//上传输入框
onUploadChange1(files) {
onUploadChange1(files,type) {
if (files.length > 0 && files[0].status == "success") {
let model = this.state.model;
model.middle_image = files[0].src;
model[type] = files[0].src;
this.setState({ model: model })
this.props.setbanner(model);
} else {
let model = this.state.model;
model.middle_image = '';
model[type] = '';
this.setState({ model: model })
this.props.setbanner(model);
}
@ -241,10 +217,12 @@ export default class edittemplate extends React.Component {
render() {
console.log(236,this.props.couponType);
console.log(237,this.state.model);
return (
<div>
<div className='control page-title-control'>
<h1 style={{ fontSize: '16px' }}>落地页设置123</h1>
<h1 style={{ fontSize: '16px' }}>落地页设置</h1>
</div>
<div style={{ width: "92%", "margin": "0 auto 60px", "overflow": "auto", "maxHeight": "100%" }}>
@ -265,19 +243,6 @@ export default class edittemplate extends React.Component {
}}
value={this.state.model.title} placeholder={"请输入"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'300px'} alignment={'left'} />
</FormItem>
{
this.state.isSystemModel ? (
<FormItem labelname="权重" required={false} prop="sort" id="sort" labelwidth="100px">
<NumberInput onChange={c => this.sortFn(c)} value={this.state.model.sort} placeholder="请输入数字" integer={true} max={999} />
</FormItem>) : null
}
{
this.state.isSystemModel ? (
<FormItem labelname="模板分类" labelwidth="100px" prop="scope" id="scope">
<Select options={this.state.mouldWay} onChange={(e) => { this.onmouldChange(e) }} placeholder="选择一项" width={300} value={this.state.model.type_id} />
</FormItem>
) : null
}
<div style={{ marginTop: '20px', marginBottom: '15px', fontWeight: 'bold' }}>样式</div>
<FormItem labelname="背景颜色:" prop="font_color" id="font_color" labelwidth="80px">
<div className="colorItembg dfleac">
@ -301,6 +266,9 @@ export default class edittemplate extends React.Component {
</div>
</div>
</FormItem>
{
this.props.couponType==4?<div>123</div>:<div>456</div>
}
<div style={{ marginTop: '20px', fontWeight: 'bold' }}>基础图层</div>
<FormItem labelname="顶部banner:" prop="top" id="top" labelwidth="100px">
<ImageUpload
@ -316,7 +284,8 @@ export default class edittemplate extends React.Component {
onError={this.onUploadError}
/>
</FormItem>
<FormItem labelname="输入框:" prop="center" id="center" labelwidth="100px">
{
this.props.couponType==4&&this.state.model.middle_image? <FormItem labelname="输入框1:" labelwidth="100px">
<ImageUpload
className="zent-image-upload-demo"
maxSize={5 * 1024 * 1024}
@ -324,12 +293,29 @@ export default class edittemplate extends React.Component {
multiple
sortable
tips="单张图片不超过 5M"
onChange={(e) => { this.onUploadChange1(e) }}
defaultFileList={this.state.model.middle_image ? [{ 'src': this.state.model.middle_image }] : null}
onChange={(e) => { this.onUploadChange1(e,'middle_image') }}
defaultFileList={[{ 'src': this.state.model.middle_image }] }
onUpload={this.onUpload}
onError={this.onUploadError}
/>
</FormItem>:
<FormItem labelname="输入框2:" labelwidth="100px">
<ImageUpload
className="zent-image-upload-demo"
maxSize={5 * 1024 * 1024}
maxAmount={1}
multiple
sortable
tips="单张图片不超过 54M"
onChange={(e) => { this.onUploadChange1(e,'white_image') }}
defaultFileList={this.state.model.white_image ? [{ 'src': this.state.model.white_image }] : null}
onUpload={this.onUpload}
onError={this.onUploadError}
/>
</FormItem>
}
{this.state.model.white_image}
<FormItem myClassName="activeSet" required={false} labelname="活动说明:" prop="bottom" id="bottom" labelwidth="100px">
<RadioGroup onChange={(e) => { this.onactivityChange(e) }} value={this.state.model.describe.type}>
<RadioButton value={"1"} onClick={() => this.hasItemFn(1)}>图片</RadioButton>

View File

@ -31,6 +31,7 @@ let model = {
title: '落地页标题',
top_image: '',
middle_image: '',
white_image: "",//白名单优惠券输入框
describe: { type: '', content: '', bg_image: '' },
bg_color: '#EEEEEE',
sort: 1,
@ -56,6 +57,7 @@ let product_detail = {
button_color: "#FACD6A",
}
}
//优惠券商品列表
let couponProduct_list = {
top_image: '',
@ -397,6 +399,7 @@ export default class edittemplate extends React.Component {
let editorList = JSON.parse(sessionStorage.getItem('editorConfig'))
let addSystemData = _.cloneDeep(editorList)
let infoWhite = addSystemData.whiteList
let infoCoupon = addSystemData.coupon//优惠券
if (!this.state.model.top_image) {
Notify.clear()
Notify.error('请上传落地页顶部banner')
@ -447,12 +450,11 @@ export default class edittemplate extends React.Component {
infoExchange.land = exchangeStateData.model
infoExchange.product_list = exchangeStateData.product_list
infoExchange.product_detail = exchangeStateData.product_detail
delete infoExchange.land.sort
delete infoExchange.land.title
delete infoWhite.land.title
delete infoWhite.land.sort
_.omit(infoExchange.land, ['title', 'sort']);
_.omit(infoWhite.land, ['title', 'sort']);
formdata.exchange = infoExchange
formdata.access_conf = infoWhite
formdata.coupon=infoCoupon
if (myInfoData) {
//编辑
putSystemTemplate(myInfoData.id, formdata).then((res) => {
@ -1260,6 +1262,7 @@ export default class edittemplate extends React.Component {
landbgcolor={(c) => this.getlandbgcolor(c)}
landftcolor={(c) => this.getlandftcolor(c)}
setbanner={(e) => this.getLandingdata(e)}
couponType={this.state.showType}
/>
) : this.state.activeNavStatus == 2 ? (
<CouponGoodsListForm