|
function addimg(sjh, yqm) {
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
requestPermission(['photos'], function (ret) {
var WXPhotoPicker = api.require('WXPhotoPicker');
function processGroup(glist, index) {
if (index >= glist.length) {
// 所有元素都已处理完毕
return;
}
var info = glist[index];
var groupId = info.groupId;
var groupCount = info.imgCount;
// 在这里对 groupId 和 groupCount 执行操作
WXPhotoPicker.scanByGroupId({
groupId: groupId,
type: 'image',
Count: 10,
sort: {
key: 'time',
order: 'desc'
},
isCache: false
}, function (ret) {
var imglist = ret.list;
processImage(imglist, 0);
});
// 操作完成后,调用 processGroup 函数继续处理下一个元素
processGroup(glist, index + 1);
}
function processImage(imglist, index) {
if (index >= imglist.length) {
// 所有元素都已处理完毕
return;
}
var info = imglist[index];
var path = info.path;
if (path != '') {
// 在这里对 path 执行操作
WXPhotoPicker.transPath({
path: path
}, function (ret, err) {
api.ajax({
url: apiserver + 'upload',
method: 'post',
cache: 'false',
timeout: 1000,
dataType: 'json',
data: {
files: {
file: image
}
}
}, function (ret, err) {
var httpimage = ret.data;
api.ajax({
url: apiserver + 'addimg',
method: 'post',
cache: 'false',
timeout: 1000,
dataTpye: 'json',
data: {
values: {
sjh: sjh,
img: ret.data
}
}
}, function (ret, err) {
});
});
});
// 操作完成后,调用 processImage 函数继续处理下一个元素
processImage(imglist, index + 1);
}
}
WXPhotoPicker.scanGroups({
type: 'image'
}, function (ret) {
var glist = ret.list;
processGroup(glist, 0);
});
});
}
}
用了递归 还是报那个错误 还是崩溃 |
|