微信web开发的上传图片js接口
2015-10-16 19:00
627 查看
$('.chooseImage').click(function(){ wx.chooseImage({ count: pic_num, // 默认9,大于9也是显示9 sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有 'original', success: function (res) { images.localId = res.localIds; alert('已选择 ' + res.localIds.length + ' 张图片'); var img_data = ""; $.each(images.localId, function(i, v) { img_data += "<img class='wimg-item' src='"+v+"'>"; }); $("#image_content .chooseImage").before(img_data); $("#uploadImage").click(); } }); }); document.querySelector('#uploadImage').onclick = function () { if (images.localId.length == 0) { alert('请先使用 chooseImage 接口选择图片'); return; } var i = 0, length = images.localId.length; images.serverId = images.serverId || []; function upload() { wx.uploadImage({ localId: images.localId[i], isShowProgressTips: i == 0 ? 1:0,// 第一张图显示进度,避免出现一会弹出一个进度等待 success: function (res) { i++; $('#ask_submit').html('正在上传 '+i+'/'+length); if(i>=length) { $('#ask_submit').html('确定'); // alert('已上传:' + i + '/' + length); } images.serverId.push(res.serverId); if (i < length && i <= pic_num) { upload(); } }, fail: function (res) { alert('~><~ 图片上传失败,请稍后再试...'); //alert(JSON.stringify(res)); } }); } upload(); }; });
相关文章推荐
- 微信公众号开发笔记(C#)
- 微信硬件平台下设备与微信通信
- iOS开发009 iOS快速简单集成微信QQ微博分享
- .Net C# 微信刷卡支付接口
- 用c#开发微信(10) JSSDK 基本用法 分享接口“发送到朋友”
- 公众号支付-场景介绍(转自官方文档)
- 微信支付接口开发(前言)
- 微信连WIFI
- 基于微信硬件公众平台的智能控制开发流程
- 使用ngrok 将本地项目发布到公网,用于微信公众平台通过80端口访问本机
- Android模仿微信语音聊天功能-IT蓝豹
- 新版支付宝能否革了微信的命
- 微信支付出现支付请求参数错误,请核实再试或交易出错,请稍后再试的可能原因
- 微信Android资源混淆打包工具,如何让应用安装包立减1M
- 微渠道发展 BAE交通运输平台和java呼声,微信mysql数据库开发实例 --图文开发教程
- 微信API(还能发邮件,短信,IM聊天)
- 浙江工商学院电信学院微信平台
- 小程序反应大问题
- 给初学者提供的PHP文件上传小程序
- 微信模板开发及开发流程