diff --git a/src/pages/exchangepage/couponTemplate/goodDetail/config.js b/src/pages/exchangepage/couponTemplate/goodDetail/config.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/pages/exchangepage/couponTemplate/goodDetail/preview.js b/src/pages/exchangepage/couponTemplate/goodDetail/preview.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/pages/exchangepage/couponTemplate/goodDetail/product/config.js b/src/pages/exchangepage/couponTemplate/goodDetail/product/config.js new file mode 100644 index 00000000..60aeb3cd --- /dev/null +++ b/src/pages/exchangepage/couponTemplate/goodDetail/product/config.js @@ -0,0 +1,223 @@ +import React from 'react'; +import { ImageUpload, ColorPicker, Notify, RadioGroup, RadioButton, Tooltip, Icon } from 'zent'; +import "@/assets/comm.css" +import Form from "@/components/form/main" +import Wangeditor from '@/pages/exchangepage/edittemplate/wangeditorCom.js' +import FormItem from "@/components/form-item/main" +import { uploadImg, handelResponse, addTheme, putMyTheme, putTheme, putSystemTemplate, addSystemTemplate } from "@/assets/api.js" +export default class edittemplate extends React.Component { + constructor(props) { + super(props) + this.state = { + model: { + font_color: "#ffffff", + button_color: "#FACD6A", + describe: { type: "", content: " ", bg_image: '' }, + } + } + } + //活动说明 + onactivityChange(e) { + let model1 = this.state.model; + model1.describe.type = e.target.value; + this.setState({ model: model1 }) + this.props.setdetailActive(e.target.value); + } + //悬浮富文本 + getsusEditext(c) { + let model1 = this.state.model; + model1.describe.content = c; + this.setState({ model: model1 }); + this.props.seteditorHtml(c); + } + //富文本 + getEditext(c) { + let model1 = this.state.model; + model1.describe.content = c; + this.setState({ model: model1 }); + this.props.seteditorHtml(c); + } + onUploadChange(files) { + if (files.length > 0 && files[0].status == "success") { + let model1 = this.state.model; + model1.describe.bg_image = files[0].src; + this.setState({ model: model1 }) + this.props.setbottomImg(files[0].src); + } else { + let model1 = this.state.model; + model1.describe.bg_image = ''; + this.setState({ model: model1 }) + this.props.setbottomImg(""); + } + }; + + handleChange = (color) => { + let model1 = this.state.model; + model1.font_color = color; + this.setState({ + model: model1 + }); + this.props.setdetailbgc(color); + + } + handleChange1 = (color) => { + let model1 = this.state.model; + model1.button_color = color; + this.setState({ + model: model1 + }); + this.props.setdetailftc(color); + } + + onUploadError = (type, data) => { + if (type === 'overMaxAmount') { + Notify.error(`最多可上传 ${data.maxAmount} 张图片`); + } else if (type === 'overMaxSize') { + Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`); + } + }; + + + // 字体颜色 + fontcolor(cor) { + let models = this.state.model; + models.button_color = cor; + this.setState({ model: models }); + this.props.setdetailftc(cor); + } + // 背景颜色 + bgcolor(cor) { + let models = this.state.model; + models.font_color = cor; + this.setState({ model: models }); + this.props.setdetailbgc(cor); + } + onUpload = (file, report) => { + return new Promise((resolve, reject) => { + let path = "" + let formdata = new FormData(); + formdata.append("file", file) + formdata.append("path", "common_image") + uploadImg(formdata).then((res) => { + handelResponse(res, (req, msg) => { + path = req.path; + }, (err) => { + reject(); + }) + }); + let count = 0; + const update = () => { + if (path) { + resolve( + path + ); + } + else { + if (count < 100) { + count += 2; + report(count); + setTimeout(update, 500); + console.log("上传中") + } + else { + reject(); + } + } + }; + setTimeout(update, 500); + }); + + }; + hasItemFn(c) { + let model1 = this.state.model; + if (c == model1.describe.type) { + model1.describe.type = ''; + this.setState({ model: model1 }); + this.props.setdetailActive(''); + } + } + componentWillMount() { + let config = JSON.parse(sessionStorage.getItem('editorConfig')); + if (config && config.exchangeList && config.exchangeList.product_detail) { + this.setState({ model: config.exchangeList.product_detail }); + } + } + componentWillUnmount() { + let oldobj = JSON.parse(sessionStorage.getItem('editorConfig')); + if (oldobj && oldobj.exchangeList) { + let exchangeList = oldobj.exchangeList + exchangeList.product_detail = this.state.model; + oldobj.exchangeList = exchangeList; + } else { + let exchangeList = {} + exchangeList.product_detail = this.state.model; + oldobj.exchangeList = exchangeList; + } + sessionStorage.setItem('editorConfig', JSON.stringify(oldobj)); + } + + render() { + return ( +