老系统对接
This commit is contained in:
60
webapp/js/weixin-api-6.1_1.js
Normal file
60
webapp/js/weixin-api-6.1_1.js
Normal file
@ -0,0 +1,60 @@
|
||||
var upObj = null;
|
||||
wx.ready(function() {
|
||||
// 5 图片接口
|
||||
// 5.1 拍照、本地选图
|
||||
var images = {
|
||||
localId : [],
|
||||
serverId : [],
|
||||
uploadIds : [],
|
||||
};
|
||||
|
||||
document.querySelector("#chooseImage").onclick = function() {
|
||||
$(".photo").empty();
|
||||
wx.chooseImage({
|
||||
success : function(res) {
|
||||
images = {
|
||||
localId : res.localIds,
|
||||
serverId : [],
|
||||
uploadIds : [],
|
||||
};
|
||||
|
||||
if (images.localId.length == 0) {
|
||||
alert('请先拍取照片');
|
||||
return;
|
||||
}
|
||||
if (images.localId.length > 4) {
|
||||
alert('最多允许上传四张,请重新选择');
|
||||
images.localId = [];
|
||||
return;
|
||||
}
|
||||
|
||||
upload(0);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function upload(i) {
|
||||
localIdMes = images.localId[i];
|
||||
|
||||
wx.uploadImage({
|
||||
localId : localIdMes,
|
||||
success : function(res) {
|
||||
showImage(res.serverId, i);
|
||||
i++;
|
||||
setTimeout(function() {
|
||||
|
||||
if (i < images.localId.length) {
|
||||
upload(i);
|
||||
}
|
||||
}, 500)
|
||||
},
|
||||
fail : function(res) {
|
||||
alert(JSON.stringify(res));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
wx.error(function(res) {
|
||||
alert(res.errMsg);
|
||||
});
|
Reference in New Issue
Block a user