1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* 微信上传 -----------------------------------------------------------------------*/ 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(); } }); } }); |