老系统对接
This commit is contained in:
135
webapp/js/weixin-api-6.1_22.js
Normal file
135
webapp/js/weixin-api-6.1_22.js
Normal file
@ -0,0 +1,135 @@
|
||||
var upObj = null;
|
||||
wx.ready(function () {
|
||||
alert("加载不到----");
|
||||
// 5 图片接口
|
||||
// 5.1 拍照、本地选图
|
||||
var images = {
|
||||
localId: [],
|
||||
serverId: []
|
||||
};
|
||||
|
||||
function chooseImage1() {
|
||||
alert("-------------");
|
||||
$(".weui-row").empty();
|
||||
|
||||
wx.chooseImage({
|
||||
success: function (res) {
|
||||
images.localId = res.localIds;
|
||||
|
||||
if (images.localId.length == 0) {
|
||||
alert('请先拍取照片');
|
||||
return;
|
||||
}
|
||||
if(images.localId.length > 4) {
|
||||
alert('最多允许上传四张,请重新选择');
|
||||
images.localId = [];
|
||||
return;
|
||||
}
|
||||
var i=0;
|
||||
upload(i);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
function upload(i) {
|
||||
var length = images.localId.length;
|
||||
|
||||
var localIdMes = images.localId[i].toString();
|
||||
wx.uploadImage({
|
||||
localId: localIdMes,
|
||||
success: function (res) {
|
||||
i++;
|
||||
images.serverId=res.serverId;
|
||||
|
||||
if (i <= length) {
|
||||
//alert(images.serverId);
|
||||
upObj = new Object();
|
||||
upObj.imageId=images.serverId;
|
||||
showImage(upObj.imageId,i);
|
||||
upload(i);
|
||||
}
|
||||
|
||||
|
||||
// showImage(upObj.imageId);
|
||||
// setTimeout("showImage(upObj.imageId)",500);
|
||||
// images.localId = [];
|
||||
|
||||
},
|
||||
fail: function (res) {
|
||||
alert(JSON.stringify(res));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//5.2 图片预览
|
||||
/*
|
||||
document.querySelector('#previewImage').onclick = function () {
|
||||
wx.previewImage({
|
||||
current: 'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
|
||||
urls: [
|
||||
'http://img3.douban.com/view/photo/photo/public/p2152117150.jpg',
|
||||
'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
|
||||
'http://img3.douban.com/view/photo/photo/public/p2152134700.jpg'
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
*/
|
||||
// 5.3 <20>ϴ<EFBFBD>ͼƬ
|
||||
|
||||
document.querySelector('#uploadImage').onclick = function () {
|
||||
uploadImage();
|
||||
};
|
||||
/*
|
||||
document.querySelector('#uploadImage').onclick = function () {
|
||||
if (images.localId.length == 0) {
|
||||
alert('请先拍取照片');
|
||||
return;
|
||||
}
|
||||
var i = 0, length = images.localId.length;
|
||||
images.serverId = [];
|
||||
function upload() {
|
||||
wx.uploadImage({
|
||||
localId: images.localId[i],
|
||||
success: function (res) {
|
||||
i++;
|
||||
alert('已上传:' + i + '/' + length);
|
||||
//alert(res.serverId);
|
||||
images.serverId.push(res.serverId);
|
||||
if (i < length) {
|
||||
upload();
|
||||
}
|
||||
upObj = new Object();
|
||||
upObj.imageId = res.serverId;
|
||||
alert(upObj.imageId);
|
||||
setTimeout("uploadImage()",1000);
|
||||
images.localId = [];
|
||||
},
|
||||
fail: function (res) {
|
||||
alert(JSON.stringify(res));
|
||||
}
|
||||
});
|
||||
}
|
||||
upload();
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
var shareData = {
|
||||
title: '方倍工作室 微信JS-SDK DEMO',
|
||||
desc: '微信JS-SDK,帮助第三方为用户提供更优质的移动web服务',
|
||||
link: 'http://www.cnblogs.com/txw1958/',
|
||||
imgUrl: 'http://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRt8Qia4lv7k3M9J1SKqKCImxJCt7j9rHYicKDI45jRPBxdzdyREWnk0ia0N5TMnMfth7SdxtzMvVgXg/0'
|
||||
};
|
||||
wx.onMenuShareAppMessage(shareData);
|
||||
wx.onMenuShareTimeline(shareData);
|
||||
});
|
||||
|
||||
wx.error(function (res) {
|
||||
alert(res.errMsg);
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user