function (res) { var l = [] var m = [] var n = [] for (var i = 0; i < res.length; i++) { var item_imgs = [] var downs = [] for (var j = 0; j < res[i].item_imgs.length; j++) { if (res[i].item_imgs[j] != '' && res[i].item_imgs[j] != null) { var img = res[i].item_imgs[j].split('@')[0] + '@180w_180h' // var down = res[i].item_imgs[j].replace('http://yuqian-dj.img-cn-hangzhou.aliyuncs.com', 'https://yuqian-dj.oss-cn-hangzhou.aliyuncs.com').split('@')[0] + '?x-oss-process=image/resize,m_lfit,h_1600,w_1600' var down = res[i].item_imgs[j] item_imgs.push(img) downs.push(down) n.push(res[i].id) } } //console.log(downs) res[i].item_imgs = item_imgs l.push(res[i]) m.push(downs) } console.log(l) that.setData({ list: l, images: m, newItem:n }) } ) }
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
https://developers.weixin.qq.com/s/DfgGnXmz7tPU
代码片段,麻烦看下。
downloadImgs() {
var that = this
// 获取权限
down.writePhotosAlbum(
function success() {
wx.showLoading({
title: '下载中0/' + that.data.urls.length,
mask: true
})
down.queue(that.data.urls).then(res => {
wx.hideLoading()
wx.showToast({
title: '下载完成'
})
})
.catch(err => {
wx.hideLoading()
console.log(err)
})
},
function fail() {
wx.showToast({
icon:'none',
title: '您拒绝了保存到相册'
})
}
)
},
不好意思,贴出了,我们下载用的是这个
var l = []
var m = []
var n = []
for (var i = 0; i < res.length; i++) {
var item_imgs = []
var downs = []
for (var j = 0; j < res[i].item_imgs.length; j++) {
if (res[i].item_imgs[j] != '' && res[i].item_imgs[j] != null) {
var img = res[i].item_imgs[j].split('@')[0] + '@180w_180h'
// var down = res[i].item_imgs[j].replace('http://yuqian-dj.img-cn-hangzhou.aliyuncs.com', 'https://yuqian-dj.oss-cn-hangzhou.aliyuncs.com').split('@')[0] + '?x-oss-process=image/resize,m_lfit,h_1600,w_1600'
var down = res[i].item_imgs[j]
item_imgs.push(img)
downs.push(down)
n.push(res[i].id)
}
}
//console.log(downs)
res[i].item_imgs = item_imgs
l.push(res[i])
m.push(downs)
}
console.log(l)
that.setData({
list: l,
images: m,
newItem:n
})
}
)
}
这两个方法