作者 sgj

kkkkk

... ... @@ -615,6 +615,7 @@
})
//上传图片
//上传图片
$(function () {
var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
$gallery = $("#gallery"), $galleryImg = $("#galleryImg"),
... ... @@ -643,6 +644,52 @@
});
});
//上传图片
$('.addpic').on('click', function (res) {
console.log(11111);
var length = $('.length').length;
if (length >= 9) {
alert('不能上传了')
$('#addpic').hide();
return false;
}
wx.chooseImage({
count: 9 - length, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
console.log(res.localIds);
console.log(1111111111);
for (var i = 0; i < res.localIds.length; i++) {
// $('.addpic').before('<img style="width:100px;height:100px;" class="length" src="'+res.localIds[i]+'"/>')
$('.addpic').before('<li class="weui-uploader__file length" src="' + res.localIds[i] + '" style="background-image:url(' + res.localIds[i] + ')"></li>')
}
uploadImages(res.localIds)// 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
}
});
})
function uploadImages(localIds) {
var localId = localIds.pop();
wx.uploadImage({
localId: localId,
isShowProgressTips: 1,
success: function (res) {
var serverId = res.serverId; // 返回图片的服务器端ID
console.log(serverId);
serverIds += serverId + ',';
if (localIds.length > 0) {
uploadImages(localIds);
}
},
fail: function (res) {
$modal.toast(JSON.stringify(res));
}
});
}
//提交按钮
$('.submit').click(function () {
/*获取疾病分类*/
... ...