From f31deff8f1eeedfba10633b963b2797a9784ef56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Wed, 19 Jan 2022 14:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/edit/edit.js | 1 + src/pages/exchangecode/product/add.js | 72 ++++++++++++++++----------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js index 37b973f4..ea46aabd 100644 --- a/src/pages/exchangecode/edit/edit.js +++ b/src/pages/exchangecode/edit/edit.js @@ -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) } diff --git a/src/pages/exchangecode/product/add.js b/src/pages/exchangecode/product/add.js index e371d867..99d0db81 100644 --- a/src/pages/exchangecode/product/add.js +++ b/src/pages/exchangecode/product/add.js @@ -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{ /> - + {this.onUploadChange2(e)}} /> @@ -526,7 +541,7 @@ export default class adduserinfo extends React.Component{ this.state.productpic ? (
-
+
{ this.state.productpic.map((item, index) => { @@ -554,8 +569,7 @@ export default class adduserinfo extends React.Component{
{ - this.state.model.goodDetail ? () : null - + this.state.model.detail_url ? () : null }