This commit is contained in:
zhangds 2022-06-24 18:27:15 +08:00
commit 6a8dfec703
2 changed files with 34 additions and 35 deletions

View File

@ -112,11 +112,11 @@ export default class adduserinfo extends React.Component {
for (let i = 0; i < pics.length; i++) { for (let i = 0; i < pics.length; i++) {
let obj = {} let obj = {}
let nameArr = pics[i].split('/') let nameArr = pics[i].split('/')
obj.name = nameArr[5] obj.name = nameArr[5] || nameArr[2]
obj.src = pics[i] obj.src = pics[i]
defaultPic.push(obj) defaultPic.push(obj)
let obj2 = { let obj2 = {
name: nameArr[5], name: nameArr[5] || nameArr[2],
url: pics[i] url: pics[i]
} }
temp_productpic.push(obj2) temp_productpic.push(obj2)
@ -260,13 +260,23 @@ export default class adduserinfo extends React.Component {
const obj2 = [] const obj2 = []
if (picItem.describe_url) { if (picItem.describe_url) {
let id_name = `${new Date().getTime()}`; let id_name = new Date().getTime()
picItem?.describe_url.map((item) => { picItem?.describe_url.map((item) => {
obj1.push({ src: item, id: `${id_name}`, type:"add", name:`${picItem.name}`}) obj1.push({
obj2.push({ url: item, id: `${id_name}`, type:"add", name:`${picItem.name}` }) src: item,
id: id_name,
type: 'add',
name: picItem.name
})
obj2.push({
url: item,
id: id_name,
type: 'add',
name: picItem.name
})
}) })
} }
console.log(" picItem =>", picItem); console.log(' picItem =>', picItem)
let quantity = this.state.model.quantity let quantity = this.state.model.quantity
let model2 = { let model2 = {
@ -325,7 +335,7 @@ export default class adduserinfo extends React.Component {
onUploadChange1(files, e) { onUploadChange1(files, e) {
console.log('编辑 ==>files', files) console.log('编辑 ==>files', files)
let arr = _.map(files, (o) => { let arr = _.map(files, (o) => {
return o.id return o.name
}) })
if (mySwiper !== 0) { if (mySwiper !== 0) {
mySwiper.destroy() mySwiper.destroy()
@ -338,13 +348,12 @@ export default class adduserinfo extends React.Component {
autoplay: 3000 autoplay: 3000
}) })
clearTimeout(timer) clearTimeout(timer)
debugger
timer = setTimeout(() => { timer = setTimeout(() => {
if (arr.length > this.state.productpic.length) { if (arr.length > this.state.productpic.length) {
//新增 //新增
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
let index = this.state.productpic.findIndex((o) => { let index = this.state.productpic.findIndex((o) => {
return o.id == arr[i] return o.name == arr[i]
}) })
if (index < 0) { if (index < 0) {
let path = '' let path = ''
@ -388,7 +397,7 @@ export default class adduserinfo extends React.Component {
let temp_arr2 = this.state.productpic let temp_arr2 = this.state.productpic
for (let i = 0; i < temp_arr.length; i++) { for (let i = 0; i < temp_arr.length; i++) {
let temp = temp_arr[i] let temp = temp_arr[i]
if (arr.indexOf(temp.id) > -1) { if (arr.indexOf(temp.name) > -1) {
temp_arr2.push(temp) temp_arr2.push(temp)
} }
} }
@ -401,7 +410,7 @@ export default class adduserinfo extends React.Component {
let pic_arr = this.state.productpic let pic_arr = this.state.productpic
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
let temp = pic_arr.find((o) => { let temp = pic_arr.find((o) => {
return o.id == arr[i] return o.name == arr[i]
}) })
temp_arr[i] = temp temp_arr[i] = temp
} }
@ -409,10 +418,10 @@ export default class adduserinfo extends React.Component {
console.log(this.state.model) console.log(this.state.model)
console.log('temp_arr =>', temp_arr) console.log('temp_arr =>', temp_arr)
let left_temp_arr = temp_arr.map((item) => { let left_temp_arr = files.map((item) => {
return { return {
...item, ...item,
src: item.url url: item.src
} }
}) })
let models = this.state.model let models = this.state.model
@ -631,10 +640,7 @@ export default class adduserinfo extends React.Component {
value={this.state.model.show_url} value={this.state.model.show_url}
/> />
</FormItem> </FormItem>
<FormItem <FormItem prop='describe_url' labelname='商品图' id='describe_url'>
prop='describe_url'
labelname='商品图2222'
id='describe_url'>
<ImageUpload <ImageUpload
className='good-image-upload-demo' className='good-image-upload-demo'
maxSize={2 * 1024 * 1024} maxSize={2 * 1024 * 1024}

View File

@ -104,11 +104,11 @@ export default class adduserinfo extends React.Component {
for (let i = 0; i < pics.length; i++) { for (let i = 0; i < pics.length; i++) {
let obj = {} let obj = {}
let nameArr = pics[i].split('/') let nameArr = pics[i].split('/')
obj.name = nameArr[5] obj.name = nameArr[5] || nameArr[2]
obj.src = pics[i] obj.src = pics[i]
defaultPic.push(obj) defaultPic.push(obj)
let obj2 = { let obj2 = {
name: nameArr[5], name: nameArr[5] || nameArr[2],
url: pics[i] url: pics[i]
} }
temp_productpic.push(obj2) temp_productpic.push(obj2)
@ -256,24 +256,25 @@ export default class adduserinfo extends React.Component {
const obj1 = [] const obj1 = []
const obj2 = [] const obj2 = []
const _id = new Date().getTime() + '48153461544'
picItem?.describe_url.map((item) => { picItem?.describe_url.map((item) => {
obj1.push({ obj1.push({
src: item, src: item,
name: 'xxx.png', name: 'xxx.png',
id: new Date().getTime() id: _id
}) })
obj2.push({ obj2.push({
url: item, url: item,
name: 'xxx.png', name: 'xxx.png',
id: new Date().getTime() id: _id
}) })
}) })
model2.describe_url = obj1 model2.describe_url = obj1
model2.map_product_name = cur_product.title model2.map_product_name = cur_product.title
model2.detail_url = '' model2.detail_url = ''
this.setState({ model: model2 })
this.setState({ this.setState({
model: model2,
show_url: picItem ? [{ src: picItem.pic, id: new Date().getTime() }] : [], show_url: picItem ? [{ src: picItem.pic, id: new Date().getTime() }] : [],
productpic: obj2 productpic: obj2
}) })
@ -420,7 +421,7 @@ export default class adduserinfo extends React.Component {
} }
// //调整位置 // //调整位置
if (arr.length == this.state.productpic.length) { if (arr.length === this.state.productpic.length) {
let temp_arr = [] let temp_arr = []
let pic_arr = this.state.productpic let pic_arr = this.state.productpic
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
@ -429,24 +430,16 @@ export default class adduserinfo extends React.Component {
}) })
temp_arr[i] = temp temp_arr[i] = temp
} }
this.setState({ productpic: temp_arr }) let left_temp_arr = files.map((item) => {
let left_temp_arr = temp_arr.map((item) => {
return { return {
...item, ...item,
src: item.url url: item.src
} }
}) })
let models = this.state.model let models = this.state.model
models.describe_url = left_temp_arr models.describe_url = left_temp_arr
this.setState({ model: models }) this.setState({ model: models, productpic: temp_arr })
} }
// if(this.mySwiper)
// {
// // this.refs.swiperwrapper
// this.mySwiper.destroy()
// }
}, 500) }, 500)
} }