商品编辑

This commit is contained in:
姜棚 2022-01-19 14:24:29 +08:00
parent 6f1eaf6fee
commit f31deff8f1
2 changed files with 44 additions and 29 deletions

View File

@ -309,6 +309,7 @@ export default class exchangedit extends React.Component{
_object.product_type= o.product_type
_object.quantity= o.quantity
_object.show_url = o.show_url
_object.detail_url = o.detail_url
_object.map_product_name = o.map_product_name
updateProduct.push(_object)
}

View File

@ -29,7 +29,7 @@ export default class adduserinfo extends React.Component{
describe_url:[],
stock:"",
usage:"",
goodDetail:"",
detail_url:"",
map_product_name:""
},
cur_product:null,
@ -47,18 +47,15 @@ export default class adduserinfo extends React.Component{
centeredSlides: true,
loop : true,
autoplay : 3000,
initialSlide :0,
observer: true, // 修改swiper自己或子元素时自动初始化swiper
observeParents: false, // 修改swiper的父元素时自动初始化swiper
observeParents: true, // 修改swiper的父元素时自动初始化swiper
pagination: '.swiper-pagination',
watchSlidesVisibility: true,
virtual: {
slides:this.state.productpic,
}
})
}
componentWillReceiveProps() {
console.log(1111);
// this.mySwiper.update();
this.mySwiper.update();
}
componentWillMount(e){
@ -75,7 +72,7 @@ export default class adduserinfo extends React.Component{
model.quantity = model_temp.quantity
model.product_name = model_temp.product_name
model.show_url = model_temp.show_url
model.detail_url = model_temp.detail_url
let defaultPic = []
let arr = []
@ -274,12 +271,11 @@ export default class adduserinfo extends React.Component{
}
};
onUploadChange1(files,e){
let arr =_.map(files,(o)=>{
return o.name
})
console.log("保留的数据",arr)
if(arr.length > this.state.productpic.length)
{
//新增
@ -321,17 +317,22 @@ export default class adduserinfo extends React.Component{
}
if(arr.length < this.state.productpic.length)
{
let temp_arr = [];
for(let i = 0;i < this.state.productpic.length;i++ )
let temp_arr = Object.assign([],this.state.productpic);
this.setState({productpic:[]})
this.state.productpic = []
let temp_arr2 = this.state.productpic
console.log(temp_arr)
console.log("删除前的数据",this.state.productpic)
for(let i = 0;i < temp_arr.length;i++ )
{
let temp = this.state.productpic[i]
let temp =temp_arr[i]
if(arr.indexOf(temp.name) > -1)
{
temp_arr.push(temp)
temp_arr2.push(temp)
}
}
console.log("移除后数据",temp_arr)
this.setState({productpic:temp_arr})
console.log("删除过后的数组",this.state.productpic)
this.setState({temp_arr2})
}
// //调整位置
@ -346,11 +347,25 @@ export default class adduserinfo extends React.Component{
}
this.setState({productpic:temp_arr})
}
console.log(this.mySwiper)
console.log( this.state.productpic)
this.mySwiper.update();
this.mySwiper.startAutoplay();
this.mySwiper.reLoop();
// console.log("swiperwrapper",this.refs.swiperwrapper)
// this.refs.swiperwrapper.innerHTML=""
// this.mySwiper.destroy();
// this.mySwiper = new Swiper('.swiper-container', {
// slidesPerView: 1,
// centeredSlides: true,
// loop : true,
// autoplay : 3000,
// observer: true, // 修改swiper自己或子元素时自动初始化swiper
// observeParents: true, // 修改swiper的父元素时自动初始化swiper
// pagination: '.swiper-pagination',
// watchSlidesVisibility: true,
// })
// this.mySwiper.update();
// let swiperBox = this.refs.swiperwrapper
};
onUploadError = (type, data) => {
@ -370,7 +385,7 @@ export default class adduserinfo extends React.Component{
handelResponse(res,(req,msg)=>{
let path = req.path;
let model = this.state.model;
model.goodDetail = path;
model.detail_url = path;
this.setState({model:model})
},(err)=>{
@ -380,7 +395,7 @@ export default class adduserinfo extends React.Component{
}
else{
let model = this.state.model;
model.goodDetail = "";
model.detail_url = "";
this.setState({model:model})
}
}
@ -507,13 +522,13 @@ export default class adduserinfo extends React.Component{
/>
</FormItem>
<FormItem prop="goodDetail" labelname="商品详情" id="goodDetail" required={false}>
<FormItem prop="detail_url" labelname="商品详情" id="detail_url" required={false}>
<ImageUpload
className="zent-image-upload-demo"
maxSize={5 * 1024 * 1024}
tips="建议尺寸 30*30图片不超过 20KB"
maxAmount={1}
fileList={this.state.model.goodDetail ? [{'src':this.state.model.goodDetail}] : null}
fileList={this.state.model.detail_url ? [{'src':this.state.model.detail_url}] : null}
onUpload={this.onUpload}
onChange={(e)=>{this.onUploadChange2(e)}}
/>
@ -526,7 +541,7 @@ export default class adduserinfo extends React.Component{
this.state.productpic ?
(
<div className="swiper-container">
<div className="swiper-wrapper">
<div className="swiper-wrapper" ref="swiperwrapper">
{
this.state.productpic.map((item, index) => {
@ -554,8 +569,7 @@ export default class adduserinfo extends React.Component{
</div>
<div className="mobile_bottom">
{
this.state.model.goodDetail ? (<img src={this.state.model.goodDetail} />) : null
this.state.model.detail_url ? (<img src={this.state.model.detail_url} />) : null
}
</div>