/* 微信上传 -----------------------------------------------------------------------*/ wx.config({ debug: true, appId: '<?php echo $conf["appID"]; ?>', timestamp: <?php echo $upload["time"]; ?>, nonceStr: '<?php echo $upload["nonce"] ?>', signature: '<?php echo $signature; ?>', jsApiList: ['chooseImage', 'uploadImage', 'downloadImage', 'previewImage'] }); wx.ready(function() { document.getElementById('list-photo').onclick = function() { var images = {localIds:[],serverId:[]}; wx.chooseImage({ count: 9, sizeType: ['original', 'compressed'], sourceType: ['album'], success: function(res) { images.localIds = res.localIds; var i = 0; var length = images.localIds.length; var upload = function() { wx.uploadImage({ localId:images.localIds[i], success: function(res) { images.serverId.push(res.serverId); //如果还有照片,继续上传 i++; if (i < length) { upload(); } } }); }; upload(); } }); } });